MIPS: ath79: add common WMAC device for AR913X based boards

Add common platform_device and helper code to make the registration
of the built-in wireless MAC easier on the Atheros AR9130/AR9132
based boards. Also register the WMAC device on the AR81 board.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: linux-mips@linux-mips.org
Cc: Imre Kaloz <kaloz@openwrt.org>,
Cc: Luis R. Rodriguez <lrodriguez@atheros.com>
Cc: Cliff Holden <Cliff.Holden@Atheros.com>
Cc: Kathy Giori <Kathy.Giori@Atheros.com>
Patchwork: https://patchwork.linux-mips.org/patch/1962/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by Gabor Juhos and committed by Ralf Baechle f5b35d0b aa6695ec

+92
+5
arch/mips/ath79/Kconfig
··· 5 config ATH79_MACH_AP81 6 bool "Atheros AP81 reference board" 7 select SOC_AR913X 8 select ATH79_DEV_GPIO_BUTTONS 9 select ATH79_DEV_LEDS_GPIO 10 select ATH79_DEV_SPI ··· 32 def_bool n 33 34 config SOC_AR913X 35 def_bool n 36 37 config ATH79_DEV_GPIO_BUTTONS
··· 5 config ATH79_MACH_AP81 6 bool "Atheros AP81 reference board" 7 select SOC_AR913X 8 + select ATH79_DEV_AR913X_WMAC 9 select ATH79_DEV_GPIO_BUTTONS 10 select ATH79_DEV_LEDS_GPIO 11 select ATH79_DEV_SPI ··· 31 def_bool n 32 33 config SOC_AR913X 34 + def_bool n 35 + 36 + config ATH79_DEV_AR913X_WMAC 37 + depends on SOC_AR913X 38 def_bool n 39 40 config ATH79_DEV_GPIO_BUTTONS
+1
arch/mips/ath79/Makefile
··· 16 # Devices 17 # 18 obj-y += dev-common.o 19 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o 20 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o 21 obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o
··· 16 # Devices 17 # 18 obj-y += dev-common.o 19 + obj-$(CONFIG_ATH79_DEV_AR913X_WMAC) += dev-ar913x-wmac.o 20 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o 21 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o 22 obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o
+60
arch/mips/ath79/dev-ar913x-wmac.c
···
··· 1 + /* 2 + * Atheros AR913X SoC built-in WMAC device support 3 + * 4 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org> 5 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License version 2 as published 9 + * by the Free Software Foundation. 10 + */ 11 + 12 + #include <linux/init.h> 13 + #include <linux/delay.h> 14 + #include <linux/irq.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/ath9k_platform.h> 17 + 18 + #include <asm/mach-ath79/ath79.h> 19 + #include <asm/mach-ath79/ar71xx_regs.h> 20 + #include "dev-ar913x-wmac.h" 21 + 22 + static struct ath9k_platform_data ar913x_wmac_data; 23 + 24 + static struct resource ar913x_wmac_resources[] = { 25 + { 26 + .start = AR913X_WMAC_BASE, 27 + .end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1, 28 + .flags = IORESOURCE_MEM, 29 + }, { 30 + .start = ATH79_CPU_IRQ_IP2, 31 + .end = ATH79_CPU_IRQ_IP2, 32 + .flags = IORESOURCE_IRQ, 33 + }, 34 + }; 35 + 36 + static struct platform_device ar913x_wmac_device = { 37 + .name = "ath9k", 38 + .id = -1, 39 + .resource = ar913x_wmac_resources, 40 + .num_resources = ARRAY_SIZE(ar913x_wmac_resources), 41 + .dev = { 42 + .platform_data = &ar913x_wmac_data, 43 + }, 44 + }; 45 + 46 + void __init ath79_register_ar913x_wmac(u8 *cal_data) 47 + { 48 + if (cal_data) 49 + memcpy(ar913x_wmac_data.eeprom_data, cal_data, 50 + sizeof(ar913x_wmac_data.eeprom_data)); 51 + 52 + /* reset the WMAC */ 53 + ath79_device_reset_set(AR913X_RESET_AMBA2WMAC); 54 + mdelay(10); 55 + 56 + ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC); 57 + mdelay(10); 58 + 59 + platform_device_register(&ar913x_wmac_device); 60 + }
+17
arch/mips/ath79/dev-ar913x-wmac.h
···
··· 1 + /* 2 + * Atheros AR913X SoC built-in WMAC device support 3 + * 4 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org> 5 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License version 2 as published 9 + * by the Free Software Foundation. 10 + */ 11 + 12 + #ifndef _ATH79_DEV_AR913X_WMAC_H 13 + #define _ATH79_DEV_AR913X_WMAC_H 14 + 15 + void ath79_register_ar913x_wmac(u8 *cal_data); 16 + 17 + #endif /* _ATH79_DEV_AR913X_WMAC_H */
+6
arch/mips/ath79/mach-ap81.c
··· 10 */ 11 12 #include "machtypes.h" 13 #include "dev-gpio-buttons.h" 14 #include "dev-leds-gpio.h" 15 #include "dev-spi.h" ··· 25 26 #define AP81_KEYS_POLL_INTERVAL 20 /* msecs */ 27 #define AP81_KEYS_DEBOUNCE_INTERVAL (3 * AP81_KEYS_POLL_INTERVAL) 28 29 static struct gpio_led ap81_leds_gpio[] __initdata = { 30 { ··· 82 83 static void __init ap81_setup(void) 84 { 85 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio), 86 ap81_leds_gpio); 87 ath79_register_gpio_keys_polled(-1, AP81_KEYS_POLL_INTERVAL, ··· 91 ap81_gpio_keys); 92 ath79_register_spi(&ap81_spi_data, ap81_spi_info, 93 ARRAY_SIZE(ap81_spi_info)); 94 } 95 96 MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
··· 10 */ 11 12 #include "machtypes.h" 13 + #include "dev-ar913x-wmac.h" 14 #include "dev-gpio-buttons.h" 15 #include "dev-leds-gpio.h" 16 #include "dev-spi.h" ··· 24 25 #define AP81_KEYS_POLL_INTERVAL 20 /* msecs */ 26 #define AP81_KEYS_DEBOUNCE_INTERVAL (3 * AP81_KEYS_POLL_INTERVAL) 27 + 28 + #define AP81_CAL_DATA_ADDR 0x1fff1000 29 30 static struct gpio_led ap81_leds_gpio[] __initdata = { 31 { ··· 79 80 static void __init ap81_setup(void) 81 { 82 + u8 *cal_data = (u8 *) KSEG1ADDR(AP81_CAL_DATA_ADDR); 83 + 84 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio), 85 ap81_leds_gpio); 86 ath79_register_gpio_keys_polled(-1, AP81_KEYS_POLL_INTERVAL, ··· 86 ap81_gpio_keys); 87 ath79_register_spi(&ap81_spi_data, ap81_spi_info, 88 ARRAY_SIZE(ap81_spi_info)); 89 + ath79_register_ar913x_wmac(cal_data); 90 } 91 92 MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
+3
arch/mips/include/asm/mach-ath79/ar71xx_regs.h
··· 34 #define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000) 35 #define AR71XX_RESET_SIZE 0x100 36 37 /* 38 * DDR_CTRL block 39 */
··· 34 #define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000) 35 #define AR71XX_RESET_SIZE 0x100 36 37 + #define AR913X_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000) 38 + #define AR913X_WMAC_SIZE 0x30000 39 + 40 /* 41 * DDR_CTRL block 42 */