ar71xx: add support for TP-Link TL-WR902AC v1
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-ap531b0.c
1 /*
2 * Rockeetech AP531B0 11ng wireless AP board support
3 *
4 * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2016 Shuanglin Liu <roboidler@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <linux/platform_device.h>
13 #include <linux/ath9k_platform.h>
14 #include <linux/ar8216_platform.h>
15
16 #include <asm/mach-ath79/ar71xx_regs.h>
17
18 #include "common.h"
19 #include "dev-eth.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
23 #include "dev-spi.h"
24 #include "dev-usb.h"
25 #include "dev-wmac.h"
26 #include "machtypes.h"
27 #include "pci.h"
28 #include "dev-ap9x-pci.h"
29
30 #define AP531B0_GPIO_LED_WLAN 12
31 #define AP531B0_GPIO_LED_STATUS 11
32
33 #define AP531B0_GPIO_RST_BTN 17
34
35 #define AP531B0_KEYS_POLL_INTERVAL 20 /* msecs */
36 #define AP531B0_KEYS_DEBOUNCE_INTERVAL (3 * AP531B0_KEYS_POLL_INTERVAL)
37
38 #define AP531B0_WMAC_CALDATA_OFFSET 0x1000
39
40
41 static struct gpio_led ap531b0_leds_gpio[] __initdata = {
42 {
43 .name = "ap531b0:green:status",
44 .gpio = AP531B0_GPIO_LED_STATUS,
45 .active_low = 1,
46 },
47 {
48 .name = "ap531b0:green:wlan",
49 .gpio = AP531B0_GPIO_LED_WLAN,
50 .active_low = 1,
51 }
52 };
53
54 static struct gpio_keys_button ap531b0_gpio_keys[] __initdata = {
55 {
56 .desc = "reset",
57 .type = EV_KEY,
58 .code = KEY_RESTART,
59 .debounce_interval = AP531B0_KEYS_DEBOUNCE_INTERVAL,
60 .gpio = AP531B0_GPIO_RST_BTN,
61 .active_low = 1,
62 },
63 };
64
65
66 static void __init ap531b0_gpio_led_setup(void)
67 {
68
69 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap531b0_leds_gpio),
70 ap531b0_leds_gpio);
71
72 ath79_register_gpio_keys_polled(-1, AP531B0_KEYS_POLL_INTERVAL,
73 ARRAY_SIZE(ap531b0_gpio_keys),
74 ap531b0_gpio_keys);
75 }
76
77 static void __init ap531b0_setup(void)
78 {
79 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
80 u8 *pmac;
81
82 ath79_register_m25p80(NULL);
83 ap531b0_gpio_led_setup();
84 ath79_register_usb();
85 ath79_register_pci();
86
87 ath79_register_mdio(0, 0x0);
88
89 pmac = art + AP531B0_WMAC_CALDATA_OFFSET + 2;
90 ath79_init_mac(ath79_eth0_data.mac_addr, pmac, 1);
91 ath79_init_mac(ath79_eth1_data.mac_addr, pmac, 2);
92
93 ath79_register_wmac(art + AP531B0_WMAC_CALDATA_OFFSET, pmac);
94
95 /* WAN port */
96 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
97 ath79_eth0_data.speed = SPEED_100;
98 ath79_eth0_data.duplex = DUPLEX_FULL;
99 ath79_eth0_data.phy_mask = BIT(4);
100 ath79_register_eth(0);
101
102 /* LAN ports */
103 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
104 ath79_eth1_data.speed = SPEED_1000;
105 ath79_eth1_data.duplex = DUPLEX_FULL;
106 ath79_switch_data.phy_poll_mask |= BIT(4);
107 ath79_switch_data.phy4_mii_en = 1;
108 ath79_register_eth(1);
109 }
110
111 MIPS_MACHINE(ATH79_MACH_AP531B0, "AP531B0", "Rockeetech AP531B0",
112 ap531b0_setup);