ar71xx: Fix LED polarity for the TP-LINK TL-MR13U.
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wp543.c
1 /*
2  *  Compex WP543/WPJ543 board support
3  *
4  *  Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
5  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
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 <asm/mach-ath79/ar71xx_regs.h>
13 #include <asm/mach-ath79/ath79.h>
14
15 #include "dev-eth.h"
16 #include "dev-gpio-buttons.h"
17 #include "dev-leds-gpio.h"
18 #include "dev-m25p80.h"
19 #include "dev-usb.h"
20 #include "machtypes.h"
21 #include "pci.h"
22
23 #define WP543_GPIO_SW6          2
24 #define WP543_GPIO_LED_1        3
25 #define WP543_GPIO_LED_2        4
26 #define WP543_GPIO_LED_WLAN     5
27 #define WP543_GPIO_LED_CONN     6
28 #define WP543_GPIO_LED_DIAG     7
29 #define WP543_GPIO_SW4          8
30
31 #define WP543_KEYS_POLL_INTERVAL        20      /* msecs */
32 #define WP543_KEYS_DEBOUNCE_INTERVAL    (3 * WP543_KEYS_POLL_INTERVAL)
33
34 static struct gpio_led wp543_leds_gpio[] __initdata = {
35         {
36                 .name           = "wp543:green:led1",
37                 .gpio           = WP543_GPIO_LED_1,
38                 .active_low     = 1,
39         }, {
40                 .name           = "wp543:green:led2",
41                 .gpio           = WP543_GPIO_LED_2,
42                 .active_low     = 1,
43         }, {
44                 .name           = "wp543:green:wlan",
45                 .gpio           = WP543_GPIO_LED_WLAN,
46                 .active_low     = 1,
47         }, {
48                 .name           = "wp543:green:conn",
49                 .gpio           = WP543_GPIO_LED_CONN,
50                 .active_low     = 1,
51         }, {
52                 .name           = "wp543:green:diag",
53                 .gpio           = WP543_GPIO_LED_DIAG,
54                 .active_low     = 1,
55         }
56 };
57
58 static struct gpio_keys_button wp543_gpio_keys[] __initdata = {
59         {
60                 .desc           = "sw6",
61                 .type           = EV_KEY,
62                 .code           = BTN_0,
63                 .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
64                 .gpio           = WP543_GPIO_SW6,
65                 .active_low     = 1,
66         }, {
67                 .desc           = "sw4",
68                 .type           = EV_KEY,
69                 .code           = KEY_RESTART,
70                 .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
71                 .gpio           = WP543_GPIO_SW4,
72                 .active_low     = 1,
73         }
74 };
75
76 static const char *wp543_part_probes[] = {
77         "MyLoader",
78         NULL,
79 };
80
81 static struct flash_platform_data wp543_flash_data = {
82         .part_probes    = wp543_part_probes,
83 };
84
85 static void __init wp543_setup(void)
86 {
87         ath79_register_m25p80(&wp543_flash_data);
88
89         ath79_register_mdio(0, 0xfffffff0);
90
91         ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
92         ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
93         ath79_eth0_data.phy_mask = 0x0f;
94         ath79_eth0_data.reset_bit = AR71XX_RESET_GE0_MAC |
95                                     AR71XX_RESET_GE0_PHY;
96         ath79_register_eth(0);
97
98         ath79_register_usb();
99         ath79_register_pci();
100
101         ath79_register_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
102                                         wp543_leds_gpio);
103
104         ath79_register_gpio_keys_polled(-1, WP543_KEYS_POLL_INTERVAL,
105                                          ARRAY_SIZE(wp543_gpio_keys),
106                                          wp543_gpio_keys);
107 }
108
109 MIPS_MACHINE(ATH79_MACH_WP543, "WP543", "Compex WP543", wp543_setup);