3216ede161098813f695bfbc5c21133ad8d50bfa
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wndr3700.c
1 /*
2 * Netgear WNDR3700 board support
3 *
4 * Copyright (C) 2009 Marco Porsch
5 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/input.h>
16 #include <linux/delay.h>
17 #include <linux/rtl8366_smi.h>
18
19 #include <asm/mips_machine.h>
20 #include <asm/mach-ar71xx/ar71xx.h>
21
22 #include "devices.h"
23 #include "dev-m25p80.h"
24 #include "dev-ap94-pci.h"
25
26 #define WNDR3700_GPIO_LED_WPS_ORANGE 0
27 #define WNDR3700_GPIO_LED_POWER_ORANGE 1
28 #define WNDR3700_GPIO_LED_POWER_GREEN 2
29 #define WNDR3700_GPIO_LED_WPS_GREEN 4
30
31 #define WNDR3700_GPIO_BTN_WPS 3
32 #define WNDR3700_GPIO_BTN_RESET 8
33 #define WNDR3700_GPIO_BTN_WIFI 11
34
35 #define WNDR3700_GPIO_RTL8366_SDA 5
36 #define WNDR3700_GPIO_RTL8366_SCK 7
37
38 #define WNDR3700_BUTTONS_POLL_INTERVAL 20
39
40 #define WNDR3700_WMAC0_MAC_OFFSET 0
41 #define WNDR3700_WMAC1_MAC_OFFSET 0xc
42 #define WNDR3700_CALDATA0_OFFSET 0x1000
43 #define WNDR3700_CALDATA1_OFFSET 0x5000
44
45 #ifdef CONFIG_MTD_PARTITIONS
46 static struct mtd_partition wndr3700_partitions[] = {
47 {
48 .name = "uboot",
49 .offset = 0,
50 .size = 0x050000,
51 .mask_flags = MTD_WRITEABLE,
52 } , {
53 .name = "env",
54 .offset = 0x050000,
55 .size = 0x020000,
56 .mask_flags = MTD_WRITEABLE,
57 } , {
58 .name = "rootfs",
59 .offset = 0x070000,
60 .size = 0x720000,
61 } , {
62 .name = "config",
63 .offset = 0x790000,
64 .size = 0x010000,
65 .mask_flags = MTD_WRITEABLE,
66 } , {
67 .name = "config_bak",
68 .offset = 0x7a0000,
69 .size = 0x010000,
70 .mask_flags = MTD_WRITEABLE,
71 } , {
72 .name = "pot",
73 .offset = 0x7b0000,
74 .size = 0x010000,
75 .mask_flags = MTD_WRITEABLE,
76 } , {
77 .name = "traffic_meter",
78 .offset = 0x7c0000,
79 .size = 0x010000,
80 .mask_flags = MTD_WRITEABLE,
81 } , {
82 .name = "language",
83 .offset = 0x7d0000,
84 .size = 0x020000,
85 .mask_flags = MTD_WRITEABLE,
86 } , {
87 .name = "caldata",
88 .offset = 0x7f0000,
89 .size = 0x010000,
90 .mask_flags = MTD_WRITEABLE,
91 }
92 };
93 #endif /* CONFIG_MTD_PARTITIONS */
94
95 static struct flash_platform_data wndr3700_flash_data = {
96 #ifdef CONFIG_MTD_PARTITIONS
97 .parts = wndr3700_partitions,
98 .nr_parts = ARRAY_SIZE(wndr3700_partitions),
99 #endif
100 };
101
102 static struct gpio_led wndr3700_leds_gpio[] __initdata = {
103 {
104 .name = "wndr3700:green:power",
105 .gpio = WNDR3700_GPIO_LED_POWER_GREEN,
106 .active_low = 1,
107 }, {
108 .name = "wndr3700:orange:power",
109 .gpio = WNDR3700_GPIO_LED_POWER_ORANGE,
110 .active_low = 1,
111 }, {
112 .name = "wndr3700:green:wps",
113 .gpio = WNDR3700_GPIO_LED_WPS_GREEN,
114 .active_low = 1,
115 }, {
116 .name = "wndr3700:orange:wps",
117 .gpio = WNDR3700_GPIO_LED_WPS_ORANGE,
118 .active_low = 1,
119 }
120 };
121
122 static struct gpio_button wndr3700_gpio_buttons[] __initdata = {
123 {
124 .desc = "reset",
125 .type = EV_KEY,
126 .code = BTN_0,
127 .threshold = 5,
128 .gpio = WNDR3700_GPIO_BTN_RESET,
129 }, {
130 .desc = "wps",
131 .type = EV_KEY,
132 .code = BTN_1,
133 .threshold = 5,
134 .gpio = WNDR3700_GPIO_BTN_WPS,
135 } , {
136 .desc = "wifi",
137 .type = EV_KEY,
138 .code = BTN_2,
139 .threshold = 5,
140 .gpio = WNDR3700_GPIO_BTN_WIFI,
141 }
142 };
143
144 static struct rtl8366_smi_platform_data wndr3700_rtl8366_smi_data = {
145 .gpio_sda = WNDR3700_GPIO_RTL8366_SDA,
146 .gpio_sck = WNDR3700_GPIO_RTL8366_SCK,
147 };
148
149 static struct platform_device wndr3700_rtl8366_smi_device = {
150 .name = "rtl8366-smi",
151 .id = -1,
152 .dev = {
153 .platform_data = &wndr3700_rtl8366_smi_data,
154 }
155 };
156
157 static void __init wndr3700_setup(void)
158 {
159 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
160
161 ar71xx_set_mac_base(art);
162
163 ar71xx_eth0_pll_data.pll_1000 = 0x11110000;
164 ar71xx_eth0_data.mii_bus_dev = &wndr3700_rtl8366_smi_device.dev;
165 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
166 ar71xx_eth0_data.phy_mask = 0xf;
167 ar71xx_eth0_data.speed = SPEED_1000;
168 ar71xx_eth0_data.duplex = DUPLEX_FULL;
169
170 ar71xx_eth1_pll_data.pll_1000 = 0x11110000;
171 ar71xx_eth1_data.mii_bus_dev = &wndr3700_rtl8366_smi_device.dev;
172 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
173 ar71xx_eth1_data.phy_mask = 0x10;
174
175 ar71xx_add_device_eth(0);
176 ar71xx_add_device_eth(1);
177
178 ar71xx_add_device_usb();
179
180 ar71xx_add_device_m25p80(&wndr3700_flash_data);
181
182 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
183 wndr3700_leds_gpio);
184
185 ar71xx_add_device_gpio_buttons(-1, WNDR3700_BUTTONS_POLL_INTERVAL,
186 ARRAY_SIZE(wndr3700_gpio_buttons),
187 wndr3700_gpio_buttons);
188
189 platform_device_register(&wndr3700_rtl8366_smi_device);
190 platform_device_register_simple("wndr3700-led-usb", -1, NULL, 0);
191
192 ap94_pci_init(art + WNDR3700_CALDATA0_OFFSET,
193 art + WNDR3700_WMAC0_MAC_OFFSET,
194 art + WNDR3700_CALDATA1_OFFSET,
195 art + WNDR3700_WMAC1_MAC_OFFSET);
196 }
197
198 MIPS_MACHINE(AR71XX_MACH_WNDR3700, "NETGEAR WNDR3700", wndr3700_setup);