ar71xx: add initial support for 3.2
[openwrt/openwrt.git] / target / linux / ar71xx / files-3.2 / arch / mips / ath79 / mach-mzk-w04nu.c
1 /*
2 * Planex MZK-W04NU board support
3 *
4 * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13
14 #include <asm/mach-ath79/ath79.h>
15
16 #include "dev-eth.h"
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19 #include "dev-m25p80.h"
20 #include "dev-usb.h"
21 #include "dev-wmac.h"
22 #include "machtypes.h"
23
24 #define MZK_W04NU_GPIO_LED_USB 0
25 #define MZK_W04NU_GPIO_LED_STATUS 1
26 #define MZK_W04NU_GPIO_LED_WPS 3
27 #define MZK_W04NU_GPIO_LED_WLAN 6
28 #define MZK_W04NU_GPIO_LED_AP 15
29 #define MZK_W04NU_GPIO_LED_ROUTER 16
30
31 #define MZK_W04NU_GPIO_BTN_APROUTER 5
32 #define MZK_W04NU_GPIO_BTN_WPS 12
33 #define MZK_W04NU_GPIO_BTN_RESET 21
34
35 #define MZK_W04NU_KEYS_POLL_INTERVAL 20 /* msecs */
36 #define MZK_W04NU_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W04NU_KEYS_POLL_INTERVAL)
37
38 static struct mtd_partition mzk_w04nu_partitions[] = {
39 {
40 .name = "u-boot",
41 .offset = 0,
42 .size = 0x040000,
43 .mask_flags = MTD_WRITEABLE,
44 }, {
45 .name = "u-boot-env",
46 .offset = 0x040000,
47 .size = 0x010000,
48 }, {
49 .name = "kernel",
50 .offset = 0x050000,
51 .size = 0x160000,
52 }, {
53 .name = "rootfs",
54 .offset = 0x1b0000,
55 .size = 0x630000,
56 }, {
57 .name = "art",
58 .offset = 0x7e0000,
59 .size = 0x020000,
60 .mask_flags = MTD_WRITEABLE,
61 }, {
62 .name = "firmware",
63 .offset = 0x050000,
64 .size = 0x790000,
65 }
66 };
67
68 static struct flash_platform_data mzk_w04nu_flash_data = {
69 .parts = mzk_w04nu_partitions,
70 .nr_parts = ARRAY_SIZE(mzk_w04nu_partitions),
71 };
72
73 static struct gpio_led mzk_w04nu_leds_gpio[] __initdata = {
74 {
75 .name = "planex:green:status",
76 .gpio = MZK_W04NU_GPIO_LED_STATUS,
77 .active_low = 1,
78 }, {
79 .name = "planex:blue:wps",
80 .gpio = MZK_W04NU_GPIO_LED_WPS,
81 .active_low = 1,
82 }, {
83 .name = "planex:green:wlan",
84 .gpio = MZK_W04NU_GPIO_LED_WLAN,
85 .active_low = 1,
86 }, {
87 .name = "planex:green:usb",
88 .gpio = MZK_W04NU_GPIO_LED_USB,
89 .active_low = 1,
90 }, {
91 .name = "planex:green:ap",
92 .gpio = MZK_W04NU_GPIO_LED_AP,
93 .active_low = 1,
94 }, {
95 .name = "planex:green:router",
96 .gpio = MZK_W04NU_GPIO_LED_ROUTER,
97 .active_low = 1,
98 }
99 };
100
101 static struct gpio_keys_button mzk_w04nu_gpio_keys[] __initdata = {
102 {
103 .desc = "reset",
104 .type = EV_KEY,
105 .code = KEY_RESTART,
106 .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
107 .gpio = MZK_W04NU_GPIO_BTN_RESET,
108 .active_low = 1,
109 }, {
110 .desc = "wps",
111 .type = EV_KEY,
112 .code = KEY_WPS_BUTTON,
113 .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
114 .gpio = MZK_W04NU_GPIO_BTN_WPS,
115 .active_low = 1,
116 }, {
117 .desc = "aprouter",
118 .type = EV_KEY,
119 .code = BTN_2,
120 .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
121 .gpio = MZK_W04NU_GPIO_BTN_APROUTER,
122 .active_low = 0,
123 }
124 };
125
126 #define MZK_W04NU_WAN_PHYMASK BIT(4)
127 #define MZK_W04NU_MDIO_MASK (~MZK_W04NU_WAN_PHYMASK)
128
129 static void __init mzk_w04nu_setup(void)
130 {
131 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
132
133 ath79_register_mdio(0, MZK_W04NU_MDIO_MASK);
134
135 ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
136 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
137 ath79_eth0_data.speed = SPEED_100;
138 ath79_eth0_data.duplex = DUPLEX_FULL;
139 ath79_eth0_data.has_ar8216 = 1;
140
141 ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
142 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
143 ath79_eth1_data.phy_mask = MZK_W04NU_WAN_PHYMASK;
144
145 ath79_register_eth(0);
146 ath79_register_eth(1);
147
148 ath79_register_m25p80(&mzk_w04nu_flash_data);
149
150 ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w04nu_leds_gpio),
151 mzk_w04nu_leds_gpio);
152
153 ath79_register_gpio_keys_polled(-1, MZK_W04NU_KEYS_POLL_INTERVAL,
154 ARRAY_SIZE(mzk_w04nu_gpio_keys),
155 mzk_w04nu_gpio_keys);
156 ath79_register_usb();
157
158 ath79_register_wmac(eeprom, NULL);
159 }
160
161 MIPS_MACHINE(ATH79_MACH_MZK_W04NU, "MZK-W04NU", "Planex MZK-W04NU",
162 mzk_w04nu_setup);