diff options
| author | Lennert Buytenhek <buytenh@wantstofly.org> | 2006-06-23 17:02:01 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-07-12 19:03:20 -0400 |
| commit | a5b7474a0364507d168c7ff473e2d82deb676b08 (patch) | |
| tree | 7a8260457db31257b841700787baf46933503da0 | |
| parent | d14feb5ee4a46218f92b21ed52338b64130a151b (diff) | |
[PATCH] USB: ohci bits for the cirrus ep93xx
This patch adds OHCI glue bits for the USB host interface in the
Cirrus ep93xx (arm920t) CPU.
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/usb/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/usb/host/ohci-ep93xx.c | 225 | ||||
| -rw-r--r-- | drivers/usb/host/ohci-hcd.c | 5 |
3 files changed, 231 insertions, 0 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 7fdbc5dad5fd..2ee742d40c43 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
| @@ -23,6 +23,7 @@ config USB_ARCH_HAS_OHCI | |||
| 23 | default y if ARCH_LH7A404 | 23 | default y if ARCH_LH7A404 |
| 24 | default y if ARCH_S3C2410 | 24 | default y if ARCH_S3C2410 |
| 25 | default y if PXA27x | 25 | default y if PXA27x |
| 26 | default y if ARCH_EP93XX | ||
| 26 | default y if ARCH_AT91RM9200 | 27 | default y if ARCH_AT91RM9200 |
| 27 | # PPC: | 28 | # PPC: |
| 28 | default y if STB03xxx | 29 | default y if STB03xxx |
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c new file mode 100644 index 000000000000..6531c4d26527 --- /dev/null +++ b/drivers/usb/host/ohci-ep93xx.c | |||
| @@ -0,0 +1,225 @@ | |||
| 1 | /* | ||
| 2 | * OHCI HCD (Host Controller Driver) for USB. | ||
| 3 | * | ||
| 4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> | ||
| 5 | * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> | ||
| 6 | * (C) Copyright 2002 Hewlett-Packard Company | ||
| 7 | * | ||
| 8 | * Bus Glue for ep93xx. | ||
| 9 | * | ||
| 10 | * Written by Christopher Hoover <ch@hpl.hp.com> | ||
| 11 | * Based on fragments of previous driver by Russell King et al. | ||
| 12 | * | ||
| 13 | * Modified for LH7A404 from ohci-sa1111.c | ||
| 14 | * by Durgesh Pattamatta <pattamattad@sharpsec.com> | ||
| 15 | * | ||
| 16 | * Modified for pxa27x from ohci-lh7a404.c | ||
| 17 | * by Nick Bane <nick@cecomputing.co.uk> 26-8-2004 | ||
| 18 | * | ||
| 19 | * Modified for ep93xx from ohci-pxa27x.c | ||
| 20 | * by Lennert Buytenhek <buytenh@wantstofly.org> 28-2-2006 | ||
| 21 | * Based on an earlier driver by Ray Lehtiniemi | ||
| 22 | * | ||
| 23 | * This file is licenced under the GPL. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <linux/clk.h> | ||
| 27 | #include <linux/device.h> | ||
| 28 | #include <linux/signal.h> | ||
| 29 | #include <linux/platform_device.h> | ||
| 30 | |||
| 31 | #include <asm/mach-types.h> | ||
| 32 | #include <asm/hardware.h> | ||
| 33 | |||
| 34 | static struct clk *usb_host_clock; | ||
| 35 | |||
| 36 | static void ep93xx_start_hc(struct device *dev) | ||
| 37 | { | ||
| 38 | clk_enable(usb_host_clock); | ||
| 39 | } | ||
| 40 | |||
| 41 | static void ep93xx_stop_hc(struct device *dev) | ||
| 42 | { | ||
| 43 | clk_disable(usb_host_clock); | ||
| 44 | } | ||
| 45 | |||
| 46 | static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, | ||
| 47 | struct platform_device *pdev) | ||
| 48 | { | ||
| 49 | int retval; | ||
| 50 | struct usb_hcd *hcd; | ||
| 51 | |||
| 52 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { | ||
| 53 | pr_debug("resource[1] is not IORESOURCE_IRQ"); | ||
| 54 | return -ENOMEM; | ||
| 55 | } | ||
| 56 | |||
| 57 | hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx"); | ||
| 58 | if (hcd == NULL) | ||
| 59 | return -ENOMEM; | ||
| 60 | |||
| 61 | hcd->rsrc_start = pdev->resource[0].start; | ||
| 62 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | ||
| 63 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
| 64 | usb_put_hcd(hcd); | ||
| 65 | retval = -EBUSY; | ||
| 66 | goto err1; | ||
| 67 | } | ||
| 68 | |||
| 69 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
| 70 | if (hcd->regs == NULL) { | ||
| 71 | pr_debug("ioremap failed"); | ||
| 72 | retval = -ENOMEM; | ||
| 73 | goto err2; | ||
| 74 | } | ||
| 75 | |||
| 76 | usb_host_clock = clk_get(&pdev->dev, "usb_host"); | ||
| 77 | ep93xx_start_hc(&pdev->dev); | ||
| 78 | |||
| 79 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
| 80 | |||
| 81 | retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT); | ||
| 82 | if (retval == 0) | ||
| 83 | return retval; | ||
| 84 | |||
| 85 | ep93xx_stop_hc(&pdev->dev); | ||
| 86 | iounmap(hcd->regs); | ||
| 87 | err2: | ||
| 88 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
| 89 | err1: | ||
| 90 | usb_put_hcd(hcd); | ||
| 91 | |||
| 92 | return retval; | ||
| 93 | } | ||
| 94 | |||
| 95 | static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd, | ||
| 96 | struct platform_device *pdev) | ||
| 97 | { | ||
| 98 | usb_remove_hcd(hcd); | ||
| 99 | ep93xx_stop_hc(&pdev->dev); | ||
| 100 | clk_put(usb_host_clock); | ||
| 101 | iounmap(hcd->regs); | ||
| 102 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
| 103 | usb_put_hcd(hcd); | ||
| 104 | } | ||
| 105 | |||
| 106 | static int __devinit ohci_ep93xx_start(struct usb_hcd *hcd) | ||
| 107 | { | ||
| 108 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
| 109 | int ret; | ||
| 110 | |||
| 111 | if ((ret = ohci_init(ohci)) < 0) | ||
| 112 | return ret; | ||
| 113 | |||
| 114 | if ((ret = ohci_run(ohci)) < 0) { | ||
| 115 | err("can't start %s", hcd->self.bus_name); | ||
| 116 | ohci_stop(hcd); | ||
| 117 | return ret; | ||
| 118 | } | ||
| 119 | |||
| 120 | return 0; | ||
| 121 | } | ||
| 122 | |||
| 123 | static struct hc_driver ohci_ep93xx_hc_driver = { | ||
| 124 | .description = hcd_name, | ||
| 125 | .product_desc = "EP93xx OHCI", | ||
| 126 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
| 127 | .irq = ohci_irq, | ||
| 128 | .flags = HCD_USB11 | HCD_MEMORY, | ||
| 129 | .start = ohci_ep93xx_start, | ||
| 130 | .stop = ohci_stop, | ||
| 131 | .urb_enqueue = ohci_urb_enqueue, | ||
| 132 | .urb_dequeue = ohci_urb_dequeue, | ||
| 133 | .endpoint_disable = ohci_endpoint_disable, | ||
| 134 | .get_frame_number = ohci_get_frame, | ||
| 135 | .hub_status_data = ohci_hub_status_data, | ||
| 136 | .hub_control = ohci_hub_control, | ||
| 137 | #ifdef CONFIG_PM | ||
| 138 | .bus_suspend = ohci_bus_suspend, | ||
| 139 | .bus_resume = ohci_bus_resume, | ||
| 140 | #endif | ||
| 141 | .start_port_reset = ohci_start_port_reset, | ||
| 142 | }; | ||
| 143 | |||
| 144 | extern int usb_disabled(void); | ||
| 145 | |||
| 146 | static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev) | ||
| 147 | { | ||
| 148 | int ret; | ||
| 149 | |||
| 150 | ret = -ENODEV; | ||
| 151 | if (!usb_disabled()) | ||
| 152 | ret = usb_hcd_ep93xx_probe(&ohci_ep93xx_hc_driver, pdev); | ||
| 153 | |||
| 154 | return ret; | ||
| 155 | } | ||
| 156 | |||
| 157 | static int ohci_hcd_ep93xx_drv_remove(struct platform_device *pdev) | ||
| 158 | { | ||
| 159 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 160 | |||
| 161 | usb_hcd_ep93xx_remove(hcd, pdev); | ||
| 162 | |||
| 163 | return 0; | ||
| 164 | } | ||
| 165 | |||
| 166 | #ifdef CONFIG_PM | ||
| 167 | static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_t state) | ||
| 168 | { | ||
| 169 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 170 | struct ochi_hcd *ohci = hcd_to_ohci(hcd); | ||
| 171 | |||
| 172 | if (time_before(jiffies, ohci->next_statechange)) | ||
| 173 | msleep(5); | ||
| 174 | ohci->next_statechange = jiffies; | ||
| 175 | |||
| 176 | ep93xx_stop_hc(&pdev->dev); | ||
| 177 | hcd->state = HC_STATE_SUSPENDED; | ||
| 178 | pdev->dev.power.power_state = PMSG_SUSPEND; | ||
| 179 | |||
| 180 | return 0; | ||
| 181 | } | ||
| 182 | |||
| 183 | static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) | ||
| 184 | { | ||
| 185 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
| 186 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
| 187 | int status; | ||
| 188 | |||
| 189 | if (time_before(jiffies, ohci->next_statechange)) | ||
| 190 | msleep(5); | ||
| 191 | ohci->next_statechange = jiffies; | ||
| 192 | |||
| 193 | ep93xx_start_hc(&pdev->dev); | ||
| 194 | pdev->dev.power.power_state = PMSG_ON; | ||
| 195 | usb_hcd_resume_root_hub(hcd); | ||
| 196 | |||
| 197 | return 0; | ||
| 198 | } | ||
| 199 | #endif | ||
| 200 | |||
| 201 | |||
| 202 | static struct platform_driver ohci_hcd_ep93xx_driver = { | ||
| 203 | .probe = ohci_hcd_ep93xx_drv_probe, | ||
| 204 | .remove = ohci_hcd_ep93xx_drv_remove, | ||
| 205 | #ifdef CONFIG_PM | ||
| 206 | .suspend = ohci_hcd_ep93xx_drv_suspend, | ||
| 207 | .resume = ohci_hcd_ep93xx_drv_resume, | ||
| 208 | #endif | ||
| 209 | .driver = { | ||
| 210 | .name = "ep93xx-ohci", | ||
| 211 | }, | ||
| 212 | }; | ||
| 213 | |||
| 214 | static int __init ohci_hcd_ep93xx_init(void) | ||
| 215 | { | ||
| 216 | return platform_driver_register(&ohci_hcd_ep93xx_driver); | ||
| 217 | } | ||
| 218 | |||
| 219 | static void __exit ohci_hcd_ep93xx_cleanup(void) | ||
| 220 | { | ||
| 221 | platform_driver_unregister(&ohci_hcd_ep93xx_driver); | ||
| 222 | } | ||
| 223 | |||
| 224 | module_init(ohci_hcd_ep93xx_init); | ||
| 225 | module_exit(ohci_hcd_ep93xx_cleanup); | ||
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 8fb842ed5f6e..afef5ac35b4a 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
| @@ -901,6 +901,10 @@ MODULE_LICENSE ("GPL"); | |||
| 901 | #include "ohci-pxa27x.c" | 901 | #include "ohci-pxa27x.c" |
| 902 | #endif | 902 | #endif |
| 903 | 903 | ||
| 904 | #ifdef CONFIG_ARCH_EP93XX | ||
| 905 | #include "ohci-ep93xx.c" | ||
| 906 | #endif | ||
| 907 | |||
| 904 | #ifdef CONFIG_SOC_AU1X00 | 908 | #ifdef CONFIG_SOC_AU1X00 |
| 905 | #include "ohci-au1xxx.c" | 909 | #include "ohci-au1xxx.c" |
| 906 | #endif | 910 | #endif |
| @@ -919,6 +923,7 @@ MODULE_LICENSE ("GPL"); | |||
| 919 | || defined(CONFIG_ARCH_OMAP) \ | 923 | || defined(CONFIG_ARCH_OMAP) \ |
| 920 | || defined (CONFIG_ARCH_LH7A404) \ | 924 | || defined (CONFIG_ARCH_LH7A404) \ |
| 921 | || defined (CONFIG_PXA27x) \ | 925 | || defined (CONFIG_PXA27x) \ |
| 926 | || defined (CONFIG_ARCH_EP93XX) \ | ||
| 922 | || defined (CONFIG_SOC_AU1X00) \ | 927 | || defined (CONFIG_SOC_AU1X00) \ |
| 923 | || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ | 928 | || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ |
| 924 | || defined (CONFIG_ARCH_AT91RM9200) \ | 929 | || defined (CONFIG_ARCH_AT91RM9200) \ |
