ramips: add preliminary support for the Asus RT-N56U board
authorGabor Juhos <juhosg@openwrt.org>
Mon, 13 Feb 2012 15:18:04 +0000 (15:18 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Mon, 13 Feb 2012 15:18:04 +0000 (15:18 +0000)
SVN-Revision: 30498

target/linux/ramips/base-files/etc/diag.sh
target/linux/ramips/base-files/etc/uci-defaults/network
target/linux/ramips/base-files/lib/preinit/06_set_iface_mac
target/linux/ramips/base-files/lib/ramips.sh
target/linux/ramips/base-files/lib/upgrade/platform.sh
target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
target/linux/ramips/files/arch/mips/ralink/rt3883/Kconfig
target/linux/ramips/files/arch/mips/ralink/rt3883/Makefile
target/linux/ramips/files/arch/mips/ralink/rt3883/mach-rt-n56u.c [new file with mode: 0644]
target/linux/ramips/rt3883/config-2.6.39
target/linux/ramips/rt3883/config-3.2

index bbadc3206eb22de6c3360f7c8caf53067432a865..262160490e9073c7f4a0125a25c75557b653edca 100755 (executable)
@@ -66,6 +66,9 @@ get_status_led() {
        rt-n15)
                status_led="rt-n15:blue:power"
                ;;
+       rt-n56u)
+               status_led="asus:blue:power"
+               ;;
        v22rw-2x2)
                status_led="v22rw-2x2:green:security"
                ;;
index 59d794f1d497dfc4cc4c2180f06b6a05acf6661c..0f97bc3647e1aa1795884f5c9b0d23be66bfab98 100755 (executable)
@@ -43,6 +43,13 @@ ramips_setup_interfaces()
                ucidef_add_switch_vlan "rtl8366rb" "2" "0 5t"
                ;;
 
+       rt-n56u)
+               ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+               ucidef_add_switch "switch0" "1" "1"
+               ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
+               ucidef_add_switch_vlan "switch0" "2" "4 8t"
+               ;;
+
        wcr-150gn)
                ucidef_set_interface_lan_wan "eth0.2" "eth0.1"
                ;;
@@ -109,6 +116,11 @@ ramips_setup_macs()
                wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
                ;;
 
+       rt-n56u)
+               lan_mac=$(ramips_get_mac_binary factory 4)
+               wan_mac=$(ramips_get_mac_binary factory 32772)
+               ;;
+
        w502u)
                 lan_mac=$(ramips_get_mac_binary factory 40)
                 wan_mac=$(ramips_get_mac_binary factory 46)
index 121b471f4f399e7b2100c17dc53a569e459401e2..9f5c02446c3aa6b05c42cefb860813dbae4c29b1 100644 (file)
@@ -10,6 +10,7 @@ preinit_set_mac_address() {
        case $(ramips_board_name) in
        bc2 |\
        nw718 |\
+       rt-n56u |\
        esr-9753)
                mac=$(ramips_get_mac_binary factory 4)
                mac=$(maccalc or "$mac" "02:00:00:00:00:00")
index 5204820fb961be69f8105bd7ad4c411505c0caa9..9c1a7dcb576da20617d7e6dd72065464669c31ea 100755 (executable)
@@ -101,6 +101,9 @@ ramips_board_name() {
        *"RT-N15")
                name="rt-n15"
                ;;
+       *"RT-N56U")
+               name="rt-n56u"
+               ;;
        *"Sparklan WCR-150GN")
                name="wcr-150gn"
                ;;
