1c0667b065c83ea84495644e078d64539cce917c
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-wcr150gn.c
1 /*
2  *  Sparklan WCR-150GN board support
3  *
4  *  Copyright (C) 2010 Roman Yeryomin <roman@advem.lv>
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/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16
17 #include <asm/mach-ralink/machine.h>
18 #include <asm/mach-ralink/dev-gpio-buttons.h>
19 #include <asm/mach-ralink/dev-gpio-leds.h>
20 #include <asm/mach-ralink/rt305x.h>
21 #include <asm/mach-ralink/rt305x_regs.h>
22
23 #include "devices.h"
24
25 #define WCR150GN_GPIO_LED_USER                 12
26 #define WCR150GN_GPIO_LED_POWER                        8
27 #define WCR150GN_GPIO_BUTTON_WPS               10
28 #define WCR150GN_GPIO_BUTTON_RESET             0
29 #define WCR150GN_KEYS_POLL_INTERVAL     20
30 #define WCR150GN_KEYS_DEBOUNCE_INTERVAL (3 * WCR150GN_KEYS_POLL_INTERVAL)
31
32 static struct gpio_led wcr150gn_leds_gpio[] __initdata = {
33         {
34                 .name       = "wcr150gn:amber:user",
35                 .gpio       = WCR150GN_GPIO_LED_USER,
36                 .active_low = 1,
37         },
38         {
39                 .name       = "wcr150gn:amber:power",
40                 .gpio       = WCR150GN_GPIO_LED_POWER,
41                 .active_low = 1,
42         }
43 };
44
45 static struct gpio_keys_button wcr150gn_gpio_buttons[] __initdata = {
46         {
47                 .desc       = "wps",
48                 .type       = EV_KEY,
49                 .code       = KEY_WPS_BUTTON,
50                 .debounce_interval = WCR150GN_KEYS_DEBOUNCE_INTERVAL,
51                 .gpio       = WCR150GN_GPIO_BUTTON_WPS,
52                 .active_low = 1,
53         },
54         {
55                 .desc       = "reset",
56                 .type       = EV_KEY,
57                 .code       = KEY_RESTART,
58                 .debounce_interval = WCR150GN_KEYS_DEBOUNCE_INTERVAL,
59                 .gpio       = WCR150GN_GPIO_BUTTON_RESET,
60                 .active_low = 1,
61         }
62 };
63
64 static struct mtd_partition wcr150gn_partitions[] = {
65         {
66                 .name   = "bootloader",
67                 .offset = 0,
68                 .size   = 0x030000,
69                 .mask_flags = MTD_WRITEABLE,
70         }, {
71                 .name   = "config",
72                 .offset = 0x030000,
73                 .size   = 0x040000,
74                 .mask_flags = MTD_WRITEABLE,
75         }, {
76                 .name   = "factory",
77                 .offset = 0x040000,
78                 .size   = 0x050000,
79                 .mask_flags = MTD_WRITEABLE,
80         }, {
81                 .name   = "kernel",
82                 .offset = 0x050000,
83                 .size   = 0x0d0000,
84         }, {
85                 .name   = "rootfs",
86                 .offset = 0x120000,
87                 .size   = 0x2e0000,
88         }, {
89                 .name   = "firmware",
90                 .offset = 0x050000,
91                 .size   = 0x3b0000,
92         }
93 };
94
95 static void __init wcr150gn_init(void)
96 {
97         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
98
99         rt305x_flash0_data.nr_parts = ARRAY_SIZE(wcr150gn_partitions);
100         rt305x_flash0_data.parts = wcr150gn_partitions;
101         rt305x_register_flash(0);
102
103         ramips_register_gpio_leds(-1, ARRAY_SIZE(wcr150gn_leds_gpio),
104                                   wcr150gn_leds_gpio);
105         ramips_register_gpio_buttons(-1, WCR150GN_KEYS_POLL_INTERVAL,
106                                      ARRAY_SIZE(wcr150gn_gpio_buttons),
107                                      wcr150gn_gpio_buttons);
108         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
109         rt305x_register_ethernet();
110         rt305x_register_wifi();
111         rt305x_register_wdt();
112         rt305x_register_usb();
113 }
114
115 MIPS_MACHINE(RAMIPS_MACH_WCR150GN, "WCR150GN", "Sparklan WCR-150GN",
116              wcr150gn_init);