ramips: add support for the Senao/EnGenius ESR-9753 board
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-esr-9753.c
1 /*
2 * Senao / EnGenius ESR-9753 board support
3 *
4 * Copyright (C) 2011 Artur Wronowski <arteqw@gmail.com>
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 ESR_9753_GPIO_LED_POWER 8
26 #define ESR_9753_GPIO_LED_WPS 14
27
28 #define ESR_9753_GPIO_BUTTON_WPS 0 /* active low */
29 #define ESR_9753_GPIO_BUTTON_RESET 10 /* active low */
30
31 #define ESR_9753_BUTTONS_POLL_INTERVAL 20
32
33 #ifdef CONFIG_MTD_PARTITIONS
34 static struct mtd_partition esr_9753_partitions[] = {
35 {
36 .name = "u-boot",
37 .offset = 0,
38 .size = 0x030000,
39 .mask_flags = MTD_WRITEABLE,
40 }, {
41 .name = "u-boot-env",
42 .offset = 0x030000,
43 .size = 0x010000,
44 .mask_flags = MTD_WRITEABLE,
45 }, {
46 .name = "factory",
47 .offset = 0x040000,
48 .size = 0x010000,
49 .mask_flags = MTD_WRITEABLE,
50 }, {
51 .name = "kernel",
52 .offset = 0x050000,
53 .size = 0x0a0000,
54 }, {
55 .name = "rootfs",
56 .offset = 0x150000,
57 .size = 0x2b0000,
58 }, {
59 .name = "firmware",
60 .offset = 0x050000,
61 .size = 0x3b0000,
62 }
63 };
64 #endif /* CONFIG_MTD_PARTITIONS */
65
66 static struct physmap_flash_data esr_9753_flash_data = {
67 #ifdef CONFIG_MTD_PARTITIONS
68 .nr_parts = ARRAY_SIZE(esr_9753_partitions),
69 .parts = esr_9753_partitions,
70 #endif
71 };
72
73 static struct gpio_led esr_9753_leds_gpio[] __initdata = {
74 {
75 .name = "esr-9753:orange:power",
76 .gpio = ESR_9753_GPIO_LED_POWER,
77 .active_low = 1,
78 }, {
79 .name = "esr-9753:orange:wps",
80 .gpio = ESR_9753_GPIO_LED_WPS,
81 .active_low = 1,
82 }
83 };
84
85 static struct gpio_button esr_9753_gpio_buttons[] __initdata = {
86 {
87 .desc = "reset",
88 .type = EV_KEY,
89 .code = KEY_RESTART,
90 .threshold = 3,
91 .gpio = ESR_9753_GPIO_BUTTON_RESET,
92 .active_low = 1,
93 }, {
94 .desc = "wps",
95 .type = EV_KEY,
96 .code = KEY_WPS_BUTTON,
97 .threshold = 3,
98 .gpio = ESR_9753_GPIO_BUTTON_WPS,
99 .active_low = 1,
100 }
101 };
102
103 static void __init esr_9753_init(void)
104 {
105 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
106
107 rt305x_register_flash(0, &esr_9753_flash_data);
108
109 ramips_register_gpio_leds(-1, ARRAY_SIZE(esr_9753_leds_gpio),
110 esr_9753_leds_gpio);
111
112 ramips_register_gpio_buttons(-1, ESR_9753_BUTTONS_POLL_INTERVAL,
113 ARRAY_SIZE(esr_9753_gpio_buttons),
114 esr_9753_gpio_buttons);
115
116 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
117 rt305x_register_ethernet();
118 rt305x_register_wifi();
119 rt305x_register_wdt();
120 }
121
122 MIPS_MACHINE(RAMIPS_MACH_ESR_9753, "ESR-9753", "Senao / EnGenius ESR-9753",
123 esr_9753_init);