| 1 | /* |
| 2 | * ALFA Network N2/N5 board support |
| 3 | * |
| 4 | * Copyright (C) 2011-2012 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 <asm/mach-ath79/ar71xx_regs.h> |
| 12 | #include <asm/mach-ath79/ath79.h> |
| 13 | |
| 14 | #include "common.h" |
| 15 | #include "dev-eth.h" |
| 16 | #include "dev-ap9x-pci.h" |
| 17 | #include "dev-gpio-buttons.h" |
| 18 | #include "dev-leds-gpio.h" |
| 19 | #include "dev-m25p80.h" |
| 20 | #include "machtypes.h" |
| 21 | |
| 22 | #define ALFA_NX_GPIO_LED_2 17 |
| 23 | #define ALFA_NX_GPIO_LED_3 16 |
| 24 | #define ALFA_NX_GPIO_LED_5 12 |
| 25 | #define ALFA_NX_GPIO_LED_6 8 |
| 26 | #define ALFA_NX_GPIO_LED_7 6 |
| 27 | #define ALFA_NX_GPIO_LED_8 7 |
| 28 | |
| 29 | #define ALFA_NX_GPIO_BTN_RESET 11 |
| 30 | |
| 31 | #define ALFA_NX_KEYS_POLL_INTERVAL 20 /* msecs */ |
| 32 | #define ALFA_NX_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_NX_KEYS_POLL_INTERVAL) |
| 33 | |
| 34 | #define ALFA_NX_MAC0_OFFSET 0 |
| 35 | #define ALFA_NX_MAC1_OFFSET 6 |
| 36 | #define ALFA_NX_CALDATA_OFFSET 0x1000 |
| 37 | |
| 38 | static struct gpio_keys_button alfa_nx_gpio_keys[] __initdata = { |
| 39 | { |
| 40 | .desc = "Reset button", |
| 41 | .type = EV_KEY, |
| 42 | .code = KEY_RESTART, |
| 43 | .debounce_interval = ALFA_NX_KEYS_DEBOUNCE_INTERVAL, |
| 44 | .gpio = ALFA_NX_GPIO_BTN_RESET, |
| 45 | .active_low = 1, |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | static struct gpio_led alfa_nx_leds_gpio[] __initdata = { |
| 50 | { |
| 51 | .name = "alfa:green:led_2", |
| 52 | .gpio = ALFA_NX_GPIO_LED_2, |
| 53 | .active_low = 1, |
| 54 | }, { |
| 55 | .name = "alfa:green:led_3", |
| 56 | .gpio = ALFA_NX_GPIO_LED_3, |
| 57 | .active_low = 1, |
| 58 | }, { |
| 59 | .name = "alfa:red:led_5", |
| 60 | .gpio = ALFA_NX_GPIO_LED_5, |
| 61 | .active_low = 1, |
| 62 | }, { |
| 63 | .name = "alfa:amber:led_6", |
| 64 | .gpio = ALFA_NX_GPIO_LED_6, |
| 65 | .active_low = 1, |
| 66 | }, { |
| 67 | .name = "alfa:green:led_7", |
| 68 | .gpio = ALFA_NX_GPIO_LED_7, |
| 69 | .active_low = 1, |
| 70 | }, { |
| 71 | .name = "alfa:green:led_8", |
| 72 | .gpio = ALFA_NX_GPIO_LED_8, |
| 73 | .active_low = 1, |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | static void __init alfa_nx_setup(void) |
| 78 | { |
| 79 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
| 80 | |
| 81 | ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE, |
| 82 | AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN | |
| 83 | AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN | |
| 84 | AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN | |
| 85 | AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN | |
| 86 | AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN); |
| 87 | |
| 88 | ath79_register_m25p80(NULL); |
| 89 | |
| 90 | ath79_register_leds_gpio(0, ARRAY_SIZE(alfa_nx_leds_gpio), |
| 91 | alfa_nx_leds_gpio); |
| 92 | |
| 93 | ath79_register_gpio_keys_polled(-1, ALFA_NX_KEYS_POLL_INTERVAL, |
| 94 | ARRAY_SIZE(alfa_nx_gpio_keys), |
| 95 | alfa_nx_gpio_keys); |
| 96 | |
| 97 | ath79_register_mdio(0, 0x0); |
| 98 | |
| 99 | ath79_init_mac(ath79_eth0_data.mac_addr, |
| 100 | art + ALFA_NX_MAC0_OFFSET, 0); |
| 101 | ath79_init_mac(ath79_eth1_data.mac_addr, |
| 102 | art + ALFA_NX_MAC1_OFFSET, 0); |
| 103 | |
| 104 | /* WAN port */ |
| 105 | ath79_register_eth(0); |
| 106 | /* LAN port */ |
| 107 | ath79_register_eth(1); |
| 108 | |
| 109 | ap91_pci_init(art + ALFA_NX_CALDATA_OFFSET, NULL); |
| 110 | } |
| 111 | |
| 112 | MIPS_MACHINE(ATH79_MACH_ALFA_NX, "ALFA-NX", "ALFA Network N2/N5", |
| 113 | alfa_nx_setup); |
| 114 | |