ar71xx: move leds-gpio device support into a spearate file
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-dir-615-c1.c
1 /*
2 * D-Link DIR-615 rev C1 board support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 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/input.h>
16
17 #include <asm/mips_machine.h>
18 #include <asm/mach-ar71xx/ar71xx.h>
19
20 #include "devices.h"
21 #include "dev-m25p80.h"
22 #include "dev-ar913x-wmac.h"
23 #include "dev-leds-gpio.h"
24
25 #define DIR_615C1_GPIO_LED_ORANGE_STATUS 1 /* ORANGE:STATUS:TRICOLOR */
26 #define DIR_615C1_GPIO_LED_BLUE_WPS 3 /* BLUE:WPS */
27 #define DIR_615C1_GPIO_LED_GREEN_WAN 4 /* GREEN:WAN:TRICOLOR */
28 #define DIR_615C1_GPIO_LED_GREEN_WANCPU 5 /* GREEN:WAN:CPU:TRICOLOR */
29 #define DIR_615C1_GPIO_LED_GREEN_WLAN 6 /* GREEN:WLAN */
30 #define DIR_615C1_GPIO_LED_GREEN_STATUS 14 /* GREEN:STATUS:TRICOLOR */
31 #define DIR_615C1_GPIO_LED_ORANGE_WAN 15 /* ORANGE:WAN:TRICOLOR */
32
33 /* buttons may need refinement */
34
35 #define DIR_615C1_GPIO_BTN_WPS 12
36 #define DIR_615C1_GPIO_BTN_RESET 21
37
38 #define DIR_615C1_BUTTONS_POLL_INTERVAL 20
39
40 #ifdef CONFIG_MTD_PARTITIONS
41 static struct mtd_partition dir_615c1_partitions[] = {
42 {
43 .name = "u-boot",
44 .offset = 0,
45 .size = 0x020000,
46 .mask_flags = MTD_WRITEABLE,
47 } , {
48 .name = "config",
49 .offset = 0x020000,
50 .size = 0x010000,
51 } , {
52 .name = "kernel",
53 .offset = 0x030000,
54 .size = 0x0d0000,
55 } , {
56 .name = "rootfs",
57 .offset = 0x100000,
58 .size = 0x2f0000,
59 } , {
60 .name = "art",
61 .offset = 0x3f0000,
62 .size = 0x010000,
63 .mask_flags = MTD_WRITEABLE,
64 } , {
65 .name = "firmware",
66 .offset = 0x030000,
67 .size = 0x3c0000,
68 }
69 };
70 #endif /* CONFIG_MTD_PARTITIONS */
71
72 static struct flash_platform_data dir_615c1_flash_data = {
73 #ifdef CONFIG_MTD_PARTITIONS
74 .parts = dir_615c1_partitions,
75 .nr_parts = ARRAY_SIZE(dir_615c1_partitions),
76 #endif
77 };
78
79 static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
80 {
81 .name = "dir-615c1:orange:status",
82 .gpio = DIR_615C1_GPIO_LED_ORANGE_STATUS,
83 .active_low = 1,
84 }, {
85 .name = "dir-615c1:blue:wps",
86 .gpio = DIR_615C1_GPIO_LED_BLUE_WPS,
87 .active_low = 1,
88 }, {
89 .name = "dir-615c1:green:wan",
90 .gpio = DIR_615C1_GPIO_LED_GREEN_WAN,
91 .active_low = 1,
92 }, {
93 .name = "dir-615c1:green:wancpu",
94 .gpio = DIR_615C1_GPIO_LED_GREEN_WANCPU,
95 .active_low = 1,
96 }, {
97 .name = "dir-615c1:green:wlan",
98 .gpio = DIR_615C1_GPIO_LED_GREEN_WLAN,
99 .active_low = 1,
100 }, {
101 .name = "dir-615c1:green:status",
102 .gpio = DIR_615C1_GPIO_LED_GREEN_STATUS,
103 .active_low = 1,
104 }, {
105 .name = "dir-615c1:orange:wan",
106 .gpio = DIR_615C1_GPIO_LED_ORANGE_WAN,
107 .active_low = 1,
108 }
109
110 };
111
112 static struct gpio_button dir_615c1_gpio_buttons[] __initdata = {
113 {
114 .desc = "reset",
115 .type = EV_KEY,
116 .code = BTN_0,
117 .threshold = 5,
118 .gpio = DIR_615C1_GPIO_BTN_RESET,
119 }, {
120 .desc = "wps",
121 .type = EV_KEY,
122 .code = BTN_1,
123 .threshold = 5,
124 .gpio = DIR_615C1_GPIO_BTN_WPS,
125 }
126 };
127
128 static void __init dir_615c1_setup(void)
129 {
130 ar71xx_add_device_mdio(0x0);
131
132 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
133 ar71xx_eth0_data.phy_mask = 0xf;
134 ar71xx_eth0_data.speed = SPEED_100;
135 ar71xx_eth0_data.duplex = DUPLEX_FULL;
136
137 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
138 ar71xx_eth1_data.phy_mask = 0x10;
139
140 ar71xx_add_device_eth(0);
141 ar71xx_add_device_eth(1);
142
143 ar71xx_add_device_m25p80(&dir_615c1_flash_data);
144
145 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
146 dir_615c1_leds_gpio);
147
148 ar71xx_add_device_gpio_buttons(-1, DIR_615C1_BUTTONS_POLL_INTERVAL,
149 ARRAY_SIZE(dir_615c1_gpio_buttons),
150 dir_615c1_gpio_buttons);
151
152 ar913x_add_device_wmac();
153 }
154
155 MIPS_MACHINE(AR71XX_MACH_DIR_615_C1, "D-Link DIR-615 rev. C1", dir_615c1_setup);