From: Gabor Juhos Date: Fri, 13 Sep 2013 15:38:42 +0000 (+0000) Subject: cns21xx: make cns21xx-ehci a separate driver X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=826ef500144a4cd1936e3395f2e71a537ffc00a0;p=openwrt%2Fstaging%2Fflorian.git cns21xx: make cns21xx-ehci a separate driver Signed-off-by: Gabor Juhos SVN-Revision: 37968 --- diff --git a/target/linux/cns21xx/modules.mk b/target/linux/cns21xx/modules.mk new file mode 100644 index 0000000000..9882ee8c10 --- /dev/null +++ b/target/linux/cns21xx/modules.mk @@ -0,0 +1,23 @@ +# +# Copyright (C) 2103 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define KernelPackage/usb2-cns21xx + TITLE:=Support for the built-in EHCI controller of the CNS21xx SoCs + DEPENDS:=@TARGET_cns21xx +kmod-usb2 + KCONFIG:=CONFIG_USB_EHCI_CNS21XX + FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-cns21xx.ko + AUTOLOAD:=$(call AutoLoad,41,ehci-cns21xx,1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb2-cns21xx/description + Kernel support for the built-in EHCI controller of the CNS21xx SoCs. +endef + +$(eval $(call KernelPackage,usb2-cns21xx)) + + diff --git a/target/linux/cns21xx/patches-3.8/104-cns21xx-usb-ehci-support.patch b/target/linux/cns21xx/patches-3.8/104-cns21xx-usb-ehci-support.patch index e68974c87b..c75aaecbe9 100644 --- a/target/linux/cns21xx/patches-3.8/104-cns21xx-usb-ehci-support.patch +++ b/target/linux/cns21xx/patches-3.8/104-cns21xx-usb-ehci-support.patch @@ -1,98 +1,43 @@ --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c -@@ -1338,6 +1338,11 @@ MODULE_LICENSE ("GPL"); - #define PLATFORM_DRIVER ehci_hcd_sead3_driver - #endif - -+#ifdef CONFIG_ARCH_CNS21XX -+#include "ehci-cns21xx.c" -+#define PLATFORM_DRIVER ehci_cns21xx_driver -+#endif -+ - #if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \ +@@ -1342,6 +1342,7 @@ MODULE_LICENSE ("GPL"); !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \ !IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \ + !IS_ENABLED(CONFIG_USB_EHCI_MXC) && \ ++ !IS_ENABLED(CONFIG_USB_EHCI_CNS21XX) && \ + !defined(PLATFORM_DRIVER) && \ + !defined(PS3_SYSTEM_BUS_DRIVER) && \ + !defined(OF_PLATFORM_DRIVER) && \ --- /dev/null +++ b/drivers/usb/host/ehci-cns21xx.c -@@ -0,0 +1,187 @@ +@@ -0,0 +1,130 @@ +/* + * Copyright (c) 2008 Cavium Networks -+ * Copyright (c) 2010-2012 Gabor Juhos ++ * Copyright (c) 2010-2013 Gabor Juhos + * + * This file 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. + */ + ++#include ++#include ++#include +#include +#include ++#include ++#include + +#include + -+#define DRIVER_NAME "cns21xx-ehci" -+ -+static int cns21xx_ehci_reset(struct usb_hcd *hcd) -+{ -+ struct ehci_hcd *ehci = hcd_to_ehci(hcd); -+ int ret; -+ -+ ret = ehci_halt(ehci); -+ if (ret) -+ return ret; -+ -+ ret = ehci_init(hcd); -+ if (ret) -+ return ret; -+ -+ ehci_reset(ehci); ++#include "ehci.h" + -+ return 0; -+} ++#define DRIVER_NAME "cns21xx-ehci" + -+static const struct hc_driver ehci_cns21xx_hc_driver = { -+ .description = hcd_name, -+ .product_desc = DRIVER_NAME, -+ .hcd_priv_size = sizeof(struct ehci_hcd), -+ -+ /* -+ * generic hardware linkage -+ */ -+ .irq = ehci_irq, -+ .flags = HCD_MEMORY | HCD_USB2, -+ -+ /* -+ * basic lifecycle operations -+ */ -+ .reset = cns21xx_ehci_reset, -+ .start = ehci_run, -+ .stop = ehci_stop, -+ .shutdown = ehci_shutdown, -+ -+ /* -+ * managing i/o requests and associated device resources -+ */ -+ .urb_enqueue = ehci_urb_enqueue, -+ .urb_dequeue = ehci_urb_dequeue, -+ .endpoint_disable = ehci_endpoint_disable, -+ .endpoint_reset = ehci_endpoint_reset, -+ -+ /* -+ * scheduling support -+ */ -+ .get_frame_number = ehci_get_frame, -+ -+ /* -+ * root hub support -+ */ -+ .hub_status_data = ehci_hub_status_data, -+ .hub_control = ehci_hub_control, -+ .relinquish_port = ehci_relinquish_port, -+ .port_handed_over = ehci_port_handed_over, -+ -+ .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, -+}; ++static const char hcd_name[] = "ehci-cns21xx"; ++static struct hc_driver __read_mostly ehci_cns21xx_hc_driver; + -+static void cns21xx_ehci_init_hc(void) ++static void ehci_cns21xx_init_hc(void) +{ + void __iomem *base = (void __iomem *) CNS21XX_EHCI_CONFIG_BASE_VIRT; + @@ -109,72 +54,50 @@ + int irq; + int ret; + -+ if (usb_disabled()) ++ irq = platform_get_irq(pdev, 0); ++ if (irq < 0) { ++ dev_dbg(&pdev->dev, "no IRQ specified for %s\n", ++ dev_name(&pdev->dev)); + return -ENODEV; ++ } + -+ res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { -+ dev_dbg(&pdev->dev, "no IRQ specified for %s\n", ++ dev_dbg(&pdev->dev, "no base address specified for %s\n", + dev_name(&pdev->dev)); -+ return -ENODEV; ++ return -EINVAL; + } -+ irq = res->start; + + hcd = usb_create_hcd(&ehci_cns21xx_hc_driver, &pdev->dev, + dev_name(&pdev->dev)); + if (!hcd) + return -ENOMEM; + -+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ if (!res) { -+ dev_dbg(&pdev->dev, "no base address specified for %s\n", -+ dev_name(&pdev->dev)); -+ ret = -ENODEV; -+ goto err_put_hcd; -+ } + hcd->rsrc_start = res->start; + hcd->rsrc_len = res->end - res->start + 1; + -+ if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { -+ dev_dbg(&pdev->dev, "controller already in use\n"); -+ ret = -EBUSY; ++ hcd->regs = devm_ioremap_resource(&pdev->dev, res); ++ if (IS_ERR(hcd->regs)) { ++ ret = PTR_ERR(hcd->regs); + goto err_put_hcd; + } + -+ hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); -+ if (!hcd->regs) { -+ dev_dbg(&pdev->dev, "error mapping memory\n"); -+ ret = -EFAULT; -+ goto err_release_region; -+ } -+ -+ cns21xx_ehci_init_hc(); ++ ehci_cns21xx_init_hc(); + + ehci = hcd_to_ehci(hcd); -+ + ehci->caps = hcd->regs; -+ ehci->regs = hcd->regs + -+ HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); -+ dbg_hcs_params(ehci, "reset"); -+ dbg_hcc_params(ehci, "reset"); -+ -+ /* cache this readonly data; minimize chip reads */ -+ ehci->hcs_params = readl(&ehci->caps->hcs_params); -+ ehci->sbrn = 0x20; + -+ ret = usb_add_hcd(hcd, CNS21XX_IRQ_EHCI, IRQF_DISABLED); ++ ret = usb_add_hcd(hcd, irq, IRQF_SHARED); + if (ret) -+ goto err_unmap; ++ goto err_put_hcd; + + platform_set_drvdata(pdev, hcd); ++ + return 0; + -+err_unmap: -+ iounmap(hcd->regs); -+err_release_region: -+ release_mem_region(hcd->rsrc_start, hcd->rsrc_len); +err_put_hcd: + usb_put_hcd(hcd); ++ + return ret; +} + @@ -183,10 +106,7 @@ + struct usb_hcd *hcd = platform_get_drvdata(pdev); + + usb_remove_hcd(hcd); -+ iounmap(hcd->regs); -+ release_mem_region(hcd->rsrc_start, hcd->rsrc_len); + usb_put_hcd(hcd); -+ platform_set_drvdata(pdev, NULL); + + return 0; +} @@ -201,7 +121,26 @@ + }, +}; + ++static int __init ehci_cns21xx_init(void) ++{ ++ if (usb_disabled()) ++ return -ENODEV; ++ ++ ehci_init_driver(&ehci_cns21xx_hc_driver, NULL); ++ ++ return platform_driver_register(&ehci_cns21xx_driver); ++} ++module_init(ehci_cns21xx_init); ++ ++static void __exit ehci_cns21xx_exit(void) ++{ ++ platform_driver_unregister(&ehci_cns21xx_driver); ++} ++module_exit(ehci_cns21xx_exit); ++ ++MODULE_DESCRIPTION("Cavium Networks CNS21xx built-in EHCI controller driver"); +MODULE_ALIAS("platform:" DRIVER_NAME); ++MODULE_LICENSE("GPL v2"); --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -382,6 +382,7 @@ config ARCH_CNS21XX @@ -212,3 +151,30 @@ help Support for Cavium Networks CNS21xx family. +--- a/drivers/usb/host/Kconfig ++++ b/drivers/usb/host/Kconfig +@@ -219,6 +219,14 @@ config USB_W90X900_EHCI + ---help--- + Enables support for the W90X900 USB controller + ++config USB_EHCI_CNS21XX ++ tristate "EHCI support for the Cavium CNS21XX SoCs" ++ depends on ARCH_CNS21XX ++ default y ++ help ++ Enables support for the built-in EHCI controller of the ++ Cavium CNS21xx SoCs. ++ + config USB_CNS3XXX_EHCI + bool "Cavium CNS3XXX EHCI Module (DEPRECATED)" + depends on USB_EHCI_HCD && ARCH_CNS3XXX +--- a/drivers/usb/host/Makefile ++++ b/drivers/usb/host/Makefile +@@ -27,6 +27,7 @@ obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o + obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o + obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o + obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o ++obj-$(CONFIG_USB_EHCI_CNS21XX) += ehci-cns21xx.o + + obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o + obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o diff --git a/target/linux/cns21xx/profiles/00-default.mk b/target/linux/cns21xx/profiles/00-default.mk index a2b669ed75..c2d26c7499 100644 --- a/target/linux/cns21xx/profiles/00-default.mk +++ b/target/linux/cns21xx/profiles/00-default.mk @@ -8,7 +8,8 @@ define Profile/Default NAME:=Default Profile (all drivers) PACKAGES:= \ - kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev + kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb2-cns21xx \ + kmod-ledtrig-usbdev endef define Profile/Default/Description