03ffe5e6868b639ddea47edd205becc32ea8fb86
[openwrt/staging/wigyori.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-mzk-w300nh.c
1 /*
2 * Planex MZK-W300NH board support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 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/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14
15 #include <asm/mach-ar71xx/ar71xx.h>
16
17 #include "machtype.h"
18 #include "devices.h"
19 #include "dev-m25p80.h"
20 #include "dev-ar9xxx-wmac.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23
24 #define MZK_W300NH_GPIO_LED_STATUS 1
25 #define MZK_W300NH_GPIO_LED_WPS 3
26 #define MZK_W300NH_GPIO_LED_WLAN 6
27 #define MZK_W300NH_GPIO_LED_AP 15
28 #define MZK_W300NH_GPIO_LED_ROUTER 16
29
30 #define MZK_W300NH_GPIO_BTN_APROUTER 5
31 #define MZK_W300NH_GPIO_BTN_WPS 12
32 #define MZK_W300NH_GPIO_BTN_RESET 21
33
34 #define MZK_W04NU_BUTTONS_POLL_INTERVAL 20
35
36 #ifdef CONFIG_MTD_PARTITIONS
37 static struct mtd_partition mzk_w300nh_partitions[] = {
38 {
39 .name = "u-boot",
40 .offset = 0,
41 .size = 0x040000,
42 .mask_flags = MTD_WRITEABLE,
43 }, {
44 .name = "u-boot-env",
45 .offset = 0x040000,
46 .size = 0x010000,
47 }, {
48 .name = "kernel",
49 .offset = 0x050000,
50 .size = 0x160000,
51 }, {
52 .name = "rootfs",
53 .offset = 0x1b0000,
54 .size = 0x630000,
55 }, {
56 .name = "art",
57 .offset = 0x7e0000,
58 .size = 0x020000,
59 .mask_flags = MTD_WRITEABLE,
60 }, {
61 .name = "firmware",
62 .offset = 0x050000,
63 .size = 0x790000,
64 }
65 };
66 #endif /* CONFIG_MTD_PARTITIONS */
67
68 static struct flash_platform_data mzk_w300nh_flash_data = {
69 #ifdef CONFIG_MTD_PARTITIONS
70 .parts = mzk_w300nh_partitions,
71 .nr_parts = ARRAY_SIZE(mzk_w300nh_partitions),
72 #endif
73 };
74
75 static struct gpio_led mzk_w300nh_leds_gpio[] __initdata = {
76 {
77 .name = "mzk-w300nh:green:status",
78 .gpio = MZK_W300NH_GPIO_LED_STATUS,
79 .active_low = 1,
80 }, {
81 .name = "mzk-w300nh:blue:wps",
82 .gpio = MZK_W300NH_GPIO_LED_WPS,
83 .active_low = 1,
84 }, {
85 .name = "mzk-w300nh:green:wlan",
86 .gpio = MZK_W300NH_GPIO_LED_WLAN,
87 .active_low = 1,
88 }, {
89 .name = "mzk-w300nh:green:ap",
90 .gpio = MZK_W300NH_GPIO_LED_AP,
91 .active_low = 1,
92 }, {
93 .name = "mzk-w300nh:green:router",
94 .gpio = MZK_W300NH_GPIO_LED_ROUTER,
95 .active_low = 1,
96 }
97 };
98
99 static struct gpio_button mzk_w300nh_gpio_buttons[] __initdata = {
100 {
101 .desc = "reset",
102 .type = EV_KEY,
103 .code = KEY_RESTART,
104 .threshold = 3,
105 .gpio = MZK_W300NH_GPIO_BTN_RESET,
106 .active_low = 1,
107 }, {
108 .desc = "wps",
109 .type = EV_KEY,
110 .code = KEY_WPS_BUTTON,
111 .threshold = 3,
112 .gpio = MZK_W300NH_GPIO_BTN_WPS,
113 .active_low = 1,
114 }, {
115 .desc = "aprouter",
116 .type = EV_KEY,
117 .code = BTN_2,
118 .threshold = 3,
119 .gpio = MZK_W300NH_GPIO_BTN_APROUTER,
120 .active_low = 0,
121 }
122 };
123
124 #define MZK_W300NH_WAN_PHYMASK BIT(4)
125 #define MZK_W300NH_MDIO_MASK (~MZK_W300NH_WAN_PHYMASK)
126
127 static void __init mzk_w300nh_setup(void)
128 {
129 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
130
131 ar71xx_add_device_mdio(MZK_W300NH_MDIO_MASK);
132
133 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0);
134 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
135 ar71xx_eth0_data.speed = SPEED_100;
136 ar71xx_eth0_data.duplex = DUPLEX_FULL;
137 ar71xx_eth0_data.has_ar8216 = 1;
138
139 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1);
140 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
141 ar71xx_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK;
142
143 ar71xx_add_device_eth(0);
144 ar71xx_add_device_eth(1);
145
146 ar71xx_add_device_m25p80(&mzk_w300nh_flash_data);
147
148 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(mzk_w300nh_leds_gpio),
149 mzk_w300nh_leds_gpio);
150
151 ar71xx_add_device_gpio_buttons(-1, MZK_W04NU_BUTTONS_POLL_INTERVAL,
152 ARRAY_SIZE(mzk_w300nh_gpio_buttons),
153 mzk_w300nh_gpio_buttons);
154 ar9xxx_add_device_wmac(eeprom, NULL);
155 }
156
157 MIPS_MACHINE(AR71XX_MACH_MZK_W300NH, "MZK-W300NH", "Planex MZK-W300NH",
158 mzk_w300nh_setup);