Revert "ar71xx: Clear bits in ath79_setup_qca955x_eth_cfg"
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-ap147.c
1 /*
2  *  Atheros AP147 reference board support
3  *
4  *  Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
5  *  Copyright (C) 2015 Sven Eckelmann <sven@open-mesh.com>
6  *
7  *  This program is free software; you can redistribute it and/or modify it
8  *  under the terms of the GNU General Public License version 2 as published
9  *  by the Free Software Foundation.
10  */
11
12 #include <linux/platform_device.h>
13 #include <linux/ar8216_platform.h>
14
15 #include <asm/mach-ath79/ar71xx_regs.h>
16 #include <asm/mach-ath79/ath79.h>
17
18 #include "common.h"
19 #include "dev-ap9x-pci.h"
20 #include "dev-eth.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
24 #include "dev-usb.h"
25 #include "dev-wmac.h"
26 #include "machtypes.h"
27 #include "pci.h"
28
29 #define AP147_GPIO_LED_WAN      4
30 #define AP147_GPIO_LED_LAN1     16
31 #define AP147_GPIO_LED_LAN2     15
32 #define AP147_GPIO_LED_LAN3     14
33 #define AP147_GPIO_LED_LAN4     11
34 #define AP147_GPIO_LED_STATUS   13
35 #define AP147_GPIO_LED_WLAN_2G  12
36
37 #define AP147_GPIO_BTN_WPS      17
38
39 #define AP147_KEYS_POLL_INTERVAL        20      /* msecs */
40 #define AP147_KEYS_DEBOUNCE_INTERVAL    (3 * AP147_KEYS_POLL_INTERVAL)
41
42 #define AP147_MAC0_OFFSET       0x1000
43
44 static struct gpio_led ap147_leds_gpio[] __initdata = {
45         {
46                 .name           = "ap147:green:status",
47                 .gpio           = AP147_GPIO_LED_STATUS,
48                 .active_low     = 1,
49         }, {
50                 .name           = "ap147:green:wlan-2g",
51                 .gpio           = AP147_GPIO_LED_WLAN_2G,
52                 .active_low     = 1,
53         }, {
54                 .name           = "ap147:green:lan1",
55                 .gpio           = AP147_GPIO_LED_LAN1,
56                 .active_low     = 1,
57         }, {
58                 .name           = "ap147:green:lan2",
59                 .gpio           = AP147_GPIO_LED_LAN2,
60                 .active_low     = 1,
61         }, {
62                 .name           = "ap147:green:lan3",
63                 .gpio           = AP147_GPIO_LED_LAN3,
64                 .active_low     = 1,
65         }, {
66                 .name           = "ap147:green:lan4",
67                 .gpio           = AP147_GPIO_LED_LAN4,
68                 .active_low     = 1,
69         }, {
70                 .name           = "ap147:green:wan",
71                 .gpio           = AP147_GPIO_LED_WAN,
72                 .active_low     = 1,
73         },
74 };
75
76 static struct gpio_keys_button ap147_gpio_keys[] __initdata = {
77         {
78                 .desc           = "wps button",
79                 .type           = EV_KEY,
80                 .code           = KEY_WPS_BUTTON,
81                 .debounce_interval = AP147_KEYS_DEBOUNCE_INTERVAL,
82                 .gpio           = AP147_GPIO_BTN_WPS,
83                 .active_low     = 1,
84         }
85 };
86
87 static void __init ap147_setup(void)
88 {
89         u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
90
91         ath79_register_m25p80(NULL);
92         ath79_register_leds_gpio(-1, ARRAY_SIZE(ap147_leds_gpio),
93                                  ap147_leds_gpio);
94         ath79_register_gpio_keys_polled(-1, AP147_KEYS_POLL_INTERVAL,
95                                         ARRAY_SIZE(ap147_gpio_keys),
96                                         ap147_gpio_keys);
97
98         ath79_register_usb();
99
100         ath79_register_pci();
101
102         ath79_register_wmac(art + AP147_MAC0_OFFSET, NULL);
103
104         ath79_setup_ar933x_phy4_switch(false, false);
105
106         ath79_register_mdio(0, 0x0);
107
108         /* LAN */
109         ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
110         ath79_eth1_data.duplex = DUPLEX_FULL;
111         ath79_switch_data.phy_poll_mask |= BIT(4);
112         ath79_init_mac(ath79_eth1_data.mac_addr, art, 0);
113         ath79_register_eth(1);
114
115         /* WAN */
116         ath79_switch_data.phy4_mii_en = 1;
117         ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
118         ath79_eth0_data.duplex = DUPLEX_FULL;
119         ath79_eth0_data.speed = SPEED_100;
120         ath79_eth0_data.phy_mask = BIT(4);
121         ath79_init_mac(ath79_eth0_data.mac_addr, art, 1);
122         ath79_register_eth(0);
123 }
124
125 MIPS_MACHINE(ATH79_MACH_AP147_010, "AP147-010", "Atheros AP147-010 reference board", ap147_setup);