ar71xx: add preliminary support for the Atheros AR933x SoCs
[openwrt/svn-archive/archive.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_SW1 16
32
33 #define DB120_CALDATA_OFFSET 0x1000
34 #define DB120_WMAC_MAC_OFFSET 0x1002
35
36 #define DB120_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define DB120_KEYS_DEBOUNCE_INTERVAL (3 * DB120_KEYS_POLL_INTERVAL)
38
39 #ifdef CONFIG_MTD_PARTITIONS
40 static struct mtd_partition db120_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 }, {
51 .name = "rootfs",
52 .offset = 0x050000,
53 .size = 0x630000,
54 }, {
55 .name = "uImage",
56 .offset = 0x680000,
57 .size = 0x160000,
58 }, {
59 .name = "NVRAM",
60 .offset = 0x7E0000,
61 .size = 0x010000,
62 }, {
63 .name = "ART",
64 .offset = 0x7F0000,
65 .size = 0x010000,
66 .mask_flags = MTD_WRITEABLE,
67 }
68 };
69 #endif /* CONFIG_MTD_PARTITIONS */
70
71 static struct flash_platform_data db120_flash_data = {
72 #ifdef CONFIG_MTD_PARTITIONS
73 .parts = db120_partitions,
74 .nr_parts = ARRAY_SIZE(db120_partitions),
75 #endif
76 };
77
78 static struct gpio_led db120_leds_gpio[] __initdata = {
79 {
80 .name = "db120:green:status",
81 .gpio = DB120_GPIO_LED_STATUS,
82 .active_low = 1,
83 }, {
84 .name = "db120:green:wps",
85 .gpio = DB120_GPIO_LED_WPS,
86 .active_low = 1,
87 }, {
88 .name = "db120:green:wlan-5g",
89 .gpio = DB120_GPIO_LED_WLAN_5G,
90 .active_low = 1,
91 }, {
92 .name = "db120:green:wlan-2g",
93 .gpio = DB120_GPIO_LED_WLAN_2G,
94 .active_low = 1,
95 }, {
96 .name = "db120:green:usb",
97 .gpio = DB120_GPIO_LED_USB,
98 .active_low = 1,
99 }
100 };
101
102 static struct gpio_keys_button db120_gpio_keys[] __initdata = {
103 {
104 .desc = "sw1",
105 .type = EV_KEY,
106 .code = BTN_0,
107 .debounce_interval = DB120_KEYS_DEBOUNCE_INTERVAL,
108 .gpio = DB120_GPIO_BTN_SW1,
109 .active_low = 1,
110 }
111 };
112
113 static void __init db120_setup(void)
114 {
115 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
116
117 ar71xx_add_device_usb();
118
119 ar71xx_add_device_m25p80(&db120_flash_data);
120
121 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(db120_leds_gpio),
122 db120_leds_gpio);
123
124 ar71xx_register_gpio_keys_polled(-1, DB120_KEYS_POLL_INTERVAL,
125 ARRAY_SIZE(db120_gpio_keys),
126 db120_gpio_keys);
127
128 ar9xxx_add_device_wmac(art + DB120_CALDATA_OFFSET,
129 art + DB120_WMAC_MAC_OFFSET);
130
131 db120_pci_init();
132 }
133
134 MIPS_MACHINE(AR71XX_MACH_DB120, "DB120", "Atheros DB120", db120_setup);