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/input.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/mtd/physmap.h>
18 #include <linux/spi/spi.h>
19 #include <linux/spi/spi_gpio.h>
20 #include <linux/spi/vsc7385.h>
22 #include <asm/mips_machine.h>
23 #include <asm/mach-ar71xx/ar71xx.h>
27 #define AP83_GPIO_LED_WLAN 6
28 #define AP83_GPIO_LED_POWER 14
29 #define AP83_GPIO_LED_JUMPSTART 15
30 #define AP83_GPIO_BTN_JUMPSTART 12
31 #define AP83_GPIO_BTN_RESET 21
33 #define AP83_050_GPIO_VSC7385_CS 1
34 #define AP83_050_GPIO_VSC7385_MISO 3
35 #define AP83_050_GPIO_VSC7385_MOSI 16
36 #define AP83_050_GPIO_VSC7385_SCK 17
38 #ifdef CONFIG_MTD_PARTITIONS
39 static struct mtd_partition ap83_flash_partitions[] = {
44 .mask_flags = MTD_WRITEABLE,
49 .mask_flags = MTD_WRITEABLE,
62 .mask_flags = MTD_WRITEABLE,
69 #endif /* CONFIG_MTD_PARTITIONS */
71 static struct physmap_flash_data ap83_flash_data = {
73 #ifdef CONFIG_MTD_PARTITIONS
74 .parts = ap83_flash_partitions,
75 .nr_parts = ARRAY_SIZE(ap83_flash_partitions),
79 static struct resource ap83_flash_resources[] = {
81 .start = AR71XX_SPI_BASE,
82 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
83 .flags = IORESOURCE_MEM,
87 static struct platform_device ap83_flash_device = {
88 .name = "physmap-flash",
90 .resource = ap83_flash_resources,
91 .num_resources = ARRAY_SIZE(ap83_flash_resources),
93 .platform_data = &ap83_flash_data,
97 static struct gpio_led ap83_leds_gpio[] __initdata = {
99 .name = "ap83:green:jumpstart",
100 .gpio = AP83_GPIO_LED_JUMPSTART,
103 .name = "ap83:green:power",
104 .gpio = AP83_GPIO_LED_POWER,
107 .name = "ap83:green:wlan",
108 .gpio = AP83_GPIO_LED_WLAN,
113 static struct gpio_button ap83_gpio_buttons[] __initdata = {
115 .desc = "soft_reset",
119 .gpio = AP83_GPIO_BTN_RESET,
126 .gpio = AP83_GPIO_BTN_JUMPSTART,
131 static struct resource ap83_040_spi_resources[] = {
133 .start = AR71XX_SPI_BASE,
134 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
135 .flags = IORESOURCE_MEM,
139 static struct platform_device ap83_040_spi_device = {
142 .resource = ap83_040_spi_resources,
143 .num_resources = ARRAY_SIZE(ap83_040_spi_resources),
146 static struct spi_gpio_platform_data ap83_050_spi_data = {
147 .miso = AP83_050_GPIO_VSC7385_MISO,
148 .mosi = AP83_050_GPIO_VSC7385_MOSI,
149 .sck = AP83_050_GPIO_VSC7385_SCK,
153 static struct platform_device ap83_050_spi_device = {
157 .platform_data = &ap83_050_spi_data,
161 static void ap83_vsc7385_reset(void)
163 ar71xx_device_stop(RESET_MODULE_GE1_PHY);
165 ar71xx_device_start(RESET_MODULE_GE1_PHY);
169 static struct vsc7385_platform_data ap83_vsc7385_data = {
170 .reset = ap83_vsc7385_reset,
173 static struct spi_board_info ap83_spi_info[] = {
177 .max_speed_hz = 25000000,
178 .modalias = "spi-vsc7385",
179 .platform_data = &ap83_vsc7385_data,
180 .controller_data = (void *) AP83_050_GPIO_VSC7385_CS,
184 static void __init ap83_generic_setup(void)
186 u8 *mac = (u8 *) KSEG1ADDR(0x1fff1000);
188 ar71xx_set_mac_base(mac);
190 ar71xx_add_device_mdio(0xfffffffe);
192 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
193 ar71xx_eth0_data.phy_mask = 0x1;
195 ar71xx_add_device_eth(0);
197 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
198 ar71xx_eth1_data.phy_mask = 0x0;
199 ar71xx_eth1_data.speed = SPEED_1000;
200 ar71xx_eth1_data.duplex = DUPLEX_FULL;
202 ar71xx_eth1_pll_data.pll_1000 = 0x1f000000;
204 ar71xx_add_device_eth(1);
206 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
209 ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(ap83_gpio_buttons),
212 ar71xx_add_device_usb();
214 ar91xx_add_device_wmac();
216 platform_device_register(&ap83_flash_device);
218 spi_register_board_info(ap83_spi_info, ARRAY_SIZE(ap83_spi_info));
221 static void __init ap83_040_setup(void)
223 ar71xx_flash_lock_enable();
224 ap83_generic_setup();
225 platform_device_register(&ap83_040_spi_device);
228 static void __init ap83_050_setup(void)
230 ap83_generic_setup();
231 platform_device_register(&ap83_050_spi_device);
234 static void __init ap83_setup(void)
236 u8 *board_id = (u8 *) KSEG1ADDR(0x1fff1244);
237 unsigned int board_version;
239 board_version = (unsigned int)(board_id[0] - '0');
240 board_version += ((unsigned int)(board_id[1] - '0')) * 10;
242 switch (board_version) {
250 printk(KERN_WARNING "AP83-%03u board is not yet supported\n",
255 MIPS_MACHINE(AR71XX_MACH_AP83, "Atheros AP83", ap83_setup);