ar71xx: add support for WHQX E1700AC/E600G/E600GAC v2
[oweals/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-lima.c
1 /*
2  *  8devices Lima board support
3  *
4  *  Copyright (C) 2016 Mantas Pucka <mantas@8devices.com>
5  *  Copyright (C) 2017 Karol Dudek <karoiz@sli.pl>
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 <asm/mach-ath79/ar71xx_regs.h>
14 #include <asm/mach-ath79/ath79.h>
15
16 #include "common.h"
17 #include "dev-ap9x-pci.h"
18 #include "dev-eth.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
22 #include "dev-spi.h"
23 #include "dev-usb.h"
24 #include "dev-wmac.h"
25 #include "machtypes.h"
26 #include "pci.h"
27
28 #define LIMA_GPIO_BTN_1_DEFAULT         16
29 #define LIMA_KEYS_POLL_INTERVAL         20      /* msecs */
30 #define LIMA_KEYS_DEBOUNCE_INTERVAL     (3 * LIMA_KEYS_POLL_INTERVAL)
31
32 #define LIMA_ETH_PHYS           (BIT(0) | BIT(1))
33
34 #define LIMA_MAC0_OFFSET        0x0000
35 #define LIMA_MAC1_OFFSET        0x0006
36
37 #define LIMA_CALDATA_OFFSET     0x1000
38 #define LIMA_WMAC_MAC_OFFSET    0x0800
39
40 static struct gpio_keys_button lima_gpio_keys[] __initdata = {
41         {
42                 .desc           = "button1",
43                 .type           = EV_KEY,
44                 .code           = BTN_1,
45                 .debounce_interval = LIMA_KEYS_DEBOUNCE_INTERVAL,
46                 .gpio           = LIMA_GPIO_BTN_1_DEFAULT,
47                 .active_low     = 1,
48         }
49 };
50
51 static void __init lima_setup(void)
52 {
53         u8 *art = (u8 *) KSEG1ADDR(0x1f080000);
54
55         ath79_register_m25p80(NULL);
56
57         ath79_register_gpio_keys_polled(-1, LIMA_KEYS_POLL_INTERVAL,
58                                         ARRAY_SIZE(lima_gpio_keys),
59                                         lima_gpio_keys);
60
61         ath79_setup_ar933x_phy4_switch(true, true);
62
63         ath79_init_mac(ath79_eth0_data.mac_addr, art + LIMA_MAC0_OFFSET, 0);
64         ath79_init_mac(ath79_eth1_data.mac_addr, art + LIMA_MAC1_OFFSET, 0);
65
66         ath79_register_mdio(0, ~LIMA_ETH_PHYS);
67
68         ath79_switch_data.phy4_mii_en = 1;
69
70         ath79_switch_data.phy_poll_mask |= BIT(0);
71         ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
72         ath79_eth1_data.duplex = DUPLEX_FULL;
73         ath79_eth1_data.phy_mask = BIT(1);
74         ath79_register_eth(1);
75
76         ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
77         ath79_eth0_data.duplex = DUPLEX_FULL;
78         ath79_eth0_data.speed = SPEED_100;
79         ath79_eth0_data.phy_mask = BIT(0);
80         ath79_register_eth(0);
81
82         ath79_register_wmac(art + LIMA_CALDATA_OFFSET,
83                         art + LIMA_WMAC_MAC_OFFSET);
84         ath79_register_usb();
85         ath79_register_pci();
86 }
87
88 MIPS_MACHINE(ATH79_MACH_LIMA, "LIMA", "8devices Lima board", lima_setup);