ar71xx: add Abicom SC300M support
[librecmc/librecmc.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-sc300m.c
1 /*
2  * Abicom International Scorpion SC300M Module support.
3  *
4  * Copyright (c) 2012 Qualcomm Atheros
5  * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
6  * Copyright (c) 2017 Conor O'Gorman <i@conorogorman.net>
7  *
8  * Permission to use, copy, modify, and/or distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  *
20  */
21
22 #include <linux/platform_device.h>
23 #include <linux/platform_data/phy-at803x.h>
24
25 #include <asm/mach-ath79/ar71xx_regs.h>
26
27 #include "common.h"
28 #include "pci.h"
29 #include "dev-ap9x-pci.h"
30 #include "dev-gpio-buttons.h"
31 #include "dev-eth.h"
32 #include "dev-leds-gpio.h"
33 #include "dev-m25p80.h"
34 #include "dev-nfc.h"
35 #include "dev-usb.h"
36 #include "dev-wmac.h"
37 #include "machtypes.h"
38
39 #define SC300M_GPIO_LED_WLAN            0
40 #define SC300M_GPIO_LED_POWER           1
41
42 #define SC300M_GPIO_BTN_RESET           17
43
44 #define SC300M_KEYS_POLL_INTERVAL       20      /* msecs */
45 #define SC300M_KEYS_DEBOUNCE_INTERVAL   (3 * SC300M_KEYS_POLL_INTERVAL)
46
47 #define SC300M_MAC0_OFFSET              0
48 #define SC300M_MAC1_OFFSET              6
49 #define SC300M_WMAC_CALDATA_OFFSET      0x1000
50 #define SC300M_PCIE_CALDATA_OFFSET      0x5000
51
52 static struct gpio_led sc300m_leds_gpio[] __initdata = {
53         {
54                 .name           = "sc300m:blue:wlan",
55                 .gpio           = SC300M_GPIO_LED_WLAN,
56                 .active_low     = 1,
57         },
58         {
59                 .name           = "sc300m:blue:power",
60                 .gpio           = SC300M_GPIO_LED_POWER,
61                 .active_low     = 1,
62         }
63 };
64
65 static struct gpio_keys_button sc300m_gpio_keys[] __initdata = {
66         {
67                 .desc           = "reset",
68                 .type           = EV_KEY,
69                 .code           = KEY_RESTART,
70                 .debounce_interval = SC300M_KEYS_DEBOUNCE_INTERVAL,
71                 .gpio           = SC300M_GPIO_BTN_RESET,
72                 .active_low     = 1,
73         }
74 };
75
76 static struct at803x_platform_data at803x_data = {
77         .disable_smarteee = 1,
78         .enable_rgmii_rx_delay = 0,
79         .enable_rgmii_tx_delay = 0,
80 };
81
82 static struct mdio_board_info sc300m_mdio0_info[] = {
83         {
84                 .bus_id = "ag71xx-mdio.0",
85                 .phy_addr = 1,
86                 .platform_data = &at803x_data,
87         },
88 };
89
90 static void __init sc300m_setup(void)
91 {
92         u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
93
94         ath79_register_m25p80(NULL);
95
96         ath79_register_leds_gpio(-1, ARRAY_SIZE(sc300m_leds_gpio),
97                                  sc300m_leds_gpio);
98         ath79_register_gpio_keys_polled(-1, SC300M_KEYS_POLL_INTERVAL,
99                                         ARRAY_SIZE(sc300m_gpio_keys),
100                                         sc300m_gpio_keys);
101
102         ath79_register_usb();
103         ath79_register_nfc();
104
105         ath79_register_wmac(art + SC300M_WMAC_CALDATA_OFFSET, NULL);
106
107         ath79_register_mdio(0, 0);
108         mdiobus_register_board_info(sc300m_mdio0_info,
109                                     ARRAY_SIZE(sc300m_mdio0_info));
110
111         ath79_init_mac(ath79_eth0_data.mac_addr, art + SC300M_MAC0_OFFSET, 0);
112
113         ath79_eth0_pll_data.pll_1000 = 0xa6000101;
114         ath79_eth0_pll_data.pll_100 = 0xa4000101;
115         /* GMAC0 is connected to the RMGII interface */
116         ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
117         ath79_eth0_data.phy_mask = 0xF;
118         ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
119
120         ath79_register_eth(0);
121
122         /* GMAC1 is connected to the SGMII interface */
123         ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
124         ath79_eth1_data.speed = SPEED_1000;
125         ath79_eth1_data.duplex = DUPLEX_FULL;
126
127         ath79_register_eth(1);
128
129         ath79_register_pci();
130 }
131
132 MIPS_MACHINE(ATH79_MACH_SC300M, "SC300M", "Abicom SC300M", sc300m_setup);