ar71xx: drop DB120_WMAC_MAC_OFFSET, it is not needed
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-db120.c
1 /*
2  *  Atheros DB120 board (WASP SoC) support
3  *
4  *  Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
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-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-usb.h"
22 #include "dev-ar9xxx-wmac.h"
23 #include "dev-db120-pci.h"
24
25 #define DB120_GPIO_LED_USB      11
26 #define DB120_GPIO_LED_WLAN_5G  12
27 #define DB120_GPIO_LED_WLAN_2G  13
28 #define DB120_GPIO_LED_STATUS   14
29 #define DB120_GPIO_LED_WPS      15
30
31 #define DB120_GPIO_BTN_WPS      16
32
33 #define DB120_MAC0_OFFSET       0
34 #define DB120_MAC1_OFFSET       6
35 #define DB120_CALDATA_OFFSET    0x1000
36
37 #define DB120_KEYS_POLL_INTERVAL        20      /* msecs */
38 #define DB120_KEYS_DEBOUNCE_INTERVAL    (3 * DB120_KEYS_POLL_INTERVAL)
39
40 #ifdef CONFIG_MTD_PARTITIONS
41 static struct mtd_partition db120_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         }, {
52                 .name           = "rootfs",
53                 .offset         = 0x050000,
54                 .size           = 0x630000,
55         }, {
56                 .name           = "uImage",
57                 .offset         = 0x680000,
58                 .size           = 0x160000,
59         }, {
60                 .name           = "NVRAM",
61                 .offset         = 0x7E0000,
62                 .size           = 0x010000,
63         }, {
64                 .name           = "ART",
65                 .offset         = 0x7F0000,
66                 .size           = 0x010000,
67                 .mask_flags     = MTD_WRITEABLE,
68         }
69 };
70 #endif /* CONFIG_MTD_PARTITIONS */
71
72 static struct flash_platform_data db120_flash_data = {
73 #ifdef CONFIG_MTD_PARTITIONS
74         .parts          = db120_partitions,
75         .nr_parts       = ARRAY_SIZE(db120_partitions),
76 #endif
77 };
78
79 static struct gpio_led db120_leds_gpio[] __initdata = {
80         {
81                 .name           = "db120:green:status",
82                 .gpio           = DB120_GPIO_LED_STATUS,
83                 .active_low     = 1,
84         }, {
85                 .name           = "db120:green:wps",
86                 .gpio           = DB120_GPIO_LED_WPS,
87                 .active_low     = 1,
88         }, {
89                 .name           = "db120:green:wlan-5g",
90                 .gpio           = DB120_GPIO_LED_WLAN_5G,
91                 .active_low     = 1,
92         }, {
93                 .name           = "db120:green:wlan-2g",
94                 .gpio           = DB120_GPIO_LED_WLAN_2G,
95                 .active_low     = 1,
96         }, {
97                 .name           = "db120:green:usb",
98                 .gpio           = DB120_GPIO_LED_USB,
99                 .active_low     = 1,
100         }
101 };
102
103 static struct gpio_keys_button db120_gpio_keys[] __initdata = {
104         {
105                 .desc           = "WPS button",
106                 .type           = EV_KEY,
107                 .code           = KEY_WPS_BUTTON,
108                 .debounce_interval = DB120_KEYS_DEBOUNCE_INTERVAL,
109                 .gpio           = DB120_GPIO_BTN_WPS,
110                 .active_low     = 1,
111         }
112 };
113
114 static void __init db120_setup(void)
115 {
116         u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
117
118         ar71xx_add_device_usb();
119
120         ar71xx_add_device_m25p80(&db120_flash_data);
121
122         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(db120_leds_gpio),
123                                         db120_leds_gpio);
124
125         ar71xx_register_gpio_keys_polled(-1, DB120_KEYS_POLL_INTERVAL,
126                                          ARRAY_SIZE(db120_gpio_keys),
127                                          db120_gpio_keys);
128
129         ar71xx_add_device_mdio(0, 0x0);
130         ar71xx_add_device_mdio(1, 0x0);
131
132         /* GMAC0 is connected to an AR8327 switch */
133         ar71xx_init_mac(ar71xx_eth0_data.mac_addr, art + DB120_MAC0_OFFSET, 0);
134         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
135         ar71xx_eth0_data.speed = SPEED_1000;
136         ar71xx_eth0_data.duplex = DUPLEX_FULL;
137
138         ar71xx_add_device_eth(0);
139
140         /* GMAC1 is connected to the internal switch */
141         ar71xx_init_mac(ar71xx_eth1_data.mac_addr, art + DB120_MAC1_OFFSET, 0);
142         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
143         ar71xx_eth1_data.speed = SPEED_100;
144         ar71xx_eth1_data.duplex = DUPLEX_FULL;
145
146         ar71xx_add_device_eth(1);
147
148         ar9xxx_add_device_wmac(art + DB120_CALDATA_OFFSET, NULL);
149
150         db120_pci_init();
151 }
152
153 MIPS_MACHINE(AR71XX_MACH_DB120, "DB120", "Atheros DB120", db120_setup);