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