ar71xx: add support for YunCore CPE830
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-antrouter-r1.c
1 /*
2 * Bitmain Antrouter R1 board support
3 *
4 * Copyright (C) 2015 L. D. Pinney <ldpinney@gmail.com>
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 <linux/gpio.h>
12
13 #include <asm/mach-ath79/ath79.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
15
16 #include "common.h"
17 #include "dev-eth.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
21 #include "dev-wmac.h"
22 #include "machtypes.h"
23 #include "dev-usb.h"
24
25 #define ANTROUTER_R1_GPIO_BTN_RESET 11
26
27 #define ANTROUTER_R1_GPIO_LED_WLAN 0
28 #define ANTROUTER_R1_GPIO_LED_BTC 22
29 #define ANTROUTER_R1_GPIO_USB_POWER 18
30
31 #define ANTROUTER_R1_KEYSPOLL_INTERVAL 44 /* msecs */
32 #define ANTROUTER_R1_KEYSDEBOUNCE_INTERVAL (4 * ANTROUTER_R1_KEYSPOLL_INTERVAL)
33
34 static const char *ANTROUTER_R1_part_probes[] = {
35 "tp-link",
36 NULL,
37 };
38
39 static struct flash_platform_data ANTROUTER_R1_flash_data = {
40 .part_probes = ANTROUTER_R1_part_probes,
41 };
42
43 static struct gpio_led ANTROUTER_R1_leds_gpio[] __initdata = {
44 {
45 .name = "antrouter-r1:green:wlan",
46 .gpio = ANTROUTER_R1_GPIO_LED_WLAN,
47 .active_low = 0,
48 },{
49 .name = "antrouter-r1:green:system",
50 .gpio = ANTROUTER_R1_GPIO_LED_BTC,
51 .active_low = 0,
52 },
53 };
54
55 static struct gpio_keys_button ANTROUTER_R1_GPIO_keys[] __initdata = {
56 {
57 .desc = "reset",
58 .type = EV_KEY,
59 .code = KEY_RESTART,
60 .debounce_interval = ANTROUTER_R1_KEYSDEBOUNCE_INTERVAL,
61 .gpio = ANTROUTER_R1_GPIO_BTN_RESET,
62 .active_low = 0,
63 },
64 };
65
66 static void __init antrouter_r1_setup(void)
67 {
68 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
69 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
70
71 /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
72 ath79_setup_ar933x_phy4_switch(false, false);
73
74 ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTROUTER_R1_leds_gpio),
75 ANTROUTER_R1_leds_gpio);
76
77 ath79_register_gpio_keys_polled(-1, ANTROUTER_R1_KEYSPOLL_INTERVAL,
78 ARRAY_SIZE(ANTROUTER_R1_GPIO_keys),
79 ANTROUTER_R1_GPIO_keys);
80
81 gpio_request_one(ANTROUTER_R1_GPIO_USB_POWER,
82 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
83 "USB power");
84 ath79_register_usb();
85
86 ath79_register_m25p80(&ANTROUTER_R1_flash_data);
87 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
88 ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
89
90 ath79_register_mdio(0, 0x0);
91 ath79_register_eth(0);
92 ath79_register_eth(1);
93
94 ath79_register_wmac(ee, mac);
95 }
96
97 MIPS_MACHINE(ATH79_MACH_ANTROUTER_R1, "ANTROUTER-R1",
98 "Antrouter-R1", antrouter_r1_setup);