diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2008-12-01 09:54:58 -0500 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2008-12-01 09:54:58 -0500 |
commit | 0a3813306f432e8925ff648c84bd488b840e5185 (patch) | |
tree | 42583fc92c9fc2fc73599a74b80ea1359b9c5f86 /arch/arm/mach-realview | |
parent | 1bbdf637baa708a2f0f46ead56c6c618b7dad7a8 (diff) |
RealView: Refactor the Ethernet device registration
This patch moves the Ethernet device registration from individual
realview_*.c files to core.c.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm/mach-realview')
-rw-r--r-- | arch/arm/mach-realview/core.c | 15 | ||||
-rw-r--r-- | arch/arm/mach-realview/core.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-realview/realview_eb.c | 18 | ||||
-rw-r--r-- | arch/arm/mach-realview/realview_pb1176.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-realview/realview_pb11mp.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-realview/realview_pba8.c | 9 |
6 files changed, 24 insertions, 37 deletions
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c index 65c39a73d1cb..d80208a1f1fe 100644 --- a/arch/arm/mach-realview/core.c +++ b/arch/arm/mach-realview/core.c | |||
@@ -125,6 +125,21 @@ int realview_flash_register(struct resource *res, u32 num) | |||
125 | return platform_device_register(&realview_flash_device); | 125 | return platform_device_register(&realview_flash_device); |
126 | } | 126 | } |
127 | 127 | ||
128 | static struct platform_device realview_eth_device = { | ||
129 | .name = "smc911x", | ||
130 | .id = 0, | ||
131 | .num_resources = 2, | ||
132 | }; | ||
133 | |||
134 | int realview_eth_register(const char *name, struct resource *res) | ||
135 | { | ||
136 | if (name) | ||
137 | realview_eth_device.name = name; | ||
138 | realview_eth_device.resource = res; | ||
139 | |||
140 | return platform_device_register(&realview_eth_device); | ||
141 | } | ||
142 | |||
128 | static struct resource realview_i2c_resource = { | 143 | static struct resource realview_i2c_resource = { |
129 | .start = REALVIEW_I2C_BASE, | 144 | .start = REALVIEW_I2C_BASE, |
130 | .end = REALVIEW_I2C_BASE + SZ_4K - 1, | 145 | .end = REALVIEW_I2C_BASE + SZ_4K - 1, |
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h index 3d97a4c84000..689c368368f7 100644 --- a/arch/arm/mach-realview/core.h +++ b/arch/arm/mach-realview/core.h | |||
@@ -62,5 +62,6 @@ extern void __iomem *timer3_va_base; | |||
62 | extern void realview_leds_event(led_event_t ledevt); | 62 | extern void realview_leds_event(led_event_t ledevt); |
63 | extern void realview_timer_init(unsigned int timer_irq); | 63 | extern void realview_timer_init(unsigned int timer_irq); |
64 | extern int realview_flash_register(struct resource *res, u32 num); | 64 | extern int realview_flash_register(struct resource *res, u32 num); |
65 | extern int realview_eth_register(const char *name, struct resource *res); | ||
65 | 66 | ||
66 | #endif | 67 | #endif |
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c index 66dc2561c8c7..e9b7b04c2fe6 100644 --- a/arch/arm/mach-realview/realview_eb.c +++ b/arch/arm/mach-realview/realview_eb.c | |||
@@ -242,12 +242,6 @@ static struct resource realview_eb_eth_resources[] = { | |||
242 | }, | 242 | }, |
243 | }; | 243 | }; |
244 | 244 | ||
245 | static struct platform_device realview_eb_eth_device = { | ||
246 | .id = 0, | ||
247 | .num_resources = ARRAY_SIZE(realview_eb_eth_resources), | ||
248 | .resource = realview_eb_eth_resources, | ||
249 | }; | ||
250 | |||
251 | /* | 245 | /* |
252 | * Detect and register the correct Ethernet device. RealView/EB rev D | 246 | * Detect and register the correct Ethernet device. RealView/EB rev D |
253 | * platforms use the newer SMSC LAN9118 Ethernet chip | 247 | * platforms use the newer SMSC LAN9118 Ethernet chip |
@@ -255,21 +249,19 @@ static struct platform_device realview_eb_eth_device = { | |||
255 | static int eth_device_register(void) | 249 | static int eth_device_register(void) |
256 | { | 250 | { |
257 | void __iomem *eth_addr = ioremap(REALVIEW_EB_ETH_BASE, SZ_4K); | 251 | void __iomem *eth_addr = ioremap(REALVIEW_EB_ETH_BASE, SZ_4K); |
252 | const char *name = NULL; | ||
258 | u32 idrev; | 253 | u32 idrev; |
259 | 254 | ||
260 | if (!eth_addr) | 255 | if (!eth_addr) |
261 | return -ENOMEM; | 256 | return -ENOMEM; |
262 | 257 | ||
263 | idrev = readl(eth_addr + 0x50); | 258 | idrev = readl(eth_addr + 0x50); |
264 | if ((idrev & 0xFFFF0000) == 0x01180000) | 259 | if ((idrev & 0xFFFF0000) != 0x01180000) |
265 | /* SMSC LAN9118 chip present */ | 260 | /* SMSC LAN9118 not present, use LAN91C111 instead */ |
266 | realview_eb_eth_device.name = "smc911x"; | 261 | name = "smc91x"; |
267 | else | ||
268 | /* SMSC 91C111 chip present */ | ||
269 | realview_eb_eth_device.name = "smc91x"; | ||
270 | 262 | ||
271 | iounmap(eth_addr); | 263 | iounmap(eth_addr); |
272 | return platform_device_register(&realview_eb_eth_device); | 264 | return realview_eth_register(name, realview_eb_eth_resources); |
273 | } | 265 | } |
274 | 266 | ||
275 | static void __init gic_init_irq(void) | 267 | static void __init gic_init_irq(void) |
diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c index a9fac653b305..0388ed06f1e5 100644 --- a/arch/arm/mach-realview/realview_pb1176.c +++ b/arch/arm/mach-realview/realview_pb1176.c | |||
@@ -222,13 +222,6 @@ static struct resource realview_pb1176_smsc911x_resources[] = { | |||
222 | }, | 222 | }, |
223 | }; | 223 | }; |
224 | 224 | ||
225 | static struct platform_device realview_pb1176_smsc911x_device = { | ||
226 | .name = "smc911x", | ||
227 | .id = 0, | ||
228 | .num_resources = ARRAY_SIZE(realview_pb1176_smsc911x_resources), | ||
229 | .resource = realview_pb1176_smsc911x_resources, | ||
230 | }; | ||
231 | |||
232 | static void __init gic_init_irq(void) | 225 | static void __init gic_init_irq(void) |
233 | { | 226 | { |
234 | /* ARM1176 DevChip GIC, primary */ | 227 | /* ARM1176 DevChip GIC, primary */ |
@@ -268,7 +261,7 @@ static void __init realview_pb1176_init(void) | |||
268 | clk_register(&realview_clcd_clk); | 261 | clk_register(&realview_clcd_clk); |
269 | 262 | ||
270 | realview_flash_register(&realview_pb1176_flash_resource, 1); | 263 | realview_flash_register(&realview_pb1176_flash_resource, 1); |
271 | platform_device_register(&realview_pb1176_smsc911x_device); | 264 | realview_eth_register(NULL, realview_pb1176_smsc911x_resources); |
272 | 265 | ||
273 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { | 266 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { |
274 | struct amba_device *d = amba_devs[i]; | 267 | struct amba_device *d = amba_devs[i]; |
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c index ba0fb33811aa..3f3f052138f1 100644 --- a/arch/arm/mach-realview/realview_pb11mp.c +++ b/arch/arm/mach-realview/realview_pb11mp.c | |||
@@ -230,13 +230,6 @@ static struct resource realview_pb11mp_smsc911x_resources[] = { | |||
230 | }, | 230 | }, |
231 | }; | 231 | }; |
232 | 232 | ||
233 | static struct platform_device realview_pb11mp_smsc911x_device = { | ||
234 | .name = "smc911x", | ||
235 | .id = 0, | ||
236 | .num_resources = ARRAY_SIZE(realview_pb11mp_smsc911x_resources), | ||
237 | .resource = realview_pb11mp_smsc911x_resources, | ||
238 | }; | ||
239 | |||
240 | struct resource realview_pb11mp_cf_resources[] = { | 233 | struct resource realview_pb11mp_cf_resources[] = { |
241 | [0] = { | 234 | [0] = { |
242 | .start = REALVIEW_PB11MP_CF_BASE, | 235 | .start = REALVIEW_PB11MP_CF_BASE, |
@@ -315,7 +308,7 @@ static void __init realview_pb11mp_init(void) | |||
315 | 308 | ||
316 | realview_flash_register(realview_pb11mp_flash_resource, | 309 | realview_flash_register(realview_pb11mp_flash_resource, |
317 | ARRAY_SIZE(realview_pb11mp_flash_resource)); | 310 | ARRAY_SIZE(realview_pb11mp_flash_resource)); |
318 | platform_device_register(&realview_pb11mp_smsc911x_device); | 311 | realview_eth_register(NULL, realview_pb11mp_smsc911x_resources); |
319 | platform_device_register(&realview_i2c_device); | 312 | platform_device_register(&realview_i2c_device); |
320 | platform_device_register(&realview_pb11mp_cf_device); | 313 | platform_device_register(&realview_pb11mp_cf_device); |
321 | 314 | ||
diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c index 0c237e90c995..34c94435d2d8 100644 --- a/arch/arm/mach-realview/realview_pba8.c +++ b/arch/arm/mach-realview/realview_pba8.c | |||
@@ -221,13 +221,6 @@ static struct resource realview_pba8_smsc911x_resources[] = { | |||
221 | }, | 221 | }, |
222 | }; | 222 | }; |
223 | 223 | ||
224 | static struct platform_device realview_pba8_smsc911x_device = { | ||
225 | .name = "smc911x", | ||
226 | .id = 0, | ||
227 | .num_resources = ARRAY_SIZE(realview_pba8_smsc911x_resources), | ||
228 | .resource = realview_pba8_smsc911x_resources, | ||
229 | }; | ||
230 | |||
231 | struct resource realview_pba8_cf_resources[] = { | 224 | struct resource realview_pba8_cf_resources[] = { |
232 | [0] = { | 225 | [0] = { |
233 | .start = REALVIEW_PBA8_CF_BASE, | 226 | .start = REALVIEW_PBA8_CF_BASE, |
@@ -281,7 +274,7 @@ static void __init realview_pba8_init(void) | |||
281 | 274 | ||
282 | realview_flash_register(realview_pba8_flash_resource, | 275 | realview_flash_register(realview_pba8_flash_resource, |
283 | ARRAY_SIZE(realview_pba8_flash_resource)); | 276 | ARRAY_SIZE(realview_pba8_flash_resource)); |
284 | platform_device_register(&realview_pba8_smsc911x_device); | 277 | realview_eth_register(NULL, realview_pba8_smsc911x_resources); |
285 | platform_device_register(&realview_i2c_device); | 278 | platform_device_register(&realview_i2c_device); |
286 | platform_device_register(&realview_pba8_cf_device); | 279 | platform_device_register(&realview_pba8_cf_device); |
287 | 280 | ||