[ar71xx] register parallel flash device 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/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/spi/spi.h>
18 #include <linux/spi/spi_gpio.h>
19
20 #include <asm/mips_machine.h>
21 #include <asm/mach-ar71xx/ar71xx.h>
22
23 #include "devices.h"
24
25 #define AP83_GPIO_LED_WLAN 6
26 #define AP83_GPIO_LED_POWER 14
27 #define AP83_GPIO_LED_JUMPSTART 15
28 #define AP83_GPIO_BTN_JUMPSTART 12
29 #define AP83_GPIO_BTN_RESET 21
30
31 #define AP83_GPIO_VSC7385_CS 1
32 #define AP83_GPIO_VSC7385_MISO 3
33 #define AP83_GPIO_VSC7385_MOSI 16
34 #define AP83_GPIO_VSC7385_SCK 17
35
36 #ifdef CONFIG_MTD_PARTITIONS
37 static struct mtd_partition ap83_flash_partitions[] = {
38 {
39 .name = "u-boot",
40 .offset = 0,
41 .size = 0x040000,
42 .mask_flags = MTD_WRITEABLE,
43 } , {
44 .name = "u-boot-env",
45 .offset = 0x040000,
46 .size = 0x020000,
47 .mask_flags = MTD_WRITEABLE,
48 } , {
49 .name = "rootfs",
50 .offset = 0x060000,
51 .size = 0x400000,
52 } , {
53 .name = "kernel",
54 .offset = 0x460000,
55 .size = 0x100000,
56 } , {
57 .name = "art",
58 .offset = 0x560000,
59 .size = 0x2a0000,
60 .mask_flags = MTD_WRITEABLE,
61 } , {
62 .name = "firmware",
63 .offset = 0x060000,
64 .size = 0x500000,
65 }
66 };
67 #endif /* CONFIG_MTD_PARTITIONS */
68
69 static struct physmap_flash_data ap83_flash_data = {
70 .width = 2,
71 #ifdef CONFIG_MTD_PARTITIONS
72 .parts = ap83_flash_partitions,
73 .nr_parts = ARRAY_SIZE(ap83_flash_partitions),
74 #endif
75 };
76
77 static struct resource ap83_flash_resources[] = {
78 [0] = {
79 .start = AR71XX_SPI_BASE,
80 .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
81 .flags = IORESOURCE_MEM,
82 },
83 };
84
85 static struct platform_device ap83_flash_device = {
86 .name = "physmap-flash",
87 .id = -1,
88 .resource = ap83_flash_resources,
89 .num_resources = ARRAY_SIZE(ap83_flash_resources),
90 .dev = {
91 .platform_data = &ap83_flash_data,
92 }
93 };
94
95 static struct gpio_led ap83_leds_gpio[] __initdata = {
96 {
97 .name = "ap83:green:jumpstart",
98 .gpio = AP83_GPIO_LED_JUMPSTART,
99 .active_low = 0,
100 }, {
101 .name = "ap83:green:power",
102 .gpio = AP83_GPIO_LED_POWER,
103 .active_low = 0,
104 }, {
105 .name = "ap83:green:wlan",
106 .gpio = AP83_GPIO_LED_WLAN,
107 .active_low = 0,
108 },
109 };
110
111 static struct gpio_button ap83_gpio_buttons[] __initdata = {
112 {
113 .desc = "soft_reset",
114 .type = EV_KEY,
115 .code = BTN_0,
116 .threshold = 5,
117 .gpio = AP83_GPIO_BTN_RESET,
118 .active_low = 1,
119 } , {
120 .desc = "jumpstart",
121 .type = EV_KEY,
122 .code = BTN_1,
123 .threshold = 5,
124 .gpio = AP83_GPIO_BTN_JUMPSTART,
125 .active_low = 1,
126 }
127 };
128
129 static struct spi_gpio_platform_data ap83_spi_data = {
130 .miso = AP83_GPIO_VSC7385_MISO,
131 .mosi = AP83_GPIO_VSC7385_MOSI,
132 .sck = AP83_GPIO_VSC7385_SCK,
133 .num_chipselect = 1,
134 };
135
136 static struct platform_device ap83_spi_device = {
137 .name = "spi_gpio",
138 .id = 0,
139 .dev = {
140 .platform_data = &ap83_spi_data,
141 }
142 };
143
144 static void __init ap83_setup(void)
145 {
146 ar71xx_add_device_mdio(0xfffffffe);
147
148 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
149 ar71xx_eth0_data.phy_mask = 0x1;
150
151 ar71xx_add_device_eth(0);
152
153 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
154 ar71xx_eth1_data.phy_mask = 0x0;
155 ar71xx_eth1_data.speed = SPEED_1000;
156 ar71xx_eth1_data.duplex = DUPLEX_FULL;
157
158 ar71xx_eth1_pll_data.pll_1000 = 0x1f000000;
159
160 ar71xx_add_device_eth(1);
161
162 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
163 ap83_leds_gpio);
164
165 ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(ap83_gpio_buttons),
166 ap83_gpio_buttons);
167
168 ar71xx_add_device_usb();
169
170 ar91xx_add_device_wmac();
171
172 platform_device_register(&ap83_spi_device);
173 platform_device_register(&ap83_flash_device);
174 }
175
176 MIPS_MACHINE(AR71XX_MACH_AP83, "Atheros AP83", ap83_setup);