ar71xx: add definitions for RouterBOARD hardware option bits
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-el-m150.c
1 /*
2 * Easy-Link EL-M150 board support
3 *
4 * Copyright (C) 2012 huangfc <huangfangcheng@163.com>
5 * Copyright (C) 2012 HYS <550663898@qq.com>
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/gpio.h>
13
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
16
17 #include "common.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-wmac.h"
23 #include "machtypes.h"
24 #include "dev-usb.h"
25
26 #define EL_M150_GPIO_BTN6 6
27 #define EL_M150_GPIO_BTN7 7
28 #define EL_M150_GPIO_BTN_RESET 11
29
30 #define EL_M150_GPIO_LED_SYSTEM 27
31 #define EL_M150_GPIO_USB_POWER 8
32
33 #define EL_M150_KEYS_POLL_INTERVAL 20 /* msecs */
34 #define EL_M150_KEYS_DEBOUNCE_INTERVAL (3 * EL_M150_KEYS_POLL_INTERVAL)
35
36 static const char *EL_M150_part_probes[] = {
37 "tp-link",
38 NULL,
39 };
40
41 static struct flash_platform_data EL_M150_flash_data = {
42 .part_probes = EL_M150_part_probes,
43 };
44
45 static struct gpio_led EL_M150_leds_gpio[] __initdata = {
46 {
47 .name = "easylink:green:system",
48 .gpio = EL_M150_GPIO_LED_SYSTEM,
49 .active_low = 1,
50 },
51 };
52
53 static struct gpio_keys_button EL_M150_gpio_keys[] __initdata = {
54 {
55 .desc = "reset",
56 .type = EV_KEY,
57 .code = KEY_RESTART,
58 .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
59 .gpio = EL_M150_GPIO_BTN_RESET,
60 .active_low = 0,
61 },
62 {
63 .desc = "BTN_6",
64 .type = EV_KEY,
65 .code = BTN_6,
66 .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
67 .gpio = EL_M150_GPIO_BTN6,
68 .active_low = 1,
69 },
70 {
71 .desc = "BTN_7",
72 .type = EV_KEY,
73 .code = BTN_7,
74 .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
75 .gpio = EL_M150_GPIO_BTN7,
76 .active_low = 1,
77 },
78 };
79
80 static void __init el_m150_setup(void)
81 {
82 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
83 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
84
85 /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
86 ath79_setup_ar933x_phy4_switch(false, false);
87
88 ath79_register_leds_gpio(-1, ARRAY_SIZE(EL_M150_leds_gpio),
89 EL_M150_leds_gpio);
90
91 ath79_register_gpio_keys_polled(-1, EL_M150_KEYS_POLL_INTERVAL,
92 ARRAY_SIZE(EL_M150_gpio_keys),
93 EL_M150_gpio_keys);
94
95 gpio_request_one(EL_M150_GPIO_USB_POWER,
96 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
97 "USB power");
98 ath79_register_usb();
99
100 ath79_register_m25p80(&EL_M150_flash_data);
101 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
102 ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
103
104 ath79_register_mdio(0, 0x0);
105 ath79_register_eth(0);
106 ath79_register_eth(1);
107
108 ath79_register_wmac(ee, mac);
109 }
110
111 MIPS_MACHINE(ATH79_MACH_EL_M150, "EL-M150",
112 "EasyLink EL-M150", el_m150_setup);