Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
aa05cfa
Documentation
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
connector
cpufreq
cpuidle
crypto
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fmc
fpga
gpio
gpu
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
ide
idle
iio
infiniband
input
iommu
ipack
irqchip
isdn
leds
lguest
lightnvm
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
sn
soc
spi
spmi
ssb
staging
target
tc
thermal
thunderbolt
tty
uio
usb
atm
c67x00
chipidea
class
common
core
dwc2
dwc3
early
gadget
host
image
isp1760
misc
mon
musb
phy
Kconfig
Makefile
am35x-phy-control.h
of.c
phy-ab8500-usb.c
phy-am335x-control.c
phy-am335x.c
phy-fsl-usb.c
phy-fsl-usb.h
phy-generic.c
phy-generic.h
phy-gpio-vbus-usb.c
phy-isp1301-omap.c
phy-isp1301.c
phy-keystone.c
phy-msm-usb.c
phy-mv-usb.c
phy-mv-usb.h
phy-mxs-usb.c
phy-omap-otg.c
phy-qcom-8x16-usb.c
phy-rcar-usb.c
phy-tahvo.c
phy-tegra-usb.c
phy-twl6030-usb.c
phy-ulpi-viewport.c
phy-ulpi.c
phy.c
renesas_usbhs
serial
storage
usbip
wusbcore
Kconfig
Makefile
README
usb-skeleton.c
uwb
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.get_maintainer.ignore
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
drivers
/
usb
/
phy
/
phy-omap-otg.c
Copy path
Blame
Blame
Latest commit
History
History
168 lines (139 loc) · 4.42 KB
Breadcrumbs
linux
/
drivers
/
usb
/
phy
/
phy-omap-otg.c
Top
File metadata and controls
Code
Blame
168 lines (139 loc) · 4.42 KB
Raw
/* * OMAP OTG controller driver * * Based on code from tahvo-usb.c and isp1301_omap.c drivers. * * Copyright (C) 2005-2006 Nokia Corporation * Copyright (C) 2004 Texas Instruments * Copyright (C) 2004 David Brownell * * This file is subject to the terms and conditions of the GNU General * Public License. See the file "COPYING" in the main directory of this * archive for more details. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/io.h> #include <linux/err.h> #include <linux/extcon.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/platform_data/usb-omap1.h> struct otg_device { void __iomem *base; bool id; bool vbus; struct extcon_dev *extcon; struct notifier_block vbus_nb; struct notifier_block id_nb; }; #define OMAP_OTG_CTRL 0x0c #define OMAP_OTG_ASESSVLD (1 << 20) #define OMAP_OTG_BSESSEND (1 << 19) #define OMAP_OTG_BSESSVLD (1 << 18) #define OMAP_OTG_VBUSVLD (1 << 17) #define OMAP_OTG_ID (1 << 16) #define OMAP_OTG_XCEIV_OUTPUTS \ (OMAP_OTG_ASESSVLD | OMAP_OTG_BSESSEND | OMAP_OTG_BSESSVLD | \ OMAP_OTG_VBUSVLD | OMAP_OTG_ID) static void omap_otg_ctrl(struct otg_device *otg_dev, u32 outputs) { u32 l; l = readl(otg_dev->base + OMAP_OTG_CTRL); l &= ~OMAP_OTG_XCEIV_OUTPUTS; l |= outputs; writel(l, otg_dev->base + OMAP_OTG_CTRL); } static void omap_otg_set_mode(struct otg_device *otg_dev) { if (!otg_dev->id && otg_dev->vbus) /* Set B-session valid. */ omap_otg_ctrl(otg_dev, OMAP_OTG_ID | OMAP_OTG_BSESSVLD); else if (otg_dev->vbus) /* Set A-session valid. */ omap_otg_ctrl(otg_dev, OMAP_OTG_ASESSVLD); else if (!otg_dev->id) /* Set B-session end to indicate no VBUS. */ omap_otg_ctrl(otg_dev, OMAP_OTG_ID | OMAP_OTG_BSESSEND); } static int omap_otg_id_notifier(struct notifier_block *nb, unsigned long event, void *ptr) { struct otg_device *otg_dev = container_of(nb, struct otg_device, id_nb); otg_dev->id = event; omap_otg_set_mode(otg_dev); return NOTIFY_DONE; } static int omap_otg_vbus_notifier(struct notifier_block *nb, unsigned long event, void *ptr) { struct otg_device *otg_dev = container_of(nb, struct otg_device, vbus_nb); otg_dev->vbus = event; omap_otg_set_mode(otg_dev); return NOTIFY_DONE; } static int omap_otg_probe(struct platform_device *pdev) { const struct omap_usb_config *config = pdev->dev.platform_data; struct otg_device *otg_dev; struct extcon_dev *extcon; int ret; u32 rev; if (!config || !config->extcon) return -ENODEV; extcon = extcon_get_extcon_dev(config->extcon); if (!extcon) return -EPROBE_DEFER; otg_dev = devm_kzalloc(&pdev->dev, sizeof(*otg_dev), GFP_KERNEL); if (!otg_dev) return -ENOMEM; otg_dev->base = devm_ioremap_resource(&pdev->dev, &pdev->resource[0]); if (IS_ERR(otg_dev->base)) return PTR_ERR(otg_dev->base); otg_dev->extcon = extcon; otg_dev->id_nb.notifier_call = omap_otg_id_notifier; otg_dev->vbus_nb.notifier_call = omap_otg_vbus_notifier; ret = extcon_register_notifier(extcon, EXTCON_USB_HOST, &otg_dev->id_nb); if (ret) return ret; ret = extcon_register_notifier(extcon, EXTCON_USB, &otg_dev->vbus_nb); if (ret) { extcon_unregister_notifier(extcon, EXTCON_USB_HOST, &otg_dev->id_nb); return ret; } otg_dev->id = extcon_get_cable_state_(extcon, EXTCON_USB_HOST); otg_dev->vbus = extcon_get_cable_state_(extcon, EXTCON_USB); omap_otg_set_mode(otg_dev); rev = readl(otg_dev->base); dev_info(&pdev->dev, "OMAP USB OTG controller rev %d.%d (%s, id=%d, vbus=%d)\n", (rev >> 4) & 0xf, rev & 0xf, config->extcon, otg_dev->id, otg_dev->vbus); return 0; } static int omap_otg_remove(struct platform_device *pdev) { struct otg_device *otg_dev = platform_get_drvdata(pdev); struct extcon_dev *edev = otg_dev->extcon; extcon_unregister_notifier(edev, EXTCON_USB_HOST,&otg_dev->id_nb); extcon_unregister_notifier(edev, EXTCON_USB, &otg_dev->vbus_nb); return 0; } static struct platform_driver omap_otg_driver = { .probe = omap_otg_probe, .remove = omap_otg_remove, .driver = { .name = "omap_otg", }, }; module_platform_driver(omap_otg_driver); MODULE_DESCRIPTION("OMAP USB OTG controller driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Aaro Koskinen <aaro.koskinen@iki.fi>");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
You can’t perform that action at this time.