2 * Netcore NW718 board support
4 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
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.
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/spi/spi.h>
16 #include <linux/spi/flash.h>
18 #include <asm/mach-ralink/machine.h>
19 #include <asm/mach-ralink/dev-gpio-buttons.h>
20 #include <asm/mach-ralink/dev-gpio-leds.h>
21 #include <asm/mach-ralink/rt305x.h>
22 #include <asm/mach-ralink/rt305x_regs.h>
26 #define NW718_GPIO_LED_USB 8
27 #define NW718_GPIO_LED_CPU 13
28 #define NW718_GPIO_LED_WPS 14
30 #define NW718_GPIO_BUTTON_WPS 0
31 #define NW718_GPIO_BUTTON_RESET 10
33 #define NW718_GPIO_SPI_CS0 3
34 #define NW718_GPIO_SPI_SCK 4
35 #define NW718_GPIO_SPI_MOSI 5
36 #define NW718_GPIO_SPI_MISO 6
38 #define NW718_BUTTONS_POLL_INTERVAL 20
40 #ifdef CONFIG_MTD_PARTITIONS
41 static struct mtd_partition nw718_partitions
[] = {
46 .mask_flags
= MTD_WRITEABLE
,
51 .mask_flags
= MTD_WRITEABLE
,
56 .mask_flags
= MTD_WRITEABLE
,
71 #define nw718_nr_parts ARRAY_SIZE(nw718_partitions)
73 #define nw718_nr_parts 0
74 #define nw718_partitions NULL
75 #endif /* CONFIG_MTD_PARTITIONS */
77 static struct flash_platform_data nw718_flash_data
= {
78 .nr_parts
= nw718_nr_parts
,
79 .parts
= nw718_partitions
,
82 static struct gpio_led nw718_leds_gpio
[] __initdata
= {
84 .name
= "nw718:amber:cpu",
85 .gpio
= NW718_GPIO_LED_CPU
,
88 .name
= "nw718:amber:usb",
89 .gpio
= NW718_GPIO_LED_USB
,
92 .name
= "nw718:amber:wps",
93 .gpio
= NW718_GPIO_LED_WPS
,
98 static struct gpio_button nw718_gpio_buttons
[] __initdata
= {
104 .gpio
= NW718_GPIO_BUTTON_RESET
,
109 .code
= KEY_WPS_BUTTON
,
111 .gpio
= NW718_GPIO_BUTTON_WPS
,
116 static struct spi_board_info nw718_spi_info
[] = {
120 .max_speed_hz
= 25000000,
121 .modalias
= "m25p80",
122 .platform_data
= &nw718_flash_data
,
123 .controller_data
= (void *) NW718_GPIO_SPI_CS0
,
127 static void __init
nw718_init(void)
129 rt305x_gpio_init(RT305X_GPIO_MODE_I2C
|
130 RT305X_GPIO_MODE_GPIO
<< RT305X_GPIO_MODE_UART0_SHIFT
);
132 rt305x_esw_data
.vlan_config
= RT305X_ESW_VLAN_CONFIG_LLLLW
;
133 rt305x_register_ethernet();
134 ramips_register_gpio_leds(-1, ARRAY_SIZE(nw718_leds_gpio
),
136 ramips_register_gpio_buttons(-1, NW718_BUTTONS_POLL_INTERVAL
,
137 ARRAY_SIZE(nw718_gpio_buttons
),
139 rt305x_register_wifi();
140 rt305x_register_wdt();
141 rt305x_register_spi(nw718_spi_info
, ARRAY_SIZE(nw718_spi_info
));
144 MIPS_MACHINE(RAMIPS_MACH_WHR_G300N
, "NW718", "Netcore NW718", nw718_init
);