3a53e16d075dd4f2d3262a03b35dcfbcb9d84a2d
[15.05/openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-all0256n.c
1 /*
2  *  Allnet ALL0256N board support
3  *
4  *  Copyright (C) 2012 Daniel Golle <dgolle@allnet.de>
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/spi/spi.h>
14 #include <linux/spi/flash.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/mtd/physmap.h>
18
19 #include <asm/mach-ralink/machine.h>
20 #include <asm/mach-ralink/dev-gpio-buttons.h>
21 #include <asm/mach-ralink/dev-gpio-leds.h>
22 #include <asm/mach-ralink/rt305x.h>
23 #include <asm/mach-ralink/rt305x_regs.h>
24
25 #include "devices.h"
26
27 #define ALL0256N_GPIO_BUTTON_RESET 0
28 #define ALL0256N_GPIO_LED_RSSI_LOW 14
29 #define ALL0256N_GPIO_LED_RSSI_MED 12
30 #define ALL0256N_GPIO_LED_RSSI_HIGH 13
31 #define ALL0256N_BUTTONS_POLL_INTERVAL 20
32
33 static struct mtd_partition all0256n_partitions[] = {
34         {
35                 .name   = "u-boot",
36                 .offset = 0,
37                 .size   = 0x030000,
38                 .mask_flags = MTD_WRITEABLE,
39         }, {
40                 .name   = "u-boot-env",
41                 .offset = 0x030000,
42                 .size   = 0x010000,
43         }, {
44                 .name   = "factory",
45                 .offset = 0x040000,
46                 .size   = 0x010000,
47         }, {
48                 .name   = "kernel",
49                 .offset = 0x050000,
50                 .size   = 0x0D0000,
51         }, {
52                 .name   = "rootfs",
53                 .offset = 0x120000,
54                 .size   = 0x2E0000,
55         }, {
56                 .name   = "firmware",
57                 .offset = 0x050000,
58                 .size   = 0x3B0000,
59         }
60 };
61
62 const struct flash_platform_data all0256n_flash = {
63         .type           = "mx25l3205d",
64         .parts          = all0256n_partitions,
65         .nr_parts       = ARRAY_SIZE(all0256n_partitions),
66 };
67
68 struct spi_board_info all0256n_spi_slave_info[] __initdata = {
69         {
70                 .modalias       = "m25p80",
71                 .platform_data  = &all0256n_flash,
72                 .irq            = -1,
73                 .max_speed_hz   = 10000000,
74                 .bus_num        = 0,
75                 .chip_select    = 0,
76         },
77 };
78
79 static struct gpio_button all0256n_gpio_buttons[] __initdata = {
80         {
81                 .desc           = "reset",
82                 .type           = EV_KEY,
83                 .code           = KEY_RESTART,
84                 .threshold      = 3,
85                 .gpio           = ALL0256N_GPIO_BUTTON_RESET,
86                 .active_low     = 1,
87         }
88 };
89
90 static struct gpio_led all0256n_leds_gpio[] __initdata = {
91         {
92                 .name           = "all0256n:green:rssilow",
93                 .gpio           = ALL0256N_GPIO_LED_RSSI_LOW,
94                 .active_low     = 1,
95         }, {
96                 .name           = "all0256n:green:rssimed",
97                 .gpio           = ALL0256N_GPIO_LED_RSSI_MED,
98                 .active_low     = 1,
99         }, {
100                 .name           = "all0256n:green:rssihigh",
101                 .gpio           = ALL0256N_GPIO_LED_RSSI_HIGH,
102                 .active_low     = 1,
103         }
104 };
105
106 static void __init all0256n_init(void)
107 {
108         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
109         rt305x_register_spi(all0256n_spi_slave_info,
110                             ARRAY_SIZE(all0256n_spi_slave_info));
111         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
112         rt305x_register_ethernet();
113         ramips_register_gpio_leds(-1, ARRAY_SIZE(all0256n_leds_gpio),
114                                   all0256n_leds_gpio);
115         ramips_register_gpio_buttons(-1, ALL0256N_BUTTONS_POLL_INTERVAL,
116                                      ARRAY_SIZE(all0256n_gpio_buttons),
117                                      all0256n_gpio_buttons);
118         rt305x_register_wifi();
119         rt305x_register_wdt();
120 }
121
122 MIPS_MACHINE(RAMIPS_MACH_ALL0256N, "ALL0256N", "Allnet ALL0256N",
123              all0256n_init);