2 * Asus RT-N56U board support
4 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/rtl8367.h>
14 #include <linux/ethtool.h>
15 #include <linux/pci.h>
16 #include <linux/rt2x00_platform.h>
18 #include <asm/mach-ralink/machine.h>
19 #include <asm/mach-ralink/dev-gpio-buttons.h>
20 #include <asm/mach-ralink/dev-gpio-leds.h>
21 #include <asm/mach-ralink/rt3883.h>
22 #include <asm/mach-ralink/rt3883_regs.h>
23 #include <asm/mach-ralink/ramips_eth_platform.h>
27 #define RT_N56U_GPIO_LED_POWER 0
28 #define RT_N56U_GPIO_LED_LAN 19
29 #define RT_N56U_GPIO_LED_USB 24
30 #define RT_N56U_GPIO_LED_WAN 27
31 #define RT_N56U_GPIO_BUTTON_RESET 13
32 #define RT_N56U_GPIO_BUTTON_WPS 26
34 #define RT_N56U_GPIO_RTL8367_SCK 2
35 #define RT_N56U_GPIO_RTL8367_SDA 1
37 #define RT_N56U_KEYS_POLL_INTERVAL 20
38 #define RT_N56U_KEYS_DEBOUNCE_INTERVAL (3 * RT_N56U_KEYS_POLL_INTERVAL)
40 static struct gpio_led rt_n56u_leds_gpio[] __initdata = {
42 .name = "asus:blue:power",
43 .gpio = RT_N56U_GPIO_LED_POWER,
47 .name = "asus:blue:lan",
48 .gpio = RT_N56U_GPIO_LED_LAN,
52 .name = "asus:blue:wan",
53 .gpio = RT_N56U_GPIO_LED_WAN,
57 .name = "asus:blue:usb",
58 .gpio = RT_N56U_GPIO_LED_USB,
63 static struct gpio_keys_button rt_n56u_gpio_buttons[] __initdata = {
68 .debounce_interval = RT_N56U_KEYS_DEBOUNCE_INTERVAL,
69 .gpio = RT_N56U_GPIO_BUTTON_RESET,
75 .code = KEY_WPS_BUTTON,
76 .debounce_interval = RT_N56U_KEYS_DEBOUNCE_INTERVAL,
77 .gpio = RT_N56U_GPIO_BUTTON_WPS,
82 static struct rtl8367_extif_config rt_n56u_rtl8367_extif1_cfg = {
85 .mode = RTL8367_EXTIF_MODE_RGMII,
92 .speed = RTL8367_PORT_SPEED_1000,
96 static struct rtl8367_platform_data rt_n56u_rtl8367_data = {
97 .gpio_sda = RT_N56U_GPIO_RTL8367_SDA,
98 .gpio_sck = RT_N56U_GPIO_RTL8367_SCK,
99 .extif1_cfg = &rt_n56u_rtl8367_extif1_cfg,
102 static struct platform_device rt_n56u_rtl8367_device = {
103 .name = RTL8367_DRIVER_NAME,
106 .platform_data = &rt_n56u_rtl8367_data,
110 static struct rt2x00_platform_data rt_n56u_pci_wlan_data = {
111 .eeprom_file_name = "rt2x00pci_1_0.eeprom",
114 static int rt_n56u_pci_plat_dev_init(struct pci_dev *dev)
116 if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 0)
117 dev->dev.platform_data = &rt_n56u_pci_wlan_data;
122 static void __init rt_n56u_init(void)
124 rt3883_gpio_init(RT3883_GPIO_MODE_I2C |
125 RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO) |
126 RT3883_GPIO_MODE_JTAG |
127 RT3883_GPIO_MODE_PCI(RT3883_GPIO_MODE_PCI_FNC));
129 rt3883_register_pflash(0);
131 ramips_register_gpio_leds(-1, ARRAY_SIZE(rt_n56u_leds_gpio),
134 ramips_register_gpio_buttons(-1, RT_N56U_KEYS_POLL_INTERVAL,
135 ARRAY_SIZE(rt_n56u_gpio_buttons),
136 rt_n56u_gpio_buttons);
138 platform_device_register(&rt_n56u_rtl8367_device);
140 rt3883_wlan_data.disable_2ghz = 1;
141 rt3883_register_wlan();
143 rt3883_eth_data.speed = SPEED_1000;
144 rt3883_eth_data.duplex = DUPLEX_FULL;
145 rt3883_eth_data.tx_fc = 1;
146 rt3883_eth_data.rx_fc = 1;
147 rt3883_register_ethernet();
149 rt3883_register_wdt(false);
150 rt3883_register_usbhost();
151 rt3883_pci_set_plat_dev_init(rt_n56u_pci_plat_dev_init);
152 rt3883_pci_init(RT3883_PCI_MODE_PCIE);
155 MIPS_MACHINE(RAMIPS_MACH_RT_N56U, "RT-N56U", "Asus RT-N56U", rt_n56u_init);