| 1 | /* |
| 2 | * Netcore NW718 board support |
| 3 | * |
| 4 | * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org> |
| 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/spi/spi.h> |
| 13 | |
| 14 | #include <asm/mach-ralink/machine.h> |
| 15 | #include <asm/mach-ralink/dev-gpio-buttons.h> |
| 16 | #include <asm/mach-ralink/dev-gpio-leds.h> |
| 17 | #include <asm/mach-ralink/rt305x.h> |
| 18 | #include <asm/mach-ralink/rt305x_regs.h> |
| 19 | |
| 20 | #include "devices.h" |
| 21 | |
| 22 | #define NW718_GPIO_LED_USB 8 |
| 23 | #define NW718_GPIO_LED_CPU 13 |
| 24 | #define NW718_GPIO_LED_WPS 14 |
| 25 | |
| 26 | #define NW718_GPIO_BUTTON_WPS 0 |
| 27 | #define NW718_GPIO_BUTTON_RESET 10 |
| 28 | |
| 29 | #define NW718_GPIO_SPI_CS0 3 |
| 30 | |
| 31 | #define NW718_KEYS_POLL_INTERVAL 20 |
| 32 | #define NW718_KEYS_DEBOUNCE_INTERVAL (3 * NW718_KEYS_POLL_INTERVAL) |
| 33 | |
| 34 | static struct gpio_led nw718_leds_gpio[] __initdata = { |
| 35 | { |
| 36 | .name = "nw718:amber:cpu", |
| 37 | .gpio = NW718_GPIO_LED_CPU, |
| 38 | .active_low = 1, |
| 39 | }, { |
| 40 | .name = "nw718:amber:usb", |
| 41 | .gpio = NW718_GPIO_LED_USB, |
| 42 | .active_low = 1, |
| 43 | }, { |
| 44 | .name = "nw718:amber:wps", |
| 45 | .gpio = NW718_GPIO_LED_WPS, |
| 46 | .active_low = 1, |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | static struct gpio_keys_button nw718_gpio_buttons[] __initdata = { |
| 51 | { |
| 52 | .desc = "reset", |
| 53 | .type = EV_KEY, |
| 54 | .code = KEY_RESTART, |
| 55 | .debounce_interval = NW718_KEYS_DEBOUNCE_INTERVAL, |
| 56 | .gpio = NW718_GPIO_BUTTON_RESET, |
| 57 | .active_low = 1, |
| 58 | }, { |
| 59 | .desc = "wps", |
| 60 | .type = EV_KEY, |
| 61 | .code = KEY_WPS_BUTTON, |
| 62 | .debounce_interval = NW718_KEYS_DEBOUNCE_INTERVAL, |
| 63 | .gpio = NW718_GPIO_BUTTON_WPS, |
| 64 | .active_low = 1, |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | static struct spi_board_info nw718_spi_info[] = { |
| 69 | { |
| 70 | .bus_num = 0, |
| 71 | .chip_select = 0, |
| 72 | .max_speed_hz = 25000000, |
| 73 | .modalias = "m25p80", |
| 74 | .controller_data = (void *) NW718_GPIO_SPI_CS0, |
| 75 | } |
| 76 | }; |
| 77 | |
| 78 | static void __init nw718_init(void) |
| 79 | { |
| 80 | rt305x_gpio_init(RT305X_GPIO_MODE_I2C | |
| 81 | RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT); |
| 82 | |
| 83 | rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW; |
| 84 | rt305x_register_ethernet(); |
| 85 | ramips_register_gpio_leds(-1, ARRAY_SIZE(nw718_leds_gpio), |
| 86 | nw718_leds_gpio); |
| 87 | ramips_register_gpio_buttons(-1, NW718_KEYS_POLL_INTERVAL, |
| 88 | ARRAY_SIZE(nw718_gpio_buttons), |
| 89 | nw718_gpio_buttons); |
| 90 | rt305x_register_wifi(); |
| 91 | rt305x_register_wdt(); |
| 92 | rt305x_register_spi(nw718_spi_info, ARRAY_SIZE(nw718_spi_info)); |
| 93 | rt305x_register_usb(); |
| 94 | } |
| 95 | |
| 96 | MIPS_MACHINE(RAMIPS_MACH_WHR_G300N, "NW718", "Netcore NW718", nw718_init); |
| 97 | |