ar71xx: add support for the wzr-hp-g300nh2
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wp543.c
1 /*
2 * Compex WP543/WPJ543 board support
3 *
4 * Copyright (C) 2008-2009 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-ar71xx/ar71xx.h>
13
14 #include "machtype.h"
15 #include "devices.h"
16 #include "dev-m25p80.h"
17 #include "dev-pb42-pci.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-usb.h"
21
22 #define WP543_GPIO_SW6 2
23 #define WP543_GPIO_LED_1 3
24 #define WP543_GPIO_LED_2 4
25 #define WP543_GPIO_LED_WLAN 5
26 #define WP543_GPIO_LED_CONN 6
27 #define WP543_GPIO_LED_DIAG 7
28 #define WP543_GPIO_SW4 8
29
30 #define WP543_KEYS_POLL_INTERVAL 20 /* msecs */
31 #define WP543_KEYS_DEBOUNCE_INTERVAL (3 * WP543_KEYS_POLL_INTERVAL)
32
33 static struct gpio_led wp543_leds_gpio[] __initdata = {
34 {
35 .name = "wp543:green:led1",
36 .gpio = WP543_GPIO_LED_1,
37 .active_low = 1,
38 }, {
39 .name = "wp543:green:led2",
40 .gpio = WP543_GPIO_LED_2,
41 .active_low = 1,
42 }, {
43 .name = "wp543:green:wlan",
44 .gpio = WP543_GPIO_LED_WLAN,
45 .active_low = 1,
46 }, {
47 .name = "wp543:green:conn",
48 .gpio = WP543_GPIO_LED_CONN,
49 .active_low = 1,
50 }, {
51 .name = "wp543:green:diag",
52 .gpio = WP543_GPIO_LED_DIAG,
53 .active_low = 1,
54 }
55 };
56
57 static struct gpio_keys_button wp543_gpio_keys[] __initdata = {
58 {
59 .desc = "sw6",
60 .type = EV_KEY,
61 .code = BTN_0,
62 .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
63 .gpio = WP543_GPIO_SW6,
64 }, {
65 .desc = "sw4",
66 .type = EV_KEY,
67 .code = BTN_1,
68 .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
69 .gpio = WP543_GPIO_SW4,
70 }
71 };
72
73 static const char *wp543_part_probes[] = {
74 "MyLoader",
75 NULL,
76 };
77
78 static struct flash_platform_data wp543_flash_data = {
79 .part_probes = wp543_part_probes,
80 };
81
82 static void __init wp543_setup(void)
83 {
84 ar71xx_add_device_m25p80(&wp543_flash_data);
85
86 ar71xx_add_device_mdio(0, 0xfffffff0);
87
88 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0);
89 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
90 ar71xx_eth0_data.phy_mask = 0x0f;
91 ar71xx_eth0_data.reset_bit = RESET_MODULE_GE0_MAC |
92 RESET_MODULE_GE0_PHY;
93 ar71xx_add_device_eth(0);
94
95 ar71xx_add_device_usb();
96
97 pb42_pci_init();
98
99 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
100 wp543_leds_gpio);
101
102 ar71xx_register_gpio_keys_polled(-1, WP543_KEYS_POLL_INTERVAL,
103 ARRAY_SIZE(wp543_gpio_keys),
104 wp543_gpio_keys);
105 }
106
107 MIPS_MACHINE(AR71XX_MACH_WP543, "WP543", "Compex WP543", wp543_setup);