2 * Netgear WNDR3700 board support
4 * Copyright (C) 2009 Marco Porsch
5 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
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.
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/input.h>
16 #include <linux/delay.h>
17 #include <linux/rtl8366_smi.h>
19 #include <asm/mips_machine.h>
20 #include <asm/mach-ar71xx/ar71xx.h>
23 #include "dev-m25p80.h"
24 #include "dev-ap94-pci.h"
26 #define WNDR3700_GPIO_LED_WPS_ORANGE 0
27 #define WNDR3700_GPIO_LED_POWER_ORANGE 1
28 #define WNDR3700_GPIO_LED_POWER_GREEN 2
29 #define WNDR3700_GPIO_LED_WPS_GREEN 4
31 #define WNDR3700_GPIO_BTN_WPS 3
32 #define WNDR3700_GPIO_BTN_RESET 8
33 #define WNDR3700_GPIO_BTN_WIFI 11
35 #define WNDR3700_GPIO_RTL8366_SDA 5
36 #define WNDR3700_GPIO_RTL8366_SCK 7
38 #define WNDR3700_BUTTONS_POLL_INTERVAL 20
40 #define WNDR3700_WMAC0_MAC_OFFSET 0
41 #define WNDR3700_WMAC1_MAC_OFFSET 0xc
42 #define WNDR3700_CALDATA0_OFFSET 0x1000
43 #define WNDR3700_CALDATA1_OFFSET 0x5000
45 #ifdef CONFIG_MTD_PARTITIONS
46 static struct mtd_partition wndr3700_partitions
[] = {
51 .mask_flags
= MTD_WRITEABLE
,
56 .mask_flags
= MTD_WRITEABLE
,
65 .mask_flags
= MTD_WRITEABLE
,
70 .mask_flags
= MTD_WRITEABLE
,
75 .mask_flags
= MTD_WRITEABLE
,
77 .name
= "traffic_meter",
80 .mask_flags
= MTD_WRITEABLE
,
85 .mask_flags
= MTD_WRITEABLE
,
90 .mask_flags
= MTD_WRITEABLE
,
93 #endif /* CONFIG_MTD_PARTITIONS */
95 static struct flash_platform_data wndr3700_flash_data
= {
96 #ifdef CONFIG_MTD_PARTITIONS
97 .parts
= wndr3700_partitions
,
98 .nr_parts
= ARRAY_SIZE(wndr3700_partitions
),
102 static struct gpio_led wndr3700_leds_gpio
[] __initdata
= {
104 .name
= "wndr3700:green:power",
105 .gpio
= WNDR3700_GPIO_LED_POWER_GREEN
,
108 .name
= "wndr3700:orange:power",
109 .gpio
= WNDR3700_GPIO_LED_POWER_ORANGE
,
112 .name
= "wndr3700:green:wps",
113 .gpio
= WNDR3700_GPIO_LED_WPS_GREEN
,
116 .name
= "wndr3700:orange:wps",
117 .gpio
= WNDR3700_GPIO_LED_WPS_ORANGE
,
122 static struct gpio_button wndr3700_gpio_buttons
[] __initdata
= {
128 .gpio
= WNDR3700_GPIO_BTN_RESET
,
134 .gpio
= WNDR3700_GPIO_BTN_WPS
,
140 .gpio
= WNDR3700_GPIO_BTN_WIFI
,
144 static struct rtl8366_smi_platform_data wndr3700_rtl8366_smi_data
= {
145 .gpio_sda
= WNDR3700_GPIO_RTL8366_SDA
,
146 .gpio_sck
= WNDR3700_GPIO_RTL8366_SCK
,
149 static struct platform_device wndr3700_rtl8366_smi_device
= {
150 .name
= "rtl8366-smi",
153 .platform_data
= &wndr3700_rtl8366_smi_data
,
157 static void __init
wndr3700_setup(void)
159 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
161 ar71xx_set_mac_base(art
);
163 ar71xx_eth0_pll_data
.pll_1000
= 0x11110000;
164 ar71xx_eth0_data
.mii_bus_dev
= &wndr3700_rtl8366_smi_device
.dev
;
165 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
166 ar71xx_eth0_data
.phy_mask
= 0xf;
167 ar71xx_eth0_data
.speed
= SPEED_1000
;
168 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
170 ar71xx_eth1_pll_data
.pll_1000
= 0x11110000;
171 ar71xx_eth1_data
.mii_bus_dev
= &wndr3700_rtl8366_smi_device
.dev
;
172 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
173 ar71xx_eth1_data
.phy_mask
= 0x10;
175 ar71xx_add_device_eth(0);
176 ar71xx_add_device_eth(1);
178 ar71xx_add_device_usb();
180 ar71xx_add_device_m25p80(&wndr3700_flash_data
);
182 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio
),
185 ar71xx_add_device_gpio_buttons(-1, WNDR3700_BUTTONS_POLL_INTERVAL
,
186 ARRAY_SIZE(wndr3700_gpio_buttons
),
187 wndr3700_gpio_buttons
);
189 platform_device_register(&wndr3700_rtl8366_smi_device
);
190 platform_device_register_simple("wndr3700-led-usb", -1, NULL
, 0);
192 ap94_pci_init(art
+ WNDR3700_CALDATA0_OFFSET
,
193 art
+ WNDR3700_WMAC0_MAC_OFFSET
,
194 art
+ WNDR3700_CALDATA1_OFFSET
,
195 art
+ WNDR3700_WMAC1_MAC_OFFSET
);
198 MIPS_MACHINE(AR71XX_MACH_WNDR3700
, "NETGEAR WNDR3700", wndr3700_setup
);