Skip to content

Commit f7e7aa5

Browse files
ctmarinasgregkh
authored andcommitted
USB: Add platform device support for the ISP1760 USB chip
Currently, the driver only supports PCI and PPC_OF but there are boards like ARM RealView where this is a platform device. The patch adds the necessary functions and registration to the isp1760-if.c file and modifies the corresponding Makefile and Kconfig to be able to use this driver even if PCI and PPC_OF are not enabled. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Sebastian Siewior <bigeasy@linutronix.de> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent f9031f2 commit f7e7aa5

3 files changed

Lines changed: 81 additions & 17 deletions

File tree

‎drivers/usb/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ obj-$(CONFIG_USB_SL811_HCD) += host/
1919
obj-$(CONFIG_USB_U132_HCD) += host/
2020
obj-$(CONFIG_USB_R8A66597_HCD) += host/
2121
obj-$(CONFIG_USB_HWA_HCD) += host/
22+
obj-$(CONFIG_USB_ISP1760_HCD) += host/
2223

2324
obj-$(CONFIG_USB_C67X00_HCD) += c67x00/
2425

‎drivers/usb/host/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ config USB_ISP116X_HCD
120120

121121
config USB_ISP1760_HCD
122122
tristate "ISP 1760 HCD support"
123-
depends on USB && EXPERIMENTAL && (PCI || PPC_OF)
123+
depends on USB && EXPERIMENTAL
124124
---help---
125125
The ISP1760 chip is a USB 2.0 host controller.
126126

‎drivers/usb/host/isp1760-if.c‎

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/usb.h>
1212
#include <linux/io.h>
13+
#include <linux/platform_device.h>
1314

1415
#include "../core/hcd.h"
1516
#include "isp1760-hcd.h"
@@ -300,39 +301,101 @@ static struct pci_driver isp1761_pci_driver = {
300301
};
301302
#endif
302303

304+
static int __devinit isp1760_plat_probe(struct platform_device *pdev)
305+
{
306+
int ret = 0;
307+
struct usb_hcd *hcd;
308+
struct resource *mem_res;
309+
struct resource *irq_res;
310+
resource_size_t mem_size;
311+
unsigned long irqflags = IRQF_SHARED | IRQF_DISABLED;
312+
313+
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
314+
if (!mem_res) {
315+
pr_warning("isp1760: Memory resource not available\n");
316+
ret = -ENODEV;
317+
goto out;
318+
}
319+
mem_size = resource_size(mem_res);
320+
if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
321+
pr_warning("isp1760: Cannot reserve the memory resource\n");
322+
ret = -EBUSY;
323+
goto out;
324+
}
325+
326+
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
327+
if (!irq_res) {
328+
pr_warning("isp1760: IRQ resource not available\n");
329+
return -ENODEV;
330+
}
331+
irqflags |= irq_res->flags & IRQF_TRIGGER_MASK;
332+
333+
hcd = isp1760_register(mem_res->start, mem_size, irq_res->start,
334+
irqflags, &pdev->dev, dev_name(&pdev->dev), 0);
335+
if (IS_ERR(hcd)) {
336+
pr_warning("isp1760: Failed to register the HCD device\n");
337+
ret = -ENODEV;
338+
goto cleanup;
339+
}
340+
341+
pr_info("ISP1760 USB device initialised\n");
342+
return ret;
343+
344+
cleanup:
345+
release_mem_region(mem_res->start, mem_size);
346+
out:
347+
return ret;
348+
}
349+
350+
static int __devexit isp1760_plat_remove(struct platform_device *pdev)
351+
{
352+
struct resource *mem_res;
353+
resource_size_t mem_size;
354+
355+
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
356+
mem_size = resource_size(mem_res);
357+
release_mem_region(mem_res->start, mem_size);
358+
359+
return 0;
360+
}
361+
362+
static struct platform_driver isp1760_plat_driver = {
363+
.probe = isp1760_plat_probe,
364+
.remove = isp1760_plat_remove,
365+
.driver = {
366+
.name = "isp1760",
367+
},
368+
};
369+
303370
static int __init isp1760_init(void)
304371
{
305-
int ret;
372+
int ret, any_ret = -ENODEV;
306373

307374
init_kmem_once();
308375

376+
ret = platform_driver_register(&isp1760_plat_driver);
377+
if (!ret)
378+
any_ret = 0;
309379
#ifdef CONFIG_PPC_OF
310380
ret = of_register_platform_driver(&isp1760_of_driver);
311-
if (ret) {
312-
deinit_kmem_cache();
313-
return ret;
314-
}
381+
if (!ret)
382+
any_ret = 0;
315383
#endif
316384
#ifdef CONFIG_PCI
317385
ret = pci_register_driver(&isp1761_pci_driver);
318-
if (ret)
319-
goto unreg_of;
386+
if (!ret)
387+
any_ret = 0;
320388
#endif
321-
return ret;
322389

323-
#ifdef CONFIG_PCI
324-
unreg_of:
325-
#endif
326-
#ifdef CONFIG_PPC_OF
327-
of_unregister_platform_driver(&isp1760_of_driver);
328-
#endif
329-
deinit_kmem_cache();
330-
return ret;
390+
if (any_ret)
391+
deinit_kmem_cache();
392+
return any_ret;
331393
}
332394
module_init(isp1760_init);
333395

334396
static void __exit isp1760_exit(void)
335397
{
398+
platform_driver_unregister(&isp1760_plat_driver);
336399
#ifdef CONFIG_PPC_OF
337400
of_unregister_platform_driver(&isp1760_of_driver);
338401
#endif

0 commit comments

Comments
 (0)