2 * TRENDnet TEW-692GR board support
4 * Copyright (C) 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/ethtool.h>
14 #include <linux/pci.h>
15 #include <linux/phy.h>
16 #include <linux/rt2x00_platform.h>
17 #include <linux/ar8216_platform.h>
19 #include <asm/mach-ralink/machine.h>
20 #include <asm/mach-ralink/dev-gpio-buttons.h>
21 #include <asm/mach-ralink/dev-gpio-leds.h>
22 #include <asm/mach-ralink/rt3883.h>
23 #include <asm/mach-ralink/rt3883_regs.h>
24 #include <asm/mach-ralink/ramips_eth_platform.h>
28 #define TEW_692GR_GPIO_LED_WPS_ORANGE 9
29 #define TEW_692GR_GPIO_LED_WPS_GREEN 28
31 #define TEW_692GR_GPIO_BUTTON_RESET 10
32 #define TEW_692GR_GPIO_BUTTON_WPS 26
34 #define TEW_692GR_KEYS_POLL_INTERVAL 20
35 #define TEW_692GR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_692GR_KEYS_POLL_INTERVAL)
37 static struct gpio_led tew_692gr_leds_gpio[] __initdata = {
39 .name = "trendnet:orange:wps",
40 .gpio = TEW_692GR_GPIO_LED_WPS_ORANGE,
44 .name = "trendnet:green:wps",
45 .gpio = TEW_692GR_GPIO_LED_WPS_GREEN,
50 static struct gpio_keys_button tew_692gr_gpio_buttons[] __initdata = {
52 .desc = "Reset button",
55 .debounce_interval = TEW_692GR_KEYS_DEBOUNCE_INTERVAL,
56 .gpio = TEW_692GR_GPIO_BUTTON_RESET,
62 .code = KEY_WPS_BUTTON,
63 .debounce_interval = TEW_692GR_KEYS_DEBOUNCE_INTERVAL,
64 .gpio = TEW_692GR_GPIO_BUTTON_WPS,
69 static struct ar8327_pad_cfg tew_692gr_ar8327_pad0_cfg = {
70 .mode = AR8327_PAD_MAC_RGMII,
71 .txclk_delay_en = true,
72 .rxclk_delay_en = true,
73 .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
74 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
77 static struct ar8327_pad_cfg tew_692gr_ar8327_pad6_cfg = {
78 .mode = AR8327_PAD_MAC_RGMII,
79 .rxclk_delay_en = true,
80 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
83 static struct ar8327_led_cfg tew_692gr_ar8327_led_cfg = {
84 .led_ctrl0 = 0xc437c437,
85 .led_ctrl1 = 0xc337c337,
86 .led_ctrl2 = 0x00000000,
87 .led_ctrl3 = 0x03ffff00,
91 static struct ar8327_platform_data tew_692gr_ar8327_data = {
92 .pad0_cfg = &tew_692gr_ar8327_pad0_cfg,
93 .pad6_cfg = &tew_692gr_ar8327_pad6_cfg,
96 .speed = AR8327_PORT_SPEED_1000,
101 .led_cfg = &tew_692gr_ar8327_led_cfg,
104 static struct mdio_board_info tew_692gr_mdio0_info[] = {
106 .bus_id = "ramips_mdio",
108 .platform_data = &tew_692gr_ar8327_data,
112 static void __init tew_692gr_init(void)
114 rt3883_gpio_init(RT3883_GPIO_MODE_I2C |
115 RT3883_GPIO_MODE_SPI |
116 RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO) |
117 RT3883_GPIO_MODE_JTAG |
118 RT3883_GPIO_MODE_PCI(RT3883_GPIO_MODE_PCI_FNC));
120 rt3883_register_pflash(0);
122 ramips_register_gpio_leds(-1, ARRAY_SIZE(tew_692gr_leds_gpio),
123 tew_692gr_leds_gpio);
125 ramips_register_gpio_buttons(-1, TEW_692GR_KEYS_POLL_INTERVAL,
126 ARRAY_SIZE(tew_692gr_gpio_buttons),
127 tew_692gr_gpio_buttons);
129 rt3883_register_wlan();
131 mdiobus_register_board_info(tew_692gr_mdio0_info,
132 ARRAY_SIZE(tew_692gr_mdio0_info));
134 rt3883_eth_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
135 rt3883_eth_data.phy_mask = BIT(0);
136 rt3883_eth_data.tx_fc = 1;
137 rt3883_eth_data.rx_fc = 1;
138 rt3883_register_ethernet();
140 rt3883_register_wdt(false);
142 rt3883_pci_init(RT3883_PCI_MODE_PCIE);
145 MIPS_MACHINE(RAMIPS_MACH_TEW_692GR, "TEW-692GR", "TRENDnet TEW-692GR",