Dear sirs, The patch adds this usb host driver to w90p910 platform. It is based on version of 2.6.30-rc3. would you please give me some advice about this patch? arch/arm/mach-w90x900/include/mach/map.h | 11 arch/arm/mach-w90x900/include/mach/regs-clock.h | 33 ++ arch/arm/mach-w90x900/include/mach/regs-usb.h | 37 ++ drivers/usb/Kconfig | 2 drivers/usb/host/Kconfig | 12 drivers/usb/host/ehci-hcd.c | 5 drivers/usb/host/ehci-w90x900.c | 175 ++++++++++++++ drivers/usb/host/ohci-hcd.c | 5 drivers/usb/host/ohci-w90x900.c | 171 +++++++++++++ 9 files changed, 451 insertions(+) --- Add this usb host driver including EHCI and OHCI. It is only one part of patch,the other will be submitted soon after. Signed-off-by: Wan ZongShun <mcuos.com@xxxxxxxxx> diff -Npur linux-2.6.29/arch/arm/mach-w90x900/include/mach/map.h linux-2.6.30-rc3/arch/arm/mach-w90x900/include/mach/map.h --- linux-2.6.29/arch/arm/mach-w90x900/include/mach/map.h 2009-03-24 07:12:14.000000000 +0800 +++ linux-2.6.30-rc3/arch/arm/mach-w90x900/include/mach/map.h 2009-04-27 14:36:51.000000000 +0800 @@ -73,4 +73,15 @@ #define W90X900_PA_GPIO (0xB8003000) #define W90X900_SZ_GPIO SZ_4K +/* usb host ports */ + +#define W90X900_VA_USBEHCIHOST W90X900_ADDR(0x00005000) +#define W90X900_PA_USBEHCIHOST (0xB0005000) +#define W90X900_SZ_USBEHCIHOST SZ_4K + +#define W90X900_VA_USBOHCIHOST W90X900_ADDR(0x00007000) +#define W90X900_PA_USBOHCIHOST (0xB0007000) +#define W90X900_SZ_USBOHCIHOST SZ_4K + + #endif /* __ASM_ARCH_MAP_H */ diff -Npur linux-2.6.29/arch/arm/mach-w90x900/include/mach/regs-clock.h linux-2.6.30-rc3/arch/arm/mach-w90x900/include/mach/regs-clock.h --- linux-2.6.29/arch/arm/mach-w90x900/include/mach/regs-clock.h 1970-01-01 08:00:00.000000000 +0800 +++ linux-2.6.30-rc3/arch/arm/mach-w90x900/include/mach/regs-clock.h 2009-04-27 15:07:59.000000000 +0800 @@ -0,0 +1,33 @@ +/* + * arch/arm/mach-w90x900/include/mach/regs-clock.h + * + * Copyright (c) 2008 Nuvoton technology corporation + * All rights reserved. + * + * Wan ZongShun <mcuos.com@xxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#ifndef __ASM_ARCH_REGS_CLOCK_H +#define __ASM_ARCH_REGS_CLOCK_H + +/* Clock Control Registers */ +#define CLK_BA W90X900_VA_CLKPWR +#define REG_CLKEN (CLK_BA + 0x00) +#define REG_CLKSEL (CLK_BA + 0x04) +#define REG_CLKDIV (CLK_BA + 0x08) +#define REG_PLLCON0 (CLK_BA + 0x0C) +#define REG_PLLCON1 (CLK_BA + 0x10) +#define REG_PMCON (CLK_BA + 0x14) +#define REG_IRQWAKECON (CLK_BA + 0x18) +#define REG_IRQWAKEFLAG (CLK_BA + 0x1C) +#define REG_IPSRST (CLK_BA + 0x20) +#define REG_CLKEN1 (CLK_BA + 0x24) +#define REG_CLKDIV1 (CLK_BA + 0x28) + +#endif /* __ASM_ARCH_REGS_CLOCK_H */ diff -Npur linux-2.6.29/arch/arm/mach-w90x900/include/mach/regs-usb.h linux-2.6.30-rc3/arch/arm/mach-w90x900/include/mach/regs-usb.h --- linux-2.6.29/arch/arm/mach-w90x900/include/mach/regs-usb.h 1970-01-01 08:00:00.000000000 +0800 +++ linux-2.6.30-rc3/arch/arm/mach-w90x900/include/mach/regs-usb.h 2009-04-27 14:41:11.000000000 +0800 @@ -0,0 +1,37 @@ +/* + * arch/arm/mach-w90x900/include/mach/regs-usb.h + * + * Copyright (c) 2008 Nuvoton technology corporation + * All rights reserved. + * + * Wan ZongShun <mcuos.com@xxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#ifndef __ASM_ARCH_REGS_USB_H +#define __ASM_ARCH_REGS_USB_H + +/* usb Control Registers */ +#define USBH_BA W90X900_VA_USBEHCIHOST +#define USBD_BA W90X900_VA_USBDEV +#define USBO_BA W90X900_VA_USBOHCIHOST + +/* USB Host Control Registers */ +#define REG_UPSCR0 (USBH_BA+0x064) +#define REG_UPSCR1 (USBH_BA+0x068) +#define REG_USBPCR0 (USBH_BA+0x0C4) +#define REG_USBPCR1 (USBH_BA+0x0C8) + +/* USBH OHCI Control Registers */ +#define REG_OpModEn (USBO_BA+0x204) +/*This bit controls the polarity of over +*current flag from external power IC. +*/ +#define OCALow 0x08 + +#endif /* __ASM_ARCH_REGS_USB_H */ diff -Npur linux-2.6.29/drivers/usb/Kconfig linux-2.6.30-rc3/drivers/usb/Kconfig --- linux-2.6.29/drivers/usb/Kconfig 2009-04-27 14:11:12.000000000 +0800 +++ linux-2.6.30-rc3/drivers/usb/Kconfig 2009-04-27 13:43:53.000000000 +0800 @@ -38,6 +38,7 @@ config USB_ARCH_HAS_OHCI default y if ARCH_AT91 default y if ARCH_PNX4008 && I2C default y if MFD_TC6393XB + default y if ARCH_W90X900 # PPC: default y if STB03xxx default y if PPC_MPC52xx @@ -57,6 +58,7 @@ config USB_ARCH_HAS_EHCI default y if PPC_83xx default y if SOC_AU1200 default y if ARCH_IXP4XX + default y if ARCH_W90X900 default PCI # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. diff -Npur linux-2.6.29/drivers/usb/host/Kconfig linux-2.6.30-rc3/drivers/usb/host/Kconfig --- linux-2.6.29/drivers/usb/host/Kconfig 2009-04-27 14:11:12.000000000 +0800 +++ linux-2.6.30-rc3/drivers/usb/host/Kconfig 2009-04-27 15:09:06.000000000 +0800 @@ -93,6 +93,12 @@ config USB_EHCI_HCD_PPC_OF Enables support for the USB controller present on the PowerPC OpenFirmware platform bus. +config USB_W90X900_EHCI + bool "W90X900(W90P910) EHCI support" + depends on USB_EHCI_HCD && ARCH_W90X900 + ---help--- + Enables support for the W90X900 USB controller + config USB_OXU210HP_HCD tristate "OXU210HP HCD support" depends on USB @@ -220,6 +226,12 @@ config USB_OHCI_LITTLE_ENDIAN default n if STB03xxx || PPC_MPC52xx default y +config USB_W90X900_OHCI + bool "W90X900(W90P910) OHCI support" + depends on USB_OHCI_HCD && ARCH_W90X900 + ---help--- + Enables support for the W90X900 USB controller + config USB_UHCI_HCD tristate "UHCI HCD (most Intel and VIA) support" depends on USB && PCI diff -Npur linux-2.6.29/drivers/usb/host/ehci-hcd.c linux-2.6.30-rc3/drivers/usb/host/ehci-hcd.c --- linux-2.6.29/drivers/usb/host/ehci-hcd.c 2009-04-27 14:11:12.000000000 +0800 +++ linux-2.6.30-rc3/drivers/usb/host/ehci-hcd.c 2009-04-27 13:47:02.000000000 +0800 @@ -1072,6 +1072,11 @@ MODULE_LICENSE ("GPL"); #define PLATFORM_DRIVER ixp4xx_ehci_driver #endif +#ifdef CONFIG_USB_W90X900_EHCI +#include "ehci-w90x900.c" +#define PLATFORM_DRIVER ehci_hcd_w90x900_driver +#endif + #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) #error "missing bus glue for ehci-hcd" diff -Npur linux-2.6.29/drivers/usb/host/ehci-w90x900.c linux-2.6.30-rc3/drivers/usb/host/ehci-w90x900.c --- linux-2.6.29/drivers/usb/host/ehci-w90x900.c 1970-01-01 08:00:00.000000000 +0800 +++ linux-2.6.30-rc3/drivers/usb/host/ehci-w90x900.c 2009-04-27 15:10:39.000000000 +0800 @@ -0,0 +1,175 @@ +/* + * linux/driver/usb/host/ehci-w90x900.c + * + * Copyright (c) 2008 Nuvoton technology corporation + * All rights reserved. + * + * Wan ZongShun <mcuos.com@xxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include <linux/platform_device.h> +#include <mach/regs-clock.h> +#include <mach/regs-usb.h> + +int usb_w90x900_probe(const struct hc_driver *driver, + struct platform_device *pdev) +{ + struct usb_hcd *hcd; + struct ehci_hcd *ehci; + int retval; + + /* enable USB Host clock */ + __raw_writel(__raw_readl(REG_CLKEN) | 0x200, REG_CLKEN); + + if (pdev->resource[1].flags != IORESOURCE_IRQ) { + pr_debug("resource[1] is not IORESOURCE_IRQ"); + retval = -ENOMEM; + } + + hcd = usb_create_hcd(driver, &pdev->dev, "w90x900 EHCI"); + if (!hcd) { + retval = -ENOMEM; + goto err1; + } + + + hcd->rsrc_start = pdev->resource[0].start; + hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; + + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { + pr_debug("request_mem_region failed"); + retval = -EBUSY; + goto err2; + } + + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); + if (hcd->regs == NULL) { + pr_debug("error mapping memory\n"); + retval = -EFAULT; + goto err3; + } + + ehci = hcd_to_ehci(hcd); + ehci->caps = hcd->regs; + ehci->regs = hcd->regs + + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); + + __raw_writel(OCALow, REG_OpModEn); + + /* enable PHY 0 */ + __raw_writel(0x160, REG_USBPCR0); + + /* enable PHY 1 */ + __raw_writel(0x520, REG_USBPCR1); + + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); + ehci->sbrn = 0x20; + + retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED); + + + if (retval != 0) + goto err4; + + ehci_writel(ehci, 1, &ehci->regs->configured_flag); + + return retval; +err4: + iounmap(hcd->regs); +err3: + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); +err2: + usb_put_hcd(hcd); +err1: + + return retval; +} + +void usb_w90x900_remove(struct usb_hcd *hcd, struct platform_device *pdev) +{ + usb_remove_hcd(hcd); + iounmap(hcd->regs); + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); + usb_put_hcd(hcd); +} + + +static const struct hc_driver ehci_w90x900_hc_driver = { + .description = hcd_name, + .product_desc = "Nuvoton w90x900 EHCI Host Controller", + .hcd_priv_size = sizeof(struct ehci_hcd), + + /* + * generic hardware linkage + */ + .irq = ehci_irq, + .flags = HCD_USB2|HCD_MEMORY, + + /* + * basic lifecycle operations + */ + .reset = ehci_init, + .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, + + /* + * scheduling support + */ + .get_frame_number = ehci_get_frame, + + /* + * root hub support + */ + .hub_status_data = ehci_hub_status_data, + .hub_control = ehci_hub_control, +#ifdef CONFIG_PM + .bus_suspend = ehci_bus_suspend, + .bus_resume = ehci_bus_resume, +#endif + .relinquish_port = ehci_relinquish_port, + .port_handed_over = ehci_port_handed_over, +}; + +static int ehci_w90x900_probe(struct platform_device *pdev) +{ + if (usb_disabled()) + return -ENODEV; + + return usb_w90x900_probe(&ehci_w90x900_hc_driver, pdev); +} + +static int ehci_w90x900_remove(struct platform_device *pdev) +{ + struct usb_hcd *hcd = platform_get_drvdata(pdev); + + usb_w90x900_remove(hcd, pdev); + + return 0; +} + +MODULE_ALIAS("platform:w90x900-ehci"); + +static struct platform_driver ehci_hcd_w90x900_driver = { + + .probe = ehci_w90x900_probe, + .remove = ehci_w90x900_remove, + .driver = { + .name = "w90x900-ehci", + .owner = THIS_MODULE, + }, +}; diff -Npur linux-2.6.29/drivers/usb/host/ohci-hcd.c linux-2.6.30-rc3/drivers/usb/host/ohci-hcd.c --- linux-2.6.29/drivers/usb/host/ohci-hcd.c 2009-04-27 14:11:12.000000000 +0800 +++ linux-2.6.30-rc3/drivers/usb/host/ohci-hcd.c 2009-04-27 13:47:25.000000000 +0800 @@ -1081,6 +1081,11 @@ MODULE_LICENSE ("GPL"); #define TMIO_OHCI_DRIVER ohci_hcd_tmio_driver #endif +#ifdef CONFIG_USB_W90X900_OHCI +#include "ohci-w90x900.c" +#define PLATFORM_DRIVER ohci_hcd_w90x900_driver +#endif + #if !defined(PCI_DRIVER) && \ !defined(PLATFORM_DRIVER) && \ !defined(OF_PLATFORM_DRIVER) && \ diff -Npur linux-2.6.29/drivers/usb/host/ohci-w90x900.c linux-2.6.30-rc3/drivers/usb/host/ohci-w90x900.c --- linux-2.6.29/drivers/usb/host/ohci-w90x900.c 1970-01-01 08:00:00.000000000 +0800 +++ linux-2.6.30-rc3/drivers/usb/host/ohci-w90x900.c 2009-04-27 15:29:00.000000000 +0800 @@ -0,0 +1,171 @@ +/* + * linux/driver/usb/host/ohci-w90x900.c + * + * Copyright (c) 2008 Nuvoton technology corporation + * All rights reserved. + * + * Wan ZongShun <mcuos.com@xxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include <linux/platform_device.h> +#include <linux/interrupt.h> + +static int usb_hcd_w90x900_probe(const struct hc_driver *driver, + struct platform_device *pdev) +{ + int retval; + struct usb_hcd *hcd; + struct ohci_hcd *ohci ; + + hcd = usb_create_hcd(driver, &pdev->dev, "w90x900 ohci"); + if (!hcd) + return -ENOMEM; + + hcd->rsrc_start = pdev->resource[0].start; + hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; + + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { + retval = -EBUSY; + goto err1; + } + + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); + if (!hcd->regs) { + retval = -ENOMEM; + goto err2; + } + + + ohci = hcd_to_ohci(hcd); + ohci_hcd_init(ohci); + + retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED); + + if (retval != 0) + goto err3; + + return retval; + +err3: + iounmap(hcd->regs); +err2: + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); +err1: + usb_put_hcd(hcd); + return retval; +} + +static void usb_hcd_w90x900_remove(struct usb_hcd *hcd, + struct platform_device *dev) +{ + usb_remove_hcd(hcd); + iounmap(hcd->regs); + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); + usb_put_hcd(hcd); +} + + +static int ohci_w90x900_start(struct usb_hcd *hcd) +{ + struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; + + ret = ohci_init(ohci); + + if (ret < 0) + return ret; + + ret = ohci_run(ohci); + + if (ret < 0) { + err("can't start %s", hcd->self.bus_name); + ohci_stop(hcd); + return ret; + } + + return ret; +} + + +static const struct hc_driver ohci_w90x900_hc_driver = { + .description = hcd_name, + .product_desc = "Nuvoton w90x900 ohci Host Controller", + .hcd_priv_size = sizeof(struct ohci_hcd), + + /* + * generic hardware linkage + */ + .irq = ohci_irq, + .flags = HCD_USB11 | HCD_MEMORY, + + /* + * basic lifecycle operations + */ + .start = ohci_w90x900_start, + .stop = ohci_stop, + .shutdown = ohci_shutdown, + /* + * managing i/o requests and associated device resources + */ + .urb_enqueue = ohci_urb_enqueue, + .urb_dequeue = ohci_urb_dequeue, + .endpoint_disable = ohci_endpoint_disable, + + /* + * scheduling support + */ + .get_frame_number = ohci_get_frame, + + /* + * root hub support + */ + .hub_status_data = ohci_hub_status_data, + .hub_control = ohci_hub_control, +#ifdef CONFIG_PM + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, +#endif + .start_port_reset = ohci_start_port_reset, +}; + + +static int ohci_hcd_w90x900_drv_probe(struct platform_device *pdev) +{ + int ret; + + if (usb_disabled()) + return -ENODEV; + + ret = usb_hcd_w90x900_probe(&ohci_w90x900_hc_driver, pdev); + return ret; +} + +static int ohci_hcd_w90x900_drv_remove(struct platform_device *pdev) +{ + struct usb_hcd *hcd = platform_get_drvdata(pdev); + + usb_hcd_w90x900_remove(hcd, pdev); + return 0; +} + + +MODULE_ALIAS("platform:w90x900-ohci"); + +static struct platform_driver ohci_hcd_w90x900_driver = { + .probe = ohci_hcd_w90x900_drv_probe, + .remove = ohci_hcd_w90x900_drv_remove, +#ifdef CONFIG_PM + +#endif + .driver = { + .name = "w90x900-ohci", + .owner = THIS_MODULE, + }, +}; + -- embedded forum http://mcuos.com -- 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