ar71xx:add support for E750G v8
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-e750g-v8.c
1 /*
2 * Qxwlan E750G v8 board support
3 *
4 * Copyright (C) 2017 Peng Zhang <sd20@qxwlan.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/phy.h>
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 "pci.h"
20 #include "dev-ap9x-pci.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-eth.h"
23 #include "dev-usb.h"
24 #include "dev-leds-gpio.h"
25 #include "dev-m25p80.h"
26 #include "dev-spi.h"
27 #include "dev-wmac.h"
28 #include "machtypes.h"
29
30 #define E750G_V8_GPIO_LED_SYS 14
31 #define E750G_V8_GPIO_LED_DS20 15
32 #define E750G_V8_GPIO_LED_DS10 20
33 #define E750G_V8_GPIO_LED_WLAN 21
34
35 #define E750G_V8_GPIO_BTN_RESET 12
36
37 #define E750G_V8_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define E750G_V8_KEYS_DEBOUNCE_INTERVAL (3 * E750G_V8_KEYS_POLL_INTERVAL)
39
40 static struct gpio_led e750g_v8_leds_gpio[] __initdata = {
41 {
42 .name = "e750g-v8:green:system",
43 .gpio = E750G_V8_GPIO_LED_SYS,
44 .active_low = 1,
45 },
46 {
47 .name = "e750g-v8:green:ds10",
48 .gpio = E750G_V8_GPIO_LED_DS10,
49 .active_low = 1,
50 },
51 {
52 .name = "e750g-v8:green:ds20",
53 .gpio = E750G_V8_GPIO_LED_DS20,
54 .active_low = 1,
55 },
56 {
57 .name = "e750g-v8:green:wlan",
58 .gpio = E750G_V8_GPIO_LED_WLAN,
59 .active_low = 1,
60 },
61 };
62
63 static struct gpio_keys_button e750g_v8_gpio_keys[] __initdata = {
64 {
65 .desc = "reset",
66 .type = EV_KEY,
67 .code = KEY_RESTART,
68 .debounce_interval = E750G_V8_KEYS_DEBOUNCE_INTERVAL,
69 .gpio = E750G_V8_GPIO_BTN_RESET,
70 .active_low = 1,
71 },
72 };
73
74 static const struct ar8327_led_info e750g_v8_leds_qca8334[] = {
75 AR8327_LED_INFO(PHY1_0, HW, "e750g-v8:green:lan"),
76 AR8327_LED_INFO(PHY2_0, HW, "e750g-v8:green:wan"),
77 };
78
79 static struct ar8327_pad_cfg e750g_v8_ar8327_pad0_cfg = {
80 .mode = AR8327_PAD_MAC_RGMII,
81 .txclk_delay_en = true,
82 .rxclk_delay_en = true,
83 .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
84 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
85 .mac06_exchange_dis = true,
86 };
87
88 static struct ar8327_led_cfg e750g_v8_ar8327_led_cfg = {
89 .led_ctrl0 = 0x00000000,
90 .led_ctrl1 = 0xc737c737,
91 .led_ctrl2 = 0x00000000,
92 .led_ctrl3 = 0x00c30c00,
93 .open_drain = true,
94 };
95
96 static struct ar8327_platform_data e750g_v8_ar8327_data = {
97 .pad0_cfg = &e750g_v8_ar8327_pad0_cfg,
98 .port0_cfg = {
99 .force_link = 1,
100 .speed = AR8327_PORT_SPEED_1000,
101 .duplex = 1,
102 .txpause = 1,
103 .rxpause = 1,
104 },
105 .led_cfg = &e750g_v8_ar8327_led_cfg,
106 .leds = e750g_v8_leds_qca8334,
107 .num_leds = ARRAY_SIZE(e750g_v8_leds_qca8334),
108 };
109
110 static struct mdio_board_info e750g_v8_mdio0_info[] = {
111 {
112 .bus_id = "ag71xx-mdio.0",
113 .phy_addr = 0,
114 .platform_data = &e750g_v8_ar8327_data,
115 },
116 };
117
118 static void __init e750g_v8_setup(void)
119 {
120 u8 *mac = (u8 *) KSEG1ADDR(0x1f050400);
121 u8 *art = (u8 *) KSEG1ADDR(0x1f061000);
122
123 ath79_register_m25p80(NULL);
124 ath79_register_leds_gpio(-1, ARRAY_SIZE(e750g_v8_leds_gpio),
125 e750g_v8_leds_gpio);
126 ath79_register_gpio_keys_polled(-1, E750G_V8_KEYS_POLL_INTERVAL,
127 ARRAY_SIZE(e750g_v8_gpio_keys),
128 e750g_v8_gpio_keys);
129
130 mdiobus_register_board_info(e750g_v8_mdio0_info,
131 ARRAY_SIZE(e750g_v8_mdio0_info));
132
133 ath79_register_mdio(0, 0x0);
134 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
135 AR934X_ETH_CFG_SW_ONLY_MODE);
136
137 /* GMAC0 is connected to an AR8327 switch */
138 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
139 ath79_eth0_data.phy_mask = BIT(0);
140 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
141 ath79_eth0_pll_data.pll_1000 = 0x06000000;
142 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
143 ath79_register_eth(0);
144
145 ath79_register_pci();
146 ath79_register_usb();
147 ath79_register_wmac(art, NULL);
148 }
149
150 MIPS_MACHINE(ATH79_MACH_E750G_V8, "E750G-V8", "Qxwlan E750G v8",
151 e750g_v8_setup);