2 * Zcomax ZCN-1523H-2-8/5-16 board support
4 * Copyright (C) 2010-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>
15 #include <asm/mach-ath79/ar71xx_regs.h>
19 #include "dev-m25p80.h"
20 #include "dev-ap9x-pci.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "machtypes.h"
25 #define ZCN_1523H_GPIO_BTN_RESET 0
26 #define ZCN_1523H_GPIO_LED_INIT 11
27 #define ZCN_1523H_GPIO_LED_LAN1 17
29 #define ZCN_1523H_2_GPIO_LED_WEAK 13
30 #define ZCN_1523H_2_GPIO_LED_MEDIUM 14
31 #define ZCN_1523H_2_GPIO_LED_STRONG 15
33 #define ZCN_1523H_5_GPIO_LED_UNKNOWN 1
34 #define ZCN_1523H_5_GPIO_LED_LAN2 13
35 #define ZCN_1523H_5_GPIO_LED_WEAK 14
36 #define ZCN_1523H_5_GPIO_LED_MEDIUM 15
37 #define ZCN_1523H_5_GPIO_LED_STRONG 16
39 #define ZCN_1523H_KEYS_POLL_INTERVAL 20 /* msecs */
40 #define ZCN_1523H_KEYS_DEBOUNCE_INTERVAL (3 * ZCN_1523H_KEYS_POLL_INTERVAL)
42 static struct mtd_partition zcn_1523h_partitions
[] = {
47 .mask_flags
= MTD_WRITEABLE
,
52 .mask_flags
= MTD_WRITEABLE
,
65 .mask_flags
= MTD_WRITEABLE
,
70 .mask_flags
= MTD_WRITEABLE
,
75 .mask_flags
= MTD_WRITEABLE
,
83 static struct flash_platform_data zcn_1523h_flash_data
= {
84 .parts
= zcn_1523h_partitions
,
85 .nr_parts
= ARRAY_SIZE(zcn_1523h_partitions
),
88 static struct gpio_keys_button zcn_1523h_gpio_keys
[] __initdata
= {
93 .debounce_interval
= ZCN_1523H_KEYS_DEBOUNCE_INTERVAL
,
94 .gpio
= ZCN_1523H_GPIO_BTN_RESET
,
99 static struct gpio_led zcn_1523h_leds_gpio
[] __initdata
= {
101 .name
= "zcn-1523h:amber:init",
102 .gpio
= ZCN_1523H_GPIO_LED_INIT
,
105 .name
= "zcn-1523h:green:lan1",
106 .gpio
= ZCN_1523H_GPIO_LED_LAN1
,
111 static struct gpio_led zcn_1523h_2_leds_gpio
[] __initdata
= {
113 .name
= "zcn-1523h:red:weak",
114 .gpio
= ZCN_1523H_2_GPIO_LED_WEAK
,
117 .name
= "zcn-1523h:amber:medium",
118 .gpio
= ZCN_1523H_2_GPIO_LED_MEDIUM
,
121 .name
= "zcn-1523h:green:strong",
122 .gpio
= ZCN_1523H_2_GPIO_LED_STRONG
,
127 static struct gpio_led zcn_1523h_5_leds_gpio
[] __initdata
= {
129 .name
= "zcn-1523h:red:weak",
130 .gpio
= ZCN_1523H_5_GPIO_LED_WEAK
,
133 .name
= "zcn-1523h:amber:medium",
134 .gpio
= ZCN_1523H_5_GPIO_LED_MEDIUM
,
137 .name
= "zcn-1523h:green:strong",
138 .gpio
= ZCN_1523H_5_GPIO_LED_STRONG
,
141 .name
= "zcn-1523h:green:lan2",
142 .gpio
= ZCN_1523H_5_GPIO_LED_LAN2
,
145 .name
= "zcn-1523h:amber:unknown",
146 .gpio
= ZCN_1523H_5_GPIO_LED_UNKNOWN
,
150 static void __init
zcn_1523h_generic_setup(void)
152 u8
*mac
= (u8
*) KSEG1ADDR(0x1f7e0004);
153 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
155 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
156 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
157 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
158 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
159 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
161 ath79_register_m25p80(&zcn_1523h_flash_data
);
163 ath79_register_leds_gpio(0, ARRAY_SIZE(zcn_1523h_leds_gpio
),
164 zcn_1523h_leds_gpio
);
166 ath79_register_gpio_keys_polled(-1, ZCN_1523H_KEYS_POLL_INTERVAL
,
167 ARRAY_SIZE(zcn_1523h_gpio_keys
),
168 zcn_1523h_gpio_keys
);
170 ap91_pci_init(ee
, mac
);
172 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
173 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 1);
175 ath79_register_mdio(0, 0x0);
178 ath79_register_eth(0);
181 static void __init
zcn_1523h_2_setup(void)
183 zcn_1523h_generic_setup();
184 ap9x_pci_setup_wmac_gpio(0, BIT(9), 0);
186 ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_2_leds_gpio
),
187 zcn_1523h_2_leds_gpio
);
190 MIPS_MACHINE(ATH79_MACH_ZCN_1523H_2
, "ZCN-1523H-2", "Zcomax ZCN-1523H-2",
193 static void __init
zcn_1523h_5_setup(void)
195 zcn_1523h_generic_setup();
196 ap9x_pci_setup_wmac_gpio(0, BIT(8), 0);
198 ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_5_leds_gpio
),
199 zcn_1523h_5_leds_gpio
);
202 ath79_register_eth(1);
205 MIPS_MACHINE(ATH79_MACH_ZCN_1523H_5
, "ZCN-1523H-5", "Zcomax ZCN-1523H-5",