70593d816859d66483a3481eb492d0a654ca751c
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wpj563.c
1 /*
2 * Compex WPJ563 board support
3 *
4 * Copyright (c) 2015 Qualcomm Atheros
5 * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
21 #include <linux/platform_device.h>
22 #include <linux/ath9k_platform.h>
23 #include <linux/ar8216_platform.h>
24 #include <asm/mach-ath79/ar71xx_regs.h>
25
26 #include "common.h"
27 #include "dev-m25p80.h"
28 #include "machtypes.h"
29 #include "pci.h"
30 #include "dev-eth.h"
31 #include "dev-gpio-buttons.h"
32 #include "dev-leds-gpio.h"
33 #include "dev-spi.h"
34 #include "dev-usb.h"
35 #include "dev-wmac.h"
36
37 #define WPJ563_GPIO_LED_SIG1 1
38 #define WPJ563_GPIO_LED_SIG2 5
39 #define WPJ563_GPIO_LED_SIG3 6
40 #define WPJ563_GPIO_LED_SIG4 7
41 #define WPJ563_GPIO_BUZZER 19
42
43 #define WPJ563_GPIO_BTN_RESET 2
44 #define WPJ563_KEYS_POLL_INTERVAL 20 /* msecs */
45 #define WPJ563_KEYS_DEBOUNCE_INTERVAL (3 * WPJ563_KEYS_POLL_INTERVAL)
46
47 #define WPJ563_MAC0_OFFSET 0x10
48 #define WPJ563_MAC1_OFFSET 0x18
49 #define WPJ563_WMAC_CALDATA_OFFSET 0x1000
50
51 static struct gpio_led WPJ563_leds_gpio[] __initdata = {
52 {
53 .name = "wpj563:green:sig1",
54 .gpio = WPJ563_GPIO_LED_SIG1,
55 .active_low = 1,
56 },
57 {
58 .name = "wpj563:green:sig2",
59 .gpio = WPJ563_GPIO_LED_SIG2,
60 .active_low = 1,
61 },
62 {
63 .name = "wpj563:green:sig3",
64 .gpio = WPJ563_GPIO_LED_SIG3,
65 .active_low = 1,
66 },
67 {
68 .name = "wpj563:green:sig4",
69 .gpio = WPJ563_GPIO_LED_SIG4,
70 .active_low = 1,
71 },
72 {
73 .name = "wpj563:buzzer",
74 .gpio = WPJ563_GPIO_BUZZER,
75 .active_low = 0,
76 }
77 };
78
79 static struct gpio_keys_button WPJ563_gpio_keys[] __initdata = {
80 {
81 .desc = "Reset button",
82 .type = EV_KEY,
83 .code = KEY_RESTART,
84 .debounce_interval = WPJ563_KEYS_DEBOUNCE_INTERVAL,
85 .gpio = WPJ563_GPIO_BTN_RESET,
86 .active_low = 1,
87 },
88 };
89
90 static struct ar8327_pad_cfg WPJ563_ar8337_pad0_cfg = {
91 .mode = AR8327_PAD_MAC_SGMII,
92 .sgmii_delay_en = true,
93 };
94
95 static struct ar8327_platform_data WPJ563_ar8337_data = {
96 .pad0_cfg = &WPJ563_ar8337_pad0_cfg,
97 .port0_cfg = {
98 .force_link = 1,
99 .speed = AR8327_PORT_SPEED_1000,
100 .duplex = 1,
101 .txpause = 1,
102 .rxpause = 1,
103 },
104 };
105
106 static struct mdio_board_info WPJ563_mdio0_info[] = {
107 {
108 .bus_id = "ag71xx-mdio.0",
109 .phy_addr = 0,
110 .platform_data = &WPJ563_ar8337_data,
111 },
112 };
113
114 static void __init WPJ563_setup(void)
115 {
116 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
117 u8 *mac = (u8 *) KSEG1ADDR(0x1f02e000);
118
119 ath79_register_m25p80(NULL);
120
121 ath79_register_leds_gpio(-1, ARRAY_SIZE(WPJ563_leds_gpio),
122 WPJ563_leds_gpio);
123 ath79_register_gpio_keys_polled(-1, WPJ563_KEYS_POLL_INTERVAL,
124 ARRAY_SIZE(WPJ563_gpio_keys),
125 WPJ563_gpio_keys);
126
127 ath79_register_usb();
128
129 ath79_register_wmac(art + WPJ563_WMAC_CALDATA_OFFSET, NULL);
130
131 ath79_register_pci();
132
133 mdiobus_register_board_info(WPJ563_mdio0_info,
134 ARRAY_SIZE(WPJ563_mdio0_info));
135 ath79_register_mdio(0, 0x0);
136
137 ath79_init_mac(ath79_eth0_data.mac_addr, mac + WPJ563_MAC0_OFFSET, 0);
138 ath79_init_mac(ath79_eth1_data.mac_addr, mac + WPJ563_MAC1_OFFSET, 0);
139
140 /* GMAC0 is connected to an QCA8334 switch */
141 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
142 ath79_eth0_data.speed = SPEED_1000;
143 ath79_eth0_data.duplex = DUPLEX_FULL;
144 ath79_eth0_data.phy_mask = BIT(0);
145 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
146
147 ath79_register_eth(0);
148 }
149
150 MIPS_MACHINE(ATH79_MACH_WPJ563, "WPJ563", "Compex WPJ563", WPJ563_setup);