1/* 2 * AnonaBox QCA9531 board support 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 as published 6 * by the Free Software Foundation. 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20#include <linux/platform_device.h> 21#include <linux/ath9k_platform.h> 22#include <linux/ar8216_platform.h> 23 24#include <asm/mach-ath79/ar71xx_regs.h> 25 26#include "common.h" 27#include "dev-eth.h" 28#include "dev-gpio-buttons.h" 29#include "dev-leds-gpio.h" 30#include "dev-m25p80.h" 31#include "dev-spi.h" 32#include "dev-usb.h" 33#include "dev-wmac.h" 34#include "machtypes.h" 35 36#define ANONABOX_PRO_GPIO_LED_STATUS 14 37 38#define ANONABOX_PRO_GPIO_BTN_RST 17 39 40#define ANONABOX_PRO_KEYS_POLL_INTERVAL 20 /* msecs */ 41#define ANONABOX_PRO_KEYS_DEBOUNCE_INTERVAL (3 * ANONABOX_PRO_KEYS_POLL_INTERVAL) 42 43#define ANONABOX_PRO_MAC0_OFFSET 0 44#define ANONABOX_PRO_MAC1_OFFSET 6 45#define ANONABOX_PRO_WMAC_CALDATA_OFFSET 0x1000 46 47static struct gpio_led anonabox_pro_leds_gpio[] __initdata = { 48 { 49 .name = "anonabox_pro:green:status", 50 .gpio = ANONABOX_PRO_GPIO_LED_STATUS, 51 .active_low = 1, 52 }, 53}; 54 55static struct gpio_keys_button anonabox_pro_gpio_keys[] __initdata = { 56 { 57 .desc = "reset button", 58 .type = EV_KEY, 59 .code = KEY_RESTART, 60 .debounce_interval = ANONABOX_PRO_KEYS_DEBOUNCE_INTERVAL, 61 .gpio = ANONABOX_PRO_GPIO_BTN_RST, 62 .active_low = 1, 63 }, 64}; 65 66static void __init anonabox_pro_gpio_led_setup(void) 67{ 68 ath79_register_leds_gpio(-1, ARRAY_SIZE(anonabox_pro_leds_gpio), 69 anonabox_pro_leds_gpio); 70 ath79_register_gpio_keys_polled(-1, ANONABOX_PRO_KEYS_POLL_INTERVAL, 71 ARRAY_SIZE(anonabox_pro_gpio_keys), 72 anonabox_pro_gpio_keys); 73} 74 75static void __init anonabox_pro_setup(void) 76{ 77 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); 78 79 ath79_register_m25p80(NULL); 80 81 anonabox_pro_gpio_led_setup(); 82 83 ath79_register_usb(); 84 85 ath79_register_wmac(art + ANONABOX_PRO_WMAC_CALDATA_OFFSET, NULL); 86 87 ath79_register_mdio(0, 0x0); 88 ath79_register_mdio(1, 0x0); 89 90 ath79_init_mac(ath79_eth0_data.mac_addr, art + ANONABOX_PRO_MAC0_OFFSET, 0); 91 ath79_init_mac(ath79_eth1_data.mac_addr, art + ANONABOX_PRO_MAC1_OFFSET, 0); 92 93 /* WAN port */ 94 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; 95 ath79_eth0_data.speed = SPEED_100; 96 ath79_eth0_data.duplex = DUPLEX_FULL; 97 ath79_eth0_data.phy_mask = BIT(4); 98 ath79_register_eth(0); 99 100 /* LAN ports */ 101 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; 102 ath79_eth1_data.speed = SPEED_1000; 103 ath79_eth1_data.duplex = DUPLEX_FULL; 104 ath79_switch_data.phy_poll_mask |= BIT(4); 105 ath79_switch_data.phy4_mii_en = 1; 106 ath79_register_eth(1); 107} 108 109MIPS_MACHINE(ATH79_MACH_ANONABOX_PRO, "ANONABOX_PRO", "Anonabox QCA9531", 110 anonabox_pro_setup); 111