uclient: update to Git HEAD (2024-04-18)
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-ew-balin.c
1 /*
2 * EW Balin board support
3 * (based on Atheros DB120 reference board support)
4 *
5 * Copyright (c) 2011 Qualcomm Atheros
6 * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
7 * Copyright (C) 2017 Embedded Wireless GmbH www.80211.de
8 *
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.
12 *
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.
20 *
21 */
22
23 #include <linux/pci.h>
24 #include <linux/phy.h>
25 #include <linux/platform_device.h>
26 #include <linux/ath9k_platform.h>
27 #include <linux/ar8216_platform.h>
28
29 #include <asm/mach-ath79/ar71xx_regs.h>
30
31 #include "common.h"
32 #include "dev-ap9x-pci.h"
33 #include "dev-eth.h"
34 #include "dev-gpio-buttons.h"
35 #include "dev-leds-gpio.h"
36 #include "dev-m25p80.h"
37 #include "dev-spi.h"
38 #include "dev-usb.h"
39 #include "dev-wmac.h"
40 #include "machtypes.h"
41 #include "pci.h"
42
43 #define BALIN_GPIO_LED_STATUS 14
44
45 #define BALIN_GPIO_BTN_WPS 18
46
47 #define BALIN_KEYS_POLL_INTERVAL 20 /* msecs */
48 #define BALIN_KEYS_DEBOUNCE_INTERVAL (3 * BALIN_KEYS_POLL_INTERVAL)
49
50 #define BALIN_CALDATA_OFFSET 0x1000
51 #define BALIN_WMAC_MAC_OFFSET (BALIN_CALDATA_OFFSET + 0x02)
52
53 static struct gpio_led balin_leds_gpio[] __initdata = {
54 {
55 .name = "balin:green:status",
56 .gpio = BALIN_GPIO_LED_STATUS,
57 .active_low = 1,
58 },
59 };
60
61 static struct gpio_keys_button balin_gpio_keys[] __initdata = {
62 {
63 .desc = "WPS button",
64 .type = EV_KEY,
65 .code = KEY_WPS_BUTTON,
66 .debounce_interval = BALIN_KEYS_DEBOUNCE_INTERVAL,
67 .gpio = BALIN_GPIO_BTN_WPS,
68 .active_low = 0,
69 },
70 };
71
72
73 static void __init balin_setup(void)
74 {
75 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
76 static u8 mac[6];
77
78 ath79_register_m25p80(NULL);
79
80 ath79_register_leds_gpio(-1, ARRAY_SIZE(balin_leds_gpio),
81 balin_leds_gpio);
82
83 ath79_register_gpio_keys_polled(-1, BALIN_KEYS_POLL_INTERVAL,
84 ARRAY_SIZE(balin_gpio_keys),
85 balin_gpio_keys);
86
87 ath79_register_usb();
88
89 ath79_register_wmac(art + BALIN_CALDATA_OFFSET, NULL);
90
91 ath79_register_pci();
92
93 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
94 AR934X_ETH_CFG_SW_ONLY_MODE);
95
96 ath79_register_mdio(1, 0x0);
97
98 /* GMAC1 is connected to the internal switch */
99 memcpy(mac, art + BALIN_WMAC_MAC_OFFSET, sizeof(mac));
100 mac[3] |= 0x40;
101 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
102 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
103 ath79_eth1_data.speed = SPEED_1000;
104 ath79_eth1_data.duplex = DUPLEX_FULL;
105
106 ath79_register_eth(1);
107 }
108
109 MIPS_MACHINE(ATH79_MACH_EW_BALIN, "EW-BALIN", "EmbWir-Balin",
110 balin_setup);