8e3ed733a27ad84bea5d2045c3916ffcf4c8a26e
[librecmc/librecmc.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_BUTTONS_POLL_INTERVAL         20
30
31 static struct gpio_led wcr150gn_leds_gpio[] __initdata = {
32         {
33                 .name       = "wcr150gn:amber:user",
34                 .gpio       = WCR150GN_GPIO_LED_USER,
35                 .active_low = 1,
36         },
37         {
38                 .name       = "wcr150gn:amber:power",
39                 .gpio       = WCR150GN_GPIO_LED_POWER,
40                 .active_low = 1,
41         }
42 };
43
44 static struct gpio_button wcr150gn_gpio_buttons[] __initdata = {
45         {
46                 .desc       = "wps",
47                 .type       = EV_KEY,
48                 .code       = KEY_WPS_BUTTON,
49                 .threshold  = 3,
50                 .gpio       = WCR150GN_GPIO_BUTTON_WPS,
51                 .active_low = 1,
52         },
53         {
54                 .desc       = "reset",
55                 .type       = EV_KEY,
56                 .code       = KEY_RESTART,
57                 .threshold  = 10,
58                 .gpio       = WCR150GN_GPIO_BUTTON_RESET,
59                 .active_low = 1,
60         }
61 };
62
63 static struct mtd_partition wcr150gn_partitions[] = {
64         {
65                 .name   = "bootloader",
66                 .offset = 0,
67                 .size   = 0x030000,
68                 .mask_flags = MTD_WRITEABLE,
69         }, {
70                 .name   = "config",
71                 .offset = 0x030000,
72                 .size   = 0x040000,
73                 .mask_flags = MTD_WRITEABLE,
74         }, {
75                 .name   = "factory",
76                 .offset = 0x040000,
77                 .size   = 0x050000,
78                 .mask_flags = MTD_WRITEABLE,
79         }, {
80                 .name   = "kernel",
81                 .offset = 0x050000,
82                 .size   = 0x0d0000,
83         }, {
84                 .name   = "rootfs",
85                 .offset = 0x120000,
86                 .size   = 0x2e0000,
87         }, {
88                 .name   = "firmware",
89                 .offset = 0x050000,
90                 .size   = 0x3b0000,
91         }
92 };
93
94 static struct physmap_flash_data wcr150gn_flash_data = {
95 #ifdef CONFIG_MTD_PARTITIONS
96         .nr_parts       = ARRAY_SIZE(wcr150gn_partitions),
97         .parts          = wcr150gn_partitions,
98 #endif
99 };
100
101 static void __init wcr150gn_init(void)
102 {
103         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
104         rt305x_register_flash(0, &wcr150gn_flash_data);
105         ramips_register_gpio_leds(-1, ARRAY_SIZE(wcr150gn_leds_gpio),
106                                   wcr150gn_leds_gpio);
107         ramips_register_gpio_buttons(-1, WCR150GN_BUTTONS_POLL_INTERVAL,
108                                      ARRAY_SIZE(wcr150gn_gpio_buttons),
109                                      wcr150gn_gpio_buttons);
110         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
111         rt305x_register_ethernet();
112         rt305x_register_wifi();
113         rt305x_register_wdt();
114         rt305x_register_usb();
115 }
116
117 MIPS_MACHINE(RAMIPS_MACH_WCR150GN, "WCR150GN", "Sparklan WCR-150GN",
118              wcr150gn_init);