ar71xx: add support for RB mAP L-2nD
[openwrt/staging/wigyori.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-bhu-bxu2000n2-a.c
1 /*
2 * BHU BXU2000n-2 A1 board support
3 *
4 * Copyright (C) 2013 Terry Yang <yangbo@bhunetworks.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #include <linux/gpio.h>
12 #include <linux/platform_device.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-usb.h"
23 #include "dev-wmac.h"
24 #include "machtypes.h"
25
26 #define BHU_BXU2000N2_A1_GPIO_LED_WLAN 13
27 #define BHU_BXU2000N2_A1_GPIO_LED_WAN 19
28 #define BHU_BXU2000N2_A1_GPIO_LED_LAN 21
29 #define BHU_BXU2000N2_A1_GPIO_LED_SYSTEM 14
30
31 #define BHU_BXU2000N2_A1_GPIO_BTN_RESET 17
32
33 #define BHU_BXU2000N2_KEYS_POLL_INTERVAL 20 /* msecs */
34 #define BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL \
35 (3 * BHU_BXU2000N2_KEYS_POLL_INTERVAL)
36
37 static const char *bhu_bxu2000n2_part_probes[] = {
38 "cmdlinepart",
39 NULL,
40 };
41
42 static struct flash_platform_data bhu_bxu2000n2_flash_data = {
43 .part_probes = bhu_bxu2000n2_part_probes,
44 };
45
46 static struct gpio_led bhu_bxu2000n2_a1_leds_gpio[] __initdata = {
47 {
48 .name = "bhu:green:status",
49 .gpio = BHU_BXU2000N2_A1_GPIO_LED_SYSTEM,
50 .active_low = 1,
51 }, {
52 .name = "bhu:green:lan",
53 .gpio = BHU_BXU2000N2_A1_GPIO_LED_LAN,
54 .active_low = 1,
55 }, {
56 .name = "bhu:green:wan",
57 .gpio = BHU_BXU2000N2_A1_GPIO_LED_WAN,
58 .active_low = 1,
59 }, {
60 .name = "bhu:green:wlan",
61 .gpio = BHU_BXU2000N2_A1_GPIO_LED_WLAN,
62 .active_low = 1,
63 },
64 };
65
66 static struct gpio_keys_button bhu_bxu2000n2_a1_gpio_keys[] __initdata = {
67 {
68 .desc = "Reset button",
69 .type = EV_KEY,
70 .code = KEY_RESTART,
71 .debounce_interval = BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL,
72 .gpio = BHU_BXU2000N2_A1_GPIO_BTN_RESET,
73 .active_low = 1,
74 }
75 };
76
77 static void __init bhu_ap123_setup(void)
78 {
79 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
80 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
81
82 ath79_register_m25p80(&bhu_bxu2000n2_flash_data);
83
84 ath79_register_mdio(1, 0x0);
85
86 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
87 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
88
89 /* GMAC0 is connected to the PHY4 of the internal switch */
90 ath79_switch_data.phy4_mii_en = 1;
91 ath79_switch_data.phy_poll_mask = BIT(4);
92 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
93 ath79_eth0_data.phy_mask = BIT(4);
94 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
95 ath79_register_eth(0);
96
97 /* GMAC1 is connected to the internal switch. Only use PHY3 */
98 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
99 ath79_eth1_data.phy_mask = BIT(3);
100 ath79_register_eth(1);
101
102 ath79_register_wmac(ee, ee+2);
103 }
104
105 static void __init bhu_bxu2000n2_a1_setup(void)
106 {
107 bhu_ap123_setup();
108
109 ath79_register_leds_gpio(-1, ARRAY_SIZE(bhu_bxu2000n2_a1_leds_gpio),
110 bhu_bxu2000n2_a1_leds_gpio);
111
112 ath79_register_gpio_keys_polled(1, BHU_BXU2000N2_KEYS_POLL_INTERVAL,
113 ARRAY_SIZE(bhu_bxu2000n2_a1_gpio_keys),
114 bhu_bxu2000n2_a1_gpio_keys);
115 }
116
117 MIPS_MACHINE(ATH79_MACH_BHU_BXU2000N2_A1, "BXU2000n-2-A1",
118 "BHU BXU2000n-2 rev. A1",
119 bhu_bxu2000n2_a1_setup);
120