]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
MIPS: ath25: add Wireless device support
authorSergey Ryazanov <ryazanov.s.a@gmail.com>
Tue, 28 Oct 2014 23:18:50 +0000 (03:18 +0400)
committerRalf Baechle <ralf@linux-mips.org>
Mon, 24 Nov 2014 06:45:29 +0000 (07:45 +0100)
Atheros AR5312 and AR2315 both have a builtin wireless device, this
patch add helper code and register platform device for all supported
WiSoCs.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Cc: Linux MIPS <linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/8249/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/ath25/ar2315.c
arch/mips/ath25/ar5312.c
arch/mips/ath25/devices.c
arch/mips/ath25/devices.h

index f02478915afd39c69aa98e63866dd8d62f2f5dff..2befa7d766a61c25c0549b30c26cf7584ab86b54 100644 (file)
@@ -171,6 +171,8 @@ void __init ar2315_init_devices(void)
 {
        /* Find board configuration */
        ath25_find_config(AR2315_SPI_READ_BASE, AR2315_SPI_READ_SIZE);
+
+       ath25_add_wmac(0, AR2315_WLAN0_BASE, AR2315_IRQ_WLAN0);
 }
 
 static void ar2315_restart(char *command)
index 383dd6c38e0ab457b1ca740ecf9ed62b4a936a6a..b6887f75144cd4f0576a81a3ed99a684ae5bc925 100644 (file)
@@ -246,6 +246,28 @@ void __init ar5312_init_devices(void)
                ath25_soc = ATH25_SOC_AR5312;
 
        platform_device_register(&ar5312_physmap_flash);
+
+       switch (ath25_soc) {
+       case ATH25_SOC_AR5312:
+               if (!ath25_board.radio)
+                       return;
+
+               if (!(config->flags & BD_WLAN0))
+                       break;
+
+               ath25_add_wmac(0, AR5312_WLAN0_BASE, AR5312_IRQ_WLAN0);
+               break;
+       case ATH25_SOC_AR2312:
+       case ATH25_SOC_AR2313:
+               if (!ath25_board.radio)
+                       return;
+               break;
+       default:
+               break;
+       }
+
+       if (config->flags & BD_WLAN1)
+               ath25_add_wmac(1, AR5312_WLAN1_BASE, AR5312_IRQ_WLAN1);
 }
 
 static void ar5312_restart(char *command)
index 62185472ef284c901d8a7d374f42eb7a7dc06f41..7a64567d1ac30bdc92e36ff4159a9cbcb05d69bf 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/serial_8250.h>
+#include <linux/platform_device.h>
 #include <asm/bootinfo.h>
 
 #include <ath25_platform.h>
 struct ar231x_board_config ath25_board;
 enum ath25_soc_type ath25_soc = ATH25_SOC_UNKNOWN;
 
+static struct resource ath25_wmac0_res[] = {
+       {
+               .name = "wmac0_membase",
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .name = "wmac0_irq",
+               .flags = IORESOURCE_IRQ,
+       }
+};
+
+static struct resource ath25_wmac1_res[] = {
+       {
+               .name = "wmac1_membase",
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .name = "wmac1_irq",
+               .flags = IORESOURCE_IRQ,
+       }
+};
+
+static struct platform_device ath25_wmac[] = {
+       {
+               .id = 0,
+               .name = "ar231x-wmac",
+               .resource = ath25_wmac0_res,
+               .num_resources = ARRAY_SIZE(ath25_wmac0_res),
+               .dev.platform_data = &ath25_board,
+       },
+       {
+               .id = 1,
+               .name = "ar231x-wmac",
+               .resource = ath25_wmac1_res,
+               .num_resources = ARRAY_SIZE(ath25_wmac1_res),
+               .dev.platform_data = &ath25_board,
+       },
+};
+
 static const char * const soc_type_strings[] = {
        [ATH25_SOC_AR5312] = "Atheros AR5312",
        [ATH25_SOC_AR2312] = "Atheros AR2312",
@@ -46,6 +86,20 @@ void __init ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk)
        early_serial_setup(&s);
 }
 
+int __init ath25_add_wmac(int nr, u32 base, int irq)
+{
+       struct resource *res;
+
+       ath25_wmac[nr].dev.platform_data = &ath25_board;
+       res = &ath25_wmac[nr].resource[0];
+       res->start = base;
+       res->end = base + 0x10000 - 1;
+       res++;
+       res->start = irq;
+       res->end = irq;
+       return platform_device_register(&ath25_wmac[nr]);
+}
+
 static int __init ath25_register_devices(void)
 {
        if (is_ar5312())
index 55adcf4f2b48d5ec2881a20e9b226e04be259db4..04d4141153563168fd149c063a7693c93f53bfd5 100644 (file)
@@ -28,6 +28,7 @@ extern void (*ath25_irq_dispatch)(void);
 
 int ath25_find_config(phys_addr_t offset, unsigned long size);
 void ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk);
+int ath25_add_wmac(int nr, u32 base, int irq);
 
 static inline bool is_ar2315(void)
 {