2 * 8devices Carambola2 board support
4 * Copyright (C) 2013 Darius Augulis <darius@8devices.com>
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.
11 #include <asm/mach-ath79/ath79.h>
12 #include <asm/mach-ath79/ar71xx_regs.h>
15 #include "dev-gpio-buttons.h"
16 #include "dev-leds-gpio.h"
17 #include "dev-m25p80.h"
21 #include "machtypes.h"
23 #define CARAMBOLA2_GPIO_LED_WLAN 0
24 #define CARAMBOLA2_GPIO_LED_ETH0 14
25 #define CARAMBOLA2_GPIO_LED_ETH1 13
27 #define CARAMBOLA2_GPIO_BTN_JUMPSTART 11
28 #define CARAMBOLA2_GPIO_BTN_RESET 12
30 #define CARAMBOLA2_KEYS_POLL_INTERVAL 20 /* msecs */
31 #define CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL (3 * CARAMBOLA2_KEYS_POLL_INTERVAL)
33 #define CARAMBOLA2_MAC0_OFFSET 0x0000
34 #define CARAMBOLA2_MAC1_OFFSET 0x0006
35 #define CARAMBOLA2_CALDATA_OFFSET 0x1000
36 #define CARAMBOLA2_WMAC_MAC_OFFSET 0x1002
38 static struct gpio_led carambola2_leds_gpio[] __initdata = {
40 .name = "carambola2:green:wlan",
41 .gpio = CARAMBOLA2_GPIO_LED_WLAN,
44 .name = "carambola2:orange:eth0",
45 .gpio = CARAMBOLA2_GPIO_LED_ETH0,
48 .name = "carambola2:orange:eth1",
49 .gpio = CARAMBOLA2_GPIO_LED_ETH1,
54 static struct gpio_keys_button carambola2_gpio_keys[] __initdata = {
56 .desc = "jumpstart button",
58 .code = KEY_WPS_BUTTON,
59 .debounce_interval = CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL,
60 .gpio = CARAMBOLA2_GPIO_BTN_JUMPSTART,
64 .desc = "reset button",
67 .debounce_interval = CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL,
68 .gpio = CARAMBOLA2_GPIO_BTN_RESET,
73 static void __init carambola2_common_setup(void)
75 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
77 ath79_register_m25p80(NULL);
78 ath79_register_wmac(art + CARAMBOLA2_CALDATA_OFFSET,
79 art + CARAMBOLA2_WMAC_MAC_OFFSET);
81 ath79_setup_ar933x_phy4_switch(true, true);
83 ath79_init_mac(ath79_eth0_data.mac_addr, art + CARAMBOLA2_MAC0_OFFSET, 0);
84 ath79_init_mac(ath79_eth1_data.mac_addr, art + CARAMBOLA2_MAC1_OFFSET, 0);
86 ath79_register_mdio(0, 0x0);
89 ath79_register_eth(1);
92 ath79_register_eth(0);
95 static void __init carambola2_setup(void)
97 carambola2_common_setup();
99 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
100 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
101 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
102 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
103 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
105 ath79_register_leds_gpio(-1, ARRAY_SIZE(carambola2_leds_gpio),
106 carambola2_leds_gpio);
107 ath79_register_gpio_keys_polled(-1, CARAMBOLA2_KEYS_POLL_INTERVAL,
108 ARRAY_SIZE(carambola2_gpio_keys),
109 carambola2_gpio_keys);
110 ath79_register_usb();
113 MIPS_MACHINE(ATH79_MACH_CARAMBOLA2, "CARAMBOLA2", "8devices Carambola2 board",