2 * Cisco Meraki Z1 board support
4 * Copyright (C) 2016 Chris Blake <chrisrblake93@gmail.com>
5 * Copyright (C) 2016 Christian Lamparter <chunkeey@googlemail.com>
7 * Based on Cisco Meraki GPL Release r23-20150601 Z1 Device Config
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <linux/ath9k_platform.h>
15 #include <linux/ar8216_platform.h>
16 #include <linux/platform/ar934x_nfc.h>
18 #include <asm/mach-ath79/ath79.h>
19 #include <asm/mach-ath79/ar71xx_regs.h>
21 #include <linux/leds-nu801.h>
22 #include <linux/firmware.h>
23 #include <linux/pci.h>
27 #include "dev-gpio-buttons.h"
28 #include "dev-leds-gpio.h"
32 #include "dev-ap9x-pci.h"
33 #include "machtypes.h"
35 #define Z1_GPIO_LED_POWER_ORANGE 17
37 #define Z1_GPIO_NU801_CKI 14
38 #define Z1_GPIO_NU801_SDI 15
40 #define Z1_GPIO_XLNA0 18
41 #define Z1_GPIO_XLNA1 19
43 #define Z1_GPIO_BTN_RESET 12
44 #define Z1_KEYS_POLL_INTERVAL 20 /* msecs */
45 #define Z1_KEYS_DEBOUNCE_INTERVAL (3 * Z1_KEYS_POLL_INTERVAL)
47 #define Z1_ETH_SWITCH_PHY 0
49 static struct gpio_led Z1_leds_gpio
[] __initdata
= {
51 .name
= "z1:orange:power",
52 .gpio
= Z1_GPIO_LED_POWER_ORANGE
,
57 static struct gpio_keys_button Z1_gpio_keys
[] __initdata
= {
62 .debounce_interval
= Z1_KEYS_DEBOUNCE_INTERVAL
,
63 .gpio
= Z1_GPIO_BTN_RESET
,
68 static struct led_nu801_template tricolor_led_template
= {
72 .cki
= Z1_GPIO_NU801_CKI
,
73 .sdi
= Z1_GPIO_NU801_SDI
,
81 .default_trigger
= "none",
84 static struct led_nu801_platform_data tricolor_led_data
= {
86 .template = &tricolor_led_template
,
89 static struct platform_device tricolor_leds
= {
92 .dev
.platform_data
= &tricolor_led_data
,
95 static struct ar8327_pad_cfg z1_ar8327_pad0_cfg
= {
96 .mode
= AR8327_PAD_MAC_RGMII
,
97 .txclk_delay_en
= true,
98 .rxclk_delay_en
= true,
99 .txclk_delay_sel
= AR8327_CLK_DELAY_SEL1
,
100 .rxclk_delay_sel
= AR8327_CLK_DELAY_SEL2
,
103 static struct ar8327_platform_data z1_ar8327_data
= {
104 .pad0_cfg
= &z1_ar8327_pad0_cfg
,
107 .speed
= AR8327_PORT_SPEED_1000
,
114 static struct mdio_board_info z1_mdio0_info
[] = {
116 .bus_id
= "ag71xx-mdio.0",
117 .phy_addr
= Z1_ETH_SWITCH_PHY
,
118 .platform_data
= &z1_ar8327_data
,
122 static void __init
z1_setup(void)
125 ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_SOFT_BCH
);
126 ath79_register_nfc();
129 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0
|
130 AR934X_ETH_CFG_SW_ONLY_MODE
);
133 ath79_register_mdio(1, 0x0);
134 ath79_register_mdio(0, 0x0);
135 mdiobus_register_board_info(z1_mdio0_info
,
136 ARRAY_SIZE(z1_mdio0_info
));
138 /* GMAC0 is connected to an AR8327 switch */
139 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
140 ath79_eth0_data
.phy_mask
= BIT(Z1_ETH_SWITCH_PHY
);
141 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
142 ath79_eth0_pll_data
.pll_1000
= 0x06000000;
143 ath79_register_eth(0);
146 ath79_wmac_set_ext_lna_gpio(0, Z1_GPIO_XLNA0
);
147 ath79_wmac_set_ext_lna_gpio(1, Z1_GPIO_XLNA1
);
149 /* LEDs and Buttons */
150 platform_device_register(&tricolor_leds
);
151 ath79_register_leds_gpio(-1, ARRAY_SIZE(Z1_leds_gpio
),
153 ath79_register_gpio_keys_polled(-1, Z1_KEYS_POLL_INTERVAL
,
154 ARRAY_SIZE(Z1_gpio_keys
),
158 ath79_register_usb();
161 ath79_register_wmac_simple();
162 ap91_pci_init_simple();
164 MIPS_MACHINE(ATH79_MACH_Z1
, "Z1", "Meraki Z1", z1_setup
);