diff options
-rw-r--r-- | drivers/usb/otg/Kconfig | 8 | ||||
-rw-r--r-- | drivers/usb/otg/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/otg/nop-usb-xceiv.c | 180 | ||||
-rw-r--r-- | include/linux/usb/otg.h | 4 |
4 files changed, 193 insertions, 0 deletions
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index ee55b449ffde..fc1ca03ce4da 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
@@ -51,4 +51,12 @@ config TWL4030_USB | |||
51 | This transceiver supports high and full speed devices plus, | 51 | This transceiver supports high and full speed devices plus, |
52 | in host mode, low speed. | 52 | in host mode, low speed. |
53 | 53 | ||
54 | config NOP_USB_XCEIV | ||
55 | tristate "NOP USB Transceiver Driver" | ||
56 | select USB_OTG_UTILS | ||
57 | help | ||
58 | this driver is to be used by all the usb transceiver which are either | ||
59 | built-in with usb ip or which are autonomous and doesn't require any | ||
60 | phy programming such as ISP1x04 etc. | ||
61 | |||
54 | endif # USB || OTG | 62 | endif # USB || OTG |
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile index d73c7cf5e2f7..208167856529 100644 --- a/drivers/usb/otg/Makefile +++ b/drivers/usb/otg/Makefile | |||
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg.o | |||
9 | obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o | 9 | obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o |
10 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 10 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
11 | obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o | 11 | obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o |
12 | obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o | ||
12 | 13 | ||
13 | ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG | 14 | ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG |
14 | ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG | 15 | ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG |
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c new file mode 100644 index 000000000000..4b933f646f2e --- /dev/null +++ b/drivers/usb/otg/nop-usb-xceiv.c | |||
@@ -0,0 +1,180 @@ | |||
1 | /* | ||
2 | * drivers/usb/otg/nop-usb-xceiv.c | ||
3 | * | ||
4 | * NOP USB transceiver for all USB transceiver which are either built-in | ||
5 | * into USB IP or which are mostly autonomous. | ||
6 | * | ||
7 | * Copyright (C) 2009 Texas Instruments Inc | ||
8 | * Author: Ajay Kumar Gupta <ajay.gupta@ti.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | * | ||
24 | * Current status: | ||
25 | * this is to add "nop" transceiver for all those phy which is | ||
26 | * autonomous such as isp1504 etc. | ||
27 | */ | ||
28 | |||
29 | #include <linux/module.h> | ||
30 | #include <linux/platform_device.h> | ||
31 | #include <linux/dma-mapping.h> | ||
32 | #include <linux/usb/otg.h> | ||
33 | |||
34 | struct nop_usb_xceiv { | ||
35 | struct otg_transceiver otg; | ||
36 | struct device *dev; | ||
37 | }; | ||
38 | |||
39 | static u64 nop_xceiv_dmamask = DMA_32BIT_MASK; | ||
40 | |||
41 | static struct platform_device nop_xceiv_device = { | ||
42 | .name = "nop_usb_xceiv", | ||
43 | .id = -1, | ||
44 | .dev = { | ||
45 | .dma_mask = &nop_xceiv_dmamask, | ||
46 | .coherent_dma_mask = DMA_32BIT_MASK, | ||
47 | .platform_data = NULL, | ||
48 | }, | ||
49 | }; | ||
50 | |||
51 | void usb_nop_xceiv_register(void) | ||
52 | { | ||
53 | if (platform_device_register(&nop_xceiv_device) < 0) { | ||
54 | printk(KERN_ERR "Unable to register usb nop transceiver\n"); | ||
55 | return; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | void usb_nop_xceiv_unregister(void) | ||
60 | { | ||
61 | platform_device_unregister(&nop_xceiv_device); | ||
62 | } | ||
63 | |||
64 | static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x) | ||
65 | { | ||
66 | return container_of(x, struct nop_usb_xceiv, otg); | ||
67 | } | ||
68 | |||
69 | static int nop_set_suspend(struct otg_transceiver *x, int suspend) | ||
70 | { | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int nop_set_peripheral(struct otg_transceiver *x, | ||
75 | struct usb_gadget *gadget) | ||
76 | { | ||
77 | struct nop_usb_xceiv *nop; | ||
78 | |||
79 | if (!x) | ||
80 | return -ENODEV; | ||
81 | |||
82 | nop = xceiv_to_nop(x); | ||
83 | |||
84 | if (!gadget) { | ||
85 | nop->otg.gadget = NULL; | ||
86 | return -ENODEV; | ||
87 | } | ||
88 | |||
89 | nop->otg.gadget = gadget; | ||
90 | nop->otg.state = OTG_STATE_B_IDLE; | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static int nop_set_host(struct otg_transceiver *x, struct usb_bus *host) | ||
95 | { | ||
96 | struct nop_usb_xceiv *nop; | ||
97 | |||
98 | if (!x) | ||
99 | return -ENODEV; | ||
100 | |||
101 | nop = xceiv_to_nop(x); | ||
102 | |||
103 | if (!host) { | ||
104 | nop->otg.host = NULL; | ||
105 | return -ENODEV; | ||
106 | } | ||
107 | |||
108 | nop->otg.host = host; | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | ||
113 | { | ||
114 | struct nop_usb_xceiv *nop; | ||
115 | int err; | ||
116 | |||
117 | nop = kzalloc(sizeof *nop, GFP_KERNEL); | ||
118 | if (!nop) | ||
119 | return -ENOMEM; | ||
120 | |||
121 | nop->dev = &pdev->dev; | ||
122 | nop->otg.dev = nop->dev; | ||
123 | nop->otg.label = "nop-xceiv"; | ||
124 | nop->otg.state = OTG_STATE_UNDEFINED; | ||
125 | nop->otg.set_host = nop_set_host; | ||
126 | nop->otg.set_peripheral = nop_set_peripheral; | ||
127 | nop->otg.set_suspend = nop_set_suspend; | ||
128 | |||
129 | err = otg_set_transceiver(&nop->otg); | ||
130 | if (err) { | ||
131 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", | ||
132 | err); | ||
133 | goto exit; | ||
134 | } | ||
135 | |||
136 | platform_set_drvdata(pdev, nop); | ||
137 | |||
138 | return 0; | ||
139 | exit: | ||
140 | kfree(nop); | ||
141 | return err; | ||
142 | } | ||
143 | |||
144 | static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev) | ||
145 | { | ||
146 | struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); | ||
147 | |||
148 | otg_set_transceiver(NULL); | ||
149 | |||
150 | platform_set_drvdata(pdev, NULL); | ||
151 | kfree(nop); | ||
152 | |||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | static struct platform_driver nop_usb_xceiv_driver = { | ||
157 | .probe = nop_usb_xceiv_probe, | ||
158 | .remove = __devexit_p(nop_usb_xceiv_remove), | ||
159 | .driver = { | ||
160 | .name = "nop_usb_xceiv", | ||
161 | .owner = THIS_MODULE, | ||
162 | }, | ||
163 | }; | ||
164 | |||
165 | static int __init nop_usb_xceiv_init(void) | ||
166 | { | ||
167 | return platform_driver_register(&nop_usb_xceiv_driver); | ||
168 | } | ||
169 | subsys_initcall(nop_usb_xceiv_init); | ||
170 | |||
171 | static void __exit nop_usb_xceiv_exit(void) | ||
172 | { | ||
173 | platform_driver_unregister(&nop_usb_xceiv_driver); | ||
174 | } | ||
175 | module_exit(nop_usb_xceiv_exit); | ||
176 | |||
177 | MODULE_ALIAS("platform:nop_usb_xceiv"); | ||
178 | MODULE_AUTHOR("Texas Instruments Inc"); | ||
179 | MODULE_DESCRIPTION("NOP USB Transceiver driver"); | ||
180 | MODULE_LICENSE("GPL"); | ||
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 60a52576fd5c..1aaa826396a1 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h | |||
@@ -80,6 +80,10 @@ struct otg_transceiver { | |||
80 | 80 | ||
81 | /* for board-specific init logic */ | 81 | /* for board-specific init logic */ |
82 | extern int otg_set_transceiver(struct otg_transceiver *); | 82 | extern int otg_set_transceiver(struct otg_transceiver *); |
83 | #ifdef CONFIG_NOP_USB_XCEIV | ||
84 | extern void usb_nop_xceiv_register(void); | ||
85 | extern void usb_nop_xceiv_unregister(void); | ||
86 | #endif | ||
83 | 87 | ||
84 | 88 | ||
85 | /* for usb host and peripheral controller drivers */ | 89 | /* for usb host and peripheral controller drivers */ |