1 --- a/drivers/usb/host/isp116x-hcd.c
2 +++ b/drivers/usb/host/isp116x-hcd.c
3 @@ -1535,6 +1535,7 @@ static struct hc_driver isp116x_hc_drive
5 /*----------------------------------------------------------------*/
7 +#ifdef CONFIG_USB_ISP116X_HCD_PLATFORM
8 static int isp116x_remove(struct platform_device *pdev)
10 struct usb_hcd *hcd = platform_get_drvdata(pdev);
11 @@ -1708,22 +1709,249 @@ static struct platform_driver isp116x_dr
15 +static inline int isp116x_platform_register(void)
17 + return platform_driver_register(&isp116x_driver);
20 +static inline void isp116x_platform_unregister(void)
22 + platform_driver_unregister(&isp116x_driver);
25 +static inline int isp116x_platform_register(void) { return 0; };
26 +static void isp116x_platform_unregister(void) {};
27 +#endif /* CONFIG_USB_ISP116X_PLATFORM */
29 +/*-----------------------------------------------------------------*/
31 +#ifdef CONFIG_USB_ISP116X_HCD_OF
33 +#include <linux/of_platform.h>
35 +#ifdef USE_PLATFORM_DELAY
36 +static void isp116x_of_delay(struct device *ddev, int delay)
41 +#define isp116x_of_delay NULL
44 +static int __devinit isp116x_of_probe(struct platform_device *op)
46 + struct device_node *dn = op->dev.of_node;
47 + struct usb_hcd *hcd;
48 + struct isp116x *isp116x;
49 + struct resource addr, data;
50 + struct isp116x_platform_data *board;
51 + void __iomem *addr_reg;
52 + void __iomem *data_reg;
55 + unsigned long irqflags;
57 + ret = of_address_to_resource(dn, 0, &data);
61 + ret = of_address_to_resource(dn, 1, &addr);
65 + board = kzalloc(sizeof(struct isp116x_platform_data), GFP_KERNEL);
69 + if (!request_mem_region(addr.start, resource_size(&addr), hcd_name)) {
71 + goto err_free_board;
74 + addr_reg = ioremap_nocache(addr.start, resource_size(&addr));
75 + if (addr_reg == NULL) {
77 + goto err_release_addr;
80 + if (!request_mem_region(data.start, resource_size(&data), hcd_name)) {
82 + goto err_unmap_addr;
85 + data_reg = ioremap_nocache(data.start, resource_size(&data));
86 + if (data_reg == NULL) {
88 + goto err_release_data;
91 + irq = irq_of_parse_and_map(dn, 0);
92 + if (irq == NO_IRQ) {
94 + goto err_unmap_data;
97 + /* allocate and initialize hcd */
98 + hcd = usb_create_hcd(&isp116x_hc_driver, &op->dev, dev_name(&op->dev));
101 + goto err_irq_dispose;
104 + /* this rsrc_start is bogus */
105 + hcd->rsrc_start = addr.start;
106 + isp116x = hcd_to_isp116x(hcd);
107 + isp116x->data_reg = data_reg;
108 + isp116x->addr_reg = addr_reg;
109 + isp116x->board = board;
110 + spin_lock_init(&isp116x->lock);
111 + INIT_LIST_HEAD(&isp116x->async);
113 + board->delay = isp116x_of_delay;
114 + if (of_get_property(dn, "sel15Kres", NULL))
115 + board->sel15Kres = 1;
116 + if (of_get_property(dn, "oc_enable", NULL))
117 + board->oc_enable = 1;
118 + if (of_get_property(dn, "remote_wakeup_enable", NULL))
119 + board->remote_wakeup_enable = 1;
121 + if (of_get_property(dn, "int_act_high", NULL))
122 + board->int_act_high = 1;
123 + if (of_get_property(dn, "int_edge_triggered", NULL))
124 + board->int_edge_triggered = 1;
126 + if (board->int_edge_triggered)
127 + irqflags = board->int_act_high ? IRQF_TRIGGER_RISING :
128 + IRQF_TRIGGER_FALLING;
130 + irqflags = board->int_act_high ? IRQF_TRIGGER_HIGH :
133 + ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED);
137 + ret = create_debug_file(isp116x);
139 + ERR("Couldn't create debugfs entry\n");
140 + goto err_remove_hcd;
146 + usb_remove_hcd(hcd);
150 + irq_dispose_mapping(irq);
154 + release_mem_region(data.start, resource_size(&data));
158 + release_mem_region(addr.start, resource_size(&addr));
164 +static __devexit int isp116x_of_remove(struct platform_device *op)
166 + struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
167 + struct isp116x *isp116x;
168 + struct resource res;
173 + dev_set_drvdata(&op->dev, NULL);
175 + isp116x = hcd_to_isp116x(hcd);
176 + remove_debug_file(isp116x);
177 + usb_remove_hcd(hcd);
179 + irq_dispose_mapping(hcd->irq);
181 + iounmap(isp116x->data_reg);
182 + (void) of_address_to_resource(op->dev.of_node, 0, &res);
183 + release_mem_region(res.start, resource_size(&res));
185 + iounmap(isp116x->addr_reg);
186 + (void) of_address_to_resource(op->dev.of_node, 1, &res);
187 + release_mem_region(res.start, resource_size(&res));
189 + kfree(isp116x->board);
195 +static struct of_device_id isp116x_of_match[] = {
196 + { .compatible = "isp116x-hcd", },
200 +static struct platform_driver isp116x_of_platform_driver = {
201 + .probe = isp116x_of_probe,
202 + .remove = __devexit_p(isp116x_of_remove),
204 + .name = "isp116x-hcd-of",
205 + .owner = THIS_MODULE,
206 + .of_match_table = isp116x_of_match,
210 +static int __init isp116x_of_register(void)
212 + return platform_driver_register(&isp116x_of_platform_driver);
215 +static void __exit isp116x_of_unregister(void)
217 + platform_driver_unregister(&isp116x_of_platform_driver);
220 +MODULE_DEVICE_TABLE(of, isp116x_of_match);
223 +static inline int isp116x_of_register(void) { return 0; };
224 +static void isp116x_of_unregister(void) {};
225 +#endif /* CONFIG_USB_ISP116X_HCD_OF */
227 /*-----------------------------------------------------------------*/
229 static int __init isp116x_init(void)
236 INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION);
237 - return platform_driver_register(&isp116x_driver);
238 + ret = isp116x_platform_register();
242 + ret = isp116x_of_register();
244 + goto err_platform_unregister;
248 + err_platform_unregister:
249 + isp116x_platform_unregister();
253 module_init(isp116x_init);
255 static void __exit isp116x_cleanup(void)
257 - platform_driver_unregister(&isp116x_driver);
258 + isp116x_of_unregister();
259 + isp116x_platform_unregister();
262 module_exit(isp116x_cleanup);
263 --- a/drivers/usb/host/Kconfig
264 +++ b/drivers/usb/host/Kconfig
265 @@ -251,6 +251,24 @@ config USB_ISP116X_HCD
266 To compile this driver as a module, choose M here: the
267 module will be called isp116x-hcd.
269 +config USB_ISP116X_HCD_PLATFORM
270 + bool "ISP116X support for controllers on platform bus"
271 + depends on USB_ISP116X_HCD
272 + default n if PPC_OF
275 + Enables support for the ISP116x USB controller present on the
278 +config USB_ISP116X_HCD_OF
279 + bool "ISP116X support for controllers on OF platform bus"
280 + depends on USB_ISP116X_HCD && PPC_OF
281 + default y if PPC_OF
284 + Enables support for the ISP116x USB controller present on the
285 + OpenFirmware platform bus.
287 config USB_ISP1760_HCD
288 tristate "ISP 1760 HCD support"
289 depends on USB && EXPERIMENTAL