diff options
author | Marcin Juszkiewicz <marcin@buglabs.net> | 2009-04-27 16:41:24 +0200 |
---|---|---|
committer | Marcin Juszkiewicz <marcin@buglabs.net> | 2009-04-28 18:09:45 +0200 |
commit | 0adc74b06210f1be01145a5977a36b83aca0aa68 (patch) | |
tree | 378495bdf474a70afef101f9e1859953d8826129 /meta/packages/linux/linux-omap-2.6.29/musb/0024-USB-otg-adding-nop-usb-transceiver.patch | |
parent | d65be3dd2aaa643b5596c8470caf7f291513efee (diff) | |
download | poky-0adc74b06210f1be01145a5977a36b83aca0aa68.tar.gz |
beagleboard: added 2.6.29 kernel from OE
tested on B7
Signed-off-by: Marcin Juszkiewicz <marcin@buglabs.net>
Diffstat (limited to 'meta/packages/linux/linux-omap-2.6.29/musb/0024-USB-otg-adding-nop-usb-transceiver.patch')
-rw-r--r-- | meta/packages/linux/linux-omap-2.6.29/musb/0024-USB-otg-adding-nop-usb-transceiver.patch | 259 |
1 files changed, 259 insertions, 0 deletions
diff --git a/meta/packages/linux/linux-omap-2.6.29/musb/0024-USB-otg-adding-nop-usb-transceiver.patch b/meta/packages/linux/linux-omap-2.6.29/musb/0024-USB-otg-adding-nop-usb-transceiver.patch new file mode 100644 index 0000000000..67004d7ec6 --- /dev/null +++ b/meta/packages/linux/linux-omap-2.6.29/musb/0024-USB-otg-adding-nop-usb-transceiver.patch | |||
@@ -0,0 +1,259 @@ | |||
1 | From de835357b3597af5304742cbd89771d70533292a Mon Sep 17 00:00:00 2001 | ||
2 | From: Ajay Kumar Gupta <ajay.gupta@ti.com> | ||
3 | Date: Fri, 6 Feb 2009 17:32:35 +0530 | ||
4 | Subject: [PATCH] USB: otg: adding nop usb transceiver | ||
5 | |||
6 | NOP transceiver is used by all the usb transceiver which are mostly | ||
7 | autonomous and doesn't require any programming or which are built | ||
8 | into the usb ip itself.NOP transceiver only allocates the memory | ||
9 | for struct xceiv and calls otg_set_transceiver() so function call | ||
10 | to otg_get_transceiver() will return a valid transceiver. | ||
11 | |||
12 | NOP transceiver device should be registered by calling | ||
13 | usb_nop_xceiv_register() from platform files. | ||
14 | |||
15 | Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com> | ||
16 | Cc: Felipe Balbi <felipe.balbi@nokia.com> | ||
17 | Cc: David Brownell <dbrownell@users.sourceforge.net> | ||
18 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | ||
19 | --- | ||
20 | drivers/usb/otg/Kconfig | 8 ++ | ||
21 | drivers/usb/otg/Makefile | 1 + | ||
22 | drivers/usb/otg/nop-usb-xceiv.c | 180 +++++++++++++++++++++++++++++++++++++++ | ||
23 | include/linux/usb/otg.h | 4 + | ||
24 | 4 files changed, 193 insertions(+), 0 deletions(-) | ||
25 | create mode 100644 drivers/usb/otg/nop-usb-xceiv.c | ||
26 | |||
27 | diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig | ||
28 | index 5790a5b..aa884d0 100644 | ||
29 | --- a/drivers/usb/otg/Kconfig | ||
30 | +++ b/drivers/usb/otg/Kconfig | ||
31 | @@ -51,4 +51,12 @@ config TWL4030_USB | ||
32 | This transceiver supports high and full speed devices plus, | ||
33 | in host mode, low speed. | ||
34 | |||
35 | +config NOP_USB_XCEIV | ||
36 | + tristate "NOP USB Transceiver Driver" | ||
37 | + select USB_OTG_UTILS | ||
38 | + help | ||
39 | + this driver is to be used by all the usb transceiver which are either | ||
40 | + built-in with usb ip or which are autonomous and doesn't require any | ||
41 | + phy programming such as ISP1x04 etc. | ||
42 | + | ||
43 | endif # USB || OTG | ||
44 | diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile | ||
45 | index d73c7cf..2081678 100644 | ||
46 | --- a/drivers/usb/otg/Makefile | ||
47 | +++ b/drivers/usb/otg/Makefile | ||
48 | @@ -9,6 +9,7 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg.o | ||
49 | obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o | ||
50 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | ||
51 | obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o | ||
52 | +obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o | ||
53 | |||
54 | ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG | ||
55 | ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG | ||
56 | diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c | ||
57 | new file mode 100644 | ||
58 | index 0000000..4b933f6 | ||
59 | --- /dev/null | ||
60 | +++ b/drivers/usb/otg/nop-usb-xceiv.c | ||
61 | @@ -0,0 +1,180 @@ | ||
62 | +/* | ||
63 | + * drivers/usb/otg/nop-usb-xceiv.c | ||
64 | + * | ||
65 | + * NOP USB transceiver for all USB transceiver which are either built-in | ||
66 | + * into USB IP or which are mostly autonomous. | ||
67 | + * | ||
68 | + * Copyright (C) 2009 Texas Instruments Inc | ||
69 | + * Author: Ajay Kumar Gupta <ajay.gupta@ti.com> | ||
70 | + * | ||
71 | + * This program is free software; you can redistribute it and/or modify | ||
72 | + * it under the terms of the GNU General Public License as published by | ||
73 | + * the Free Software Foundation; either version 2 of the License, or | ||
74 | + * (at your option) any later version. | ||
75 | + * | ||
76 | + * This program is distributed in the hope that it will be useful, | ||
77 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
78 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
79 | + * GNU General Public License for more details. | ||
80 | + * | ||
81 | + * You should have received a copy of the GNU General Public License | ||
82 | + * along with this program; if not, write to the Free Software | ||
83 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
84 | + * | ||
85 | + * Current status: | ||
86 | + * this is to add "nop" transceiver for all those phy which is | ||
87 | + * autonomous such as isp1504 etc. | ||
88 | + */ | ||
89 | + | ||
90 | +#include <linux/module.h> | ||
91 | +#include <linux/platform_device.h> | ||
92 | +#include <linux/dma-mapping.h> | ||
93 | +#include <linux/usb/otg.h> | ||
94 | + | ||
95 | +struct nop_usb_xceiv { | ||
96 | + struct otg_transceiver otg; | ||
97 | + struct device *dev; | ||
98 | +}; | ||
99 | + | ||
100 | +static u64 nop_xceiv_dmamask = DMA_32BIT_MASK; | ||
101 | + | ||
102 | +static struct platform_device nop_xceiv_device = { | ||
103 | + .name = "nop_usb_xceiv", | ||
104 | + .id = -1, | ||
105 | + .dev = { | ||
106 | + .dma_mask = &nop_xceiv_dmamask, | ||
107 | + .coherent_dma_mask = DMA_32BIT_MASK, | ||
108 | + .platform_data = NULL, | ||
109 | + }, | ||
110 | +}; | ||
111 | + | ||
112 | +void usb_nop_xceiv_register(void) | ||
113 | +{ | ||
114 | + if (platform_device_register(&nop_xceiv_device) < 0) { | ||
115 | + printk(KERN_ERR "Unable to register usb nop transceiver\n"); | ||
116 | + return; | ||
117 | + } | ||
118 | +} | ||
119 | + | ||
120 | +void usb_nop_xceiv_unregister(void) | ||
121 | +{ | ||
122 | + platform_device_unregister(&nop_xceiv_device); | ||
123 | +} | ||
124 | + | ||
125 | +static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x) | ||
126 | +{ | ||
127 | + return container_of(x, struct nop_usb_xceiv, otg); | ||
128 | +} | ||
129 | + | ||
130 | +static int nop_set_suspend(struct otg_transceiver *x, int suspend) | ||
131 | +{ | ||
132 | + return 0; | ||
133 | +} | ||
134 | + | ||
135 | +static int nop_set_peripheral(struct otg_transceiver *x, | ||
136 | + struct usb_gadget *gadget) | ||
137 | +{ | ||
138 | + struct nop_usb_xceiv *nop; | ||
139 | + | ||
140 | + if (!x) | ||
141 | + return -ENODEV; | ||
142 | + | ||
143 | + nop = xceiv_to_nop(x); | ||
144 | + | ||
145 | + if (!gadget) { | ||
146 | + nop->otg.gadget = NULL; | ||
147 | + return -ENODEV; | ||
148 | + } | ||
149 | + | ||
150 | + nop->otg.gadget = gadget; | ||
151 | + nop->otg.state = OTG_STATE_B_IDLE; | ||
152 | + return 0; | ||
153 | +} | ||
154 | + | ||
155 | +static int nop_set_host(struct otg_transceiver *x, struct usb_bus *host) | ||
156 | +{ | ||
157 | + struct nop_usb_xceiv *nop; | ||
158 | + | ||
159 | + if (!x) | ||
160 | + return -ENODEV; | ||
161 | + | ||
162 | + nop = xceiv_to_nop(x); | ||
163 | + | ||
164 | + if (!host) { | ||
165 | + nop->otg.host = NULL; | ||
166 | + return -ENODEV; | ||
167 | + } | ||
168 | + | ||
169 | + nop->otg.host = host; | ||
170 | + return 0; | ||
171 | +} | ||
172 | + | ||
173 | +static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | ||
174 | +{ | ||
175 | + struct nop_usb_xceiv *nop; | ||
176 | + int err; | ||
177 | + | ||
178 | + nop = kzalloc(sizeof *nop, GFP_KERNEL); | ||
179 | + if (!nop) | ||
180 | + return -ENOMEM; | ||
181 | + | ||
182 | + nop->dev = &pdev->dev; | ||
183 | + nop->otg.dev = nop->dev; | ||
184 | + nop->otg.label = "nop-xceiv"; | ||
185 | + nop->otg.state = OTG_STATE_UNDEFINED; | ||
186 | + nop->otg.set_host = nop_set_host; | ||
187 | + nop->otg.set_peripheral = nop_set_peripheral; | ||
188 | + nop->otg.set_suspend = nop_set_suspend; | ||
189 | + | ||
190 | + err = otg_set_transceiver(&nop->otg); | ||
191 | + if (err) { | ||
192 | + dev_err(&pdev->dev, "can't register transceiver, err: %d\n", | ||
193 | + err); | ||
194 | + goto exit; | ||
195 | + } | ||
196 | + | ||
197 | + platform_set_drvdata(pdev, nop); | ||
198 | + | ||
199 | + return 0; | ||
200 | +exit: | ||
201 | + kfree(nop); | ||
202 | + return err; | ||
203 | +} | ||
204 | + | ||
205 | +static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev) | ||
206 | +{ | ||
207 | + struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); | ||
208 | + | ||
209 | + otg_set_transceiver(NULL); | ||
210 | + | ||
211 | + platform_set_drvdata(pdev, NULL); | ||
212 | + kfree(nop); | ||
213 | + | ||
214 | + return 0; | ||
215 | +} | ||
216 | + | ||
217 | +static struct platform_driver nop_usb_xceiv_driver = { | ||
218 | + .probe = nop_usb_xceiv_probe, | ||
219 | + .remove = __devexit_p(nop_usb_xceiv_remove), | ||
220 | + .driver = { | ||
221 | + .name = "nop_usb_xceiv", | ||
222 | + .owner = THIS_MODULE, | ||
223 | + }, | ||
224 | +}; | ||
225 | + | ||
226 | +static int __init nop_usb_xceiv_init(void) | ||
227 | +{ | ||
228 | + return platform_driver_register(&nop_usb_xceiv_driver); | ||
229 | +} | ||
230 | +subsys_initcall(nop_usb_xceiv_init); | ||
231 | + | ||
232 | +static void __exit nop_usb_xceiv_exit(void) | ||
233 | +{ | ||
234 | + platform_driver_unregister(&nop_usb_xceiv_driver); | ||
235 | +} | ||
236 | +module_exit(nop_usb_xceiv_exit); | ||
237 | + | ||
238 | +MODULE_ALIAS("platform:nop_usb_xceiv"); | ||
239 | +MODULE_AUTHOR("Texas Instruments Inc"); | ||
240 | +MODULE_DESCRIPTION("NOP USB Transceiver driver"); | ||
241 | +MODULE_LICENSE("GPL"); | ||
242 | diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h | ||
243 | index 94df4fe..54f2424 100644 | ||
244 | --- a/include/linux/usb/otg.h | ||
245 | +++ b/include/linux/usb/otg.h | ||
246 | @@ -80,6 +80,10 @@ struct otg_transceiver { | ||
247 | |||
248 | /* for board-specific init logic */ | ||
249 | extern int otg_set_transceiver(struct otg_transceiver *); | ||
250 | +#ifdef CONFIG_NOP_USB_XCEIV | ||
251 | +extern void usb_nop_xceiv_register(void); | ||
252 | +extern void usb_nop_xceiv_unregister(void); | ||
253 | +#endif | ||
254 | |||
255 | |||
256 | /* for usb host and peripheral controller drivers */ | ||
257 | -- | ||
258 | 1.6.0.4 | ||
259 | |||