2 * EnGenius ESR1750 board support
4 * Copyright (c) 2014 Jon Suphammer <jon@suphammer.net>
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.
11 #include <linux/platform_device.h>
12 #include <linux/ar8216_platform.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include "dev-ap9x-pci.h"
19 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
25 #include "machtypes.h"
28 #define ESR1750_GPIO_LED_WLAN_5G 23
29 #define ESR1750_GPIO_LED_WLAN_2G 13
30 #define ESR1750_GPIO_LED_POWER_AMBER 2
31 #define ESR1750_GPIO_LED_WPS_AMBER 22
32 #define ESR1750_GPIO_LED_WPS_BLUE 19
34 #define ESR1750_GPIO_BTN_WPS 16
35 #define ESR1750_GPIO_BTN_RESET 17
37 #define ESR1750_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define ESR1750_KEYS_DEBOUNCE_INTERVAL (3 * ESR1750_KEYS_POLL_INTERVAL)
40 #define ESR1750_CALDATA_ADDR 0x1fff0000
41 #define ESR1750_WMAC_CALDATA_OFFSET 0x1000
42 #define ESR1750_PCIE_CALDATA_OFFSET 0x5000
44 #define ESR1750_NVRAM_ADDR 0x1f030000
45 #define ESR1750_NVRAM_SIZE 0x10000
47 static struct gpio_led esr1750_leds_gpio
[] __initdata
= {
49 .name
= "esr1750:amber:power",
50 .gpio
= ESR1750_GPIO_LED_POWER_AMBER
,
54 .name
= "esr1750:blue:wps",
55 .gpio
= ESR1750_GPIO_LED_WPS_BLUE
,
59 .name
= "esr1750:amber:wps",
60 .gpio
= ESR1750_GPIO_LED_WPS_AMBER
,
64 .name
= "esr1750:blue:wlan-2g",
65 .gpio
= ESR1750_GPIO_LED_WLAN_2G
,
69 .name
= "esr1750:blue:wlan-5g",
70 .gpio
= ESR1750_GPIO_LED_WLAN_5G
,
75 static struct gpio_keys_button esr1750_gpio_keys
[] __initdata
= {
79 .code
= KEY_WPS_BUTTON
,
80 .debounce_interval
= ESR1750_KEYS_DEBOUNCE_INTERVAL
,
81 .gpio
= ESR1750_GPIO_BTN_WPS
,
85 .desc
= "Reset button",
88 .debounce_interval
= ESR1750_KEYS_DEBOUNCE_INTERVAL
,
89 .gpio
= ESR1750_GPIO_BTN_RESET
,
94 static struct ar8327_pad_cfg esr1750_ar8327_pad0_cfg
= {
95 .mode
= AR8327_PAD_MAC_RGMII
,
96 .txclk_delay_en
= true,
97 .rxclk_delay_en
= true,
98 .txclk_delay_sel
= AR8327_CLK_DELAY_SEL2
,
99 .rxclk_delay_sel
= AR8327_CLK_DELAY_SEL2
,
102 static struct ar8327_platform_data esr1750_ar8327_data
= {
103 .pad0_cfg
= &esr1750_ar8327_pad0_cfg
,
106 .speed
= AR8327_PORT_SPEED_1000
,
113 static struct mdio_board_info esr1750_mdio0_info
[] = {
115 .bus_id
= "ag71xx-mdio.0",
117 .platform_data
= &esr1750_ar8327_data
,
121 static int esr1750_get_mac(const char *name
, char *mac
)
123 u8
*nvram
= (u8
*) KSEG1ADDR(ESR1750_NVRAM_ADDR
);
126 err
= ath79_nvram_parse_mac_addr(nvram
, ESR1750_NVRAM_SIZE
,
129 pr_err("no MAC address found for %s\n", name
);
136 static void __init
esr1750_setup(void)
138 u8
*caldata
= (u8
*) KSEG1ADDR(ESR1750_CALDATA_ADDR
);
141 ath79_register_m25p80(NULL
);
143 ath79_register_leds_gpio(-1, ARRAY_SIZE(esr1750_leds_gpio
),
145 ath79_register_gpio_keys_polled(-1, ESR1750_KEYS_POLL_INTERVAL
,
146 ARRAY_SIZE(esr1750_gpio_keys
),
149 ath79_register_usb();
151 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN
);
153 ath79_register_mdio(0, 0x0);
155 mdiobus_register_board_info(esr1750_mdio0_info
,
156 ARRAY_SIZE(esr1750_mdio0_info
));
158 /* GMAC0 is connected to an QCA8327N switch */
159 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
160 ath79_eth0_data
.phy_mask
= BIT(0);
161 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
163 if (esr1750_get_mac("ethaddr=", mac1
))
164 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac1
, 0);
166 ath79_eth0_pll_data
.pll_1000
= 0xa6000000;
167 ath79_register_eth(0);
169 ath79_register_wmac(caldata
+ ESR1750_WMAC_CALDATA_OFFSET
, mac1
);
171 ath79_register_pci();
174 MIPS_MACHINE(ATH79_MACH_ESR1750
, "ESR1750",