1 --- a/drivers/usb/host/isp116x-hcd.c
2 +++ b/drivers/usb/host/isp116x-hcd.c
3 @@ -1534,6 +1534,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 @@ -1710,4 +1711,251 @@ static struct platform_driver isp116x_dr
15 -module_platform_driver(isp116x_driver);
16 +static inline int isp116x_platform_register(void)
18 + return platform_driver_register(&isp116x_driver);
21 +static inline void isp116x_platform_unregister(void)
23 + platform_driver_unregister(&isp116x_driver);
26 +static inline int isp116x_platform_register(void) { return 0; };
27 +static void isp116x_platform_unregister(void) {};
28 +#endif /* CONFIG_USB_ISP116X_PLATFORM */
30 +/*-----------------------------------------------------------------*/
32 +#ifdef CONFIG_USB_ISP116X_HCD_OF
34 +/* TODO: rework platform probe instead of using a separate probe */
36 +#include <linux/of_platform.h>
38 +#ifdef USE_PLATFORM_DELAY
39 +static void isp116x_of_delay(struct device *ddev, int delay)
44 +#define isp116x_of_delay NULL
47 +static int __devinit isp116x_of_probe(struct platform_device *op)
49 + struct device_node *dn = op->dev.of_node;
50 + struct usb_hcd *hcd;
51 + struct isp116x *isp116x;
52 + struct resource addr, data;
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 + board = kzalloc(sizeof(struct isp116x_platform_data), GFP_KERNEL);
72 + if (!request_mem_region(addr.start, resource_size(&addr), hcd_name)) {
74 + goto err_free_board;
77 + addr_reg = ioremap_nocache(addr.start, resource_size(&addr));
78 + if (addr_reg == NULL) {
80 + goto err_release_addr;
83 + if (!request_mem_region(data.start, resource_size(&data), hcd_name)) {
85 + goto err_unmap_addr;
88 + data_reg = ioremap_nocache(data.start, resource_size(&data));
89 + if (data_reg == NULL) {
91 + goto err_release_data;
94 + irq = irq_of_parse_and_map(dn, 0);
95 + if (irq == NO_IRQ) {
97 + goto err_unmap_data;
100 + /* allocate and initialize hcd */
101 + hcd = usb_create_hcd(&isp116x_hc_driver, &op->dev, dev_name(&op->dev));
104 + goto err_irq_dispose;
107 + /* this rsrc_start is bogus */
108 + hcd->rsrc_start = addr.start;
109 + isp116x = hcd_to_isp116x(hcd);
110 + isp116x->data_reg = data_reg;
111 + isp116x->addr_reg = addr_reg;
112 + isp116x->board = board;
113 + spin_lock_init(&isp116x->lock);
114 + INIT_LIST_HEAD(&isp116x->async);
116 + board->delay = isp116x_of_delay;
117 + if (of_get_property(dn, "sel15Kres", NULL))
118 + board->sel15Kres = 1;
119 + if (of_get_property(dn, "oc_enable", NULL))
120 + board->oc_enable = 1;
121 + if (of_get_property(dn, "remote_wakeup_enable", NULL))
122 + board->remote_wakeup_enable = 1;
124 + if (of_get_property(dn, "int_act_high", NULL))
125 + board->int_act_high = 1;
126 + if (of_get_property(dn, "int_edge_triggered", NULL))
127 + board->int_edge_triggered = 1;
129 + if (board->int_edge_triggered)
130 + irqflags = board->int_act_high ? IRQF_TRIGGER_RISING :
131 + IRQF_TRIGGER_FALLING;
133 + irqflags = board->int_act_high ? IRQF_TRIGGER_HIGH :
136 + ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED);
140 + ret = create_debug_file(isp116x);
142 + ERR("Couldn't create debugfs entry\n");
143 + goto err_remove_hcd;
149 + usb_remove_hcd(hcd);
153 + irq_dispose_mapping(irq);
157 + release_mem_region(data.start, resource_size(&data));
161 + release_mem_region(addr.start, resource_size(&addr));
167 +static __devexit int isp116x_of_remove(struct platform_device *op)
169 + struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
170 + struct isp116x *isp116x;
171 + struct resource res;
176 + dev_set_drvdata(&op->dev, NULL);
178 + isp116x = hcd_to_isp116x(hcd);
179 + remove_debug_file(isp116x);
180 + usb_remove_hcd(hcd);
182 + irq_dispose_mapping(hcd->irq);
184 + iounmap(isp116x->data_reg);
185 + (void) of_address_to_resource(op->dev.of_node, 0, &res);
186 + release_mem_region(res.start, resource_size(&res));
188 + iounmap(isp116x->addr_reg);
189 + (void) of_address_to_resource(op->dev.of_node, 1, &res);
190 + release_mem_region(res.start, resource_size(&res));
192 + kfree(isp116x->board);
198 +static struct of_device_id isp116x_of_match[] = {
199 + { .compatible = "isp116x-hcd", },
203 +static struct platform_driver isp116x_of_platform_driver = {
204 + .probe = isp116x_of_probe,
205 + .remove = __devexit_p(isp116x_of_remove),
207 + .name = "isp116x-hcd-of",
208 + .owner = THIS_MODULE,
209 + .of_match_table = isp116x_of_match,
213 +static int __init isp116x_of_register(void)
215 + return platform_driver_register(&isp116x_of_platform_driver);
218 +static void __exit isp116x_of_unregister(void)
220 + platform_driver_unregister(&isp116x_of_platform_driver);
223 +MODULE_DEVICE_TABLE(of, isp116x_of_match);
226 +static inline int isp116x_of_register(void) { return 0; };
227 +static void isp116x_of_unregister(void) {};
228 +#endif /* CONFIG_USB_ISP116X_HCD_OF */
230 +/*-----------------------------------------------------------------*/
232 +static int __init isp116x_init(void)
236 + if (usb_disabled())
239 + INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION);
240 + ret = isp116x_platform_register();
244 + ret = isp116x_of_register();
246 + goto err_platform_unregister;
250 + err_platform_unregister:
251 + isp116x_platform_unregister();
255 +module_init(isp116x_init);
257 +static void __exit isp116x_cleanup(void)
259 + isp116x_of_unregister();
260 + isp116x_platform_unregister();
263 +module_exit(isp116x_cleanup);
264 --- a/drivers/usb/host/Kconfig
265 +++ b/drivers/usb/host/Kconfig
266 @@ -260,6 +260,24 @@ config USB_ISP116X_HCD
267 To compile this driver as a module, choose M here: the
268 module will be called isp116x-hcd.
270 +config USB_ISP116X_HCD_PLATFORM
271 + bool "ISP116X support for controllers on platform bus"
272 + depends on USB_ISP116X_HCD
273 + default n if PPC_OF
276 + Enables support for the ISP116x USB controller present on the
279 +config USB_ISP116X_HCD_OF
280 + bool "ISP116X support for controllers on OF platform bus"
281 + depends on USB_ISP116X_HCD && PPC_OF
282 + default y if PPC_OF
285 + Enables support for the ISP116x USB controller present on the
286 + OpenFirmware platform bus.
288 config USB_ISP1760_HCD
289 tristate "ISP 1760 HCD support"
290 depends on USB && EXPERIMENTAL