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,253 @@ 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.h>
34 +#include <linux/of_device.h>
35 +#include <linux/of_platform.h>
37 +#ifdef USE_PLATFORM_DELAY
38 +static void isp116x_of_delay(struct device *ddev, int delay)
43 +#define isp116x_of_delay NULL
46 +static int __devinit isp116x_of_probe(struct of_device *op,
47 + const struct of_device_id *match)
49 + struct device_node *dn = op->node;
50 + struct usb_hcd *hcd;
51 + struct isp116x *isp116x;
52 + struct resource addr, data, ires;
53 + struct isp116x_platform_data *board;
54 + void __iomem *addr_reg;
55 + void __iomem *data_reg;
58 + unsigned long irqflags;
60 + ret = of_address_to_resource(dn, 0, &data);
64 + ret = of_address_to_resource(dn, 1, &addr);
68 + ret = of_irq_to_resource(dn, 1, &ires);
72 + irqflags = ires.flags & IRQF_TRIGGER_MASK;
74 + board = kzalloc(sizeof(struct isp116x_platform_data), GFP_KERNEL);
78 + if (!request_mem_region(addr.start, resource_size(&addr), hcd_name)) {
80 + goto err_free_board;
83 + addr_reg = ioremap_nocache(addr.start, resource_size(&addr));
84 + if (addr_reg == NULL) {
86 + goto err_release_addr;
89 + if (!request_mem_region(data.start, resource_size(&data), hcd_name)) {
91 + goto err_unmap_addr;
94 + data_reg = ioremap_nocache(data.start, resource_size(&data));
95 + if (data_reg == NULL) {
97 + goto err_release_data;
100 + irq = irq_of_parse_and_map(op->node, 0);
101 + if (irq == NO_IRQ) {
103 + goto err_unmap_data;
106 + /* allocate and initialize hcd */
107 + hcd = usb_create_hcd(&isp116x_hc_driver, &op->dev, dev_name(&op->dev));
110 + goto err_irq_dispose;
113 + /* this rsrc_start is bogus */
114 + hcd->rsrc_start = addr.start;
115 + isp116x = hcd_to_isp116x(hcd);
116 + isp116x->data_reg = data_reg;
117 + isp116x->addr_reg = addr_reg;
118 + isp116x->board = board;
119 + spin_lock_init(&isp116x->lock);
120 + INIT_LIST_HEAD(&isp116x->async);
122 + board->delay = isp116x_of_delay;
123 + if (of_get_property(dn, "sel15Kres", NULL))
124 + board->sel15Kres = 1;
125 + if (of_get_property(dn, "oc_enable", NULL))
126 + board->oc_enable = 1;
127 + if (of_get_property(dn, "remote_wakeup_enable", NULL))
128 + board->remote_wakeup_enable = 1;
130 + if (of_get_property(dn, "int_act_high", NULL))
131 + board->int_act_high = 1;
132 + if (of_get_property(dn, "int_edge_triggered", NULL))
133 + board->int_edge_triggered = 1;
135 + ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED);
139 + ret = create_debug_file(isp116x);
141 + ERR("Couldn't create debugfs entry\n");
142 + goto err_remove_hcd;
148 + usb_remove_hcd(hcd);
152 + irq_dispose_mapping(irq);
156 + release_mem_region(data.start, resource_size(&data));
160 + release_mem_region(addr.start, resource_size(&addr));
166 +static __devexit int isp116x_of_remove(struct of_device *op)
168 + struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
169 + struct isp116x *isp116x;
170 + struct resource res;
175 + dev_set_drvdata(&op->dev, NULL);
177 + isp116x = hcd_to_isp116x(hcd);
178 + remove_debug_file(isp116x);
179 + usb_remove_hcd(hcd);
181 + irq_dispose_mapping(hcd->irq);
183 + iounmap(isp116x->data_reg);
184 + (void) of_address_to_resource(op->node, 0, &res);
185 + release_mem_region(res.start, resource_size(&res));
187 + iounmap(isp116x->addr_reg);
188 + (void) of_address_to_resource(op->node, 1, &res);
189 + release_mem_region(res.start, resource_size(&res));
191 + kfree(isp116x->board);
197 +static struct of_device_id isp116x_of_match[] = {
198 + { .compatible = "isp116x-hcd", },
202 +static struct of_platform_driver isp116x_of_platform_driver = {
203 + .owner = THIS_MODULE,
204 + .name = "isp116x-hcd-of",
205 + .match_table = isp116x_of_match,
206 + .probe = isp116x_of_probe,
207 + .remove = __devexit_p(isp116x_of_remove),
209 + .name = "isp116x-hcd-of",
210 + .owner = THIS_MODULE,
214 +static int __init isp116x_of_register(void)
216 + return of_register_platform_driver(&isp116x_of_platform_driver);
219 +static void __exit isp116x_of_unregister(void)
221 + of_unregister_platform_driver(&isp116x_of_platform_driver);
224 +MODULE_DEVICE_TABLE(of, isp116x_of_match);
227 +static inline int isp116x_of_register(void) { return 0; };
228 +static void isp116x_of_unregister(void) {};
229 +#endif /* CONFIG_USB_ISP116X_HCD_OF */
231 /*-----------------------------------------------------------------*/
233 static int __init isp116x_init(void)
240 INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION);
241 - return platform_driver_register(&isp116x_driver);
242 + ret = isp116x_platform_register();
246 + ret = isp116x_of_register();
248 + goto err_platform_unregister;
252 + err_platform_unregister:
253 + isp116x_platform_unregister();
257 module_init(isp116x_init);
259 static void __exit isp116x_cleanup(void)
261 - platform_driver_unregister(&isp116x_driver);
262 + isp116x_of_unregister();
263 + isp116x_platform_unregister();
266 module_exit(isp116x_cleanup);
267 --- a/drivers/usb/host/Kconfig
268 +++ b/drivers/usb/host/Kconfig
269 @@ -242,6 +242,24 @@ config USB_ISP116X_HCD
270 To compile this driver as a module, choose M here: the
271 module will be called isp116x-hcd.
273 +config USB_ISP116X_HCD_PLATFORM
274 + bool "ISP116X support for controllers on platform bus"
275 + depends on USB_ISP116X_HCD
276 + default n if PPC_OF
279 + Enables support for the ISP116x USB controller present on the
282 +config USB_ISP116X_HCD_OF
283 + bool "ISP116X support for controllers on OF platform bus"
284 + depends on USB_ISP116X_HCD && PPC_OF
285 + default y if PPC_OF
288 + Enables support for the ISP116x USB controller present on the
289 + OpenFirmware platform bus.
291 config USB_ISP1760_HCD
292 tristate "ISP 1760 HCD support"
293 depends on USB && EXPERIMENTAL