ar71xx: remove the built-in MTD map of the Zcomax devices
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-tew-673gru.c
1 /*
2 * TRENDnet TEW-673GRU 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/platform_device.h>
12 #include <linux/delay.h>
13 #include <linux/rtl8366.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/spi_gpio.h>
16
17 #include <asm/mach-ath79/ath79.h>
18
19 #include "dev-ap9x-pci.h"
20 #include "dev-eth.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
24 #include "dev-usb.h"
25 #include "machtypes.h"
26
27 #define TEW673GRU_GPIO_LCD_SCK 0
28 #define TEW673GRU_GPIO_LCD_MOSI 1
29 #define TEW673GRU_GPIO_LCD_MISO 2
30 #define TEW673GRU_GPIO_LCD_CS 6
31
32 #define TEW673GRU_GPIO_LED_WPS 9
33
34 #define TEW673GRU_GPIO_BTN_RESET 3
35 #define TEW673GRU_GPIO_BTN_WPS 8
36
37 #define TEW673GRU_GPIO_RTL8366_SDA 5
38 #define TEW673GRU_GPIO_RTL8366_SCK 7
39
40 #define TEW673GRU_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define TEW673GRU_KEYS_DEBOUNCE_INTERVAL (3 * TEW673GRU_KEYS_POLL_INTERVAL)
42
43 #define TEW673GRU_CAL_LOCATION_0 0x1f661000
44 #define TEW673GRU_CAL_LOCATION_1 0x1f665000
45
46 #define TEW673GRU_MAC_LOCATION_0 0x1f66ffa0
47 #define TEW673GRU_MAC_LOCATION_1 0x1f66ffb4
48
49 static struct gpio_led tew673gru_leds_gpio[] __initdata = {
50 {
51 .name = "trendnet:blue:wps",
52 .gpio = TEW673GRU_GPIO_LED_WPS,
53 .active_low = 1,
54 }
55 };
56
57 static struct gpio_keys_button tew673gru_gpio_keys[] __initdata = {
58 {
59 .desc = "reset",
60 .type = EV_KEY,
61 .code = KEY_RESTART,
62 .debounce_interval = TEW673GRU_KEYS_DEBOUNCE_INTERVAL,
63 .gpio = TEW673GRU_GPIO_BTN_RESET,
64 .active_low = 1,
65 }, {
66 .desc = "wps",
67 .type = EV_KEY,
68 .code = KEY_WPS_BUTTON,
69 .debounce_interval = TEW673GRU_KEYS_DEBOUNCE_INTERVAL,
70 .gpio = TEW673GRU_GPIO_BTN_WPS,
71 .active_low = 1,
72 }
73 };
74
75 static struct rtl8366_initval tew673gru_rtl8366s_initvals[] = {
76 { .reg = 0x06, .val = 0x0108 },
77 };
78
79 static struct rtl8366_platform_data tew673gru_rtl8366s_data = {
80 .gpio_sda = TEW673GRU_GPIO_RTL8366_SDA,
81 .gpio_sck = TEW673GRU_GPIO_RTL8366_SCK,
82 .num_initvals = ARRAY_SIZE(tew673gru_rtl8366s_initvals),
83 .initvals = tew673gru_rtl8366s_initvals,
84 };
85
86 static struct platform_device tew673gru_rtl8366s_device = {
87 .name = RTL8366S_DRIVER_NAME,
88 .id = -1,
89 .dev = {
90 .platform_data = &tew673gru_rtl8366s_data,
91 }
92 };
93
94 static struct spi_board_info tew673gru_spi_info[] = {
95 {
96 .bus_num = 1,
97 .chip_select = 0,
98 .max_speed_hz = 400000,
99 .modalias = "spidev",
100 .mode = SPI_MODE_2,
101 .controller_data = (void *) TEW673GRU_GPIO_LCD_CS,
102 },
103 };
104
105 static struct spi_gpio_platform_data tew673gru_spi_data = {
106 .sck = TEW673GRU_GPIO_LCD_SCK,
107 .miso = TEW673GRU_GPIO_LCD_MISO,
108 .mosi = TEW673GRU_GPIO_LCD_MOSI,
109 .num_chipselect = 1,
110 };
111
112 static struct platform_device tew673gru_spi_device = {
113 .name = "spi_gpio",
114 .id = 1,
115 .dev = {
116 .platform_data = &tew673gru_spi_data,
117 },
118 };
119
120 static void tew673gru_read_ascii_mac(u8 *dest, unsigned int src_addr)
121 {
122 int ret;
123 u8 *src = (u8 *)KSEG1ADDR(src_addr);
124
125 ret = sscanf(src, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
126 &dest[0], &dest[1], &dest[2],
127 &dest[3], &dest[4], &dest[5]);
128
129 if (ret != ETH_ALEN) memset(dest, 0, ETH_ALEN);
130 }
131
132 static void __init tew673gru_setup(void)
133 {
134 u8 mac1[ETH_ALEN], mac2[ETH_ALEN];
135
136 tew673gru_read_ascii_mac(mac1, TEW673GRU_MAC_LOCATION_0);
137 tew673gru_read_ascii_mac(mac2, TEW673GRU_MAC_LOCATION_1);
138
139 ath79_register_mdio(0, 0x0);
140
141 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 2);
142 ath79_eth0_data.mii_bus_dev = &tew673gru_rtl8366s_device.dev;
143 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
144 ath79_eth0_data.speed = SPEED_1000;
145 ath79_eth0_data.duplex = DUPLEX_FULL;
146 ath79_eth0_pll_data.pll_1000 = 0x11110000;
147
148 ath79_init_mac(ath79_eth1_data.mac_addr, mac1, 3);
149 ath79_eth1_data.mii_bus_dev = &tew673gru_rtl8366s_device.dev;
150 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
151 ath79_eth1_data.phy_mask = 0x10;
152 ath79_eth1_pll_data.pll_1000 = 0x11110000;
153
154 ath79_register_eth(0);
155 ath79_register_eth(1);
156
157 ath79_register_m25p80(NULL);
158
159 ath79_register_leds_gpio(-1, ARRAY_SIZE(tew673gru_leds_gpio),
160 tew673gru_leds_gpio);
161
162 ath79_register_gpio_keys_polled(-1, TEW673GRU_KEYS_POLL_INTERVAL,
163 ARRAY_SIZE(tew673gru_gpio_keys),
164 tew673gru_gpio_keys);
165
166 ath79_register_usb();
167
168 platform_device_register(&tew673gru_rtl8366s_device);
169
170 ap9x_pci_setup_wmac_led_pin(0, 5);
171 ap9x_pci_setup_wmac_led_pin(1, 5);
172
173 ap94_pci_init((u8 *) KSEG1ADDR(TEW673GRU_CAL_LOCATION_0), mac1,
174 (u8 *) KSEG1ADDR(TEW673GRU_CAL_LOCATION_1), mac2);
175
176 spi_register_board_info(tew673gru_spi_info,
177 ARRAY_SIZE(tew673gru_spi_info));
178 platform_device_register(&tew673gru_spi_device);
179 }
180
181 MIPS_MACHINE(ATH79_MACH_TEW_673GRU, "TEW-673GRU", "TRENDnet TEW-673GRU",
182 tew673gru_setup);
This page took 0.055126 seconds and 5 git commands to generate.