1d59f7478625ddfdd13e0d4ef99c8ad5e4b3f6b4
[openwrt/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_WMAC_CALDATA_OFFSET 0x1000
36 #define DB120_PCIE_CALDATA_OFFSET 0x5000
37
38 #define DB120_KEYS_POLL_INTERVAL 20 /* msecs */
39 #define DB120_KEYS_DEBOUNCE_INTERVAL (3 * DB120_KEYS_POLL_INTERVAL)
40
41 #ifdef CONFIG_MTD_PARTITIONS
42 static struct mtd_partition db120_partitions[] = {
43 {
44 .name = "u-boot",
45 .offset = 0,
46 .size = 0x040000,
47 .mask_flags = MTD_WRITEABLE,
48 }, {
49 .name = "u-boot-env",
50 .offset = 0x040000,
51 .size = 0x010000,
52 }, {
53 .name = "rootfs",
54 .offset = 0x050000,
55 .size = 0x630000,
56 }, {
57 .name = "uImage",
58 .offset = 0x680000,
59 .size = 0x160000,
60 }, {
61 .name = "NVRAM",
62 .offset = 0x7E0000,
63 .size = 0x010000,
64 }, {
65 .name = "ART",
66 .offset = 0x7F0000,
67 .size = 0x010000,
68 .mask_flags = MTD_WRITEABLE,
69 }
70 };
71 #endif /* CONFIG_MTD_PARTITIONS */
72
73 static struct flash_platform_data db120_flash_data = {
74 #ifdef CONFIG_MTD_PARTITIONS
75 .parts = db120_partitions,
76 .nr_parts = ARRAY_SIZE(db120_partitions),
77 #endif
78 };
79
80 static struct gpio_led db120_leds_gpio[] __initdata = {
81 {
82 .name = "db120:green:status",
83 .gpio = DB120_GPIO_LED_STATUS,
84 .active_low = 1,
85 }, {
86 .name = "db120:green:wps",
87 .gpio = DB120_GPIO_LED_WPS,
88 .active_low = 1,
89 }, {
90 .name = "db120:green:wlan-5g",
91 .gpio = DB120_GPIO_LED_WLAN_5G,
92 .active_low = 1,
93 }, {
94 .name = "db120:green:wlan-2g",
95 .gpio = DB120_GPIO_LED_WLAN_2G,
96 .active_low = 1,
97 }, {
98 .name = "db120:green:usb",
99 .gpio = DB120_GPIO_LED_USB,
100 .active_low = 1,
101 }
102 };
103
104 static struct gpio_keys_button db120_gpio_keys[] __initdata = {
105 {
106 .desc = "WPS button",
107 .type = EV_KEY,
108 .code = KEY_WPS_BUTTON,
109 .debounce_interval = DB120_KEYS_DEBOUNCE_INTERVAL,
110 .gpio = DB120_GPIO_BTN_WPS,
111 .active_low = 1,
112 }
113 };
114
115 static void __init db120_setup(void)
116 {
117 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
118
119 ar71xx_gpio_output_select(DB120_GPIO_LED_USB, AR934X_GPIO_OUT_GPIO);
120
121 ar71xx_add_device_usb();
122
123 ar71xx_add_device_m25p80(&db120_flash_data);
124
125 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(db120_leds_gpio),
126 db120_leds_gpio);
127
128 ar71xx_register_gpio_keys_polled(-1, DB120_KEYS_POLL_INTERVAL,
129 ARRAY_SIZE(db120_gpio_keys),
130 db120_gpio_keys);
131
132 ar71xx_add_device_mdio(0, 0x0);
133 ar71xx_add_device_mdio(1, 0x0);
134
135 /* GMAC0 is connected to an AR8327 switch */
136 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, art + DB120_MAC0_OFFSET, 0);
137 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
138 ar71xx_eth0_data.speed = SPEED_1000;
139 ar71xx_eth0_data.duplex = DUPLEX_FULL;
140
141 ar71xx_add_device_eth(0);
142
143 /* GMAC1 is connected to the internal switch */
144 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, art + DB120_MAC1_OFFSET, 0);
145 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
146 ar71xx_eth1_data.speed = SPEED_1000;
147 ar71xx_eth1_data.duplex = DUPLEX_FULL;
148
149 ar71xx_add_device_eth(1);
150
151 ar9xxx_add_device_wmac(art + DB120_WMAC_CALDATA_OFFSET, NULL);
152
153 db120_pci_init(art + DB120_PCIE_CALDATA_OFFSET, NULL);
154 }
155
156 MIPS_MACHINE(AR71XX_MACH_DB120, "DB120", "Atheros DB120", db120_setup);