4040a652da7b5820357fd8cc82f0f47399e56b98
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wrt400n.c
1 /*
2 * Linksys WRT400N board support
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2009 Imre Kaloz <kaloz@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/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/input.h>
18
19 #include <asm/mips_machine.h>
20 #include <asm/mach-ar71xx/ar71xx.h>
21
22 #include "devices.h"
23
24 #define WRT400N_GPIO_LED_ORANGE 5
25 #define WRT400N_GPIO_LED_GREEN 4
26 #define WRT400N_GPIO_LED_POWER 1
27 #define WRT400N_GPIO_LED_WLAN 0
28
29 #define WRT400N_GPIO_BTN_RESET 8
30 #define WRT400N_GPIO_BTN_WLSEC 3
31
32 #define WRT400N_BUTTONS_POLL_INTERVAL 20
33
34 #ifdef CONFIG_MTD_PARTITIONS
35 static struct mtd_partition wrt400n_partitions[] = {
36 {
37 .name = "uboot",
38 .offset = 0,
39 .size = 0x030000,
40 .mask_flags = MTD_WRITEABLE,
41 } , {
42 .name = "env",
43 .offset = 0x030000,
44 .size = 0x010000,
45 .mask_flags = MTD_WRITEABLE,
46 } , {
47 .name = "linux",
48 .offset = 0x040000,
49 .size = 0x770000,
50 } , {
51 .name = "kernel",
52 .offset = 0x040000,
53 .size = 0x140000,
54 } , {
55 .name = "rootfs",
56 .offset = 0x180000,
57 .size = 0x630000,
58 } , {
59 .name = "nvram",
60 .offset = 0x7b0000,
61 .size = 0x010000,
62 .mask_flags = MTD_WRITEABLE,
63 } , {
64 .name = "factory",
65 .offset = 0x7c0000,
66 .size = 0x010000,
67 .mask_flags = MTD_WRITEABLE,
68 } , {
69 .name = "language",
70 .offset = 0x7d0000,
71 .size = 0x020000,
72 .mask_flags = MTD_WRITEABLE,
73 } , {
74 .name = "caldata",
75 .offset = 0x7f0000,
76 .size = 0x010000,
77 .mask_flags = MTD_WRITEABLE,
78 }
79 };
80 #endif /* CONFIG_MTD_PARTITIONS */
81
82 static struct flash_platform_data wrt400n_flash_data = {
83 #ifdef CONFIG_MTD_PARTITIONS
84 .parts = wrt400n_partitions,
85 .nr_parts = ARRAY_SIZE(wrt400n_partitions),
86 #endif
87 };
88
89 static struct spi_board_info wrt400n_spi_info[] = {
90 {
91 .bus_num = 0,
92 .chip_select = 0,
93 .max_speed_hz = 25000000,
94 .modalias = "m25p80",
95 .platform_data = &wrt400n_flash_data,
96 }
97 };
98
99 static struct gpio_led wrt400n_leds_gpio[] __initdata = {
100 {
101 .name = "wrt400n:green:status",
102 .gpio = WRT400N_GPIO_LED_GREEN,
103 .active_low = 1,
104 }, {
105 .name = "wrt400n:amber:aoss",
106 .gpio = WRT400N_GPIO_LED_ORANGE,
107 .active_low = 1,
108 }, {
109 .name = "wrt400n:green:wlan",
110 .gpio = WRT400N_GPIO_LED_WLAN,
111 .active_low = 1,
112 }, {
113 .name = "wrt400n:green:power",
114 .gpio = WRT400N_GPIO_LED_POWER,
115 .active_low = 1,
116 }
117 };
118
119 static struct gpio_button wrt400n_gpio_buttons[] __initdata = {
120 {
121 .desc = "reset",
122 .type = EV_KEY,
123 .code = BTN_0,
124 .threshold = 5,
125 .gpio = WRT400N_GPIO_BTN_RESET,
126 .active_low = 1,
127 } , {
128 .desc = "wlsec",
129 .type = EV_KEY,
130 .code = BTN_1,
131 .threshold = 5,
132 .gpio = WRT400N_GPIO_BTN_WLSEC,
133 .active_low = 1,
134 }
135 };
136
137 static void __init wrt400n_setup(void)
138 {
139 ar71xx_add_device_mdio(0x0);
140
141 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
142 ar71xx_eth0_data.phy_mask = 0xf;
143 ar71xx_eth0_data.speed = SPEED_100;
144 ar71xx_eth0_data.duplex = DUPLEX_FULL;
145 ar71xx_eth0_data.has_ar8216 = 1;
146
147 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
148 ar71xx_eth1_data.phy_mask = 0x10;
149
150 ar71xx_add_device_eth(0);
151 ar71xx_add_device_eth(1);
152
153 ar71xx_add_device_spi(NULL, wrt400n_spi_info,
154 ARRAY_SIZE(wrt400n_spi_info));
155
156 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wrt400n_leds_gpio),
157 wrt400n_leds_gpio);
158
159 ar71xx_add_device_gpio_buttons(-1, WRT400N_BUTTONS_POLL_INTERVAL,
160 ARRAY_SIZE(wrt400n_gpio_buttons),
161 wrt400n_gpio_buttons);
162
163 /* TODO: PCI support */
164 }
165
166 MIPS_MACHINE(AR71XX_MACH_WRT400N, "Linksys WRT400N", wrt400n_setup);