| 1 | /* |
| 2 | * AWB WR6202 board support |
| 3 | * |
| 4 | * Copyright (C) 2012 Johnathan Boyce<jon.boyce@globalreach.eu.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/gpio.h> |
| 14 | |
| 15 | #include<asm/mach-ralink/machine.h> |
| 16 | #include<asm/mach-ralink/dev-gpio-buttons.h> |
| 17 | #include<asm/mach-ralink/dev-gpio-leds.h> |
| 18 | #include<asm/mach-ralink/rt305x.h> |
| 19 | #include<asm/mach-ralink/rt305x_regs.h> |
| 20 | |
| 21 | #include "devices.h" |
| 22 | |
| 23 | #define WR6202_GPIO_BUTTON_RESET 10 /* active low */ |
| 24 | #define WR6202_GPIO_BUTTON_WPS 0 /* active low */ |
| 25 | |
| 26 | #define WR6202_KEYS_POLL_INTERVAL 20 |
| 27 | #define WR6202_KEYS_DEBOUNCE_INTERVAL (3 * WR6202_KEYS_POLL_INTERVAL) |
| 28 | |
| 29 | #define WR6202_GPIO_USB_POWER 11 |
| 30 | |
| 31 | #define WR6202_GPIO_LED_3G 13 |
| 32 | #define WR6202_GPIO_LED_WPS 14 |
| 33 | |
| 34 | static struct gpio_led wr6202_leds_gpio[] __initdata = { |
| 35 | { |
| 36 | .name = "wr6202:blue:wps", |
| 37 | .gpio = WR6202_GPIO_LED_WPS, |
| 38 | .active_low = 1, |
| 39 | }, { |
| 40 | .name = "wr6202:blue:3g", |
| 41 | .gpio = WR6202_GPIO_LED_3G, |
| 42 | .active_low = 1, |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | static struct gpio_keys_button wr6202_gpio_buttons[] __initdata = { |
| 47 | { |
| 48 | .desc = "reset", |
| 49 | .type = EV_KEY, |
| 50 | .code = KEY_RESTART, |
| 51 | .debounce_interval = WR6202_KEYS_DEBOUNCE_INTERVAL, |
| 52 | .gpio = WR6202_GPIO_BUTTON_RESET, |
| 53 | .active_low = 1, |
| 54 | }, { |
| 55 | .desc = "wps", |
| 56 | .type = EV_KEY, |
| 57 | .code = KEY_WPS_BUTTON, |
| 58 | .debounce_interval = WR6202_KEYS_DEBOUNCE_INTERVAL, |
| 59 | .gpio = WR6202_GPIO_BUTTON_WPS, |
| 60 | .active_low = 1, |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | static void __init wr6202_init(void) |
| 65 | { |
| 66 | rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL; |
| 67 | |
| 68 | rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT); |
| 69 | |
| 70 | ramips_register_gpio_leds(-1, ARRAY_SIZE(wr6202_leds_gpio), |
| 71 | wr6202_leds_gpio); |
| 72 | ramips_register_gpio_buttons(-1, WR6202_KEYS_POLL_INTERVAL, |
| 73 | ARRAY_SIZE(wr6202_gpio_buttons), |
| 74 | wr6202_gpio_buttons); |
| 75 | |
| 76 | /* Power to the USB port is controlled by GPIO line */ |
| 77 | gpio_request(WR6202_GPIO_USB_POWER, "WR6202_GPIO_USB_POWER"); |
| 78 | gpio_direction_output(WR6202_GPIO_USB_POWER, 0); |
| 79 | gpio_free(WR6202_GPIO_USB_POWER); |
| 80 | |
| 81 | rt305x_register_flash(0); |
| 82 | |
| 83 | rt305x_register_ethernet(); |
| 84 | rt305x_register_wifi(); |
| 85 | rt305x_register_wdt(); |
| 86 | rt305x_register_usb(); |
| 87 | } |
| 88 | |
| 89 | MIPS_MACHINE(RAMIPS_MACH_WR6202, "WR6202", "AWB WR6202", |
| 90 | wr6202_init); |
| 91 | |