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