From 67b0f0f1b355df293f92069a0409452c9e24370b Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Fri, 18 Nov 2011 00:17:53 +0000 Subject: MIPS: ath79: Remove 'ar913x' from common variable and function names The wireless MAC specific variables and the registration code can be shared between multiple SoCs. Remove the 'ar913x' part from the function and variable names to avoid confusions. Signed-off-by: Gabor Juhos Cc: Imre Kaloz Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/3028/ Signed-off-by: Ralf Baechle --- arch/mips/ath79/dev-ar913x-wmac.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'arch/mips/ath79/dev-ar913x-wmac.c') diff --git a/arch/mips/ath79/dev-ar913x-wmac.c b/arch/mips/ath79/dev-ar913x-wmac.c index 48f425a5ba28..2c9ba40be96e 100644 --- a/arch/mips/ath79/dev-ar913x-wmac.c +++ b/arch/mips/ath79/dev-ar913x-wmac.c @@ -19,9 +19,9 @@ #include #include "dev-ar913x-wmac.h" -static struct ath9k_platform_data ar913x_wmac_data; +static struct ath9k_platform_data ath79_wmac_data; -static struct resource ar913x_wmac_resources[] = { +static struct resource ath79_wmac_resources[] = { { .start = AR913X_WMAC_BASE, .end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1, @@ -33,21 +33,21 @@ static struct resource ar913x_wmac_resources[] = { }, }; -static struct platform_device ar913x_wmac_device = { +static struct platform_device ath79_wmac_device = { .name = "ath9k", .id = -1, - .resource = ar913x_wmac_resources, - .num_resources = ARRAY_SIZE(ar913x_wmac_resources), + .resource = ath79_wmac_resources, + .num_resources = ARRAY_SIZE(ath79_wmac_resources), .dev = { - .platform_data = &ar913x_wmac_data, + .platform_data = &ath79_wmac_data, }, }; -void __init ath79_register_ar913x_wmac(u8 *cal_data) +void __init ath79_register_wmac(u8 *cal_data) { if (cal_data) - memcpy(ar913x_wmac_data.eeprom_data, cal_data, - sizeof(ar913x_wmac_data.eeprom_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); @@ -56,5 +56,5 @@ void __init ath79_register_ar913x_wmac(u8 *cal_data) ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC); mdelay(10); - platform_device_register(&ar913x_wmac_device); + platform_device_register(&ath79_wmac_device); } -- cgit v1.2.3 From 6903bb49da18e0bf3e2909e6b1342ee9a26b78ff Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Fri, 18 Nov 2011 00:17:53 +0000 Subject: MIPS: ath79: Separate AR913x SoC specific WMAC setup code 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 Cc: Imre Kaloz Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/3029/ Signed-off-by: Ralf Baechle --- arch/mips/ath79/dev-ar913x-wmac.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'arch/mips/ath79/dev-ar913x-wmac.c') diff --git a/arch/mips/ath79/dev-ar913x-wmac.c b/arch/mips/ath79/dev-ar913x-wmac.c index 2c9ba40be96e..21118fb461ab 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); } -- cgit v1.2.3 From 34cfcd26bd34884e9bcbbfae4f87b36e42931c30 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Fri, 18 Nov 2011 00:17:53 +0000 Subject: MIPS: ath79: Add AR933x specific WMAC setup code The wireless MAC of the AR933x SoCs uses different base address, and requires different setup code. Signed-off-by: Gabor Juhos Cc: Imre Kaloz Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/3030/ Signed-off-by: Ralf Baechle --- arch/mips/ath79/dev-ar913x-wmac.c | 43 ++++++++++++++++++++++++-- arch/mips/ath79/dev-ar913x-wmac.h | 4 +-- arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 4 ++- 3 files changed, 46 insertions(+), 5 deletions(-) (limited to 'arch/mips/ath79/dev-ar913x-wmac.c') diff --git a/arch/mips/ath79/dev-ar913x-wmac.c b/arch/mips/ath79/dev-ar913x-wmac.c index 21118fb461ab..c424e9a2160d 100644 --- a/arch/mips/ath79/dev-ar913x-wmac.c +++ b/arch/mips/ath79/dev-ar913x-wmac.c @@ -1,7 +1,7 @@ /* - * Atheros AR913X SoC built-in WMAC device support + * Atheros AR913X/AR933X SoC built-in WMAC device support * - * Copyright (C) 2008-2010 Gabor Juhos + * Copyright (C) 2008-2011 Gabor Juhos * Copyright (C) 2008 Imre Kaloz * * This program is free software; you can redistribute it and/or modify it @@ -55,10 +55,49 @@ static void __init ar913x_wmac_setup(void) ath79_wmac_resources[0].end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1; } + +static int ar933x_wmac_reset(void) +{ + ath79_device_reset_clear(AR933X_RESET_WMAC); + ath79_device_reset_set(AR933X_RESET_WMAC); + + return 0; +} + +static int ar933x_r1_get_wmac_revision(void) +{ + return ath79_soc_rev; +} + +static void __init ar933x_wmac_setup(void) +{ + u32 t; + + ar933x_wmac_reset(); + + ath79_wmac_device.name = "ar933x_wmac"; + + ath79_wmac_resources[0].start = AR933X_WMAC_BASE; + ath79_wmac_resources[0].end = AR933X_WMAC_BASE + AR933X_WMAC_SIZE - 1; + + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP); + if (t & AR933X_BOOTSTRAP_REF_CLK_40) + ath79_wmac_data.is_clk_25mhz = false; + else + ath79_wmac_data.is_clk_25mhz = true; + + if (ath79_soc_rev == 1) + ath79_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision; + + ath79_wmac_data.external_reset = ar933x_wmac_reset; +} + void __init ath79_register_wmac(u8 *cal_data) { if (soc_is_ar913x()) ar913x_wmac_setup(); + if (soc_is_ar933x()) + ar933x_wmac_setup(); else BUG(); diff --git a/arch/mips/ath79/dev-ar913x-wmac.h b/arch/mips/ath79/dev-ar913x-wmac.h index de1d78497fc9..c9cd8709f090 100644 --- a/arch/mips/ath79/dev-ar913x-wmac.h +++ b/arch/mips/ath79/dev-ar913x-wmac.h @@ -1,7 +1,7 @@ /* - * Atheros AR913X SoC built-in WMAC device support + * Atheros AR913X/AR933X SoC built-in WMAC device support * - * Copyright (C) 2008-2010 Gabor Juhos + * Copyright (C) 2008-2011 Gabor Juhos * Copyright (C) 2008 Imre Kaloz * * This program is free software; you can redistribute it and/or modify it diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h index 733bacace778..2f0becb4ec8f 100644 --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h @@ -55,7 +55,8 @@ #define AR933X_UART_BASE (AR71XX_APB_BASE + 0x00020000) #define AR933X_UART_SIZE 0x14 - +#define AR933X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000) +#define AR933X_WMAC_SIZE 0x20000 #define AR933X_EHCI_BASE 0x1b000000 #define AR933X_EHCI_SIZE 0x1000 @@ -233,6 +234,7 @@ #define AR913X_RESET_USB_HOST BIT(5) #define AR913X_RESET_USB_PHY BIT(4) +#define AR933X_RESET_WMAC BIT(11) #define AR933X_RESET_USB_HOST BIT(5) #define AR933X_RESET_USB_PHY BIT(4) #define AR933X_RESET_USBSUS_OVERRIDE BIT(3) -- cgit v1.2.3 From 009b9d52e5bdd4b79ae214db10afb677998b33b1 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Fri, 18 Nov 2011 00:17:54 +0000 Subject: MIPS: ath79: Rename dev-ar913x-wmac.h to dev-wmac.h The 'ar913x' part was removed from the common variable and function names, so remove that from the relevant header file name as well. Signed-off-by: Gabor Juhos Cc: Imre Kaloz Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/3033/ Signed-off-by: Ralf Baechle --- arch/mips/ath79/dev-ar913x-wmac.c | 2 +- arch/mips/ath79/dev-ar913x-wmac.h | 17 ----------------- arch/mips/ath79/dev-wmac.h | 17 +++++++++++++++++ arch/mips/ath79/mach-ap121.c | 2 +- arch/mips/ath79/mach-ap81.c | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 arch/mips/ath79/dev-ar913x-wmac.h create mode 100644 arch/mips/ath79/dev-wmac.h (limited to 'arch/mips/ath79/dev-ar913x-wmac.c') diff --git a/arch/mips/ath79/dev-ar913x-wmac.c b/arch/mips/ath79/dev-ar913x-wmac.c index c424e9a2160d..24f546985b69 100644 --- a/arch/mips/ath79/dev-ar913x-wmac.c +++ b/arch/mips/ath79/dev-ar913x-wmac.c @@ -17,7 +17,7 @@ #include #include -#include "dev-ar913x-wmac.h" +#include "dev-wmac.h" static struct ath9k_platform_data ath79_wmac_data; diff --git a/arch/mips/ath79/dev-ar913x-wmac.h b/arch/mips/ath79/dev-ar913x-wmac.h deleted file mode 100644 index c9cd8709f090..000000000000 --- a/arch/mips/ath79/dev-ar913x-wmac.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Atheros AR913X/AR933X SoC built-in WMAC device support - * - * Copyright (C) 2008-2011 Gabor Juhos - * Copyright (C) 2008 Imre Kaloz - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#ifndef _ATH79_DEV_WMAC_H -#define _ATH79_DEV_WMAC_H - -void ath79_register_wmac(u8 *cal_data); - -#endif /* _ATH79_DEV_WMAC_H */ diff --git a/arch/mips/ath79/dev-wmac.h b/arch/mips/ath79/dev-wmac.h new file mode 100644 index 000000000000..c9cd8709f090 --- /dev/null +++ b/arch/mips/ath79/dev-wmac.h @@ -0,0 +1,17 @@ +/* + * Atheros AR913X/AR933X SoC built-in WMAC device support + * + * Copyright (C) 2008-2011 Gabor Juhos + * Copyright (C) 2008 Imre Kaloz + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#ifndef _ATH79_DEV_WMAC_H +#define _ATH79_DEV_WMAC_H + +void ath79_register_wmac(u8 *cal_data); + +#endif /* _ATH79_DEV_WMAC_H */ diff --git a/arch/mips/ath79/mach-ap121.c b/arch/mips/ath79/mach-ap121.c index 39ee82802e49..4c20200d7c72 100644 --- a/arch/mips/ath79/mach-ap121.c +++ b/arch/mips/ath79/mach-ap121.c @@ -13,7 +13,7 @@ #include "dev-leds-gpio.h" #include "dev-spi.h" #include "dev-usb.h" -#include "dev-ar913x-wmac.h" +#include "dev-wmac.h" #define AP121_GPIO_LED_WLAN 0 #define AP121_GPIO_LED_USB 1 diff --git a/arch/mips/ath79/mach-ap81.c b/arch/mips/ath79/mach-ap81.c index 84442da2d23c..abe19836331c 100644 --- a/arch/mips/ath79/mach-ap81.c +++ b/arch/mips/ath79/mach-ap81.c @@ -10,7 +10,7 @@ */ #include "machtypes.h" -#include "dev-ar913x-wmac.h" +#include "dev-wmac.h" #include "dev-gpio-buttons.h" #include "dev-leds-gpio.h" #include "dev-spi.h" -- cgit v1.2.3 From b606d5ae905f5e560021298307ab7b9ef69a60f1 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Fri, 18 Nov 2011 00:17:54 +0000 Subject: MIPS: ath79: Rename dev-ar913x-wmac.c to dev-wmac.c Rename the file as a last step of the 'ar913x' removal changes. Signed-off-by: Gabor Juhos Cc: Imre Kaloz Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/3034/ Signed-off-by: Ralf Baechle --- arch/mips/ath79/Makefile | 2 +- arch/mips/ath79/dev-ar913x-wmac.c | 109 -------------------------------------- arch/mips/ath79/dev-wmac.c | 109 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 110 deletions(-) delete mode 100644 arch/mips/ath79/dev-ar913x-wmac.c create mode 100644 arch/mips/ath79/dev-wmac.c (limited to 'arch/mips/ath79/dev-ar913x-wmac.c') diff --git a/arch/mips/ath79/Makefile b/arch/mips/ath79/Makefile index 53eca55d5b53..3b911e09dbec 100644 --- a/arch/mips/ath79/Makefile +++ b/arch/mips/ath79/Makefile @@ -20,7 +20,7 @@ obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o obj-$(CONFIG_ATH79_DEV_USB) += dev-usb.o -obj-$(CONFIG_ATH79_DEV_WMAC) += dev-ar913x-wmac.o +obj-$(CONFIG_ATH79_DEV_WMAC) += dev-wmac.o # # Machines diff --git a/arch/mips/ath79/dev-ar913x-wmac.c b/arch/mips/ath79/dev-ar913x-wmac.c deleted file mode 100644 index 24f546985b69..000000000000 --- a/arch/mips/ath79/dev-ar913x-wmac.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Atheros AR913X/AR933X SoC built-in WMAC device support - * - * Copyright (C) 2008-2011 Gabor Juhos - * Copyright (C) 2008 Imre Kaloz - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include "dev-wmac.h" - -static struct ath9k_platform_data ath79_wmac_data; - -static struct resource ath79_wmac_resources[] = { - { - /* .start and .end fields are filled dynamically */ - .flags = IORESOURCE_MEM, - }, { - .start = ATH79_CPU_IRQ_IP2, - .end = ATH79_CPU_IRQ_IP2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device ath79_wmac_device = { - .name = "ath9k", - .id = -1, - .resource = ath79_wmac_resources, - .num_resources = ARRAY_SIZE(ath79_wmac_resources), - .dev = { - .platform_data = &ath79_wmac_data, - }, -}; - -static void __init ar913x_wmac_setup(void) -{ - /* reset the WMAC */ - ath79_device_reset_set(AR913X_RESET_AMBA2WMAC); - mdelay(10); - - 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; -} - - -static int ar933x_wmac_reset(void) -{ - ath79_device_reset_clear(AR933X_RESET_WMAC); - ath79_device_reset_set(AR933X_RESET_WMAC); - - return 0; -} - -static int ar933x_r1_get_wmac_revision(void) -{ - return ath79_soc_rev; -} - -static void __init ar933x_wmac_setup(void) -{ - u32 t; - - ar933x_wmac_reset(); - - ath79_wmac_device.name = "ar933x_wmac"; - - ath79_wmac_resources[0].start = AR933X_WMAC_BASE; - ath79_wmac_resources[0].end = AR933X_WMAC_BASE + AR933X_WMAC_SIZE - 1; - - t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP); - if (t & AR933X_BOOTSTRAP_REF_CLK_40) - ath79_wmac_data.is_clk_25mhz = false; - else - ath79_wmac_data.is_clk_25mhz = true; - - if (ath79_soc_rev == 1) - ath79_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision; - - ath79_wmac_data.external_reset = ar933x_wmac_reset; -} - -void __init ath79_register_wmac(u8 *cal_data) -{ - if (soc_is_ar913x()) - ar913x_wmac_setup(); - if (soc_is_ar933x()) - ar933x_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); -} diff --git a/arch/mips/ath79/dev-wmac.c b/arch/mips/ath79/dev-wmac.c new file mode 100644 index 000000000000..24f546985b69 --- /dev/null +++ b/arch/mips/ath79/dev-wmac.c @@ -0,0 +1,109 @@ +/* + * Atheros AR913X/AR933X SoC built-in WMAC device support + * + * Copyright (C) 2008-2011 Gabor Juhos + * Copyright (C) 2008 Imre Kaloz + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include "dev-wmac.h" + +static struct ath9k_platform_data ath79_wmac_data; + +static struct resource ath79_wmac_resources[] = { + { + /* .start and .end fields are filled dynamically */ + .flags = IORESOURCE_MEM, + }, { + .start = ATH79_CPU_IRQ_IP2, + .end = ATH79_CPU_IRQ_IP2, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device ath79_wmac_device = { + .name = "ath9k", + .id = -1, + .resource = ath79_wmac_resources, + .num_resources = ARRAY_SIZE(ath79_wmac_resources), + .dev = { + .platform_data = &ath79_wmac_data, + }, +}; + +static void __init ar913x_wmac_setup(void) +{ + /* reset the WMAC */ + ath79_device_reset_set(AR913X_RESET_AMBA2WMAC); + mdelay(10); + + 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; +} + + +static int ar933x_wmac_reset(void) +{ + ath79_device_reset_clear(AR933X_RESET_WMAC); + ath79_device_reset_set(AR933X_RESET_WMAC); + + return 0; +} + +static int ar933x_r1_get_wmac_revision(void) +{ + return ath79_soc_rev; +} + +static void __init ar933x_wmac_setup(void) +{ + u32 t; + + ar933x_wmac_reset(); + + ath79_wmac_device.name = "ar933x_wmac"; + + ath79_wmac_resources[0].start = AR933X_WMAC_BASE; + ath79_wmac_resources[0].end = AR933X_WMAC_BASE + AR933X_WMAC_SIZE - 1; + + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP); + if (t & AR933X_BOOTSTRAP_REF_CLK_40) + ath79_wmac_data.is_clk_25mhz = false; + else + ath79_wmac_data.is_clk_25mhz = true; + + if (ath79_soc_rev == 1) + ath79_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision; + + ath79_wmac_data.external_reset = ar933x_wmac_reset; +} + +void __init ath79_register_wmac(u8 *cal_data) +{ + if (soc_is_ar913x()) + ar913x_wmac_setup(); + if (soc_is_ar933x()) + ar933x_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); +} -- cgit v1.2.3