[ar71xx] register SPI bus on the AP83 board
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-ap83.c
1 /*
2 * Atheros AP83 board support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
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.
10 */
11
12 #include <linux/platform_device.h>
13 #include <linux/input.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/spi_gpio.h>
16
17 #include <asm/mips_machine.h>
18 #include <asm/mach-ar71xx/ar71xx.h>
19
20 #include "devices.h"
21
22 #define AP83_GPIO_LED_WLAN 6
23 #define AP83_GPIO_LED_POWER 14
24 #define AP83_GPIO_LED_JUMPSTART 15
25 #define AP83_GPIO_BTN_JUMPSTART 12
26 #define AP83_GPIO_BTN_RESET 21
27
28 #define AP83_GPIO_VSC7385_CS 1
29 #define AP83_GPIO_VSC7385_MISO 3
30 #define AP83_GPIO_VSC7385_MOSI 16
31 #define AP83_GPIO_VSC7385_SCK 17
32
33 static struct gpio_led ap83_leds_gpio[] __initdata = {
34 {
35 .name = "ap83:green:jumpstart",
36 .gpio = AP83_GPIO_LED_JUMPSTART,
37 .active_low = 0,
38 }, {
39 .name = "ap83:green:power",
40 .gpio = AP83_GPIO_LED_POWER,
41 .active_low = 0,
42 }, {
43 .name = "ap83:green:wlan",
44 .gpio = AP83_GPIO_LED_WLAN,
45 .active_low = 0,
46 },
47 };
48
49 static struct gpio_button ap83_gpio_buttons[] __initdata = {
50 {
51 .desc = "soft_reset",
52 .type = EV_KEY,
53 .code = BTN_0,
54 .threshold = 5,
55 .gpio = AP83_GPIO_BTN_RESET,
56 .active_low = 1,
57 } , {
58 .desc = "jumpstart",
59 .type = EV_KEY,
60 .code = BTN_1,
61 .threshold = 5,
62 .gpio = AP83_GPIO_BTN_JUMPSTART,
63 .active_low = 1,
64 }
65 };
66
67 static struct spi_gpio_platform_data ap83_spi_data = {
68 .miso = AP83_GPIO_VSC7385_MISO,
69 .mosi = AP83_GPIO_VSC7385_MOSI,
70 .sck = AP83_GPIO_VSC7385_SCK,
71 .num_chipselect = 1,
72 };
73
74 static struct platform_device ap83_spi_device = {
75 .name = "spi_gpio",
76 .id = 0,
77 .dev = {
78 .platform_data = &ap83_spi_data,
79 }
80 };
81
82 static void __init ap83_setup(void)
83 {
84 ar71xx_add_device_mdio(0xfffffffe);
85
86 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
87 ar71xx_eth0_data.phy_mask = 0x1;
88
89 ar71xx_add_device_eth(0);
90
91 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
92 ar71xx_eth1_data.phy_mask = 0x0;
93 ar71xx_eth1_data.speed = SPEED_1000;
94 ar71xx_eth1_data.duplex = DUPLEX_FULL;
95
96 ar71xx_add_device_eth(1);
97
98 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
99 ap83_leds_gpio);
100
101 ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(ap83_gpio_buttons),
102 ap83_gpio_buttons);
103
104 ar71xx_add_device_usb();
105
106 ar91xx_add_device_wmac();
107
108 platform_device_register(&ap83_spi_device);
109 }
110
111 MIPS_MACHINE(AR71XX_MACH_AP83, "Atheros AP83", ap83_setup);