Revert "ar71xx: Clear bits in ath79_setup_qca955x_eth_cfg"
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-tellstick-znet-lite.c
1 /*
2  *  Telldus TellStick ZNet Lite board support
3  *
4  *  Copyright (C) 2016 Micke Prag <micke.prag@telldus.se>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  */
10
11 #include <linux/gpio.h>
12
13 #include <asm/mach-ath79/ath79.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
15
16 #include "common.h"
17 #include "dev-eth.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
21 #include "dev-usb.h"
22 #include "dev-wmac.h"
23 #include "machtypes.h"
24
25 #define TELLSTICK_GPIO_LED_SYSTEM       27
26 #define TELLSTICK_GPIO_LED_BLUE 0
27 #define TELLSTICK_GPIO_LED_RED  14
28 #define TELLSTICK_GPIO_LED_GREEN        15
29 #define TELLSTICK_GPIO_LED_LAN_GREEN    16
30 #define TELLSTICK_GPIO_LED_LAN_ORANGE   17
31
32 #define TELLSTICK_GPIO_BTN_RESET        11
33
34 #define TELLSTICK_GPIO_RF433_RESET      13
35
36 #define TELLSTICK_KEYS_POLL_INTERVAL    20      /* msecs */
37 #define TELLSTICK_KEYS_DEBOUNCE_INTERVAL        (3 * TELLSTICK_KEYS_POLL_INTERVAL)
38
39 static const char *tellstick_part_probes[] = {
40         "tp-link",
41         NULL,
42 };
43
44 static struct flash_platform_data tellstick_flash_data = {
45         .part_probes    = tellstick_part_probes,
46 };
47
48 static struct gpio_led tellstick_leds_gpio[] __initdata = {
49         {
50                 .name           = "tellstick:white:system",
51                 .gpio           = TELLSTICK_GPIO_LED_SYSTEM,
52                 .active_low     = 0,
53         },
54         {
55                 .name           = "tellstick:blue:status",
56                 .gpio           = TELLSTICK_GPIO_LED_BLUE,
57                 .active_low     = 0,
58         },
59         {
60                 .name           = "tellstick:red:status",
61                 .gpio           = TELLSTICK_GPIO_LED_RED,
62                 .active_low     = 0,
63         },
64         {
65                 .name           = "tellstick:green:status",
66                 .gpio           = TELLSTICK_GPIO_LED_GREEN,
67                 .active_low     = 0,
68         },
69         {
70                 .name           = "tellstick:green:lan",
71                 .gpio           = TELLSTICK_GPIO_LED_LAN_GREEN,
72                 .active_low     = 0,
73         },
74         {
75                 .name           = "tellstick:orange:lan",
76                 .gpio           = TELLSTICK_GPIO_LED_LAN_ORANGE,
77                 .active_low     = 0,
78         },
79 };
80
81 static struct gpio_keys_button tellstick_gpio_keys[] __initdata = {
82         {
83                 .desc           = "reset",
84                 .type           = EV_KEY,
85                 .code           = KEY_RESTART,
86                 .debounce_interval = TELLSTICK_KEYS_DEBOUNCE_INTERVAL,
87                 .gpio           = TELLSTICK_GPIO_BTN_RESET,
88                 .active_low     = 0,
89         }
90 };
91
92 static void __init tellstick_znet_lite_setup(void)
93 {
94         u8 *ee =  (u8 *) KSEG1ADDR(0x1fff1000);
95         u8 mac[ETH_ALEN];
96         memcpy(&mac, (u8 *) KSEG1ADDR(0x1f01fc00), sizeof(mac));
97
98         ath79_gpio_function_disable(
99                 AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
100                 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
101                 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
102                 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
103                 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN
104         );
105
106         ath79_register_m25p80(&tellstick_flash_data);
107         ath79_register_leds_gpio(-1, ARRAY_SIZE(tellstick_leds_gpio),
108                                  tellstick_leds_gpio);
109         ath79_register_gpio_keys_polled(-1, TELLSTICK_KEYS_POLL_INTERVAL,
110                                         ARRAY_SIZE(tellstick_gpio_keys),
111                                         tellstick_gpio_keys);
112
113         gpio_request_one(TELLSTICK_GPIO_RF433_RESET,
114                          GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
115                          "rf433 reset");
116         ath79_register_usb();
117
118         ath79_init_mac(ath79_eth0_data.mac_addr, (u8 *)mac, 0);
119
120         ath79_register_mdio(0, 0x0);
121         ath79_register_eth(0);
122
123         // wlan0 mac needs to be different then eth0
124         mac[3] += 1;
125         ath79_register_wmac(ee, (u8 *)mac);
126 }
127
128 MIPS_MACHINE(ATH79_MACH_TELLSTICK_ZNET_LITE, "TELLSTICK-ZNET-LITE", "Telldus TellStick ZNet Lite",
129              tellstick_znet_lite_setup);