ar71xx: fix whitespaces nits
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-dir-615-c1.c
1 /*
2  *  D-Link DIR-615 rev C1 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-ar913x-wmac.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "nvram.h"
24
25 #define DIR_615C1_GPIO_LED_ORANGE_STATUS 1      /* ORANGE:STATUS:TRICOLOR */
26 #define DIR_615C1_GPIO_LED_BLUE_WPS     3       /* BLUE:WPS */
27 #define DIR_615C1_GPIO_LED_GREEN_WAN    4       /* GREEN:WAN:TRICOLOR */
28 #define DIR_615C1_GPIO_LED_GREEN_WANCPU 5       /* GREEN:WAN:CPU:TRICOLOR */
29 #define DIR_615C1_GPIO_LED_GREEN_WLAN   6       /* GREEN:WLAN */
30 #define DIR_615C1_GPIO_LED_GREEN_STATUS 14      /* GREEN:STATUS:TRICOLOR */
31 #define DIR_615C1_GPIO_LED_ORANGE_WAN   15      /* ORANGE:WAN:TRICOLOR */
32
33 /* buttons may need refinement */
34
35 #define DIR_615C1_GPIO_BTN_WPS          12
36 #define DIR_615C1_GPIO_BTN_RESET        21
37
38 #define DIR_615C1_BUTTONS_POLL_INTERVAL 20
39
40 #define DIR_615C1_CONFIG_ADDR           0x1f020000
41 #define DIR_615C1_CONFIG_SIZE           0x10000
42
43 #ifdef CONFIG_MTD_PARTITIONS
44 static struct mtd_partition dir_615c1_partitions[] = {
45         {
46                 .name           = "u-boot",
47                 .offset         = 0,
48                 .size           = 0x020000,
49                 .mask_flags     = MTD_WRITEABLE,
50         }, {
51                 .name           = "config",
52                 .offset         = 0x020000,
53                 .size           = 0x010000,
54         }, {
55                 .name           = "kernel",
56                 .offset         = 0x030000,
57                 .size           = 0x0d0000,
58         }, {
59                 .name           = "rootfs",
60                 .offset         = 0x100000,
61                 .size           = 0x2f0000,
62         }, {
63                 .name           = "art",
64                 .offset         = 0x3f0000,
65                 .size           = 0x010000,
66                 .mask_flags     = MTD_WRITEABLE,
67         }, {
68                 .name           = "firmware",
69                 .offset         = 0x030000,
70                 .size           = 0x3c0000,
71         }
72 };
73 #endif /* CONFIG_MTD_PARTITIONS */
74
75 static struct flash_platform_data dir_615c1_flash_data = {
76 #ifdef CONFIG_MTD_PARTITIONS
77         .parts          = dir_615c1_partitions,
78         .nr_parts       = ARRAY_SIZE(dir_615c1_partitions),
79 #endif
80 };
81
82 static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
83         {
84                 .name           = "dir-615c1:orange:status",
85                 .gpio           = DIR_615C1_GPIO_LED_ORANGE_STATUS,
86                 .active_low     = 1,
87         }, {
88                 .name           = "dir-615c1:blue:wps",
89                 .gpio           = DIR_615C1_GPIO_LED_BLUE_WPS,
90                 .active_low     = 1,
91         }, {
92                 .name           = "dir-615c1:green:wan",
93                 .gpio           = DIR_615C1_GPIO_LED_GREEN_WAN,
94                 .active_low     = 1,
95         }, {
96                 .name           = "dir-615c1:green:wancpu",
97                 .gpio           = DIR_615C1_GPIO_LED_GREEN_WANCPU,
98                 .active_low     = 1,
99         }, {
100                 .name           = "dir-615c1:green:wlan",
101                 .gpio           = DIR_615C1_GPIO_LED_GREEN_WLAN,
102                 .active_low     = 1,
103         }, {
104                 .name           = "dir-615c1:green:status",
105                 .gpio           = DIR_615C1_GPIO_LED_GREEN_STATUS,
106                 .active_low     = 1,
107         }, {
108                 .name           = "dir-615c1:orange:wan",
109                 .gpio           = DIR_615C1_GPIO_LED_ORANGE_WAN,
110                 .active_low     = 1,
111         }
112
113 };
114
115 static struct gpio_button dir_615c1_gpio_buttons[] __initdata = {
116         {
117                 .desc           = "reset",
118                 .type           = EV_KEY,
119                 .code           = KEY_RESTART,
120                 .threshold      = 3,
121                 .gpio           = DIR_615C1_GPIO_BTN_RESET,
122         }, {
123                 .desc           = "wps",
124                 .type           = EV_KEY,
125                 .code           = KEY_WPS_BUTTON,
126                 .threshold      = 3,
127                 .gpio           = DIR_615C1_GPIO_BTN_WPS,
128         }
129 };
130
131 #define DIR_615C1_LAN_PHYMASK   BIT(0)
132 #define DIR_615C1_WAN_PHYMASK   BIT(4)
133 #define DIR_615C1_MDIO_MASK     (~(DIR_615C1_LAN_PHYMASK | \
134                                    DIR_615C1_WAN_PHYMASK))
135
136 static void __init dir_615c1_setup(void)
137 {
138         const char *config = (char *) KSEG1ADDR(DIR_615C1_CONFIG_ADDR);
139         u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
140         u8 mac[6];
141         u8 *wlan_mac = NULL;
142
143         if (nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE,
144                                         "lan_mac=", mac) == 0) {
145                 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
146                 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
147                 wlan_mac = mac;
148         }
149
150         ar71xx_add_device_mdio(DIR_615C1_MDIO_MASK);
151
152         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
153         ar71xx_eth0_data.phy_mask = DIR_615C1_LAN_PHYMASK;
154
155         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
156         ar71xx_eth1_data.phy_mask = DIR_615C1_WAN_PHYMASK;
157
158         ar71xx_add_device_eth(0);
159         ar71xx_add_device_eth(1);
160
161         ar71xx_add_device_m25p80(&dir_615c1_flash_data);
162
163         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
164                                         dir_615c1_leds_gpio);
165
166         ar71xx_add_device_gpio_buttons(-1, DIR_615C1_BUTTONS_POLL_INTERVAL,
167                                         ARRAY_SIZE(dir_615c1_gpio_buttons),
168                                         dir_615c1_gpio_buttons);
169
170         ar913x_add_device_wmac(eeprom, wlan_mac);
171 }
172
173 MIPS_MACHINE(AR71XX_MACH_DIR_615_C1, "DIR-615-C1", "D-Link DIR-615 rev. C1",
174              dir_615c1_setup);