Signed-off-by: Andrew 'Necromant' Andrianov <[email protected]>
---
 .../files/arch/mips/ath79/mach-mercury-mw150r.c    |  119 ++++++++++++++++++++
 .../610-MIPS-ath79-openwrt-machines.patch          |   49 ++++++---
 2 files changed, 154 insertions(+), 14 deletions(-)
 create mode 100644 
target/linux/ar71xx/files/arch/mips/ath79/mach-mercury-mw150r.c

diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-mercury-mw150r.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-mercury-mw150r.c
new file mode 100644
index 0000000..7ed2602
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-mercury-mw150r.c
@@ -0,0 +1,119 @@
+/*
+ *  Mercury MW150R board support
+ *
+ *  Copyright (C) 2012 Andrew 'Necromant' Andrianov <[email protected]>
+ *
+ *  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 <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include "common.h"
+#include "dev-ap9x-pci.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "machtypes.h"
+
+#define MW150R_GPIO_LED_GEAR   27
+#define MW150R_GPIO_LED_WLAN   0
+#define MW150R_GPIO_LED_LOCK   26
+#define MW150R_GPIO_LED_LAN1   13
+#define MW150R_GPIO_LED_LAN2   14
+#define MW150R_GPIO_LED_LAN3   15
+#define MW150R_GPIO_LED_LAN4   16
+#define MW150R_GPIO_LED_WAN            17
+
+#define MW150R_GPIO_BTN_RESET          11
+
+#define MW150R_KEYS_POLL_INTERVAL      20      /* msecs */
+#define MW150R_KEYS_DEBOUNCE_INTERVAL (3 * MW150R_KEYS_POLL_INTERVAL)
+
+static const char *mw150r_part_probes[] = {
+       "tp-link",
+       NULL,
+};
+
+static struct flash_platform_data mw150r_flash_data = {
+       .part_probes    = mw150r_part_probes,
+};
+
+static struct gpio_led mw150r_leds_gpio[] __initdata = {
+       {
+               .name           = "mercury:green:lan1",
+               .gpio           = MW150R_GPIO_LED_LAN1,
+       }, {
+               .name           = "mercury:green:lan2",
+               .gpio           = MW150R_GPIO_LED_LAN2,
+       }, {
+               .name           = "mercury:green:lan3",
+               .gpio           = MW150R_GPIO_LED_LAN3,
+       }, {
+               .name           = "mercury:green:lan4",
+               .gpio           = MW150R_GPIO_LED_LAN4,
+       }, {
+               .name           = "mercury:green:gear",
+               .gpio           = MW150R_GPIO_LED_GEAR,
+               .active_low     = 1,
+       }, {
+               .name           = "mercury:green:lock",
+               .gpio           = MW150R_GPIO_LED_LOCK,
+       }, {
+               .name           = "mercury:green:wan",
+               .gpio           = MW150R_GPIO_LED_WAN,
+       }, {
+               .name           = "mercury:green:wlan",
+               .gpio           = MW150R_GPIO_LED_WLAN,
+       },
+};
+
+static struct gpio_keys_button mw150r_gpio_keys[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = MW150R_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = MW150R_GPIO_BTN_RESET,
+       }
+};
+
+static void __init mw150r_setup(void)
+{
+       u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
+       u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
+
+       ath79_register_m25p80(&mw150r_flash_data);
+
+       ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
+                                   AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
+                                   AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
+                                   AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
+                                   AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(mw150r_leds_gpio),
+                                mw150r_leds_gpio);
+
+       ath79_register_gpio_keys_polled(-1, MW150R_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(mw150r_gpio_keys),
+                                       mw150r_gpio_keys);
+
+       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
+       ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
+
+       ath79_register_mdio(0, 0x0);
+
+       /* LAN ports */
+       ath79_register_eth(1);
+
+       /* WAN port */
+       ath79_register_eth(0);
+
+       ap9x_pci_setup_wmac_led_pin(0, 1);
+       ap91_pci_init(ee, mac);
+}
+MIPS_MACHINE(ATH79_MACH_MERCURY_MW150R, "MERCURY-MW150R", "Mercury MW150R",
+            mw150r_setup);
diff --git 
a/target/linux/ar71xx/patches-3.3/610-MIPS-ath79-openwrt-machines.patch 
b/target/linux/ar71xx/patches-3.3/610-MIPS-ath79-openwrt-machines.patch
index f0727ad..e8f8196 100644
--- a/target/linux/ar71xx/patches-3.3/610-MIPS-ath79-openwrt-machines.patch
+++ b/target/linux/ar71xx/patches-3.3/610-MIPS-ath79-openwrt-machines.patch
@@ -1,6 +1,8 @@
---- a/arch/mips/ath79/machtypes.h
-+++ b/arch/mips/ath79/machtypes.h
-@@ -16,18 +16,91 @@
+Index: linux-3.3.8/arch/mips/ath79/machtypes.h
+===================================================================
+--- linux-3.3.8.orig/arch/mips/ath79/machtypes.h
++++ linux-3.3.8/arch/mips/ath79/machtypes.h
+@@ -16,18 +16,92 @@
  
  enum ath79_mach_type {
        ATH79_MACH_GENERIC = 0,
@@ -89,11 +91,14 @@
 +      ATH79_MACH_WZR_HP_G300NH2,      /* Buffalo WZR-HP-G300NH2 */
 +      ATH79_MACH_WZR_HP_G450H,        /* Buffalo WZR-HP-G450H */
 +      ATH79_MACH_ZCN_1523H_2,         /* Zcomax ZCN-1523H-2-xx */
++      ATH79_MACH_MERCURY_MW150R,      /* Mercury MW150R */
  };
  
  #endif /* _ATH79_MACHTYPE_H */
