2 * Planex MZK-W04NU board support
4 * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
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.
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
14 #include <asm/mach-ath79/ath79.h>
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19 #include "dev-m25p80.h"
22 #include "machtypes.h"
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
31 #define MZK_W04NU_GPIO_BTN_APROUTER 5
32 #define MZK_W04NU_GPIO_BTN_WPS 12
33 #define MZK_W04NU_GPIO_BTN_RESET 21
35 #define MZK_W04NU_KEYS_POLL_INTERVAL 20 /* msecs */
36 #define MZK_W04NU_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W04NU_KEYS_POLL_INTERVAL)
38 static struct mtd_partition mzk_w04nu_partitions
[] = {
43 .mask_flags
= MTD_WRITEABLE
,
60 .mask_flags
= MTD_WRITEABLE
,
68 static struct flash_platform_data mzk_w04nu_flash_data
= {
69 .parts
= mzk_w04nu_partitions
,
70 .nr_parts
= ARRAY_SIZE(mzk_w04nu_partitions
),
73 static struct gpio_led mzk_w04nu_leds_gpio
[] __initdata
= {
75 .name
= "planex:green:status",
76 .gpio
= MZK_W04NU_GPIO_LED_STATUS
,
79 .name
= "planex:blue:wps",
80 .gpio
= MZK_W04NU_GPIO_LED_WPS
,
83 .name
= "planex:green:wlan",
84 .gpio
= MZK_W04NU_GPIO_LED_WLAN
,
87 .name
= "planex:green:usb",
88 .gpio
= MZK_W04NU_GPIO_LED_USB
,
91 .name
= "planex:green:ap",
92 .gpio
= MZK_W04NU_GPIO_LED_AP
,
95 .name
= "planex:green:router",
96 .gpio
= MZK_W04NU_GPIO_LED_ROUTER
,
101 static struct gpio_keys_button mzk_w04nu_gpio_keys
[] __initdata
= {
106 .debounce_interval
= MZK_W04NU_KEYS_DEBOUNCE_INTERVAL
,
107 .gpio
= MZK_W04NU_GPIO_BTN_RESET
,
112 .code
= KEY_WPS_BUTTON
,
113 .debounce_interval
= MZK_W04NU_KEYS_DEBOUNCE_INTERVAL
,
114 .gpio
= MZK_W04NU_GPIO_BTN_WPS
,
120 .debounce_interval
= MZK_W04NU_KEYS_DEBOUNCE_INTERVAL
,
121 .gpio
= MZK_W04NU_GPIO_BTN_APROUTER
,
126 #define MZK_W04NU_WAN_PHYMASK BIT(4)
127 #define MZK_W04NU_MDIO_MASK (~MZK_W04NU_WAN_PHYMASK)
129 static void __init
mzk_w04nu_setup(void)
131 u8
*eeprom
= (u8
*) KSEG1ADDR(0x1fff1000);
133 ath79_register_mdio(0, MZK_W04NU_MDIO_MASK
);
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;
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
;
145 ath79_register_eth(0);
146 ath79_register_eth(1);
148 ath79_register_m25p80(&mzk_w04nu_flash_data
);
150 ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w04nu_leds_gpio
),
151 mzk_w04nu_leds_gpio
);
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();
158 ath79_register_wmac(eeprom
, NULL
);
161 MIPS_MACHINE(ATH79_MACH_MZK_W04NU
, "MZK-W04NU", "Planex MZK-W04NU",