[RFC 15/18] MIPS: ar231x: add Wireless device support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 arch/mips/ar231x/ar2315.c  |  8 ++++---
 arch/mips/ar231x/ar5312.c  | 28 +++++++++++++++++++++++-
 arch/mips/ar231x/devices.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/mips/ar231x/devices.h |  1 +
 4 files changed, 87 insertions(+), 4 deletions(-)

diff --git a/arch/mips/ar231x/ar2315.c b/arch/mips/ar231x/ar2315.c
index a9fbe4b..ce4be47 100644
--- a/arch/mips/ar231x/ar2315.c
+++ b/arch/mips/ar231x/ar2315.c
@@ -103,12 +103,13 @@ static void ar2315_irq_dispatch(void)
 {
 	u32 pending = read_c0_status() & read_c0_cause();
 
+	if (pending & CAUSEF_IP3)
+		do_IRQ(AR2315_IRQ_WLAN0);
 #ifdef CONFIG_PCI_AR2315
-	if (pending & CAUSEF_IP5)
+	else if (pending & CAUSEF_IP5)
 		do_IRQ(AR2315_IRQ_LCBUS_PCI);
-	else
 #endif
-	if (pending & CAUSEF_IP2)
+	else if (pending & CAUSEF_IP2)
 		do_IRQ(AR2315_IRQ_MISC);
 	else if (pending & CAUSEF_IP7)
 		do_IRQ(AR231X_IRQ_CPU_CLOCK);
@@ -223,6 +224,7 @@ void __init ar2315_init_devices(void)
 	platform_device_register(&ar2315_gpio);
 	platform_device_register(&ar2315_wdt);
 	platform_device_register(&ar2315_spiflash);
+	ar231x_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0);
 }
 
 static void ar2315_restart(char *command)
diff --git a/arch/mips/ar231x/ar5312.c b/arch/mips/ar231x/ar5312.c
index 944cd16..975f580 100644
--- a/arch/mips/ar231x/ar5312.c
+++ b/arch/mips/ar231x/ar5312.c
@@ -95,7 +95,11 @@ static void ar5312_irq_dispatch(void)
 {
 	u32 pending = read_c0_status() & read_c0_cause();
 
-	if (pending & CAUSEF_IP6)
+	if (pending & CAUSEF_IP2)
+		do_IRQ(AR5312_IRQ_WLAN0);
+	else if (pending & CAUSEF_IP5)
+		do_IRQ(AR5312_IRQ_WLAN1);
+	else if (pending & CAUSEF_IP6)
 		do_IRQ(AR5312_IRQ_MISC);
 	else if (pending & CAUSEF_IP7)
 		do_IRQ(AR231X_IRQ_CPU_CLOCK);
@@ -222,6 +226,28 @@ void __init ar5312_init_devices(void)
 
 	platform_device_register(&ar5312_physmap_flash);
 	platform_device_register(&ar5312_gpio);
+
+	switch (ar231x_devtype) {
+	case DEV_TYPE_AR5312:
+		if (!ar231x_board.radio)
+			return;
+
+		if (!(config->flags & BD_WLAN0))
+			break;
+
+		ar231x_add_wmac(0, AR5312_WLAN0, AR5312_IRQ_WLAN0);
+		break;
+	case DEV_TYPE_AR2312:
+	case DEV_TYPE_AR2313:
+		if (!ar231x_board.radio)
+			return;
+		break;
+	default:
+		break;
+	}
+
+	if (config->flags & BD_WLAN1)
+		ar231x_add_wmac(1, AR5312_WLAN1, AR5312_IRQ_WLAN1);
 }
 
 static void ar5312_restart(char *command)
diff --git a/arch/mips/ar231x/devices.c b/arch/mips/ar231x/devices.c
index 95083b0..951e7d7 100644
--- a/arch/mips/ar231x/devices.c
+++ b/arch/mips/ar231x/devices.c
@@ -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 <ar231x_platform.h>
@@ -11,6 +12,45 @@
 struct ar231x_board_config ar231x_board;
 int ar231x_devtype = DEV_TYPE_UNKNOWN;
 
+static struct resource ar231x_wmac0_res[] = {
+	{
+		.name = "wmac0_membase",
+		.flags = IORESOURCE_MEM,
+	},
+	{
+		.name = "wmac0_irq",
+		.flags = IORESOURCE_IRQ,
+	}
+};
+
+static struct resource ar231x_wmac1_res[] = {
+	{
+		.name = "wmac1_membase",
+		.flags = IORESOURCE_MEM,
+	},
+	{
+		.name = "wmac1_irq",
+		.flags = IORESOURCE_IRQ,
+	}
+};
+
+static struct platform_device ar231x_wmac[] = {
+	{
+		.id = 0,
+		.name = "ar231x-wmac",
+		.resource = ar231x_wmac0_res,
+		.num_resources = ARRAY_SIZE(ar231x_wmac0_res),
+		.dev.platform_data = &ar231x_board,
+	},
+	{
+		.id = 1,
+		.name = "ar231x-wmac",
+		.resource = ar231x_wmac1_res,
+		.num_resources = ARRAY_SIZE(ar231x_wmac1_res),
+		.dev.platform_data = &ar231x_board,
+	},
+};
+
 static const char * const devtype_strings[] = {
 	[DEV_TYPE_AR5312] = "Atheros AR5312",
 	[DEV_TYPE_AR2312] = "Atheros AR2312",
@@ -46,6 +86,20 @@ void __init ar231x_serial_setup(u32 mapbase, int irq, unsigned int uartclk)
 	early_serial_setup(&s);
 }
 
+int __init ar231x_add_wmac(int nr, u32 base, int irq)
+{
+	struct resource *res;
+
+	ar231x_wmac[nr].dev.platform_data = &ar231x_board;
+	res = &ar231x_wmac[nr].resource[0];
+	res->start = base;
+	res->end = base + 0x10000 - 1;
+	res++;
+	res->start = irq;
+	res->end = irq;
+	return platform_device_register(&ar231x_wmac[nr]);
+}
+
 static int __init ar231x_register_devices(void)
 {
 	ar5312_init_devices();
diff --git a/arch/mips/ar231x/devices.h b/arch/mips/ar231x/devices.h
index 5ffa091..6e3d242 100644
--- a/arch/mips/ar231x/devices.h
+++ b/arch/mips/ar231x/devices.h
@@ -24,6 +24,7 @@ extern void (*ar231x_irq_dispatch)(void);
 
 int ar231x_find_config(const u8 *flash_limit);
 void ar231x_serial_setup(u32 mapbase, int irq, unsigned int uartclk);
+int ar231x_add_wmac(int nr, u32 base, int irq);
 
 static inline bool is_2315(void)
 {
-- 
1.8.1.5



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux