ar71xx: add support for compex wpj531
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wpj531.c
1 /*
2  * Compex WPJ531 board support
3  *
4  * Copyright (c) 2012 Qualcomm Atheros
5  * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  *
19  */
20
21 #include <linux/irq.h>
22 #include <linux/platform_device.h>
23 #include <linux/ar8216_platform.h>
24
25 #include <asm/mach-ath79/ar71xx_regs.h>
26
27 #include "pci.h"
28 #include "common.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-usb.h"
35 #include "dev-wmac.h"
36 #include "machtypes.h"
37
38 #define WPJ531_GPIO_LED_SIG1    14
39 #define WPJ531_GPIO_LED_SIG2    15
40 #define WPJ531_GPIO_LED_SIG3    22
41 #define WPJ531_GPIO_LED_SIG4    23
42 #define WPJ531_GPIO_BUZZER      4
43
44 #define WPJ531_GPIO_BTN_RESET   17
45
46 #define WPJ531_KEYS_POLL_INTERVAL       20      /* msecs */
47 #define WPJ531_KEYS_DEBOUNCE_INTERVAL   (3 * WPJ531_KEYS_POLL_INTERVAL)
48
49 #define WPJ531_MAC0_OFFSET              0x10
50 #define WPJ531_MAC1_OFFSET              0x18
51 #define WPJ531_WMAC_CALDATA_OFFSET      0x1000
52 #define WPJ531_PCIE_CALDATA_OFFSET      0x5000
53
54 #define WPJ531_ART_SIZE         0x8000
55
56 static struct gpio_led wpj531_leds_gpio[] __initdata = {
57         {
58                 .name           = "wpj531:red:sig1",
59                 .gpio           = WPJ531_GPIO_LED_SIG1,
60                 .active_low     = 1,
61         },
62         {
63                 .name           = "wpj531:yellow:sig2",
64                 .gpio           = WPJ531_GPIO_LED_SIG2,
65                 .active_low     = 1,
66         },
67         {
68                 .name           = "wpj531:green:sig3",
69                 .gpio           = WPJ531_GPIO_LED_SIG3,
70                 .active_low     = 1,
71         },
72         {
73                 .name           = "wpj531:green:sig4",
74                 .gpio           = WPJ531_GPIO_LED_SIG4,
75                 .active_low     = 1,
76         },
77         {
78                 .name           = "wpj531:buzzer",
79                 .gpio           = WPJ531_GPIO_BUZZER,
80                 .active_low     = 0,
81         }
82 };
83
84 static struct gpio_keys_button wpj531_gpio_keys[] __initdata = {
85         {
86                 .desc           = "reset",
87                 .type           = EV_KEY,
88                 .code           = KEY_RESTART,
89                 .debounce_interval = WPJ531_KEYS_DEBOUNCE_INTERVAL,
90                 .gpio           = WPJ531_GPIO_BTN_RESET,
91                 .active_low     = 1,
92         },
93 };
94
95 static void __init common_setup(void)
96 {
97         u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
98         u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
99         u8 tmpmac[ETH_ALEN];
100
101         ath79_register_m25p80(NULL);
102
103         ath79_setup_ar933x_phy4_switch(false, false);
104
105         ath79_register_mdio(0, 0x0);
106
107         /* LAN */
108         ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
109         ath79_register_eth(0);
110
111         /* WAN */
112         ath79_switch_data.phy4_mii_en = 1;
113         ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
114         ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
115         ath79_register_eth(1);
116
117         ath79_register_wmac(ee, tmpmac);
118
119         ath79_register_pci();
120 }
121
122 static void __init wpj531_setup(void)
123 {
124         common_setup();
125
126         ath79_register_leds_gpio(-1,
127                                 ARRAY_SIZE(wpj531_leds_gpio),
128                                 wpj531_leds_gpio);
129
130         ath79_register_gpio_keys_polled(-1,
131                                         WPJ531_KEYS_POLL_INTERVAL,
132                                         ARRAY_SIZE(wpj531_gpio_keys),
133                                         wpj531_gpio_keys);
134 }
135
136 MIPS_MACHINE(ATH79_MACH_WPJ531, "WPJ531", "Compex WPJ531", wpj531_setup);