Root/target/linux/ar71xx/files/arch/mips/ar71xx/mach-zcn-1523h.c

1/*
2 * Zcomax ZCN-1523H-2-8/5-16 board support
3 *
4 * Copyright (C) 2010 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-ar71xx/ar71xx.h>
15
16#include "machtype.h"
17#include "devices.h"
18#include "dev-m25p80.h"
19#include "dev-ap91-pci.h"
20#include "dev-gpio-buttons.h"
21#include "dev-leds-gpio.h"
22
23#define ZCN_1523H_GPIO_BTN_RESET 0
24#define ZCN_1523H_GPIO_LED_INIT 11
25#define ZCN_1523H_GPIO_LED_LAN1 17
26
27#define ZCN_1523H_2_GPIO_LED_WEAK 13
28#define ZCN_1523H_2_GPIO_LED_MEDIUM 14
29#define ZCN_1523H_2_GPIO_LED_STRONG 15
30
31#define ZCN_1523H_5_GPIO_LED_UNKNOWN 1
32#define ZCN_1523H_5_GPIO_LED_LAN2 13
33#define ZCN_1523H_5_GPIO_LED_WEAK 14
34#define ZCN_1523H_5_GPIO_LED_MEDIUM 15
35#define ZCN_1523H_5_GPIO_LED_STRONG 16
36
37#define ZCN_1523H_KEYS_POLL_INTERVAL 20 /* msecs */
38#define ZCN_1523H_KEYS_DEBOUNCE_INTERVAL (3 * ZCN_1523H_KEYS_POLL_INTERVAL)
39
40#ifdef CONFIG_MTD_PARTITIONS
41static struct mtd_partition zcn_1523h_partitions[] = {
42    {
43        .name = "u-boot",
44        .offset = 0,
45        .size = 0x040000,
46        .mask_flags = MTD_WRITEABLE,
47    }, {
48        .name = "u-boot-env",
49        .offset = 0x040000,
50        .size = 0x010000,
51        .mask_flags = MTD_WRITEABLE,
52    }, {
53        .name = "rootfs",
54        .offset = 0x050000,
55        .size = 0x610000,
56    }, {
57        .name = "kernel",
58        .offset = 0x660000,
59        .size = 0x170000,
60    }, {
61        .name = "configure",
62        .offset = 0x7d0000,
63        .size = 0x010000,
64        .mask_flags = MTD_WRITEABLE,
65    }, {
66        .name = "mfg",
67        .offset = 0x7e0000,
68        .size = 0x010000,
69        .mask_flags = MTD_WRITEABLE,
70    }, {
71        .name = "eeprom",
72        .offset = 0x7f0000,
73        .size = 0x010000,
74        .mask_flags = MTD_WRITEABLE,
75    }, {
76        .name = "firmware",
77        .offset = 0x050000,
78        .size = 0x780000,
79    }
80};
81#endif /* CONFIG_MTD_PARTITIONS */
82
83static struct flash_platform_data zcn_1523h_flash_data = {
84#ifdef CONFIG_MTD_PARTITIONS
85    .parts = zcn_1523h_partitions,
86    .nr_parts = ARRAY_SIZE(zcn_1523h_partitions),
87#endif
88};
89
90static struct gpio_keys_button zcn_1523h_gpio_keys[] __initdata = {
91    {
92        .desc = "reset",
93        .type = EV_KEY,
94        .code = KEY_RESTART,
95        .debounce_interval = ZCN_1523H_KEYS_DEBOUNCE_INTERVAL,
96        .gpio = ZCN_1523H_GPIO_BTN_RESET,
97        .active_low = 1,
98    }
99};
100
101static struct gpio_led zcn_1523h_leds_gpio[] __initdata = {
102    {
103        .name = "zcn-1523h:amber:init",
104        .gpio = ZCN_1523H_GPIO_LED_INIT,
105        .active_low = 1,
106    }, {
107        .name = "zcn-1523h:green:lan1",
108        .gpio = ZCN_1523H_GPIO_LED_LAN1,
109        .active_low = 1,
110    }
111};
112
113static struct gpio_led zcn_1523h_2_leds_gpio[] __initdata = {
114    {
115        .name = "zcn-1523h:red:weak",
116        .gpio = ZCN_1523H_2_GPIO_LED_WEAK,
117        .active_low = 1,
118    }, {
119        .name = "zcn-1523h:amber:medium",
120        .gpio = ZCN_1523H_2_GPIO_LED_MEDIUM,
121        .active_low = 1,
122    }, {
123        .name = "zcn-1523h:green:strong",
124        .gpio = ZCN_1523H_2_GPIO_LED_STRONG,
125        .active_low = 1,
126    }
127};
128
129static struct gpio_led zcn_1523h_5_leds_gpio[] __initdata = {
130    {
131        .name = "zcn-1523h:red:weak",
132        .gpio = ZCN_1523H_5_GPIO_LED_WEAK,
133        .active_low = 1,
134    }, {
135        .name = "zcn-1523h:amber:medium",
136        .gpio = ZCN_1523H_5_GPIO_LED_MEDIUM,
137        .active_low = 1,
138    }, {
139        .name = "zcn-1523h:green:strong",
140        .gpio = ZCN_1523H_5_GPIO_LED_STRONG,
141        .active_low = 1,
142    }, {
143        .name = "zcn-1523h:green:lan2",
144        .gpio = ZCN_1523H_5_GPIO_LED_LAN2,
145        .active_low = 1,
146    }, {
147        .name = "zcn-1523h:amber:unknown",
148        .gpio = ZCN_1523H_5_GPIO_LED_UNKNOWN,
149    }
150};
151
152static void __init zcn_1523h_generic_setup(void)
153{
154    u8 *mac = (u8 *) KSEG1ADDR(0x1f7e0004);
155    u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
156
157    ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
158                     AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
159                     AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
160                     AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
161                     AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
162
163    ar71xx_add_device_m25p80(&zcn_1523h_flash_data);
164
165    ar71xx_add_device_leds_gpio(0, ARRAY_SIZE(zcn_1523h_leds_gpio),
166                    zcn_1523h_leds_gpio);
167
168    ar71xx_register_gpio_keys_polled(-1, ZCN_1523H_KEYS_POLL_INTERVAL,
169                     ARRAY_SIZE(zcn_1523h_gpio_keys),
170                     zcn_1523h_gpio_keys);
171
172    ap91_pci_init(ee, mac);
173
174    ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
175    ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
176
177    /* LAN1 port */
178    ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
179    ar71xx_eth0_data.speed = SPEED_100;
180    ar71xx_eth0_data.duplex = DUPLEX_FULL;
181
182    /* LAN2 port */
183    ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
184    ar71xx_eth1_data.speed = SPEED_1000;
185    ar71xx_eth1_data.duplex = DUPLEX_FULL;
186
187    ar71xx_add_device_mdio(0x0);
188    ar71xx_add_device_eth(0);
189}
190
191static void __init zcn_1523h_2_setup(void)
192{
193    zcn_1523h_generic_setup();
194    ap91_pci_setup_wmac_gpio(BIT(9), 0);
195
196    ar71xx_add_device_leds_gpio(1, ARRAY_SIZE(zcn_1523h_2_leds_gpio),
197                    zcn_1523h_2_leds_gpio);
198}
199
200MIPS_MACHINE(AR71XX_MACH_ZCN_1523H_2, "ZCN-1523H-2", "Zcomax ZCN-1523H-2",
201         zcn_1523h_2_setup);
202
203static void __init zcn_1523h_5_setup(void)
204{
205    zcn_1523h_generic_setup();
206    ap91_pci_setup_wmac_gpio(BIT(8), 0);
207
208    ar71xx_add_device_leds_gpio(1, ARRAY_SIZE(zcn_1523h_5_leds_gpio),
209                    zcn_1523h_5_leds_gpio);
210    ar71xx_add_device_eth(1);
211}
212
213MIPS_MACHINE(AR71XX_MACH_ZCN_1523H_5, "ZCN-1523H-5", "Zcomax ZCN-1523H-5",
214         zcn_1523h_5_setup);
215

Archive Download this file



interactive