ap81: register SPI flash, and add default MTD partitions
[oweals/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-ap81.c
1 /*
2  *  Atheros AP81 board support
3  *
4  *  Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5  *  Copyright (C) 2009 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/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/input.h>
18
19 #include <asm/mips_machine.h>
20 #include <asm/mach-ar71xx/ar71xx.h>
21
22 #include "devices.h"
23
24 #define AP81_GPIO_BTN_SW4       12
25 #define AP81_GPIO_BTN_SW1       21
26
27 #define AP81_BUTTONS_POLL_INTERVAL      20
28
29 #ifdef CONFIG_MTD_PARTITIONS
30 static struct mtd_partition ap81_partitions[] = {
31         {
32                 .name           = "u-boot",
33                 .offset         = 0,
34                 .size           = 0x040000,
35                 .mask_flags     = MTD_WRITEABLE,
36         } , {
37                 .name           = "u-boot-env",
38                 .offset         = 0x040000,
39                 .size           = 0x010000,
40         } , {
41                 .name           = "rootfs",
42                 .offset         = 0x050000,
43                 .size           = 0x500000,
44         } , {
45                 .name           = "uImage",
46                 .offset         = 0x550000,
47                 .size           = 0x100000,
48         } , {
49                 .name           = "ART",
50                 .offset         = 0x650000,
51                 .size           = 0x1b0000,
52                 .mask_flags     = MTD_WRITEABLE,
53         }
54 };
55 #endif /* CONFIG_MTD_PARTITIONS */
56
57 static struct flash_platform_data ap81_flash_data = {
58 #ifdef CONFIG_MTD_PARTITIONS
59         .parts          = ap81_partitions,
60         .nr_parts       = ARRAY_SIZE(ap81_partitions),
61 #endif
62 };
63
64 static struct spi_board_info ap81_spi_info[] = {
65         {
66                 .bus_num        = 0,
67                 .chip_select    = 0,
68                 .max_speed_hz   = 25000000,
69                 .modalias       = "m25p80",
70                 .platform_data  = &ap81_flash_data,
71         }
72 };
73
74 static struct gpio_button ap81_gpio_buttons[] __initdata = {
75         {
76                 .desc           = "sw1",
77                 .type           = EV_KEY,
78                 .code           = BTN_0,
79                 .threshold      = 5,
80                 .gpio           = AP81_GPIO_BTN_SW1,
81                 .active_low     = 1,
82         } , {
83                 .desc           = "sw4",
84                 .type           = EV_KEY,
85                 .code           = BTN_1,
86                 .threshold      = 5,
87                 .gpio           = AP81_GPIO_BTN_SW4,
88                 .active_low     = 1,
89         }
90 };
91
92 static void __init ap81_setup(void)
93 {
94         ar71xx_add_device_mdio(0x0);
95
96         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
97         ar71xx_eth0_data.phy_mask = 0xf;
98         ar71xx_eth0_data.speed = SPEED_100;
99         ar71xx_eth0_data.duplex = DUPLEX_FULL;
100         ar71xx_eth0_data.has_ar8216 = 1;
101
102         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
103         ar71xx_eth1_data.phy_mask = 0x10;
104
105         ar71xx_add_device_eth(0);
106         ar71xx_add_device_eth(1);
107
108         ar71xx_add_device_usb();
109
110         ar71xx_add_device_spi(NULL, ap81_spi_info,
111                               ARRAY_SIZE(ap81_spi_info));
112
113         ar71xx_add_device_gpio_buttons(-1, AP81_BUTTONS_POLL_INTERVAL,
114                                         ARRAY_SIZE(ap81_gpio_buttons),
115                                         ap81_gpio_buttons);
116
117         ar91xx_add_device_wmac();
118 }
119
120 MIPS_MACHINE(AR71XX_MACH_AP81, "Atheros AP81", ap81_setup);