ar71xx: move leds-gpio device support into a spearate file
[oweals/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wnr2000.c
1 /*
2  *  NETGEAR WNR2000 board support
3  *
4  *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6  *  Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
7  *
8  *  This program is free software; you can redistribute it and/or modify it
9  *  under the terms of the GNU General Public License version 2 as published
10  *  by the Free Software Foundation.
11  */
12
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/input.h>
17
18 #include <asm/mips_machine.h>
19
20 #include <asm/mach-ar71xx/ar71xx.h>
21
22 #include "devices.h"
23 #include "dev-m25p80.h"
24 #include "dev-ar913x-wmac.h"
25 #include "dev-leds-gpio.h"
26
27 #define WNR2000_GPIO_LED_PWR_GREEN      14
28 #define WNR2000_GPIO_LED_PWR_AMBER      7
29 #define WNR2000_GPIO_LED_WPS            4
30 #define WNR2000_GPIO_LED_WLAN           6
31 #define WNR2000_GPIO_BTN_RESET          21
32 #define WNR2000_GPIO_BTN_WPS            8
33
34 #define WNR2000_BUTTONS_POLL_INTERVAL   20
35
36 #ifdef CONFIG_MTD_PARTITIONS
37 static struct mtd_partition wnr2000_partitions[] = {
38         {
39                 .name           = "u-boot",
40                 .offset         = 0,
41                 .size           = 0x040000,
42                 .mask_flags     = MTD_WRITEABLE,
43         } , {
44                 .name           = "u-boot-env",
45                 .offset         = 0x040000,
46                 .size           = 0x010000,
47         } , {
48                 .name           = "rootfs",
49                 .offset         = 0x050000,
50                 .size           = 0x240000,
51         } , {
52                 .name           = "user-config",
53                 .offset         = 0x290000,
54                 .size           = 0x010000,
55         } , {
56                 .name           = "uImage",
57                 .offset         = 0x2a0000,
58                 .size           = 0x120000,
59         } , {
60                 .name           = "language_table",
61                 .offset         = 0x3c0000,
62                 .size           = 0x020000,
63         } , {
64                 .name           = "rootfs_checksum",
65                 .offset         = 0x3e0000,
66                 .size           = 0x010000,
67         } , {
68                 .name           = "art",
69                 .offset         = 0x3f0000,
70                 .size           = 0x010000,
71                 .mask_flags     = MTD_WRITEABLE,
72         }
73 };
74 #endif /* CONFIG_MTD_PARTITIONS */
75
76 static struct flash_platform_data wnr2000_flash_data = {
77 #ifdef CONFIG_MTD_PARTITIONS
78         .parts          = wnr2000_partitions,
79         .nr_parts       = ARRAY_SIZE(wnr2000_partitions),
80 #endif
81 };
82
83 static struct gpio_led wnr2000_leds_gpio[] __initdata = {
84         {
85                 .name           = "wnr2000:green:power",
86                 .gpio           = WNR2000_GPIO_LED_PWR_GREEN,
87                 .active_low     = 1,
88         }, {
89                 .name           = "wnr2000:amber:power",
90                 .gpio           = WNR2000_GPIO_LED_PWR_AMBER,
91                 .active_low     = 1,
92         }, {
93                 .name           = "wnr2000:green:wps",
94                 .gpio           = WNR2000_GPIO_LED_WPS,
95                 .active_low     = 1,
96         }, {
97                 .name           = "wnr2000:blue:wlan",
98                 .gpio           = WNR2000_GPIO_LED_WLAN,
99                 .active_low     = 1,
100         }
101 };
102
103 static struct gpio_button wnr2000_gpio_buttons[] __initdata = {
104         {
105                 .desc           = "reset",
106                 .type           = EV_KEY,
107                 .code           = BTN_0,
108                 .threshold      = 5,
109                 .gpio           = WNR2000_GPIO_BTN_RESET,
110         }, {
111                 .desc           = "wps",
112                 .type           = EV_KEY,
113                 .code           = BTN_1,
114                 .threshold      = 5,
115                 .gpio           = WNR2000_GPIO_BTN_WPS,
116         }
117 };
118
119 static void __init wnr2000_setup(void)
120 {
121         u8 *mac = (u8 *) KSEG1ADDR(0x1fff1000);
122
123         ar71xx_set_mac_base(mac);
124         ar71xx_add_device_mdio(0x0);
125
126         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
127         ar71xx_eth0_data.phy_mask = 0xf;
128         ar71xx_eth0_data.speed = SPEED_100;
129         ar71xx_eth0_data.duplex = DUPLEX_FULL;
130         ar71xx_eth0_data.has_ar8216 = 1;
131
132         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
133         ar71xx_eth1_data.phy_mask = 0x10;
134
135         ar71xx_add_device_eth(0);
136         ar71xx_add_device_eth(1);
137
138         ar71xx_add_device_m25p80(&wnr2000_flash_data);
139
140         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
141                                         wnr2000_leds_gpio);
142
143         ar71xx_add_device_gpio_buttons(-1, WNR2000_BUTTONS_POLL_INTERVAL,
144                                         ARRAY_SIZE(wnr2000_gpio_buttons),
145                                         wnr2000_gpio_buttons);
146
147
148         ar913x_add_device_wmac();
149 }
150
151 MIPS_MACHINE(AR71XX_MACH_WNR2000, "NETGEAR WNR2000", wnr2000_setup);