3e4af40bdbb81c7d20f07913a084e62bba5e0f0e
[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-ar934x-wmac.h"
23
24 #define DB120_GPIO_LED_USB      11
25 #define DB120_GPIO_LED_WLAN_5G  12
26 #define DB120_GPIO_LED_WLAN_2G  13
27 #define DB120_GPIO_LED_STATUS   14
28 #define DB120_GPIO_LED_WPS      15
29
30 #define DB120_GPIO_BTN_SW1      16
31
32 #define DB120_CALDATA_OFFSET    0x1000
33 #define DB120_WMAC_MAC_OFFSET   0x1003
34
35 #define DB120_BUTTONS_POLL_INTERVAL     20
36
37 #ifdef CONFIG_MTD_PARTITIONS
38 static struct mtd_partition db120_partitions[] = {
39         {
40                 .name           = "u-boot",
41                 .offset         = 0,
42                 .size           = 0x040000,
43                 .mask_flags     = MTD_WRITEABLE,
44         }, {
45                 .name           = "u-boot-env",
46                 .offset         = 0x040000,
47                 .size           = 0x010000,
48         }, {
49                 .name           = "rootfs",
50                 .offset         = 0x050000,
51                 .size           = 0x630000,
52         }, {
53                 .name           = "uImage",
54                 .offset         = 0x680000,
55                 .size           = 0x160000,
56         }, {
57                 .name           = "NVRAM",
58                 .offset         = 0x7E0000,
59                 .size           = 0x010000,
60         }, {
61                 .name           = "ART",
62                 .offset         = 0x7F0000,
63                 .size           = 0x010000,
64                 .mask_flags     = MTD_WRITEABLE,
65         }
66 };
67 #endif /* CONFIG_MTD_PARTITIONS */
68
69 static struct flash_platform_data db120_flash_data = {
70 #ifdef CONFIG_MTD_PARTITIONS
71         .parts          = db120_partitions,
72         .nr_parts       = ARRAY_SIZE(db120_partitions),
73 #endif
74 };
75
76 static struct gpio_led db120_leds_gpio[] __initdata = {
77         {
78                 .name           = "db120:green:status",
79                 .gpio           = DB120_GPIO_LED_STATUS,
80                 .active_low     = 1,
81         }, {
82                 .name           = "db120:green:wps",
83                 .gpio           = DB120_GPIO_LED_WPS,
84                 .active_low     = 1,
85         }, {
86                 .name           = "db120:green:wlan-5g",
87                 .gpio           = DB120_GPIO_LED_WLAN_5G,
88                 .active_low     = 1,
89         }, {
90                 .name           = "db120:green:wlan-2g",
91                 .gpio           = DB120_GPIO_LED_WLAN_2G,
92                 .active_low     = 1,
93         }, {
94                 .name           = "db120:green:usb",
95                 .gpio           = DB120_GPIO_LED_USB,
96                 .active_low     = 1,
97         }
98 };
99
100 static struct gpio_button db120_gpio_buttons[] __initdata = {
101         {
102                 .desc           = "sw1",
103                 .type           = EV_KEY,
104                 .code           = BTN_0,
105                 .threshold      = 3,
106                 .gpio           = DB120_GPIO_BTN_SW1,
107                 .active_low     = 1,
108         }
109 };
110
111 static void __init db120_setup(void)
112 {
113         u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
114
115         ar71xx_add_device_usb();
116
117         ar71xx_add_device_m25p80(&db120_flash_data);
118
119         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(db120_leds_gpio),
120                                         db120_leds_gpio);
121
122         ar71xx_add_device_gpio_buttons(-1, DB120_BUTTONS_POLL_INTERVAL,
123                                         ARRAY_SIZE(db120_gpio_buttons),
124                                         db120_gpio_buttons);
125
126         ar934x_add_device_wmac(art + DB120_CALDATA_OFFSET,
127                                 art + DB120_WMAC_MAC_OFFSET);
128 }
129
130 MIPS_MACHINE(AR71XX_MACH_DB120, "DB120", "Atheros DB120", db120_setup);