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