index 2751fdda290e2b10de89ffd8d12406ae1189d093..2bcfa4b821d57462082c88d4dbd665fa6d45a55e 100755 (executable)
@@ -28,6 +28,7 @@ platform_check_image() {
        omni-emb | \
        rt-g32-b1 | \
        rt-n15 | \
+       rt-n56u | \
        w502u |\
        wr6202 |\
        v22rw-2x2 | \
index 600e8bf905120f3b2594f5d88a979796abc5e39c..fa6d985665032ded96d2f701758aa0e67482c8ae 100644 (file)
@@ -46,4 +46,7 @@ enum ramips_mach_type {
        RAMIPS_MACH_WL351,              /* Sitecom WL-351 v1 002 */
        RAMIPS_MACH_WR512_3GN,          /* SH-WR512NU/WS-WR512N1-like 3GN*/
        RAMIPS_MACH_WR6202,             /* Accton WR6202 */
+
+       /* RT3662 based machines */
+       RAMIPS_MACH_RT_N56U,            /* Asus RT-N56U */
 };
index 7b4579adbc6c056515eb7e33fedd0d03f7e884a6..1b1c057c84fd0d0d225ff8ffa787b33cbaddefc7 100644 (file)
@@ -2,6 +2,11 @@ if RALINK_RT3883
 
 menu "Ralink RT3662/RT3883 machine selection"
 
+config RT3883_MACH_RT_N56U
+       bool "Asus RT-N56U support"
+       select RALINK_DEV_GPIO_BUTTONS
+       select RALINK_DEV_GPIO_LEDS
+
 endmenu
 
 endif
index f8098592b162aeeb1f895a6069a1d8c77823d0c7..3068d58d2ea1e1345d389888862e5eb889c07975 100644 (file)
@@ -10,3 +10,5 @@
 obj-y  := irq.o setup.o devices.o rt3883.o clock.o
 
 obj-$(CONFIG_EARLY_PRINTK)             += early_printk.o
+
+obj-$(CONFIG_RT3883_MACH_RT_N56U)      += mach-rt-n56u.o
diff --git a/target/linux/ramips/files/arch/mips/ralink/rt3883/mach-rt-n56u.c b/target/linux/ramips/files/arch/mips/ralink/rt3883/mach-rt-n56u.c
new file mode 100644 (file)
index 0000000..3f03747
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ *  Asus RT-N56U board support
+ *
+ *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@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/platform_device.h>
+#include <linux/rtl8367.h>
+#include <linux/ethtool.h>
+
+#include <asm/mach-ralink/machine.h>
+#include <asm/mach-ralink/dev-gpio-buttons.h>
+#include <asm/mach-ralink/dev-gpio-leds.h>
+#include <asm/mach-ralink/rt3883.h>
+#include <asm/mach-ralink/rt3883_regs.h>
+#include <asm/mach-ralink/ramips_eth_platform.h>
+
+#include "devices.h"
+
+#define RT_N56U_GPIO_LED_POWER         0
+#define RT_N56U_GPIO_LED_LAN           19
+#define RT_N56U_GPIO_LED_USB           24
+#define RT_N56U_GPIO_LED_WAN           27
+#define RT_N56U_GPIO_BUTTON_RESET      13
+#define RT_N56U_GPIO_BUTTON_WPS                26
+
+#define RT_N56U_GPIO_RTL8367_SCK       2
+#define RT_N56U_GPIO_RTL8367_SDA       1
+
+#define RT_N56U_KEYS_POLL_INTERVAL     20
+#define RT_N56U_KEYS_DEBOUNCE_INTERVAL (3 * RT_N56U_KEYS_POLL_INTERVAL)
+
+static struct gpio_led rt_n56u_leds_gpio[] __initdata = {
+       {
+               .name           = "asus:blue:power",
+               .gpio           = RT_N56U_GPIO_LED_POWER,
+               .active_low     = 1,
+       },
+       {
+               .name           = "asus:blue:lan",
+               .gpio           = RT_N56U_GPIO_LED_LAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "asus:blue:wan",
+               .gpio           = RT_N56U_GPIO_LED_WAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "asus:blue:usb",
+               .gpio           = RT_N56U_GPIO_LED_USB,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button rt_n56u_gpio_buttons[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = RT_N56U_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = RT_N56U_GPIO_BUTTON_RESET,
+               .active_low     = 1,
+       },
+       {
+               .desc           = "wps",
+               .type           = EV_KEY,
+               .code           = KEY_WPS_BUTTON,
+               .debounce_interval = RT_N56U_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = RT_N56U_GPIO_BUTTON_WPS,
+               .active_low     = 1,
+       }
+};
+
+static struct rtl8367_extif_config rt_n56u_rtl8367_extif1_cfg = {
+       .txdelay = 1,
+       .rxdelay = 0,
+       .mode = RTL8367_EXTIF_MODE_RGMII,
+       .ability = {
+               .force_mode = 1,
+               .txpause = 1,
+               .rxpause = 1,
+               .link = 1,
+               .duplex = 1,
+               .speed = RTL8367_PORT_SPEED_1000,
+       }
+};
+
+static struct rtl8367_platform_data rt_n56u_rtl8367_data = {
+       .gpio_sda       = RT_N56U_GPIO_RTL8367_SDA,
+       .gpio_sck       = RT_N56U_GPIO_RTL8367_SCK,
+       .extif1_cfg     = &rt_n56u_rtl8367_extif1_cfg,
+};
+
+static struct platform_device rt_n56u_rtl8367_device = {
+       .name           = RTL8367_DRIVER_NAME,
+       .id             = -1,
+       .dev = {
+               .platform_data  = &rt_n56u_rtl8367_data,
+       }
+};
+
+static void __init rt_n56u_init(void)
+{
+       rt3883_gpio_init(RT3883_GPIO_MODE_I2C |
+                        RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO) |
+                        RT3883_GPIO_MODE_JTAG |
+                        RT3883_GPIO_MODE_PCI(RT3883_GPIO_MODE_PCI_FNC));
+
+       rt3883_register_pflash(0);
+
+       ramips_register_gpio_leds(-1, ARRAY_SIZE(rt_n56u_leds_gpio),
+                                 rt_n56u_leds_gpio);
+
+       ramips_register_gpio_buttons(-1, RT_N56U_KEYS_POLL_INTERVAL,
+                                    ARRAY_SIZE(rt_n56u_gpio_buttons),
+                                    rt_n56u_gpio_buttons);
+
+       platform_device_register(&rt_n56u_rtl8367_device);
+
+       rt3883_register_wlan();
+
+       rt3883_eth_data.speed = SPEED_1000;
+       rt3883_eth_data.duplex = DUPLEX_FULL;
+       rt3883_eth_data.tx_fc = 1;
+       rt3883_eth_data.rx_fc = 1;
+       rt3883_register_ethernet();
+
+       rt3883_register_wdt(false);
+       rt3883_register_usbhost();
+}
+
+MIPS_MACHINE(RAMIPS_MACH_RT_N56U, "RT-N56U", "Asus RT-N56U", rt_n56u_init);
index b6d52ea4ece6f71f6d6ad8f0a332b0f53a010a68..4301e6e56ba9c828c2ae61adc95a86cf859fd5c4 100644 (file)
@@ -90,6 +90,9 @@ CONFIG_RALINK_DEV_GPIO_LEDS=y
 CONFIG_RALINK_RT3883=y
 # CONFIG_RAMIPS_ETH_DEBUG is not set
 CONFIG_RAMIPS_WDT=y
+CONFIG_RT3883_MACH_RT_N56U=y
+CONFIG_RTL8366_SMI=y
+CONFIG_RTL8367_PHY=y
 # CONFIG_SCSI_DMA is not set
 CONFIG_SERIAL_8250_NR_UARTS=4
 CONFIG_SERIAL_8250_RT288X=y
index b62d99306c210d9a4500385adf8706fd0ef52e04..568f86a3d0e064a627c87163101446ca8d401964 100644 (file)
@@ -89,6 +89,9 @@ CONFIG_RALINK_DEV_GPIO_LEDS=y
 CONFIG_RALINK_RT3883=y
 # CONFIG_RAMIPS_ETH_DEBUG is not set
 CONFIG_RAMIPS_WDT=y
+CONFIG_RT3883_MACH_RT_N56U=y
+CONFIG_RTL8366_SMI=y
+CONFIG_RTL8367_PHY=y
 # CONFIG_SCSI_DMA is not set
 CONFIG_SERIAL_8250_NR_UARTS=4
 CONFIG_SERIAL_8250_RT288X=y