Root/target/linux/ramips/files/arch/mips/ralink/rt3883/mach-tew-692gr.c

1/*
2 * TRENDnet TEW-692GR board support
3 *
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
5 *
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.
9 */
10
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>
18
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>
25
26#include "devices.h"
27
28#define TEW_692GR_GPIO_LED_WPS_ORANGE 9
29#define TEW_692GR_GPIO_LED_WPS_GREEN 28
30
31#define TEW_692GR_GPIO_BUTTON_RESET 10
32#define TEW_692GR_GPIO_BUTTON_WPS 26
33
34#define TEW_692GR_KEYS_POLL_INTERVAL 20
35#define TEW_692GR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_692GR_KEYS_POLL_INTERVAL)
36
37static struct gpio_led tew_692gr_leds_gpio[] __initdata = {
38    {
39        .name = "trendnet:orange:wps",
40        .gpio = TEW_692GR_GPIO_LED_WPS_ORANGE,
41        .active_low = 1,
42    },
43    {
44        .name = "trendnet:green:wps",
45        .gpio = TEW_692GR_GPIO_LED_WPS_GREEN,
46        .active_low = 1,
47    },
48};
49
50static struct gpio_keys_button tew_692gr_gpio_buttons[] __initdata = {
51    {
52        .desc = "Reset button",
53        .type = EV_KEY,
54        .code = KEY_RESTART,
55        .debounce_interval = TEW_692GR_KEYS_DEBOUNCE_INTERVAL,
56        .gpio = TEW_692GR_GPIO_BUTTON_RESET,
57        .active_low = 1,
58    },
59    {
60        .desc = "WPS button",
61        .type = EV_KEY,
62        .code = KEY_WPS_BUTTON,
63        .debounce_interval = TEW_692GR_KEYS_DEBOUNCE_INTERVAL,
64        .gpio = TEW_692GR_GPIO_BUTTON_WPS,
65        .active_low = 1,
66    },
67};
68
69static 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,
75};
76
77static 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,
81};
82
83static 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,
88    .open_drain = false,
89};
90
91static struct ar8327_platform_data tew_692gr_ar8327_data = {
92    .pad0_cfg = &tew_692gr_ar8327_pad0_cfg,
93    .pad6_cfg = &tew_692gr_ar8327_pad6_cfg,
94    .port0_cfg = {
95        .force_link = 1,
96        .speed = AR8327_PORT_SPEED_1000,
97        .duplex = 1,
98        .txpause = 1,
99        .rxpause = 1,
100    },
101    .led_cfg = &tew_692gr_ar8327_led_cfg,
102};
103
104static struct mdio_board_info tew_692gr_mdio0_info[] = {
105    {
106        .bus_id = "ramips_mdio",
107        .phy_addr = 0,
108        .platform_data = &tew_692gr_ar8327_data,
109    },
110};
111
112static void __init tew_692gr_init(void)
113{
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));
119
120    rt3883_register_pflash(0);
121
122    ramips_register_gpio_leds(-1, ARRAY_SIZE(tew_692gr_leds_gpio),
123                  tew_692gr_leds_gpio);
124
125    ramips_register_gpio_buttons(-1, TEW_692GR_KEYS_POLL_INTERVAL,
126                     ARRAY_SIZE(tew_692gr_gpio_buttons),
127                     tew_692gr_gpio_buttons);
128
129    rt3883_wlan_data.disable_5ghz = 1;
130    rt3883_register_wlan();
131
132    mdiobus_register_board_info(tew_692gr_mdio0_info,
133                    ARRAY_SIZE(tew_692gr_mdio0_info));
134
135    rt3883_eth_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
136    rt3883_eth_data.phy_mask = BIT(0);
137    rt3883_eth_data.tx_fc = 1;
138    rt3883_eth_data.rx_fc = 1;
139    rt3883_register_ethernet();
140
141    rt3883_register_wdt(false);
142
143    rt3883_pci_init(RT3883_PCI_MODE_PCIE);
144}
145
146MIPS_MACHINE(RAMIPS_MACH_TEW_692GR, "TEW-692GR", "TRENDnet TEW-692GR",
147         tew_692gr_init);
148

Archive Download this file



interactive