98b3f009263c42f737e952072b47222c1ed29963
[openwrt.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_W300NH_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define MZK_W300NH_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W300NH_KEYS_POLL_INTERVAL)
36
37 #ifdef CONFIG_MTD_PARTITIONS
38 static struct mtd_partition mzk_w300nh_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 #endif /* CONFIG_MTD_PARTITIONS */
68
69 static struct flash_platform_data mzk_w300nh_flash_data = {
70 #ifdef CONFIG_MTD_PARTITIONS
71 .parts = mzk_w300nh_partitions,
72 .nr_parts = ARRAY_SIZE(mzk_w300nh_partitions),
73 #endif
74 };
75
76 static struct gpio_led mzk_w300nh_leds_gpio[] __initdata = {
77 {
78 .name = "planex:green:status",
79 .gpio = MZK_W300NH_GPIO_LED_STATUS,
80 .active_low = 1,
81 }, {
82 .name = "planex:blue:wps",
83 .gpio = MZK_W300NH_GPIO_LED_WPS,
84 .active_low = 1,
85 }, {
86 .name = "planex:green:wlan",
87 .gpio = MZK_W300NH_GPIO_LED_WLAN,
88 .active_low = 1,
89 }, {
90 .name = "planex:green:ap",
91 .gpio = MZK_W300NH_GPIO_LED_AP,
92 .active_low = 1,
93 }, {
94 .name = "planex:green:router",
95 .gpio = MZK_W300NH_GPIO_LED_ROUTER,
96 .active_low = 1,
97 }
98 };
99
100 static struct gpio_keys_button mzk_w300nh_gpio_keys[] __initdata = {
101 {
102 .desc = "reset",
103 .type = EV_KEY,
104 .code = KEY_RESTART,
105 .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
106 .gpio = MZK_W300NH_GPIO_BTN_RESET,
107 .active_low = 1,
108 }, {
109 .desc = "wps",
110 .type = EV_KEY,
111 .code = KEY_WPS_BUTTON,
112 .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
113 .gpio = MZK_W300NH_GPIO_BTN_WPS,
114 .active_low = 1,
115 }, {
116 .desc = "aprouter",
117 .type = EV_KEY,
118 .code = BTN_2,
119 .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
120 .gpio = MZK_W300NH_GPIO_BTN_APROUTER,
121 .active_low = 0,
122 }
123 };
124
125 #define MZK_W300NH_WAN_PHYMASK BIT(4)
126 #define MZK_W300NH_MDIO_MASK (~MZK_W300NH_WAN_PHYMASK)
127
128 static void __init mzk_w300nh_setup(void)
129 {
130 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
131
132 ar71xx_add_device_mdio(0, MZK_W300NH_MDIO_MASK);
133
134 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0);
135 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
136 ar71xx_eth0_data.speed = SPEED_100;
137 ar71xx_eth0_data.duplex = DUPLEX_FULL;
138 ar71xx_eth0_data.has_ar8216 = 1;
139
140 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1);
141 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
142 ar71xx_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK;
143
144 ar71xx_add_device_eth(0);
145 ar71xx_add_device_eth(1);
146
147 ar71xx_add_device_m25p80(&mzk_w300nh_flash_data);
148
149 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(mzk_w300nh_leds_gpio),
150 mzk_w300nh_leds_gpio);
151
152 ar71xx_register_gpio_keys_polled(-1, MZK_W300NH_KEYS_POLL_INTERVAL,
153 ARRAY_SIZE(mzk_w300nh_gpio_keys),
154 mzk_w300nh_gpio_keys);
155 ar9xxx_add_device_wmac(eeprom, NULL);
156 }
157
158 MIPS_MACHINE(AR71XX_MACH_MZK_W300NH, "MZK-W300NH", "Planex MZK-W300NH",
159 mzk_w300nh_setup);
This page took 0.056464 seconds and 3 git commands to generate.