| 1 | From 6e3f244874b8ae660136531b696ad05abe549607 Mon Sep 17 00:00:00 2001 |
| 2 | From: Gabor Juhos <juhosg@openwrt.org> |
| 3 | Date: Fri, 18 Nov 2011 00:17:53 +0000 |
| 4 | Subject: [PATCH 21/27] MIPS: ath79: Separate AR913x SoC specific WMAC setup code |
| 5 | |
| 6 | The device registration code can be shared between the different SoCs, but |
| 7 | the required setup code varies Move AR913x specific setup code into a |
| 8 | separate function in order to make adding support for another SoCs easier. |
| 9 | |
| 10 | Signed-off-by: Gabor Juhos <juhosg@openwrt.org> |
| 11 | Cc: Imre Kaloz <kaloz@openwrt.org> |
| 12 | Cc: linux-mips@linux-mips.org |
| 13 | Patchwork: https://patchwork.linux-mips.org/patch/3029/ |
| 14 | Signed-off-by: Ralf Baechle <ralf@linux-mips.org> |
| 15 | --- |
| 16 | arch/mips/ath79/dev-ar913x-wmac.c | 24 +++++++++++++++++------- |
| 17 | 1 files changed, 17 insertions(+), 7 deletions(-) |
| 18 | |
| 19 | --- a/arch/mips/ath79/dev-ar913x-wmac.c |
| 20 | +++ b/arch/mips/ath79/dev-ar913x-wmac.c |
| 21 | @@ -23,8 +23,7 @@ static struct ath9k_platform_data ath79_ |
| 22 | |
| 23 | static struct resource ath79_wmac_resources[] = { |
| 24 | { |
| 25 | - .start = AR913X_WMAC_BASE, |
| 26 | - .end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1, |
| 27 | + /* .start and .end fields are filled dynamically */ |
| 28 | .flags = IORESOURCE_MEM, |
| 29 | }, { |
| 30 | .start = ATH79_CPU_IRQ_IP2, |
| 31 | @@ -43,12 +42,8 @@ static struct platform_device ath79_wmac |
| 32 | }, |
| 33 | }; |
| 34 | |
| 35 | -void __init ath79_register_wmac(u8 *cal_data) |
| 36 | +static void __init ar913x_wmac_setup(void) |
| 37 | { |
| 38 | - if (cal_data) |
| 39 | - memcpy(ath79_wmac_data.eeprom_data, cal_data, |
| 40 | - sizeof(ath79_wmac_data.eeprom_data)); |
| 41 | - |
| 42 | /* reset the WMAC */ |
| 43 | ath79_device_reset_set(AR913X_RESET_AMBA2WMAC); |
| 44 | mdelay(10); |
| 45 | @@ -56,5 +51,20 @@ void __init ath79_register_wmac(u8 *cal_ |
| 46 | ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC); |
| 47 | mdelay(10); |
| 48 | |
| 49 | + ath79_wmac_resources[0].start = AR913X_WMAC_BASE; |
| 50 | + ath79_wmac_resources[0].end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1; |
| 51 | +} |
| 52 | + |
| 53 | +void __init ath79_register_wmac(u8 *cal_data) |
| 54 | +{ |
| 55 | + if (soc_is_ar913x()) |
| 56 | + ar913x_wmac_setup(); |
| 57 | + else |
| 58 | + BUG(); |
| 59 | + |
| 60 | + if (cal_data) |
| 61 | + memcpy(ath79_wmac_data.eeprom_data, cal_data, |
| 62 | + sizeof(ath79_wmac_data.eeprom_data)); |
| 63 | + |
| 64 | platform_device_register(&ath79_wmac_device); |
| 65 | } |
| 66 | |