2 * PowerCloud Systems CR3000 support
4 * Copyright (c) 2011 Qualcomm Atheros
5 * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (c) 2012-2013 PowerCloud Systems
7 * Copyright (c) 2015 Daniel Dickinson <openwrt@daniel.thecshore.com>
9 * Permission to use, copy, modify, and/or distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include <linux/gpio.h>
24 #include <linux/phy.h>
25 #include <linux/platform_device.h>
26 #include <linux/ath9k_platform.h>
27 #include <linux/ar8216_platform.h>
29 #include <asm/mach-ath79/ar71xx_regs.h>
30 #include <asm/mach-ath79/ath79.h>
34 #include "dev-gpio-buttons.h"
35 #include "dev-leds-gpio.h"
36 #include "dev-m25p80.h"
39 #include "machtypes.h"
41 #define CR3000_GPIO_LED_WLAN_2G 13
42 #define CR3000_GPIO_LED_POWER_AMBER 15
43 #define CR3000_GPIO_LED_WAN 18
44 #define CR3000_GPIO_LED_LAN1 19
45 #define CR3000_GPIO_LED_LAN2 20
46 #define CR3000_GPIO_LED_LAN3 21
47 #define CR3000_GPIO_LED_LAN4 22
49 #define CR3000_GPIO_BTN_WPS 16
50 #define CR3000_GPIO_BTN_RESET 17
52 #define CR3000_KEYS_POLL_INTERVAL 20 /* msecs */
53 #define CR3000_KEYS_DEBOUNCE_INTERVAL (3 * CR3000_KEYS_POLL_INTERVAL)
55 #define CR3000_MAC0_OFFSET 0
56 #define CR3000_MAC1_OFFSET 6
57 #define CR3000_WMAC_CALDATA_OFFSET 0x1000
58 #define CR3000_WMAC_MAC_OFFSET 0x1002
60 static struct gpio_led cr3000_leds_gpio
[] __initdata
= {
62 .name
= "pcs:amber:power",
63 .gpio
= CR3000_GPIO_LED_POWER_AMBER
,
67 .name
= "pcs:blue:wlan",
68 .gpio
= CR3000_GPIO_LED_WLAN_2G
,
72 .name
= "pcs:blue:wan",
73 .gpio
= CR3000_GPIO_LED_WAN
,
77 .name
= "pcs:blue:lan1",
78 .gpio
= CR3000_GPIO_LED_LAN1
,
82 .name
= "pcs:blue:lan2",
83 .gpio
= CR3000_GPIO_LED_LAN2
,
87 .name
= "pcs:blue:lan3",
88 .gpio
= CR3000_GPIO_LED_LAN3
,
92 .name
= "pcs:blue:lan4",
93 .gpio
= CR3000_GPIO_LED_LAN4
,
98 static struct gpio_keys_button cr3000_gpio_keys
[] __initdata
= {
100 .desc
= "WPS button",
102 .code
= KEY_WPS_BUTTON
,
103 .debounce_interval
= CR3000_KEYS_DEBOUNCE_INTERVAL
,
104 .gpio
= CR3000_GPIO_BTN_WPS
,
108 .desc
= "Reset button",
110 .code
= KEY_WPS_BUTTON
,
111 .debounce_interval
= CR3000_KEYS_DEBOUNCE_INTERVAL
,
112 .gpio
= CR3000_GPIO_BTN_RESET
,
117 static void __init
cr3000_setup(void)
119 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
121 ath79_register_m25p80(NULL
);
123 ath79_register_leds_gpio(-1, ARRAY_SIZE(cr3000_leds_gpio
),
126 ath79_register_gpio_keys_polled(-1, CR3000_KEYS_POLL_INTERVAL
,
127 ARRAY_SIZE(cr3000_gpio_keys
),
130 /* WLAN 2GHz onboard */
131 ath79_register_wmac(art
+ CR3000_WMAC_CALDATA_OFFSET
, art
+ CR3000_WMAC_MAC_OFFSET
);
133 /* FE Lan on first 4-ports of internal switch and attached to GMAC1
134 * WAN Fast Ethernet interface attached to GMAC0
135 * Could be configured as a 5-port switch, but we use
136 * the SoC capabilities to attach port 5 to a separate PHY/MAC
137 * theoretically this leaves future possibility of using SoC
138 * acceleration/offloading.
140 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP
);
142 /* GMAC0 attached to PHY4 (port 5 of the internal switch) */
143 ath79_switch_data
.phy4_mii_en
= 1;
144 /* For switch carrier ignore port 5 (wan) */
145 ath79_switch_data
.phy_poll_mask
= 0x1;
147 /* Register MII bus */
148 ath79_register_mdio(1, 0x0);
150 /* GMAC0 attached to PHY4 (port 5 of the internal switch) */
151 ath79_switch_data
.phy4_mii_en
= 1;
152 ath79_switch_data
.phy_poll_mask
= 0x1;
155 ath79_init_mac(ath79_eth1_data
.mac_addr
, art
+ CR3000_MAC0_OFFSET
, 0);
156 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
157 ath79_register_eth(1);
160 ath79_init_mac(ath79_eth0_data
.mac_addr
, art
+ CR3000_MAC0_OFFSET
, 1);
161 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
162 ath79_eth0_data
.phy_mask
= BIT(0);
163 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio1_device
.dev
;
164 ath79_register_eth(0);
167 MIPS_MACHINE(ATH79_MACH_CR3000
, "CR3000", "PowerCloud Systems CR3000",