[PATCH] Add platform device support for the ISP1760 USB chip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 isp1760-plat.c file responsible for the driver registration and
modifies the corresponding Makefile and Kconfig to be able to use this
driver even if PCI and PPC_OF are not enabled.

In addition, it changes the function prototype for the
isp1760_register() function to use predefined types like phys_addr_t and
size_t rather than u64.

Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Sebastian Siewior <bigeasy@xxxxxxxxxxxxx>
Cc: Russell King <rmk@xxxxxxxxxxxxxxxx>
---
 drivers/usb/Makefile            |    1 
 drivers/usb/host/Kconfig        |    2 -
 drivers/usb/host/Makefile       |    4 +
 drivers/usb/host/isp1760-hcd.c  |    7 +-
 drivers/usb/host/isp1760-hcd.h  |    7 +-
 drivers/usb/host/isp1760-plat.c |  117 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 130 insertions(+), 8 deletions(-)
 create mode 100644 drivers/usb/host/isp1760-plat.c

diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 8bcde8c..304c0fd 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_USB_SL811_HCD)	+= host/
 obj-$(CONFIG_USB_U132_HCD)	+= host/
 obj-$(CONFIG_USB_R8A66597_HCD)	+= host/
 obj-$(CONFIG_USB_HWA_HCD)	+= host/
+obj-$(CONFIG_USB_ISP1760_HCD)	+= host/
 
 obj-$(CONFIG_USB_C67X00_HCD)	+= c67x00/
 
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2c63bfb..56de061 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -123,7 +123,7 @@ config USB_ISP116X_HCD
 
 config USB_ISP1760_HCD
 	tristate "ISP 1760 HCD support"
-	depends on USB && EXPERIMENTAL && (PCI || PPC_OF)
+	depends on USB && EXPERIMENTAL
 	---help---
 	  The ISP1760 chip is a USB 2.0 host controller.
 
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index f163571..54a9d81 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -6,7 +6,9 @@ ifeq ($(CONFIG_USB_DEBUG),y)
 	EXTRA_CFLAGS		+= -DDEBUG
 endif
 
-isp1760-objs := isp1760-hcd.o isp1760-if.o
+isp1760-$(CONFIG_PPC_OF)	+= isp1760-if.o
+isp1760-$(CONFIG_PCI)		+= isp1760-if.o
+isp1760-objs := isp1760-hcd.o isp1760-plat.o $(sort $(isp1760-y))
 fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \
 	     fhci-tds.o fhci-sched.o
 ifeq ($(CONFIG_FHCI_DEBUG),y)
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index b899f1a..e32f7a9 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -2235,9 +2235,10 @@ void deinit_kmem_cache(void)
 	kmem_cache_destroy(qh_cachep);
 }
 
-struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq,
-		u64 irqflags, struct device *dev, const char *busname,
-		unsigned int devflags)
+struct usb_hcd *isp1760_register(phys_addr_t res_start, size_t res_len,
+				 int irq, unsigned long irqflags,
+				 struct device *dev, const char *busname,
+				 unsigned int devflags)
 {
 	struct usb_hcd *hcd;
 	struct isp1760_hcd *priv;
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h
index a9daea5..c2b0914 100644
--- a/drivers/usb/host/isp1760-hcd.h
+++ b/drivers/usb/host/isp1760-hcd.h
@@ -2,9 +2,10 @@
 #define _ISP1760_HCD_H_
 
 /* exports for if */
-struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq,
-		u64 irqflags, struct device *dev, const char *busname,
-		unsigned int devflags);
+struct usb_hcd *isp1760_register(phys_addr_t res_start, size_t res_len,
+				 int irq, unsigned long irqflags,
+				 struct device *dev, const char *busname,
+				 unsigned int devflags);
 int init_kmem_once(void);
 void deinit_kmem_cache(void);
 
diff --git a/drivers/usb/host/isp1760-plat.c b/drivers/usb/host/isp1760-plat.c
new file mode 100644
index 0000000..1b15f09
--- /dev/null
+++ b/drivers/usb/host/isp1760-plat.c
@@ -0,0 +1,117 @@
+/*
+ * drivers/usb/host/isp1760-plat.c
+ *
+ * Glue code for the ISP1760 driver and bus using the patform device
+ * interface.
+ *
+ * Copyright (C) 2009 ARM Limited
+ * Written by Catalin Marinas <catalin.marinas@xxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/usb.h>
+
+#include "../core/hcd.h"
+#include "isp1760-hcd.h"
+
+static int __devinit isp1760_drv_probe(struct platform_device *pdev)
+{
+	int ret = 0;
+	struct usb_hcd *hcd;
+	struct resource *mem_res;
+	struct resource *irq_res;
+	size_t mem_size;
+
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!mem_res) {
+		pr_warning("isp1760: Memory resource not available\n");
+		ret = -ENODEV;
+		goto out;
+	}
+	mem_size = mem_res->end - mem_res->start + 1;
+	if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
+		pr_warning("isp1760: Cannot reserve the memory resource\n");
+		ret = -EBUSY;
+		goto out;
+	}
+
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!irq_res) {
+		pr_warning("isp1760: IRQ resource not available\n");
+		return -ENODEV;
+	}
+
+	hcd = isp1760_register(mem_res->start, mem_size, irq_res->start,
+			       IRQF_SHARED | IRQF_DISABLED, &pdev->dev,
+			       dev_name(&pdev->dev), 0);
+	if (IS_ERR(hcd)) {
+		pr_warning("isp1760: Failed to register the HCD device\n");
+		ret = -ENODEV;
+		goto cleanup;
+	}
+
+	pr_info("ISP1760 USB device initialised\n");
+	return ret;
+
+cleanup:
+	release_mem_region(mem_res->start, mem_size);
+out:
+	return ret;
+}
+
+static int __devexit isp1760_drv_remove(struct platform_device *pdev)
+{
+	struct resource *mem_res;
+	size_t mem_size;
+
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	mem_size = mem_res->end - mem_res->start + 1;
+	release_mem_region(mem_res->start, mem_size);
+
+	return 0;
+}
+
+static struct platform_driver isp1760_driver = {
+	.probe	= isp1760_drv_probe,
+	.remove	= isp1760_drv_remove,
+	.driver	= {
+		.name	= "isp1760",
+	},
+};
+
+static int __init isp1760_init(void)
+{
+	int ret;
+
+	ret = init_kmem_once();
+	if (ret)
+		goto out;
+	ret = platform_driver_register(&isp1760_driver);
+	if (ret)
+		deinit_kmem_cache();
+out:
+	return ret;
+}
+module_init(isp1760_init);
+
+static void __exit isp1760_exit(void)
+{
+	platform_driver_unregister(&isp1760_driver);
+	deinit_kmem_cache();
+}
+module_exit(isp1760_exit);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux