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 ar91xx_flash_platform_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
= "ar91xx-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
,
171 .ucode_name
= "vsc7385_ucode_ap83.bin",
174 static struct spi_board_info ap83_spi_info
[] = {
178 .max_speed_hz
= 25000000,
179 .modalias
= "spi-vsc7385",
180 .platform_data
= &ap83_vsc7385_data
,
181 .controller_data
= (void *) AP83_050_GPIO_VSC7385_CS
,
185 static void __init
ap83_generic_setup(void)
187 u8
*mac
= (u8
*) KSEG1ADDR(0x1fff1000);
189 ar71xx_set_mac_base(mac
);
191 ar71xx_add_device_mdio(0xfffffffe);
193 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
194 ar71xx_eth0_data
.phy_mask
= 0x1;
196 ar71xx_add_device_eth(0);
198 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
199 ar71xx_eth1_data
.phy_mask
= 0x0;
200 ar71xx_eth1_data
.speed
= SPEED_1000
;
201 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
203 ar71xx_eth1_pll_data
.pll_1000
= 0x1f000000;
205 ar71xx_add_device_eth(1);
207 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio
),
210 ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(ap83_gpio_buttons
),
213 ar71xx_add_device_usb();
215 ar91xx_add_device_wmac();
217 platform_device_register(&ap83_flash_device
);
219 spi_register_board_info(ap83_spi_info
, ARRAY_SIZE(ap83_spi_info
));
222 static void __init
ap83_040_setup(void)
224 ap83_flash_data
.is_shared
=1;
225 ap83_generic_setup();
226 platform_device_register(&ap83_040_spi_device
);
229 static void __init
ap83_050_setup(void)
231 ap83_generic_setup();
232 platform_device_register(&ap83_050_spi_device
);
235 static void __init
ap83_setup(void)
237 u8
*board_id
= (u8
*) KSEG1ADDR(0x1fff1244);
238 unsigned int board_version
;
240 board_version
= (unsigned int)(board_id
[0] - '0');
241 board_version
+= ((unsigned int)(board_id
[1] - '0')) * 10;
243 switch (board_version
) {
251 printk(KERN_WARNING
"AP83-%03u board is not yet supported\n",
256 MIPS_MACHINE(AR71XX_MACH_AP83
, "Atheros AP83", ap83_setup
);