aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-06-05 17:38:46 -0400
committerRalf Baechle <ralf@linux-mips.org>2011-12-07 17:02:44 -0500
commit7e98aa4639cba9ef5c99b1484bc86ddb04f67b80 (patch)
tree9851f7472dbf493118df0be3040323c9f3afa275
parentd2b4ac1e5d34648cc56785f6bd11bfa020ad4f02 (diff)
MIPS: ath79: add common USB Host Controller device
Add common platform_device and helper code to make the registration of the built-in USB controllers easier on the board which are using them. Also register the USB controller on the AP81 and PB44 boards. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Imre Kaloz <kaloz@openwrt.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2442/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/ath79/Kconfig5
-rw-r--r--arch/mips/ath79/Makefile1
-rw-r--r--arch/mips/ath79/dev-usb.c178
-rw-r--r--arch/mips/ath79/dev-usb.h17
-rw-r--r--arch/mips/ath79/mach-ap81.c2
-rw-r--r--arch/mips/ath79/mach-pb44.c2
-rw-r--r--arch/mips/include/asm/mach-ath79/ar71xx_regs.h32
7 files changed, 236 insertions, 1 deletions
diff --git a/arch/mips/ath79/Kconfig b/arch/mips/ath79/Kconfig
index 47707410582c..af01669ba665 100644
--- a/arch/mips/ath79/Kconfig
+++ b/arch/mips/ath79/Kconfig
@@ -9,6 +9,7 @@ config ATH79_MACH_AP81
9 select ATH79_DEV_GPIO_BUTTONS 9 select ATH79_DEV_GPIO_BUTTONS
10 select ATH79_DEV_LEDS_GPIO 10 select ATH79_DEV_LEDS_GPIO
11 select ATH79_DEV_SPI 11 select ATH79_DEV_SPI
12 select ATH79_DEV_USB
12 help 13 help
13 Say 'Y' here if you want your kernel to support the 14 Say 'Y' here if you want your kernel to support the
14 Atheros AP81 reference board. 15 Atheros AP81 reference board.
@@ -19,6 +20,7 @@ config ATH79_MACH_PB44
19 select ATH79_DEV_GPIO_BUTTONS 20 select ATH79_DEV_GPIO_BUTTONS
20 select ATH79_DEV_LEDS_GPIO 21 select ATH79_DEV_LEDS_GPIO
21 select ATH79_DEV_SPI 22 select ATH79_DEV_SPI
23 select ATH79_DEV_USB
22 help 24 help
23 Say 'Y' here if you want your kernel to support the 25 Say 'Y' here if you want your kernel to support the
24 Atheros PB44 reference board. 26 Atheros PB44 reference board.
@@ -52,4 +54,7 @@ config ATH79_DEV_LEDS_GPIO
52config ATH79_DEV_SPI 54config ATH79_DEV_SPI
53 def_bool n 55 def_bool n
54 56
57config ATH79_DEV_USB
58 def_bool n
59
55endif 60endif
diff --git a/arch/mips/ath79/Makefile b/arch/mips/ath79/Makefile
index c33d4653007c..57188b61b9ae 100644
--- a/arch/mips/ath79/Makefile
+++ b/arch/mips/ath79/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_ATH79_DEV_AR913X_WMAC) += dev-ar913x-wmac.o
20obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o 20obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o
21obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o 21obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o
22obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o 22obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o
23obj-$(CONFIG_ATH79_DEV_USB) += dev-usb.o
23 24
24# 25#
25# Machines 26# Machines
diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c
new file mode 100644
index 000000000000..c3f1999c761b
--- /dev/null
+++ b/arch/mips/ath79/dev-usb.c
@@ -0,0 +1,178 @@
1/*
2 * Atheros AR7XXX/AR9XXX USB Host Controller device
3 *
4 * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * Parts of this file are based on Atheros' 2.6.15 BSP
8 *
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.
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/irq.h>
18#include <linux/dma-mapping.h>
19#include <linux/platform_device.h>
20
21#include <asm/mach-ath79/ath79.h>
22#include <asm/mach-ath79/ar71xx_regs.h>
23#include "common.h"
24#include "dev-usb.h"
25
26static struct resource ath79_ohci_resources[] = {
27 [0] = {
28 /* .start and .end fields are filled dynamically */
29 .flags = IORESOURCE_MEM,
30 },
31 [1] = {
32 .start = ATH79_MISC_IRQ_OHCI,
33 .end = ATH79_MISC_IRQ_OHCI,
34 .flags = IORESOURCE_IRQ,
35 },
36};
37
38static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32);
39static struct platform_device ath79_ohci_device = {
40 .name = "ath79-ohci",
41 .id = -1,
42 .resource = ath79_ohci_resources,
43 .num_resources = ARRAY_SIZE(ath79_ohci_resources),
44 .dev = {
45 .dma_mask = &ath79_ohci_dmamask,
46 .coherent_dma_mask = DMA_BIT_MASK(32),
47 },
48};
49
50static struct resource ath79_ehci_resources[] = {
51 [0] = {
52 /* .start and .end fields are filled dynamically */
53 .flags = IORESOURCE_MEM,
54 },
55 [1] = {
56 .start = ATH79_CPU_IRQ_USB,
57 .end = ATH79_CPU_IRQ_USB,
58 .flags = IORESOURCE_IRQ,
59 },
60};
61
62static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32);
63static struct platform_device ath79_ehci_device = {
64 .name = "ath79-ehci",
65 .id = -1,
66 .resource = ath79_ehci_resources,
67 .num_resources = ARRAY_SIZE(ath79_ehci_resources),
68 .dev = {
69 .dma_mask = &ath79_ehci_dmamask,
70 .coherent_dma_mask = DMA_BIT_MASK(32),
71 },
72};
73
74#define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \
75 AR71XX_RESET_USB_PHY | \
76 AR71XX_RESET_USB_OHCI_DLL)
77
78static void __init ath79_usb_setup(void)
79{
80 void __iomem *usb_ctrl_base;
81
82 ath79_device_reset_set(AR71XX_USB_RESET_MASK);
83 mdelay(1000);
84 ath79_device_reset_clear(AR71XX_USB_RESET_MASK);
85
86 usb_ctrl_base = ioremap(AR71XX_USB_CTRL_BASE, AR71XX_USB_CTRL_SIZE);
87
88 /* Turning on the Buff and Desc swap bits */
89 __raw_writel(0xf0000, usb_ctrl_base + AR71XX_USB_CTRL_REG_CONFIG);
90
91 /* WAR for HW bug. Here it adjusts the duration between two SOFS */
92 __raw_writel(0x20c00, usb_ctrl_base + AR71XX_USB_CTRL_REG_FLADJ);
93
94 iounmap(usb_ctrl_base);
95
96 mdelay(900);
97
98 ath79_ohci_resources[0].start = AR71XX_OHCI_BASE;
99 ath79_ohci_resources[0].end = AR71XX_OHCI_BASE + AR71XX_OHCI_SIZE - 1;
100 platform_device_register(&ath79_ohci_device);
101
102 ath79_ehci_resources[0].start = AR71XX_EHCI_BASE;
103 ath79_ehci_resources[0].end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1;
104 ath79_ehci_device.name = "ar71xx-ehci";
105 platform_device_register(&ath79_ehci_device);
106}
107
108static void __init ar7240_usb_setup(void)
109{
110 void __iomem *usb_ctrl_base;
111
112 ath79_device_reset_clear(AR7240_RESET_OHCI_DLL);
113 ath79_device_reset_set(AR7240_RESET_USB_HOST);
114
115 mdelay(1000);
116
117 ath79_device_reset_set(AR7240_RESET_OHCI_DLL);
118 ath79_device_reset_clear(AR7240_RESET_USB_HOST);
119
120 usb_ctrl_base = ioremap(AR7240_USB_CTRL_BASE, AR7240_USB_CTRL_SIZE);
121
122 /* WAR for HW bug. Here it adjusts the duration between two SOFS */
123 __raw_writel(0x3, usb_ctrl_base + AR71XX_USB_CTRL_REG_FLADJ);
124
125 iounmap(usb_ctrl_base);
126
127 ath79_ohci_resources[0].start = AR7240_OHCI_BASE;
128 ath79_ohci_resources[0].end = AR7240_OHCI_BASE + AR7240_OHCI_SIZE - 1;
129 platform_device_register(&ath79_ohci_device);
130}
131
132static void __init ar724x_usb_setup(void)
133{
134 ath79_device_reset_set(AR724X_RESET_USBSUS_OVERRIDE);
135 mdelay(10);
136
137 ath79_device_reset_clear(AR724X_RESET_USB_HOST);
138 mdelay(10);
139
140 ath79_device_reset_clear(AR724X_RESET_USB_PHY);
141 mdelay(10);
142
143 ath79_ehci_resources[0].start = AR724X_EHCI_BASE;
144 ath79_ehci_resources[0].end = AR724X_EHCI_BASE + AR724X_EHCI_SIZE - 1;
145 ath79_ehci_device.name = "ar724x-ehci";
146 platform_device_register(&ath79_ehci_device);
147}
148
149static void __init ar913x_usb_setup(void)
150{
151 ath79_device_reset_set(AR913X_RESET_USBSUS_OVERRIDE);
152 mdelay(10);
153
154 ath79_device_reset_clear(AR913X_RESET_USB_HOST);
155 mdelay(10);
156
157 ath79_device_reset_clear(AR913X_RESET_USB_PHY);
158 mdelay(10);
159
160 ath79_ehci_resources[0].start = AR913X_EHCI_BASE;
161 ath79_ehci_resources[0].end = AR913X_EHCI_BASE + AR913X_EHCI_SIZE - 1;
162 ath79_ehci_device.name = "ar913x-ehci";
163 platform_device_register(&ath79_ehci_device);
164}
165
166void __init ath79_register_usb(void)
167{
168 if (soc_is_ar71xx())
169 ath79_usb_setup();
170 else if (soc_is_ar7240())
171 ar7240_usb_setup();
172 else if (soc_is_ar7241() || soc_is_ar7242())
173 ar724x_usb_setup();
174 else if (soc_is_ar913x())
175 ar913x_usb_setup();
176 else
177 BUG();
178}
diff --git a/arch/mips/ath79/dev-usb.h b/arch/mips/ath79/dev-usb.h
new file mode 100644
index 000000000000..4b86a69ca080
--- /dev/null
+++ b/arch/mips/ath79/dev-usb.h
@@ -0,0 +1,17 @@
1/*
2 * Atheros AR71XX/AR724X/AR913X USB Host Controller support
3 *
4 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12#ifndef _ATH79_DEV_USB_H
13#define _ATH79_DEV_USB_H
14
15void ath79_register_usb(void);
16
17#endif /* _ATH79_DEV_USB_H */
diff --git a/arch/mips/ath79/mach-ap81.c b/arch/mips/ath79/mach-ap81.c
index eee4c121deb4..6c0826736012 100644
--- a/arch/mips/ath79/mach-ap81.c
+++ b/arch/mips/ath79/mach-ap81.c
@@ -14,6 +14,7 @@
14#include "dev-gpio-buttons.h" 14#include "dev-gpio-buttons.h"
15#include "dev-leds-gpio.h" 15#include "dev-leds-gpio.h"
16#include "dev-spi.h" 16#include "dev-spi.h"
17#include "dev-usb.h"
17 18
18#define AP81_GPIO_LED_STATUS 1 19#define AP81_GPIO_LED_STATUS 1
19#define AP81_GPIO_LED_AOSS 3 20#define AP81_GPIO_LED_AOSS 3
@@ -92,6 +93,7 @@ static void __init ap81_setup(void)
92 ath79_register_spi(&ap81_spi_data, ap81_spi_info, 93 ath79_register_spi(&ap81_spi_data, ap81_spi_info,
93 ARRAY_SIZE(ap81_spi_info)); 94 ARRAY_SIZE(ap81_spi_info));
94 ath79_register_ar913x_wmac(cal_data); 95 ath79_register_ar913x_wmac(cal_data);
96 ath79_register_usb();
95} 97}
96 98
97MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board", 99MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
diff --git a/arch/mips/ath79/mach-pb44.c b/arch/mips/ath79/mach-pb44.c
index ec7b7a135d53..fe9701a32291 100644
--- a/arch/mips/ath79/mach-pb44.c
+++ b/arch/mips/ath79/mach-pb44.c
@@ -18,6 +18,7 @@
18#include "dev-gpio-buttons.h" 18#include "dev-gpio-buttons.h"
19#include "dev-leds-gpio.h" 19#include "dev-leds-gpio.h"
20#include "dev-spi.h" 20#include "dev-spi.h"
21#include "dev-usb.h"
21 22
22#define PB44_GPIO_I2C_SCL 0 23#define PB44_GPIO_I2C_SCL 0
23#define PB44_GPIO_I2C_SDA 1 24#define PB44_GPIO_I2C_SDA 1
@@ -112,6 +113,7 @@ static void __init pb44_init(void)
112 pb44_gpio_keys); 113 pb44_gpio_keys);
113 ath79_register_spi(&pb44_spi_data, pb44_spi_info, 114 ath79_register_spi(&pb44_spi_data, pb44_spi_info,
114 ARRAY_SIZE(pb44_spi_info)); 115 ARRAY_SIZE(pb44_spi_info));
116 ath79_register_usb();
115} 117}
116 118
117MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board", 119MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
index da0d89478259..86f0fc8c07c1 100644
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -20,6 +20,10 @@
20#include <linux/bitops.h> 20#include <linux/bitops.h>
21 21
22#define AR71XX_APB_BASE 0x18000000 22#define AR71XX_APB_BASE 0x18000000
23#define AR71XX_EHCI_BASE 0x1b000000
24#define AR71XX_EHCI_SIZE 0x1000
25#define AR71XX_OHCI_BASE 0x1c000000
26#define AR71XX_OHCI_SIZE 0x1000
23#define AR71XX_SPI_BASE 0x1f000000 27#define AR71XX_SPI_BASE 0x1f000000
24#define AR71XX_SPI_SIZE 0x01000000 28#define AR71XX_SPI_SIZE 0x01000000
25 29
@@ -27,6 +31,8 @@
27#define AR71XX_DDR_CTRL_SIZE 0x100 31#define AR71XX_DDR_CTRL_SIZE 0x100
28#define AR71XX_UART_BASE (AR71XX_APB_BASE + 0x00020000) 32#define AR71XX_UART_BASE (AR71XX_APB_BASE + 0x00020000)
29#define AR71XX_UART_SIZE 0x100 33#define AR71XX_UART_SIZE 0x100
34#define AR71XX_USB_CTRL_BASE (AR71XX_APB_BASE + 0x00030000)
35#define AR71XX_USB_CTRL_SIZE 0x100
30#define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000) 36#define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000)
31#define AR71XX_GPIO_SIZE 0x100 37#define AR71XX_GPIO_SIZE 0x100
32#define AR71XX_PLL_BASE (AR71XX_APB_BASE + 0x00050000) 38#define AR71XX_PLL_BASE (AR71XX_APB_BASE + 0x00050000)
@@ -34,6 +40,16 @@
34#define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000) 40#define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
35#define AR71XX_RESET_SIZE 0x100 41#define AR71XX_RESET_SIZE 0x100
36 42
43#define AR7240_USB_CTRL_BASE (AR71XX_APB_BASE + 0x00030000)
44#define AR7240_USB_CTRL_SIZE 0x100
45#define AR7240_OHCI_BASE 0x1b000000
46#define AR7240_OHCI_SIZE 0x1000
47
48#define AR724X_EHCI_BASE 0x1b000000
49#define AR724X_EHCI_SIZE 0x1000
50
51#define AR913X_EHCI_BASE 0x1b000000
52#define AR913X_EHCI_SIZE 0x1000
37#define AR913X_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000) 53#define AR913X_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000)
38#define AR913X_WMAC_SIZE 0x30000 54#define AR913X_WMAC_SIZE 0x30000
39 55
@@ -105,6 +121,12 @@
105#define AR913X_AHB_DIV_MASK 0x1 121#define AR913X_AHB_DIV_MASK 0x1
106 122
107/* 123/*
124 * USB_CONFIG block
125 */
126#define AR71XX_USB_CTRL_REG_FLADJ 0x00
127#define AR71XX_USB_CTRL_REG_CONFIG 0x04
128
129/*
108 * RESET block 130 * RESET block
109 */ 131 */
110#define AR71XX_RESET_REG_TIMER 0x00 132#define AR71XX_RESET_REG_TIMER 0x00
@@ -162,14 +184,22 @@
162#define AR71XX_RESET_PCI_BUS BIT(1) 184#define AR71XX_RESET_PCI_BUS BIT(1)
163#define AR71XX_RESET_PCI_CORE BIT(0) 185#define AR71XX_RESET_PCI_CORE BIT(0)
164 186
187#define AR7240_RESET_USB_HOST BIT(5)
188#define AR7240_RESET_OHCI_DLL BIT(3)
189
165#define AR724X_RESET_GE1_MDIO BIT(23) 190#define AR724X_RESET_GE1_MDIO BIT(23)
166#define AR724X_RESET_GE0_MDIO BIT(22) 191#define AR724X_RESET_GE0_MDIO BIT(22)
167#define AR724X_RESET_PCIE_PHY_SERIAL BIT(10) 192#define AR724X_RESET_PCIE_PHY_SERIAL BIT(10)
168#define AR724X_RESET_PCIE_PHY BIT(7) 193#define AR724X_RESET_PCIE_PHY BIT(7)
169#define AR724X_RESET_PCIE BIT(6) 194#define AR724X_RESET_PCIE BIT(6)
170#define AR724X_RESET_OHCI_DLL BIT(3) 195#define AR724X_RESET_USB_HOST BIT(5)
196#define AR724X_RESET_USB_PHY BIT(4)
197#define AR724X_RESET_USBSUS_OVERRIDE BIT(3)
171 198
172#define AR913X_RESET_AMBA2WMAC BIT(22) 199#define AR913X_RESET_AMBA2WMAC BIT(22)
200#define AR913X_RESET_USBSUS_OVERRIDE BIT(10)
201#define AR913X_RESET_USB_HOST BIT(5)
202#define AR913X_RESET_USB_PHY BIT(4)
173 203
174#define REV_ID_MAJOR_MASK 0xfff0 204#define REV_ID_MAJOR_MASK 0xfff0
175#define REV_ID_MAJOR_AR71XX 0x00a0 205#define REV_ID_MAJOR_AR71XX 0x00a0