ar71xx: add Netgear WNR1000v2/WNR1000v2-VC support (#18633)
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wnr2000-v3.c
1 /*
2 * NETGEAR WNR2000v3/WNR612v2/WNR1000v2 board support
3 *
4 * Copytight (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
5 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 */
13
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16
17 #include <asm/mach-ath79/ath79.h>
18
19 #include "dev-ap9x-pci.h"
20 #include "dev-eth.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
24 #include "machtypes.h"
25
26 #define WNR2000V3_GPIO_LED_WAN_GREEN 0
27 #define WNR2000V3_GPIO_LED_LAN1_AMBER 1
28 #define WNR2000V3_GPIO_LED_LAN4_AMBER 12
29 #define WNR2000V3_GPIO_LED_PWR_GREEN 14
30 #define WNR2000V3_GPIO_BTN_WPS 11
31
32 #define WNR612V2_GPIO_LED_PWR_GREEN 11
33
34 #define WNR1000V2_GPIO_LED_PWR_AMBER 1
35 #define WNR1000V2_GPIO_LED_PWR_GREEN 11
36
37 #define WNR2000V3_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define WNR2000V3_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V3_KEYS_POLL_INTERVAL)
39
40 #define WNR2000V3_MAC0_OFFSET 0
41 #define WNR2000V3_MAC1_OFFSET 6
42 #define WNR2000V3_PCIE_CALDATA_OFFSET 0x1000
43
44 static struct gpio_led wnr2000v3_leds_gpio[] __initdata = {
45 {
46 .name = "wnr2000v3:green:power",
47 .gpio = WNR2000V3_GPIO_LED_PWR_GREEN,
48 .active_low = 1,
49 }, {
50 .name = "wnr2000v3:green:wan",
51 .gpio = WNR2000V3_GPIO_LED_WAN_GREEN,
52 .active_low = 1,
53 }
54 };
55
56 static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
57 {
58 .name = "netgear:green:power",
59 .gpio = WNR612V2_GPIO_LED_PWR_GREEN,
60 .active_low = 1,
61 }
62 };
63
64 static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
65 {
66 .name = "netgear:green:power",
67 .gpio = WNR1000V2_GPIO_LED_PWR_GREEN,
68 .active_low = 1,
69 }, {
70 .name = "netgear:amber:power",
71 .gpio = WNR1000V2_GPIO_LED_PWR_AMBER,
72 .active_low = 1,
73 }
74 };
75
76 static struct gpio_keys_button wnr2000v3_gpio_keys[] __initdata = {
77 {
78 .desc = "wps",
79 .type = EV_KEY,
80 .code = KEY_WPS_BUTTON,
81 .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
82 .gpio = WNR2000V3_GPIO_BTN_WPS,
83 }
84 };
85
86 static void __init wnr_common_setup(void)
87 {
88 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
89
90 ath79_register_mdio(0, 0x0);
91
92 ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V3_MAC0_OFFSET, 0);
93 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
94 ath79_eth0_data.speed = SPEED_100;
95 ath79_eth0_data.duplex = DUPLEX_FULL;
96
97 ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V3_MAC1_OFFSET, 0);
98 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
99 ath79_eth1_data.phy_mask = 0x10;
100
101 ath79_register_eth(0);
102 ath79_register_eth(1);
103
104 ath79_register_m25p80(NULL);
105 ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, NULL);
106 }
107
108 static void __init wnr2000v3_setup(void)
109 {
110 wnr_common_setup();
111
112 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
113 wnr2000v3_leds_gpio);
114
115 ath79_register_gpio_keys_polled(-1, WNR2000V3_KEYS_POLL_INTERVAL,
116 ARRAY_SIZE(wnr2000v3_gpio_keys),
117 wnr2000v3_gpio_keys);
118 }
119
120 MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup);
121
122 static void __init wnr612v2_setup(void)
123 {
124 wnr_common_setup();
125
126 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
127 wnr612v2_leds_gpio);
128 }
129
130 MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
131
132 static void __init wnr1000v2_setup(void)
133 {
134 wnr_common_setup();
135
136 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
137 wnr1000v2_leds_gpio);
138 }
139
140 MIPS_MACHINE(ATH79_MACH_WNR1000_V2, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup);