ar71xx: add Abicom SC300M support
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-weio.c
1 /**
2 * WEIO Web Of Things Platform
3 *
4 * Copyright (C) 2013 Drasko DRASKOVIC and Uros PETREVSKI
5 *
6 * ## ## ######## #### #######
7 * ## ## ## ## ## ## ##
8 * ## ## ## ## ## ## ##
9 * ## ## ## ###### ## ## ##
10 * ## ## ## ## ## ## ##
11 * ## ## ## ## ## ## ##
12 * ### ### ######## #### #######
13 *
14 * Web Of Things Platform
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 *
30 * Authors :
31 * Drasko DRASKOVIC <drasko.draskovic@gmail.com>
32 * Uros PETREVSKI <uros@nodesign.net>
33 */
34
35 #include <asm/mach-ath79/ath79.h>
36 #include <asm/mach-ath79/ar71xx_regs.h>
37 #include <linux/i2c-gpio.h>
38 #include <linux/platform_device.h>
39 #include "common.h"
40 #include "dev-eth.h"
41 #include "dev-gpio-buttons.h"
42 #include "dev-leds-gpio.h"
43 #include "dev-m25p80.h"
44 #include "dev-spi.h"
45 #include "dev-usb.h"
46 #include "dev-wmac.h"
47 #include "machtypes.h"
48
49 #define WEIO_GPIO_LED_STA 1
50 #define WEIO_GPIO_LED_AP 16
51
52 #define WEIO_GPIO_BTN_AP 20
53 #define WEIO_GPIO_BTN_RESET 23
54
55 #define WEIO_KEYS_POLL_INTERVAL 20 /* msecs */
56 #define WEIO_KEYS_DEBOUNCE_INTERVAL (3 * WEIO_KEYS_POLL_INTERVAL)
57
58 #define WEIO_MAC0_OFFSET 0x0000
59 #define WEIO_MAC1_OFFSET 0x0006
60 #define WEIO_CALDATA_OFFSET 0x1000
61 #define WEIO_WMAC_MAC_OFFSET 0x1002
62
63 static struct gpio_led weio_leds_gpio[] __initdata = {
64 {
65 .name = "weio:green:sta",
66 .gpio = WEIO_GPIO_LED_STA,
67 .active_low = 1,
68 .default_state = LEDS_GPIO_DEFSTATE_ON,
69 },
70 {
71 .name = "weio:green:ap",
72 .gpio = WEIO_GPIO_LED_AP,
73 .active_low = 1,
74 .default_state = LEDS_GPIO_DEFSTATE_ON,
75 }
76 };
77
78 static struct gpio_keys_button weio_gpio_keys[] __initdata = {
79 {
80 .desc = "ap button",
81 .type = EV_KEY,
82 .code = BTN_0,
83 .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
84 .gpio = WEIO_GPIO_BTN_AP,
85 .active_low = 1,
86 },
87 {
88 .desc = "soft-reset button",
89 .type = EV_KEY,
90 .code = BTN_1,
91 .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
92 .gpio = WEIO_GPIO_BTN_RESET,
93 .active_low = 1,
94 }
95 };
96
97 static struct i2c_gpio_platform_data weio_i2c_gpio_data = {
98 .sda_pin = 18,
99 .scl_pin = 19,
100 };
101
102 static struct platform_device weio_i2c_gpio = {
103 .name = "i2c-gpio",
104 .id = 0,
105 .dev = {
106 .platform_data = &weio_i2c_gpio_data,
107 },
108 };
109
110 static void __init weio_common_setup(void)
111 {
112 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
113
114 ath79_register_m25p80(NULL);
115 ath79_register_wmac(art + WEIO_CALDATA_OFFSET, art + WEIO_WMAC_MAC_OFFSET);
116 }
117
118 static void __init weio_setup(void)
119 {
120 weio_common_setup();
121
122 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
123 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
124 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
125 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
126 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
127
128 platform_device_register(&weio_i2c_gpio);
129
130 ath79_register_leds_gpio(-1, ARRAY_SIZE(weio_leds_gpio),
131 weio_leds_gpio);
132
133 ath79_register_gpio_keys_polled(-1, WEIO_KEYS_POLL_INTERVAL,
134 ARRAY_SIZE(weio_gpio_keys),
135 weio_gpio_keys);
136
137 ath79_register_usb();
138 }
139
140 MIPS_MACHINE(ATH79_MACH_WEIO, "WEIO", "WeIO board", weio_setup);