2 * Atheros AP83 board support
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@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/delay.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/spi/spi.h>
17 #include <linux/spi/spi_gpio.h>
18 #include <linux/spi/vsc7385.h>
20 #include <asm/mips_machine.h>
21 #include <asm/mach-ar71xx/ar71xx.h>
22 #include <asm/mach-ar71xx/ar91xx_flash.h>
25 #include "dev-ar913x-wmac.h"
26 #include "dev-gpio-buttons.h"
27 #include "dev-leds-gpio.h"
30 #define AP83_GPIO_LED_WLAN 6
31 #define AP83_GPIO_LED_POWER 14
32 #define AP83_GPIO_LED_JUMPSTART 15
33 #define AP83_GPIO_BTN_JUMPSTART 12
34 #define AP83_GPIO_BTN_RESET 21
36 #define AP83_050_GPIO_VSC7385_CS 1
37 #define AP83_050_GPIO_VSC7385_MISO 3
38 #define AP83_050_GPIO_VSC7385_MOSI 16
39 #define AP83_050_GPIO_VSC7385_SCK 17
41 #define AP83_BUTTONS_POLL_INTERVAL 20
43 #ifdef CONFIG_MTD_PARTITIONS
44 static struct mtd_partition ap83_flash_partitions[] = {
49 .mask_flags = MTD_WRITEABLE,
54 .mask_flags = MTD_WRITEABLE,
67 .mask_flags = MTD_WRITEABLE,
74 #endif /* CONFIG_MTD_PARTITIONS */
76 static struct ar91xx_flash_platform_data ap83_flash_data = {
78 #ifdef CONFIG_MTD_PARTITIONS
79 .parts = ap83_flash_partitions,
80 .nr_parts = ARRAY_SIZE(ap83_flash_partitions),
84 static struct resource ap83_flash_resources[] = {
86 .start = AR71XX_SPI_BASE,
87 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
88 .flags = IORESOURCE_MEM,
92 static struct platform_device ap83_flash_device = {
93 .name = "ar91xx-flash",
95 .resource = ap83_flash_resources,
96 .num_resources = ARRAY_SIZE(ap83_flash_resources),
98 .platform_data = &ap83_flash_data,
102 static struct gpio_led ap83_leds_gpio[] __initdata = {
104 .name = "ap83:green:jumpstart",
105 .gpio = AP83_GPIO_LED_JUMPSTART,
108 .name = "ap83:green:power",
109 .gpio = AP83_GPIO_LED_POWER,
112 .name = "ap83:green:wlan",
113 .gpio = AP83_GPIO_LED_WLAN,
118 static struct gpio_button ap83_gpio_buttons[] __initdata = {
120 .desc = "soft_reset",
124 .gpio = AP83_GPIO_BTN_RESET,
131 .gpio = AP83_GPIO_BTN_JUMPSTART,
136 static struct resource ap83_040_spi_resources[] = {
138 .start = AR71XX_SPI_BASE,
139 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
140 .flags = IORESOURCE_MEM,
144 static struct platform_device ap83_040_spi_device = {
147 .resource = ap83_040_spi_resources,
148 .num_resources = ARRAY_SIZE(ap83_040_spi_resources),
151 static struct spi_gpio_platform_data ap83_050_spi_data = {
152 .miso = AP83_050_GPIO_VSC7385_MISO,
153 .mosi = AP83_050_GPIO_VSC7385_MOSI,
154 .sck = AP83_050_GPIO_VSC7385_SCK,
158 static struct platform_device ap83_050_spi_device = {
162 .platform_data = &ap83_050_spi_data,
166 static void ap83_vsc7385_reset(void)
168 ar71xx_device_stop(RESET_MODULE_GE1_PHY);
170 ar71xx_device_start(RESET_MODULE_GE1_PHY);
174 static struct vsc7385_platform_data ap83_vsc7385_data = {
175 .reset = ap83_vsc7385_reset,
176 .ucode_name = "vsc7385_ucode_ap83.bin",
184 static struct spi_board_info ap83_spi_info[] = {
188 .max_speed_hz = 25000000,
189 .modalias = "spi-vsc7385",
190 .platform_data = &ap83_vsc7385_data,
191 .controller_data = (void *) AP83_050_GPIO_VSC7385_CS,
195 static void __init ap83_generic_setup(void)
197 u8 *mac = (u8 *) KSEG1ADDR(0x1fff1000);
199 ar71xx_set_mac_base(mac);
201 ar71xx_add_device_mdio(0xfffffffe);
203 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
204 ar71xx_eth0_data.phy_mask = 0x1;
206 ar71xx_add_device_eth(0);
208 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
209 ar71xx_eth1_data.phy_mask = 0x0;
210 ar71xx_eth1_data.speed = SPEED_1000;
211 ar71xx_eth1_data.duplex = DUPLEX_FULL;
213 ar71xx_eth1_pll_data.pll_1000 = 0x1f000000;
215 ar71xx_add_device_eth(1);
217 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
220 ar71xx_add_device_gpio_buttons(-1, AP83_BUTTONS_POLL_INTERVAL,
221 ARRAY_SIZE(ap83_gpio_buttons),
224 ar71xx_add_device_usb();
226 ar913x_add_device_wmac();
228 platform_device_register(&ap83_flash_device);
230 spi_register_board_info(ap83_spi_info, ARRAY_SIZE(ap83_spi_info));
233 static void __init ap83_040_setup(void)
235 ap83_flash_data.is_shared=1;
236 ap83_generic_setup();
237 platform_device_register(&ap83_040_spi_device);
240 static void __init ap83_050_setup(void)
242 ap83_generic_setup();
243 platform_device_register(&ap83_050_spi_device);
246 static void __init ap83_setup(void)
248 u8 *board_id = (u8 *) KSEG1ADDR(0x1fff1244);
249 unsigned int board_version;
251 board_version = (unsigned int)(board_id[0] - '0');
252 board_version += ((unsigned int)(board_id[1] - '0')) * 10;
254 switch (board_version) {
262 printk(KERN_WARNING "AP83-%03u board is not yet supported\n",
267 MIPS_MACHINE(AR71XX_MACH_AP83, "Atheros AP83", ap83_setup);