| 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 | |
| 16 | #include <asm/mach-ralink/machine.h> |
| 17 | #include <asm/mach-ralink/dev-gpio-buttons.h> |
| 18 | #include <asm/mach-ralink/dev-gpio-leds.h> |
| 19 | #include <asm/mach-ralink/rt305x.h> |
| 20 | #include <asm/mach-ralink/rt305x_regs.h> |
| 21 | |
| 22 | #include "devices.h" |
| 23 | |
| 24 | #define ALL0256N_GPIO_BUTTON_RESET 0 |
| 25 | #define ALL0256N_GPIO_LED_RSSI_LOW 14 |
| 26 | #define ALL0256N_GPIO_LED_RSSI_MED 12 |
| 27 | #define ALL0256N_GPIO_LED_RSSI_HIGH 13 |
| 28 | #define ALL0256N_KEYS_POLL_INTERVAL 20 |
| 29 | #define ALL0256N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0256N_KEYS_POLL_INTERVAL) |
| 30 | |
| 31 | const struct flash_platform_data all0256n_flash = { |
| 32 | .type = "mx25l3205d", |
| 33 | }; |
| 34 | |
| 35 | struct spi_board_info all0256n_spi_slave_info[] __initdata = { |
| 36 | { |
| 37 | .modalias = "m25p80", |
| 38 | .platform_data = &all0256n_flash, |
| 39 | .irq = -1, |
| 40 | .max_speed_hz = 10000000, |
| 41 | .bus_num = 0, |
| 42 | .chip_select = 0, |
| 43 | }, |
| 44 | }; |
| 45 | |
| 46 | static struct gpio_keys_button all0256n_gpio_buttons[] __initdata = { |
| 47 | { |
| 48 | .desc = "reset", |
| 49 | .type = EV_KEY, |
| 50 | .code = KEY_RESTART, |
| 51 | .debounce_interval = ALL0256N_KEYS_DEBOUNCE_INTERVAL, |
| 52 | .gpio = ALL0256N_GPIO_BUTTON_RESET, |
| 53 | .active_low = 1, |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | static struct gpio_led all0256n_leds_gpio[] __initdata = { |
| 58 | { |
| 59 | .name = "all0256n:green:rssilow", |
| 60 | .gpio = ALL0256N_GPIO_LED_RSSI_LOW, |
| 61 | .active_low = 1, |
| 62 | }, { |
| 63 | .name = "all0256n:green:rssimed", |
| 64 | .gpio = ALL0256N_GPIO_LED_RSSI_MED, |
| 65 | .active_low = 1, |
| 66 | }, { |
| 67 | .name = "all0256n:green:rssihigh", |
| 68 | .gpio = ALL0256N_GPIO_LED_RSSI_HIGH, |
| 69 | .active_low = 1, |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | static void __init all0256n_init(void) |
| 74 | { |
| 75 | rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT); |
| 76 | rt305x_register_spi(all0256n_spi_slave_info, |
| 77 | ARRAY_SIZE(all0256n_spi_slave_info)); |
| 78 | rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_NONE; |
| 79 | rt305x_register_ethernet(); |
| 80 | ramips_register_gpio_leds(-1, ARRAY_SIZE(all0256n_leds_gpio), |
| 81 | all0256n_leds_gpio); |
| 82 | ramips_register_gpio_buttons(-1, ALL0256N_KEYS_POLL_INTERVAL, |
| 83 | ARRAY_SIZE(all0256n_gpio_buttons), |
| 84 | all0256n_gpio_buttons); |
| 85 | rt305x_register_wifi(); |
| 86 | rt305x_register_wdt(); |
| 87 | } |
| 88 | |
| 89 | MIPS_MACHINE(RAMIPS_MACH_ALL0256N, "ALL0256N", "Allnet ALL0256N", |
| 90 | all0256n_init); |
| 91 | |