[ar71xx] wnr2000: enable ar8216 workaround, add network config. LAN ports now work
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wnr2000.c
1 /*
2 * NETGEAR WNR2000 board support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/spi/spi.h>
17 #include <linux/spi/flash.h>
18 #include <linux/input.h>
19
20 #include <asm/mips_machine.h>
21
22 #include <asm/mach-ar71xx/ar71xx.h>
23
24 #include "devices.h"
25
26 #define WNR2000_GPIO_LED_PWR_GREEN 14
27 #define WNR2000_GPIO_LED_PWR_AMBER 7
28 #define WNR2000_GPIO_LED_WPS 4
29 #define WNR2000_GPIO_LED_WLAN 6
30 #define WNR2000_GPIO_BTN_RESET 21
31 #define WNR2000_GPIO_BTN_WPS 8
32
33 #define WNR2000_BUTTONS_POLL_INTERVAL 20
34
35 #ifdef CONFIG_MTD_PARTITIONS
36 static struct mtd_partition wnr2000_partitions[] = {
37 {
38 .name = "u-boot",
39 .offset = 0,
40 .size = 0x040000,
41 .mask_flags = MTD_WRITEABLE,
42 } , {
43 .name = "u-boot-env",
44 .offset = 0x040000,
45 .size = 0x010000,
46 } , {
47 .name = "rootfs",
48 .offset = 0x050000,
49 .size = 0x240000,
50 } , {
51 .name = "user-config",
52 .offset = 0x290000,
53 .size = 0x010000,
54 } , {
55 .name = "uImage",
56 .offset = 0x2a0000,
57 .size = 0x120000,
58 } , {
59 .name = "language_table",
60 .offset = 0x3c0000,
61 .size = 0x020000,
62 } , {
63 .name = "rootfs_checksum",
64 .offset = 0x3e0000,
65 .size = 0x010000,
66 } , {
67 .name = "art",
68 .offset = 0x3f0000,
69 .size = 0x010000,
70 .mask_flags = MTD_WRITEABLE,
71 }
72 };
73 #endif /* CONFIG_MTD_PARTITIONS */
74
75 static struct flash_platform_data wnr2000_flash_data = {
76 #ifdef CONFIG_MTD_PARTITIONS
77 .parts = wnr2000_partitions,
78 .nr_parts = ARRAY_SIZE(wnr2000_partitions),
79 #endif
80 };
81
82 static struct spi_board_info wnr2000_spi_info[] = {
83 {
84 .bus_num = 0,
85 .chip_select = 0,
86 .max_speed_hz = 25000000,
87 .modalias = "m25p80",
88 .platform_data = &wnr2000_flash_data,
89 }
90 };
91
92 static struct gpio_led wnr2000_leds_gpio[] __initdata = {
93 {
94 .name = "wnr2000:green:power",
95 .gpio = WNR2000_GPIO_LED_PWR_GREEN,
96 .active_low = 1,
97 }, {
98 .name = "wnr2000:amber:power",
99 .gpio = WNR2000_GPIO_LED_PWR_AMBER,
100 .active_low = 1,
101 }, {
102 .name = "wnr2000:green:wps",
103 .gpio = WNR2000_GPIO_LED_WPS,
104 .active_low = 1,
105 }, {
106 .name = "wnr2000:blue:wlan",
107 .gpio = WNR2000_GPIO_LED_WLAN,
108 .active_low = 1,
109 }
110 };
111
112 static struct gpio_button wnr2000_gpio_buttons[] __initdata = {
113 {
114 .desc = "reset",
115 .type = EV_KEY,
116 .code = BTN_0,
117 .threshold = 5,
118 .gpio = WNR2000_GPIO_BTN_RESET,
119 }, {
120 .desc = "wps",
121 .type = EV_KEY,
122 .code = BTN_1,
123 .threshold = 5,
124 .gpio = WNR2000_GPIO_BTN_WPS,
125 }
126 };
127
128 static void __init wnr2000_setup(void)
129 {
130 ar71xx_add_device_mdio(0x0);
131
132 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
133 ar71xx_eth0_data.phy_mask = 0xf;
134 ar71xx_eth0_data.speed = SPEED_100;
135 ar71xx_eth0_data.duplex = DUPLEX_FULL;
136 ar71xx_eth0_data.has_ar8216 = 1;
137
138 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
139 ar71xx_eth1_data.phy_mask = 0x10;
140
141 ar71xx_add_device_eth(0);
142 ar71xx_add_device_eth(1);
143
144 ar71xx_add_device_spi(NULL, wnr2000_spi_info,
145 ARRAY_SIZE(wnr2000_spi_info));
146
147 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
148 wnr2000_leds_gpio);
149
150 ar71xx_add_device_gpio_buttons(-1, WNR2000_BUTTONS_POLL_INTERVAL,
151 ARRAY_SIZE(wnr2000_gpio_buttons),
152 wnr2000_gpio_buttons);
153
154
155 ar91xx_add_device_wmac();
156 }
157
158 MIPS_MACHINE(AR71XX_MACH_WNR2000, "NETGEAR WNR2000", wnr2000_setup);