2 * Atheros AR71xx USB host device support
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * Parts of this file are based on Atheros' 2.6.15 BSP
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
17 #include <linux/dma-mapping.h>
18 #include <linux/platform_device.h>
20 #include <asm/mach-ar71xx/ar71xx.h>
21 #include <asm/mach-ar71xx/platform.h>
26 * OHCI (USB full speed host controller)
28 static struct resource ar71xx_ohci_resources
[] = {
30 .start
= AR71XX_OHCI_BASE
,
31 .end
= AR71XX_OHCI_BASE
+ AR71XX_OHCI_SIZE
- 1,
32 .flags
= IORESOURCE_MEM
,
35 .start
= AR71XX_MISC_IRQ_OHCI
,
36 .end
= AR71XX_MISC_IRQ_OHCI
,
37 .flags
= IORESOURCE_IRQ
,
41 static struct resource ar7240_ohci_resources
[] = {
43 .start
= AR7240_OHCI_BASE
,
44 .end
= AR7240_OHCI_BASE
+ AR7240_OHCI_SIZE
- 1,
45 .flags
= IORESOURCE_MEM
,
48 .start
= AR71XX_CPU_IRQ_USB
,
49 .end
= AR71XX_CPU_IRQ_USB
,
50 .flags
= IORESOURCE_IRQ
,
54 static u64 ar71xx_ohci_dmamask
= DMA_BIT_MASK(32);
55 static struct platform_device ar71xx_ohci_device
= {
56 .name
= "ar71xx-ohci",
58 .resource
= ar71xx_ohci_resources
,
59 .num_resources
= ARRAY_SIZE(ar71xx_ohci_resources
),
61 .dma_mask
= &ar71xx_ohci_dmamask
,
62 .coherent_dma_mask
= DMA_BIT_MASK(32),
67 * EHCI (USB high/full speed host controller)
69 static struct resource ar71xx_ehci_resources
[] = {
71 .start
= AR71XX_EHCI_BASE
,
72 .end
= AR71XX_EHCI_BASE
+ AR71XX_EHCI_SIZE
- 1,
73 .flags
= IORESOURCE_MEM
,
76 .start
= AR71XX_CPU_IRQ_USB
,
77 .end
= AR71XX_CPU_IRQ_USB
,
78 .flags
= IORESOURCE_IRQ
,
82 static u64 ar71xx_ehci_dmamask
= DMA_BIT_MASK(32);
83 static struct ar71xx_ehci_platform_data ar71xx_ehci_data
;
85 static struct platform_device ar71xx_ehci_device
= {
86 .name
= "ar71xx-ehci",
88 .resource
= ar71xx_ehci_resources
,
89 .num_resources
= ARRAY_SIZE(ar71xx_ehci_resources
),
91 .dma_mask
= &ar71xx_ehci_dmamask
,
92 .coherent_dma_mask
= DMA_BIT_MASK(32),
93 .platform_data
= &ar71xx_ehci_data
,
97 #define AR71XX_USB_RESET_MASK \
98 (RESET_MODULE_USB_HOST | RESET_MODULE_USB_PHY \
99 | RESET_MODULE_USB_OHCI_DLL)
101 #define AR7240_USB_RESET_MASK \
102 (RESET_MODULE_USB_HOST | RESET_MODULE_USB_OHCI_DLL_7240)
104 static void __init
ar71xx_usb_setup(void)
106 ar71xx_device_stop(AR71XX_USB_RESET_MASK
);
108 ar71xx_device_start(AR71XX_USB_RESET_MASK
);
110 /* Turning on the Buff and Desc swap bits */
111 ar71xx_usb_ctrl_wr(USB_CTRL_REG_CONFIG
, 0xf0000);
113 /* WAR for HW bug. Here it adjusts the duration between two SOFS */
114 ar71xx_usb_ctrl_wr(USB_CTRL_REG_FLADJ
, 0x20c00);
118 platform_device_register(&ar71xx_ohci_device
);
119 platform_device_register(&ar71xx_ehci_device
);
122 static void __init
ar7240_usb_setup(void)
124 ar71xx_device_stop(AR7240_USB_RESET_MASK
);
126 ar71xx_device_start(AR7240_USB_RESET_MASK
);
128 /* WAR for HW bug. Here it adjusts the duration between two SOFS */
129 ar71xx_usb_ctrl_wr(USB_CTRL_REG_FLADJ
, 0x3);
131 ar71xx_ohci_device
.resource
= ar7240_ohci_resources
;
132 ar71xx_ohci_device
.num_resources
= ARRAY_SIZE(ar7240_ohci_resources
);
133 platform_device_register(&ar71xx_ohci_device
);
136 static void __init
ar7241_usb_setup(void)
138 ar71xx_device_start(AR724X_RESET_USBSUS_OVERRIDE
);
141 ar71xx_device_start(AR724X_RESET_USB_HOST
);
144 ar71xx_device_start(AR724X_RESET_USB_PHY
);
147 ar71xx_ehci_data
.is_ar91xx
= 1;
148 ar71xx_ehci_device
.resource
= ar7240_ohci_resources
;
149 ar71xx_ehci_device
.num_resources
= ARRAY_SIZE(ar7240_ohci_resources
);
150 platform_device_register(&ar71xx_ehci_device
);
153 static void __init
ar91xx_usb_setup(void)
155 ar71xx_device_stop(RESET_MODULE_USBSUS_OVERRIDE
);
158 ar71xx_device_start(RESET_MODULE_USB_HOST
);
161 ar71xx_device_start(RESET_MODULE_USB_PHY
);
164 ar71xx_ehci_data
.is_ar91xx
= 1;
165 platform_device_register(&ar71xx_ehci_device
);
168 static void __init
ar933x_usb_setup(void)
170 ar71xx_device_reset_rmw(0, AR933X_RESET_USBSUS_OVERRIDE
);
173 ar71xx_device_reset_rmw(AR933X_RESET_USB_HOST
,
174 AR933X_RESET_USBSUS_OVERRIDE
);
177 ar71xx_device_reset_rmw(AR933X_RESET_USB_PHY
,
178 AR933X_RESET_USBSUS_OVERRIDE
);
181 ar71xx_ehci_data
.is_ar91xx
= 1;
182 platform_device_register(&ar71xx_ehci_device
);
185 void __init
ar71xx_add_device_usb(void)
187 switch (ar71xx_soc
) {
188 case AR71XX_SOC_AR7240
:
192 case AR71XX_SOC_AR7241
:
193 case AR71XX_SOC_AR7242
:
197 case AR71XX_SOC_AR7130
:
198 case AR71XX_SOC_AR7141
:
199 case AR71XX_SOC_AR7161
:
203 case AR71XX_SOC_AR9130
:
204 case AR71XX_SOC_AR9132
:
205 case AR71XX_SOC_AR9341
:
206 case AR71XX_SOC_AR9342
:
207 case AR71XX_SOC_AR9344
:
211 case AR71XX_SOC_AR9330
:
212 case AR71XX_SOC_AR9331
: