]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
MIPS: ath79: add common WMAC device for AR913X based boards
authorGabor Juhos <juhosg@openwrt.org>
Tue, 4 Jan 2011 20:28:29 +0000 (21:28 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 18 Jan 2011 18:30:28 +0000 (19:30 +0100)
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>
arch/mips/ath79/Kconfig
arch/mips/ath79/Makefile
arch/mips/ath79/dev-ar913x-wmac.c [new file with mode: 0644]
arch/mips/ath79/dev-ar913x-wmac.h [new file with mode: 0644]
arch/mips/ath79/mach-ap81.c
arch/mips/include/asm/mach-ath79/ar71xx_regs.h

index 2e397708e2f75b47b0d29ad88fdb4bac9a7dc7d2..b05828260f7f92b6e6c834efbd9c8d6173566fab 100644 (file)
@@ -5,6 +5,7 @@ menu "Atheros AR71XX/AR724X/AR913X machine selection"
 config ATH79_MACH_AP81
        bool "Atheros AP81 reference board"
        select SOC_AR913X
+       select ATH79_DEV_AR913X_WMAC
        select ATH79_DEV_GPIO_BUTTONS
        select ATH79_DEV_LEDS_GPIO
        select ATH79_DEV_SPI
@@ -33,6 +34,10 @@ config SOC_AR724X
 config SOC_AR913X
        def_bool n
 
+config ATH79_DEV_AR913X_WMAC
+       depends on SOC_AR913X
+       def_bool n
+
 config ATH79_DEV_GPIO_BUTTONS
        def_bool n
 
index a245e3645271866d916581d70d0b4e4e34c560af..c33d4653007c3cd1545873fc2e151e1cf04f2e48 100644 (file)
@@ -16,6 +16,7 @@ obj-$(CONFIG_EARLY_PRINTK)            += early_printk.o
 # Devices
 #
 obj-y                                  += dev-common.o
+obj-$(CONFIG_ATH79_DEV_AR913X_WMAC)    += dev-ar913x-wmac.o
 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
diff --git a/arch/mips/ath79/dev-ar913x-wmac.c b/arch/mips/ath79/dev-ar913x-wmac.c
new file mode 100644 (file)
index 0000000..48f425a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  Atheros AR913X SoC built-in WMAC device support
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ *  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 <linux/init.h>
+#include <linux/delay.h>
+#include <linux/irq.h>
+#include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+#include "dev-ar913x-wmac.h"
+
+static struct ath9k_platform_data ar913x_wmac_data;
+
+static struct resource ar913x_wmac_resources[] = {
+       {
+               .start  = AR913X_WMAC_BASE,
+               .end    = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       }, {
+               .start  = ATH79_CPU_IRQ_IP2,
+               .end    = ATH79_CPU_IRQ_IP2,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device ar913x_wmac_device = {
+       .name           = "ath9k",
+       .id             = -1,
+       .resource       = ar913x_wmac_resources,
+       .num_resources  = ARRAY_SIZE(ar913x_wmac_resources),
+       .dev = {
+               .platform_data = &ar913x_wmac_data,
+       },
+};
+
+void __init ath79_register_ar913x_wmac(u8 *cal_data)
+{
+       if (cal_data)
+               memcpy(ar913x_wmac_data.eeprom_data, cal_data,
+                      sizeof(ar913x_wmac_data.eeprom_data));
+
+       /* reset the WMAC */
+       ath79_device_reset_set(AR913X_RESET_AMBA2WMAC);
+       mdelay(10);
+
+       ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC);
+       mdelay(10);
+
+       platform_device_register(&ar913x_wmac_device);
+}
diff --git a/arch/mips/ath79/dev-ar913x-wmac.h b/arch/mips/ath79/dev-ar913x-wmac.h
new file mode 100644 (file)
index 0000000..579d562
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ *  Atheros AR913X SoC built-in WMAC device support
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ *  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_AR913X_WMAC_H
+#define _ATH79_DEV_AR913X_WMAC_H
+
+void ath79_register_ar913x_wmac(u8 *cal_data);
+
+#endif /* _ATH79_DEV_AR913X_WMAC_H */
index 4e4ccd4f80d90a4ff6b25689688144cd0d60d052..eee4c121deb4297ca756d131a2d2908fa9eacbea 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include "machtypes.h"
+#include "dev-ar913x-wmac.h"
 #include "dev-gpio-buttons.h"
 #include "dev-leds-gpio.h"
 #include "dev-spi.h"
@@ -25,6 +26,8 @@
 #define AP81_KEYS_POLL_INTERVAL                20      /* msecs */
 #define AP81_KEYS_DEBOUNCE_INTERVAL    (3 * AP81_KEYS_POLL_INTERVAL)
 
+#define AP81_CAL_DATA_ADDR     0x1fff1000
+
 static struct gpio_led ap81_leds_gpio[] __initdata = {
        {
                .name           = "ap81:green:status",
@@ -79,6 +82,8 @@ static struct ath79_spi_platform_data ap81_spi_data = {
 
 static void __init ap81_setup(void)
 {
+       u8 *cal_data = (u8 *) KSEG1ADDR(AP81_CAL_DATA_ADDR);
+
        ath79_register_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio),
                                 ap81_leds_gpio);
        ath79_register_gpio_keys_polled(-1, AP81_KEYS_POLL_INTERVAL,
@@ -86,6 +91,7 @@ static void __init ap81_setup(void)
                                        ap81_gpio_keys);
        ath79_register_spi(&ap81_spi_data, ap81_spi_info,
                           ARRAY_SIZE(ap81_spi_info));
+       ath79_register_ar913x_wmac(cal_data);
 }
 
 MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
index 4f2b621638d9392bfbd58410f0f595e57bf1a28f..cda1c8070b27a4c0aa6afeea96fe24474e5026ba 100644 (file)
@@ -34,6 +34,9 @@
 #define AR71XX_RESET_BASE      (AR71XX_APB_BASE + 0x00060000)
 #define AR71XX_RESET_SIZE      0x100
 
+#define AR913X_WMAC_BASE       (AR71XX_APB_BASE + 0x000C0000)
+#define AR913X_WMAC_SIZE       0x30000
+
 /*
  * DDR_CTRL block
  */