1 --- a/drivers/usb/host/isp116x-hcd.c
2 +++ b/drivers/usb/host/isp116x-hcd.c
3 @@ -1531,8 +1531,11 @@ static struct hc_driver isp116x_hc_drive
4 .bus_resume = isp116x_bus_resume,
7 +#define resource_len(r) (((r)->end - (r)->start) + 1)
9 /*----------------------------------------------------------------*/
11 +#ifdef CONFIG_USB_ISP116X_HCD_PLATFORM
12 static int isp116x_remove(struct platform_device *pdev)
14 struct usb_hcd *hcd = platform_get_drvdata(pdev);
15 @@ -1556,8 +1559,6 @@ static int isp116x_remove(struct platfor
19 -#define resource_len(r) (((r)->end - (r)->start) + 1)
21 static int __devinit isp116x_probe(struct platform_device *pdev)
24 @@ -1708,22 +1709,253 @@ static struct platform_driver isp116x_dr
28 +static inline int isp116x_platform_register(void)
30 + return platform_driver_register(&isp116x_driver);
33 +static inline void isp116x_platform_unregister(void)
35 + platform_driver_unregister(&isp116x_driver);
38 +static inline int isp116x_platform_register(void) { return 0; };
39 +static void isp116x_platform_unregister(void) {};
40 +#endif /* CONFIG_USB_ISP116X_PLATFORM */
42 +/*-----------------------------------------------------------------*/
44 +#ifdef CONFIG_USB_ISP116X_HCD_OF
46 +#include <linux/of.h>
47 +#include <linux/of_device.h>
48 +#include <linux/of_platform.h>
50 +#ifdef USE_PLATFORM_DELAY
51 +static void isp116x_of_delay(struct device *ddev, int delay)
56 +#define isp116x_of_delay NULL
59 +static int __devinit isp116x_of_probe(struct of_device *op,
60 + const struct of_device_id *match)
62 + struct device_node *dn = op->node;
63 + struct usb_hcd *hcd;
64 + struct isp116x *isp116x;
65 + struct resource addr, data, ires;
66 + struct isp116x_platform_data *board;
67 + void __iomem *addr_reg;
68 + void __iomem *data_reg;
71 + unsigned long irqflags;
73 + ret = of_address_to_resource(dn, 0, &data);
77 + ret = of_address_to_resource(dn, 1, &addr);
81 + ret = of_irq_to_resource(dn, 1, &ires);
85 + irqflags = ires.flags & IRQF_TRIGGER_MASK;
87 + board = kzalloc(sizeof(struct isp116x_platform_data), GFP_KERNEL);
91 + if (!request_mem_region(addr.start, resource_len(&addr), hcd_name)) {
93 + goto err_free_board;
96 + addr_reg = ioremap_nocache(addr.start, resource_len(&addr));
97 + if (addr_reg == NULL) {
99 + goto err_release_addr;
102 + if (!request_mem_region(data.start, resource_len(&data), hcd_name)) {
104 + goto err_unmap_addr;
107 + data_reg = ioremap_nocache(data.start, resource_len(&data));
108 + if (data_reg == NULL) {
110 + goto err_release_data;
113 + irq = irq_of_parse_and_map(op->node, 0);
114 + if (irq == NO_IRQ) {
116 + goto err_unmap_data;
119 + /* allocate and initialize hcd */
120 + hcd = usb_create_hcd(&isp116x_hc_driver, &op->dev, dev_name(&op->dev));
123 + goto err_irq_dispose;
126 + /* this rsrc_start is bogus */
127 + hcd->rsrc_start = addr.start;
128 + isp116x = hcd_to_isp116x(hcd);
129 + isp116x->data_reg = data_reg;
130 + isp116x->addr_reg = addr_reg;
131 + isp116x->board = board;
132 + spin_lock_init(&isp116x->lock);
133 + INIT_LIST_HEAD(&isp116x->async);
135 + board->delay = isp116x_of_delay;
136 + if (of_get_property(dn, "sel15Kres", NULL))
137 + board->sel15Kres = 1;
138 + if (of_get_property(dn, "oc_enable", NULL))
139 + board->oc_enable = 1;
140 + if (of_get_property(dn, "remote_wakeup_enable", NULL))
141 + board->remote_wakeup_enable = 1;
143 + if (of_get_property(dn, "int_act_high", NULL))
144 + board->int_act_high = 1;
145 + if (of_get_property(dn, "int_edge_triggered", NULL))
146 + board->int_edge_triggered = 1;
148 + ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED);
152 + ret = create_debug_file(isp116x);
154 + ERR("Couldn't create debugfs entry\n");
155 + goto err_remove_hcd;
161 + usb_remove_hcd(hcd);
165 + irq_dispose_mapping(irq);
169 + release_mem_region(data.start, resource_len(&data));
173 + release_mem_region(addr.start, resource_len(&addr));
179 +static __devexit int isp116x_of_remove(struct of_device *op)
181 + struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
182 + struct isp116x *isp116x;
183 + struct resource res;
188 + dev_set_drvdata(&op->dev, NULL);
190 + isp116x = hcd_to_isp116x(hcd);
191 + remove_debug_file(isp116x);
192 + usb_remove_hcd(hcd);
194 + irq_dispose_mapping(hcd->irq);
196 + iounmap(isp116x->data_reg);
197 + (void) of_address_to_resource(op->node, 0, &res);
198 + release_mem_region(res.start, resource_len(&res));
200 + iounmap(isp116x->addr_reg);
201 + (void) of_address_to_resource(op->node, 1, &res);
202 + release_mem_region(res.start, resource_len(&res));
204 + kfree(isp116x->board);
210 +static struct of_device_id isp116x_of_match[] = {
211 + { .compatible = "isp116x-hcd", },
215 +static struct of_platform_driver isp116x_of_platform_driver = {
216 + .owner = THIS_MODULE,
217 + .name = "isp116x-hcd-of",
218 + .match_table = isp116x_of_match,
219 + .probe = isp116x_of_probe,
220 + .remove = __devexit_p(isp116x_of_remove),
222 + .name = "isp116x-hcd-of",
223 + .owner = THIS_MODULE,
227 +static int __init isp116x_of_register(void)
229 + return of_register_platform_driver(&isp116x_of_platform_driver);
232 +static void __exit isp116x_of_unregister(void)
234 + of_unregister_platform_driver(&isp116x_of_platform_driver);
237 +MODULE_DEVICE_TABLE(of, isp116x_of_match);
240 +static inline int isp116x_of_register(void) { return 0; };
241 +static void isp116x_of_unregister(void) {};
242 +#endif /* CONFIG_USB_ISP116X_HCD_OF */
244 /*-----------------------------------------------------------------*/
246 static int __init isp116x_init(void)
253 INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION);
254 - return platform_driver_register(&isp116x_driver);
255 + ret = isp116x_platform_register();
259 + ret = isp116x_of_register();
261 + goto err_platform_unregister;
265 + err_platform_unregister:
266 + isp116x_platform_unregister();
270 module_init(isp116x_init);
272 static void __exit isp116x_cleanup(void)
274 - platform_driver_unregister(&isp116x_driver);
275 + isp116x_of_unregister();
276 + isp116x_platform_unregister();
279 module_exit(isp116x_cleanup);
280 --- a/drivers/usb/host/Kconfig
281 +++ b/drivers/usb/host/Kconfig
282 @@ -144,6 +144,24 @@ config USB_ISP116X_HCD
283 To compile this driver as a module, choose M here: the
284 module will be called isp116x-hcd.
286 +config USB_ISP116X_HCD_PLATFORM
287 + bool "ISP116X support for controllers on platform bus"
288 + depends on USB_ISP116X_HCD
289 + default n if PPC_OF
292 + Enables support for the ISP116x USB controller present on the
295 +config USB_ISP116X_HCD_OF
296 + bool "ISP116X support for controllers on OF platform bus"
297 + depends on USB_ISP116X_HCD && PPC_OF
298 + default y if PPC_OF
301 + Enables support for the ISP116x USB controller present on the
302 + OpenFirmware platform bus.
304 config USB_ISP1760_HCD
305 tristate "ISP 1760 HCD support"
306 depends on USB && EXPERIMENTAL