aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-08-04 11:03:55 -0400
committerJohn Crispin <blogic@openwrt.org>2012-08-28 06:29:57 -0400
commit8d3e03e186cb94a333d0176fe8b22a6df200fcc7 (patch)
tree3ac3438fc2fcc43f4e93cfb180a0d29cd50b91d2 /arch
parentc182ae42cc3611f7b3fa803c0bcab6e5d29bea63 (diff)
MIPS: ath79: use a helper function for USB resource initialization
This improves code readability, and ensures that all resource fields will be initialized correctly. Additionally, it helps to reduce the size of the kernel image by using uninitialized resource variables. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4171/ Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/ath79/dev-usb.c64
1 files changed, 28 insertions, 36 deletions
diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c
index b2a2311ec85b..87fe48e8e301 100644
--- a/arch/mips/ath79/dev-usb.c
+++ b/arch/mips/ath79/dev-usb.c
@@ -25,17 +25,7 @@
25#include "common.h" 25#include "common.h"
26#include "dev-usb.h" 26#include "dev-usb.h"
27 27
28static struct resource ath79_ohci_resources[] = { 28static struct resource ath79_ohci_resources[2];
29 [0] = {
30 /* .start and .end fields are filled dynamically */
31 .flags = IORESOURCE_MEM,
32 },
33 [1] = {
34 .start = ATH79_MISC_IRQ_OHCI,
35 .end = ATH79_MISC_IRQ_OHCI,
36 .flags = IORESOURCE_IRQ,
37 },
38};
39 29
40static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32); 30static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32);
41 31
@@ -54,17 +44,7 @@ static struct platform_device ath79_ohci_device = {
54 }, 44 },
55}; 45};
56 46
57static struct resource ath79_ehci_resources[] = { 47static struct resource ath79_ehci_resources[2];
58 [0] = {
59 /* .start and .end fields are filled dynamically */
60 .flags = IORESOURCE_MEM,
61 },
62 [1] = {
63 .start = ATH79_CPU_IRQ_USB,
64 .end = ATH79_CPU_IRQ_USB,
65 .flags = IORESOURCE_IRQ,
66 },
67};
68 48
69static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32); 49static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32);
70 50
@@ -90,6 +70,20 @@ static struct platform_device ath79_ehci_device = {
90 }, 70 },
91}; 71};
92 72
73static void __init ath79_usb_init_resource(struct resource res[2],
74 unsigned long base,
75 unsigned long size,
76 int irq)
77{
78 res[0].flags = IORESOURCE_MEM;
79 res[0].start = base;
80 res[0].end = base + size - 1;
81
82 res[1].flags = IORESOURCE_IRQ;
83 res[1].start = irq;
84 res[1].end = irq;
85}
86
93#define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \ 87#define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \
94 AR71XX_RESET_USB_PHY | \ 88 AR71XX_RESET_USB_PHY | \
95 AR71XX_RESET_USB_OHCI_DLL) 89 AR71XX_RESET_USB_OHCI_DLL)
@@ -114,12 +108,12 @@ static void __init ath79_usb_setup(void)
114 108
115 mdelay(900); 109 mdelay(900);
116 110
117 ath79_ohci_resources[0].start = AR71XX_OHCI_BASE; 111 ath79_usb_init_resource(ath79_ohci_resources, AR71XX_OHCI_BASE,
118 ath79_ohci_resources[0].end = AR71XX_OHCI_BASE + AR71XX_OHCI_SIZE - 1; 112 AR71XX_OHCI_SIZE, ATH79_MISC_IRQ_OHCI);
119 platform_device_register(&ath79_ohci_device); 113 platform_device_register(&ath79_ohci_device);
120 114
121 ath79_ehci_resources[0].start = AR71XX_EHCI_BASE; 115 ath79_usb_init_resource(ath79_ehci_resources, AR71XX_EHCI_BASE,
122 ath79_ehci_resources[0].end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1; 116 AR71XX_EHCI_SIZE, ATH79_CPU_IRQ_USB);
123 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1; 117 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1;
124 platform_device_register(&ath79_ehci_device); 118 platform_device_register(&ath79_ehci_device);
125} 119}
@@ -143,10 +137,8 @@ static void __init ar7240_usb_setup(void)
143 137
144 iounmap(usb_ctrl_base); 138 iounmap(usb_ctrl_base);
145 139
146 ath79_ohci_resources[0].start = AR7240_OHCI_BASE; 140 ath79_usb_init_resource(ath79_ohci_resources, AR7240_OHCI_BASE,
147 ath79_ohci_resources[0].end = AR7240_OHCI_BASE + AR7240_OHCI_SIZE - 1; 141 AR7240_OHCI_SIZE, ATH79_CPU_IRQ_USB);
148 ath79_ohci_resources[1].start = ATH79_CPU_IRQ_USB;
149 ath79_ohci_resources[1].end = ATH79_CPU_IRQ_USB;
150 platform_device_register(&ath79_ohci_device); 142 platform_device_register(&ath79_ohci_device);
151} 143}
152 144
@@ -161,8 +153,8 @@ static void __init ar724x_usb_setup(void)
161 ath79_device_reset_clear(AR724X_RESET_USB_PHY); 153 ath79_device_reset_clear(AR724X_RESET_USB_PHY);
162 mdelay(10); 154 mdelay(10);
163 155
164 ath79_ehci_resources[0].start = AR724X_EHCI_BASE; 156 ath79_usb_init_resource(ath79_ehci_resources, AR724X_EHCI_BASE,
165 ath79_ehci_resources[0].end = AR724X_EHCI_BASE + AR724X_EHCI_SIZE - 1; 157 AR724X_EHCI_SIZE, ATH79_CPU_IRQ_USB);
166 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; 158 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
167 platform_device_register(&ath79_ehci_device); 159 platform_device_register(&ath79_ehci_device);
168} 160}
@@ -178,8 +170,8 @@ static void __init ar913x_usb_setup(void)
178 ath79_device_reset_clear(AR913X_RESET_USB_PHY); 170 ath79_device_reset_clear(AR913X_RESET_USB_PHY);
179 mdelay(10); 171 mdelay(10);
180 172
181 ath79_ehci_resources[0].start = AR913X_EHCI_BASE; 173 ath79_usb_init_resource(ath79_ehci_resources, AR913X_EHCI_BASE,
182 ath79_ehci_resources[0].end = AR913X_EHCI_BASE + AR913X_EHCI_SIZE - 1; 174 AR913X_EHCI_SIZE, ATH79_CPU_IRQ_USB);
183 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; 175 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
184 platform_device_register(&ath79_ehci_device); 176 platform_device_register(&ath79_ehci_device);
185} 177}
@@ -195,8 +187,8 @@ static void __init ar933x_usb_setup(void)
195 ath79_device_reset_clear(AR933X_RESET_USB_PHY); 187 ath79_device_reset_clear(AR933X_RESET_USB_PHY);
196 mdelay(10); 188 mdelay(10);
197 189
198 ath79_ehci_resources[0].start = AR933X_EHCI_BASE; 190 ath79_usb_init_resource(ath79_ehci_resources, AR933X_EHCI_BASE,
199 ath79_ehci_resources[0].end = AR933X_EHCI_BASE + AR933X_EHCI_SIZE - 1; 191 AR933X_EHCI_SIZE, ATH79_CPU_IRQ_USB);
200 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; 192 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
201 platform_device_register(&ath79_ehci_device); 193 platform_device_register(&ath79_ehci_device);
202} 194}