ar71xx: Add support for AirTight Networks C-55
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-c55.c
1 /*
2 * AirTight Networks C-55 board support
3 *
4 * Copyright (C) 2014-2015 Chris Blake <chrisrblake93@gmail.com>
5 *
6 * Based on Senao CAP4200AG board support
7 *
8 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 */
14
15 #include <linux/pci.h>
16 #include <linux/phy.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/platform_device.h>
21 #include <linux/ath9k_platform.h>
22
23 #include <asm/mach-ath79/ar71xx_regs.h>
24
25 #include "common.h"
26 #include "pci.h"
27 #include "dev-ap9x-pci.h"
28 #include "dev-eth.h"
29 #include "dev-gpio-buttons.h"
30 #include "dev-leds-gpio.h"
31 #include "dev-m25p80.h"
32 #include "dev-spi.h"
33 #include "dev-wmac.h"
34 #include "machtypes.h"
35
36 #define C55_GPIO_LED_PWR_GREEN 12
37 #define C55_GPIO_LED_PWR_AMBER 13
38 #define C55_GPIO_LED_LAN_GREEN 14
39 #define C55_GPIO_LED_LAN_AMBER 15
40 #define C55_GPIO_LED_WLAN_GREEN 18
41 #define C55_GPIO_LED_WLAN_AMBER 19
42
43 #define C55_GPIO_BTN_RESET 17
44
45 #define C55_KEYS_POLL_INTERVAL 20 /* msecs */
46 #define C55_KEYS_DEBOUNCE_INTERVAL (3 * C55_KEYS_POLL_INTERVAL)
47
48 #define C55_MAC_OFFSET 0
49 #define C55_WMAC_CALDATA_OFFSET 0x1000
50 #define C55_PCIE_CALDATA_OFFSET 0x5000
51
52 static struct gpio_led c55_leds_gpio[] __initdata = {
53 {
54 .name = "c-55:green:pwr",
55 .gpio = C55_GPIO_LED_PWR_GREEN,
56 .active_low = 1,
57 },
58 {
59 .name = "c-55:amber:pwr",
60 .gpio = C55_GPIO_LED_PWR_AMBER,
61 .active_low = 1,
62 },
63 {
64 .name = "c-55:green:lan",
65 .gpio = C55_GPIO_LED_LAN_GREEN,
66 .active_low = 1,
67 },
68 {
69 .name = "c-55:amber:lan",
70 .gpio = C55_GPIO_LED_LAN_AMBER,
71 .active_low = 1,
72 },
73 {
74 .name = "c-55:green:wlan",
75 .gpio = C55_GPIO_LED_WLAN_GREEN,
76 .active_low = 1,
77 },
78 {
79 .name = "c-55:amber:wlan",
80 .gpio = C55_GPIO_LED_WLAN_AMBER,
81 .active_low = 1,
82 },
83 };
84
85 static struct gpio_keys_button c55_gpio_keys[] __initdata = {
86 {
87 .desc = "Reset button",
88 .type = EV_KEY,
89 .code = KEY_RESTART,
90 .debounce_interval = C55_KEYS_DEBOUNCE_INTERVAL,
91 .gpio = C55_GPIO_BTN_RESET,
92 .active_low = 1,
93 },
94 };
95
96 static void __init c55_setup(void)
97 {
98 /* SPI Storage*/
99 ath79_register_m25p80_large(NULL);
100
101 /* MDIO Interface */
102 ath79_register_mdio(0, 0x0);
103
104 /* AR8035-A Ethernet */
105 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
106 AR934X_ETH_CFG_SW_ONLY_MODE);
107 ath79_init_mac(ath79_eth0_data.mac_addr, NULL, 0);
108 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
109 ath79_eth0_data.phy_mask = BIT(0);
110 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
111 ath79_eth0_pll_data.pll_1000 = 0x06000000;
112 ath79_register_eth(0);
113
114 /* LEDs & GPIO */
115 ath79_gpio_output_select(C55_GPIO_LED_LAN_GREEN,
116 AR934X_GPIO_OUT_GPIO);
117 ath79_gpio_output_select(C55_GPIO_LED_LAN_AMBER,
118 AR934X_GPIO_OUT_GPIO);
119 ath79_register_leds_gpio(-1, ARRAY_SIZE(c55_leds_gpio),
120 c55_leds_gpio);
121 ath79_register_gpio_keys_polled(-1, C55_KEYS_POLL_INTERVAL,
122 ARRAY_SIZE(c55_gpio_keys),
123 c55_gpio_keys);
124
125 /* WiFi */
126 ath79_wmac_disable_2ghz();
127 ath79_register_wmac_simple();
128 ap91_pci_init_simple();
129
130 }
131 MIPS_MACHINE(ATH79_MACH_C55, "C-55", "AirTight Networks C-55",
132 c55_setup);