| 1 | /* |
| 2 | * Redwave RW2458N support |
| 3 | * |
| 4 | * Copyright (C) 2011-2012 Cezary Jackiewicz <cezary@eko.one.pl> |
| 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 <asm/mach-ath79/ath79.h> |
| 12 | |
| 13 | #include "dev-eth.h" |
| 14 | #include "dev-ap9x-pci.h" |
| 15 | #include "dev-gpio-buttons.h" |
| 16 | #include "dev-leds-gpio.h" |
| 17 | #include "dev-m25p80.h" |
| 18 | #include "dev-usb.h" |
| 19 | #include "machtypes.h" |
| 20 | |
| 21 | #define RW2458N_GPIO_LED_D3 1 |
| 22 | #define RW2458N_GPIO_LED_D4 0 |
| 23 | #define RW2458N_GPIO_LED_D5 11 |
| 24 | #define RW2458N_GPIO_LED_D6 7 |
| 25 | #define RW2458N_GPIO_BTN_RESET 12 |
| 26 | |
| 27 | #define RW2458N_KEYS_POLL_INTERVAL 20 /* msecs */ |
| 28 | #define RW2458N_KEYS_DEBOUNCE_INTERVAL (3 * RW2458N_KEYS_POLL_INTERVAL) |
| 29 | |
| 30 | static struct gpio_keys_button rw2458n_gpio_keys[] __initdata = { |
| 31 | { |
| 32 | .desc = "reset", |
| 33 | .type = EV_KEY, |
| 34 | .code = KEY_RESTART, |
| 35 | .debounce_interval = RW2458N_KEYS_DEBOUNCE_INTERVAL, |
| 36 | .gpio = RW2458N_GPIO_BTN_RESET, |
| 37 | .active_low = 1, |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | #define RW2458N_WAN_PHYMASK BIT(4) |
| 42 | |
| 43 | static struct gpio_led rw2458n_leds_gpio[] __initdata = { |
| 44 | { |
| 45 | .name = "rw2458n:green:d3", |
| 46 | .gpio = RW2458N_GPIO_LED_D3, |
| 47 | .active_low = 1, |
| 48 | }, { |
| 49 | .name = "rw2458n:green:d4", |
| 50 | .gpio = RW2458N_GPIO_LED_D4, |
| 51 | .active_low = 1, |
| 52 | }, { |
| 53 | .name = "rw2458n:green:d5", |
| 54 | .gpio = RW2458N_GPIO_LED_D5, |
| 55 | .active_low = 1, |
| 56 | }, { |
| 57 | .name = "rw2458n:green:d6", |
| 58 | .gpio = RW2458N_GPIO_LED_D6, |
| 59 | .active_low = 1, |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | static const char *rw2458n_part_probes[] = { |
| 64 | "RedBoot", |
| 65 | NULL, |
| 66 | }; |
| 67 | |
| 68 | static struct flash_platform_data rw2458n_flash_data = { |
| 69 | .part_probes = rw2458n_part_probes, |
| 70 | }; |
| 71 | |
| 72 | static void __init rw2458n_setup(void) |
| 73 | { |
| 74 | u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000); |
| 75 | u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN); |
| 76 | u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
| 77 | |
| 78 | ath79_register_m25p80(&rw2458n_flash_data); |
| 79 | |
| 80 | ath79_register_mdio(0, ~RW2458N_WAN_PHYMASK); |
| 81 | |
| 82 | ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); |
| 83 | ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0); |
| 84 | |
| 85 | ath79_register_eth(0); |
| 86 | ath79_register_eth(1); |
| 87 | |
| 88 | ap91_pci_init(ee, NULL); |
| 89 | |
| 90 | ath79_register_leds_gpio(-1, ARRAY_SIZE(rw2458n_leds_gpio), |
| 91 | rw2458n_leds_gpio); |
| 92 | |
| 93 | ath79_register_gpio_keys_polled(-1, RW2458N_KEYS_POLL_INTERVAL, |
| 94 | ARRAY_SIZE(rw2458n_gpio_keys), |
| 95 | rw2458n_gpio_keys); |
| 96 | ath79_register_usb(); |
| 97 | } |
| 98 | |
| 99 | MIPS_MACHINE(ATH79_MACH_RW2458N, "RW2458N", "Redwave RW2458N", |
| 100 | rw2458n_setup); |
| 101 | |