---- a/arch/mips/ath79/Kconfig
-+++ b/arch/mips/ath79/Kconfig
+Index: linux-3.3.8/arch/mips/ath79/Kconfig
+===================================================================
+--- linux-3.3.8.orig/arch/mips/ath79/Kconfig
++++ linux-3.3.8/arch/mips/ath79/Kconfig
 @@ -2,6 +2,52 @@ if ATH79
  
  menu "Atheros AR71XX/AR724X/AR913X machine selection"
@@ -606,7 +611,7 @@
  config ATH79_MACH_UBNT_XM
        bool "Ubiquiti Networks XM (rev 1.0) board"
        select SOC_AR724X
-@@ -79,6 +563,24 @@ config ATH79_MACH_UBNT_XM
+@@ -79,6 +563,35 @@ config ATH79_MACH_UBNT_XM
          Say 'Y' here if you want your kernel to support the
          Ubiquiti Networks XM (rev 1.0) board.
  
@@ -628,10 +633,21 @@
 +      select ATH79_DEV_M25P80
 +      select ATH79_DEV_WMAC
 +
++config ATH79_MACH_MERCURY_MW150R
++      bool "Mercury MW150R support"
++      select SOC_AR934X
++      select ATH79_DEV_AP9X_PCI if PCI
++      select ATH79_DEV_ETH
++      select ATH79_DEV_GPIO_BUTTONS
++      select ATH79_DEV_LEDS_GPIO
++      select ATH79_DEV_M25P80
++      select ATH79_DEV_USB
++      select ATH79_DEV_WMAC
++
  endmenu
  
  config SOC_AR71XX
-@@ -114,10 +616,6 @@ config SOC_QCA955X
+@@ -114,10 +627,6 @@ config SOC_QCA955X
        select PCI_AR724X if PCI
        def_bool n
  
@@ -642,7 +658,7 @@
  config ATH79_DEV_AP9X_PCI
        select ATH79_PCI_ATH9K_FIXUP
        def_bool n
-@@ -128,7 +626,14 @@ config ATH79_DEV_DSA
+@@ -128,7 +637,14 @@ config ATH79_DEV_DSA
  config ATH79_DEV_ETH
        def_bool n
  
@@ -658,7 +674,7 @@
        def_bool n
  
  config ATH79_DEV_GPIO_BUTTONS
-@@ -153,4 +658,7 @@ config ATH79_NVRAM
+@@ -153,4 +669,7 @@ config ATH79_NVRAM
  config ATH79_PCI_ATH9K_FIXUP
        def_bool n
  
@@ -666,9 +682,11 @@
 +      def_bool n
 +
  endif
---- a/arch/mips/ath79/Makefile
-+++ b/arch/mips/ath79/Makefile
-@@ -36,9 +36,61 @@ obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP) += p
+Index: linux-3.3.8/arch/mips/ath79/Makefile
+===================================================================
+--- linux-3.3.8.orig/arch/mips/ath79/Makefile
++++ linux-3.3.8/arch/mips/ath79/Makefile
+@@ -36,9 +36,62 @@ obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP) += p
  #
  # Machines
  #
@@ -730,8 +748,11 @@
 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G300NH2)       += mach-wzr-hp-g300nh2.o
 +obj-$(CONFIG_ATH79_MACH_WZR_HP_AG300H)        += mach-wzr-hp-ag300h.o
 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H) += mach-wzr-hp-g450h.o
---- a/arch/mips/ath79/prom.c
-+++ b/arch/mips/ath79/prom.c
++obj-$(CONFIG_ATH79_MACH_MERCURY_MW150R)       += mach-mercury-mw150r.o
+Index: linux-3.3.8/arch/mips/ath79/prom.c
+===================================================================
+--- linux-3.3.8.orig/arch/mips/ath79/prom.c
++++ linux-3.3.8/arch/mips/ath79/prom.c
 @@ -180,6 +180,9 @@ void __init prom_init(void)
                        ath79_prom_append_cmdline("board", env);
                }
-- 
1.7.6

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to