[ar71xx] ap81: register GPIO LEDs
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-ap81.c
1 /*
2 * Atheros AP81 board support
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2009 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/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/input.h>
18
19 #include <asm/mips_machine.h>
20 #include <asm/mach-ar71xx/ar71xx.h>
21
22 #include "devices.h"
23
24 #define AP81_GPIO_LED_STATUS 1
25 #define AP81_GPIO_LED_AOSS 3
26 #define AP81_GPIO_LED_WLAN 6
27 #define AP81_GPIO_LED_POWER 14
28
29 #define AP81_GPIO_BTN_SW4 12
30 #define AP81_GPIO_BTN_SW1 21
31
32 #define AP81_BUTTONS_POLL_INTERVAL 20
33
34 #ifdef CONFIG_MTD_PARTITIONS
35 static struct mtd_partition ap81_partitions[] = {
36 {
37 .name = "u-boot",
38 .offset = 0,
39 .size = 0x040000,
40 .mask_flags = MTD_WRITEABLE,
41 } , {
42 .name = "u-boot-env",
43 .offset = 0x040000,
44 .size = 0x010000,
45 } , {
46 .name = "rootfs",
47 .offset = 0x050000,
48 .size = 0x500000,
49 } , {
50 .name = "uImage",
51 .offset = 0x550000,
52 .size = 0x100000,
53 } , {
54 .name = "ART",
55 .offset = 0x650000,
56 .size = 0x1b0000,
57 .mask_flags = MTD_WRITEABLE,
58 }
59 };
60 #endif /* CONFIG_MTD_PARTITIONS */
61
62 static struct flash_platform_data ap81_flash_data = {
63 #ifdef CONFIG_MTD_PARTITIONS
64 .parts = ap81_partitions,
65 .nr_parts = ARRAY_SIZE(ap81_partitions),
66 #endif
67 };
68
69 static struct spi_board_info ap81_spi_info[] = {
70 {
71 .bus_num = 0,
72 .chip_select = 0,
73 .max_speed_hz = 25000000,
74 .modalias = "m25p80",
75 .platform_data = &ap81_flash_data,
76 }
77 };
78
79 static struct gpio_led ap81_leds_gpio[] __initdata = {
80 {
81 .name = "ap81:green:status",
82 .gpio = AP81_GPIO_LED_STATUS,
83 .active_low = 1,
84 }, {
85 .name = "ap81:amber:aoss",
86 .gpio = AP81_GPIO_LED_AOSS,
87 .active_low = 1,
88 }, {
89 .name = "ap81:green:wlan",
90 .gpio = AP81_GPIO_LED_WLAN,
91 .active_low = 1,
92 }, {
93 .name = "ap81:green:power",
94 .gpio = AP81_GPIO_LED_POWER,
95 .active_low = 1,
96 }
97 };
98
99 static struct gpio_button ap81_gpio_buttons[] __initdata = {
100 {
101 .desc = "sw1",
102 .type = EV_KEY,
103 .code = BTN_0,
104 .threshold = 5,
105 .gpio = AP81_GPIO_BTN_SW1,
106 .active_low = 1,
107 } , {
108 .desc = "sw4",
109 .type = EV_KEY,
110 .code = BTN_1,
111 .threshold = 5,
112 .gpio = AP81_GPIO_BTN_SW4,
113 .active_low = 1,
114 }
115 };
116
117 static void __init ap81_setup(void)
118 {
119 ar71xx_add_device_mdio(0x0);
120
121 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
122 ar71xx_eth0_data.phy_mask = 0xf;
123 ar71xx_eth0_data.speed = SPEED_100;
124 ar71xx_eth0_data.duplex = DUPLEX_FULL;
125 ar71xx_eth0_data.has_ar8216 = 1;
126
127 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
128 ar71xx_eth1_data.phy_mask = 0x10;
129
130 ar71xx_add_device_eth(0);
131 ar71xx_add_device_eth(1);
132
133 ar71xx_add_device_usb();
134
135 ar71xx_add_device_spi(NULL, ap81_spi_info,
136 ARRAY_SIZE(ap81_spi_info));
137
138 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio),
139 ap81_leds_gpio);
140
141 ar71xx_add_device_gpio_buttons(-1, AP81_BUTTONS_POLL_INTERVAL,
142 ARRAY_SIZE(ap81_gpio_buttons),
143 ap81_gpio_buttons);
144
145 ar91xx_add_device_wmac();
146 }
147
148 MIPS_MACHINE(AR71XX_MACH_AP81, "Atheros AP81", ap81_setup);