linux-mips
[Top] [All Lists]

[PATCH 3/6] MIPS: ath79: separate AR913x SoC specific WMAC setup code

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH 3/6] MIPS: ath79: separate AR913x SoC specific WMAC setup code
From: Gabor Juhos <juhosg@openwrt.org>
Date: Thu, 17 Nov 2011 23:13:44 +0100
Cc: Imre Kaloz <kaloz@openwrt.org>, linux-mips@linux-mips.org, Gabor Juhos <juhosg@openwrt.org>
In-reply-to: <1321568027-32066-1-git-send-email-juhosg@openwrt.org>
References: <1321568027-32066-1-git-send-email-juhosg@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
The device registration code can be shared between
the different SoCs, but the required setup code varies
Move AR913x specific setup code into a separate function
in order to make adding support for another SoCs easier.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/dev-ar913x-wmac.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/arch/mips/ath79/dev-ar913x-wmac.c 
b/arch/mips/ath79/dev-ar913x-wmac.c
index 2c9ba40..21118fb 100644
--- a/arch/mips/ath79/dev-ar913x-wmac.c
+++ b/arch/mips/ath79/dev-ar913x-wmac.c
@@ -23,8 +23,7 @@ static struct ath9k_platform_data ath79_wmac_data;
 
 static struct resource ath79_wmac_resources[] = {
        {
-               .start  = AR913X_WMAC_BASE,
-               .end    = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1,
+               /* .start and .end fields are filled dynamically */
                .flags  = IORESOURCE_MEM,
        }, {
                .start  = ATH79_CPU_IRQ_IP2,
@@ -43,12 +42,8 @@ static struct platform_device ath79_wmac_device = {
        },
 };
 
-void __init ath79_register_wmac(u8 *cal_data)
+static void __init ar913x_wmac_setup(void)
 {
-       if (cal_data)
-               memcpy(ath79_wmac_data.eeprom_data, cal_data,
-                      sizeof(ath79_wmac_data.eeprom_data));
-
        /* reset the WMAC */
        ath79_device_reset_set(AR913X_RESET_AMBA2WMAC);
        mdelay(10);
@@ -56,5 +51,20 @@ void __init ath79_register_wmac(u8 *cal_data)
        ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC);
        mdelay(10);
 
+       ath79_wmac_resources[0].start = AR913X_WMAC_BASE;
+       ath79_wmac_resources[0].end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1;
+}
+
+void __init ath79_register_wmac(u8 *cal_data)
+{
+       if (soc_is_ar913x())
+               ar913x_wmac_setup();
+       else
+               BUG();
+
+       if (cal_data)
+               memcpy(ath79_wmac_data.eeprom_data, cal_data,
+                      sizeof(ath79_wmac_data.eeprom_data));
+
        platform_device_register(&ath79_wmac_device);
 }
-- 
1.7.2.1


<Prev in Thread] Current Thread [Next in Thread>