ar71xx: add common m25p80 device
[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/input.h>
16
17 #include <asm/mips_machine.h>
18 #include <asm/mach-ar71xx/ar71xx.h>
19
20 #include "devices.h"
21 #include "dev-m25p80.h"
22
23 #define AP81_GPIO_LED_STATUS    1
24 #define AP81_GPIO_LED_AOSS      3
25 #define AP81_GPIO_LED_WLAN      6
26 #define AP81_GPIO_LED_POWER     14
27
28 #define AP81_GPIO_BTN_SW4       12
29 #define AP81_GPIO_BTN_SW1       21
30
31 #define AP81_BUTTONS_POLL_INTERVAL      20
32
33 #ifdef CONFIG_MTD_PARTITIONS
34 static struct mtd_partition ap81_partitions[] = {
35         {
36                 .name           = "u-boot",
37                 .offset         = 0,
38                 .size           = 0x040000,
39                 .mask_flags     = MTD_WRITEABLE,
40         } , {
41                 .name           = "u-boot-env",
42                 .offset         = 0x040000,
43                 .size           = 0x010000,
44         } , {
45                 .name           = "rootfs",
46                 .offset         = 0x050000,
47                 .size           = 0x500000,
48         } , {
49                 .name           = "uImage",
50                 .offset         = 0x550000,
51                 .size           = 0x100000,
52         } , {
53                 .name           = "ART",
54                 .offset         = 0x650000,
55                 .size           = 0x1b0000,
56                 .mask_flags     = MTD_WRITEABLE,
57         }
58 };
59 #endif /* CONFIG_MTD_PARTITIONS */
60
61 static struct flash_platform_data ap81_flash_data = {
62 #ifdef CONFIG_MTD_PARTITIONS
63         .parts          = ap81_partitions,
64         .nr_parts       = ARRAY_SIZE(ap81_partitions),
65 #endif
66 };
67
68 static struct gpio_led ap81_leds_gpio[] __initdata = {
69         {
70                 .name           = "ap81:green:status",
71                 .gpio           = AP81_GPIO_LED_STATUS,
72                 .active_low     = 1,
73         }, {
74                 .name           = "ap81:amber:aoss",
75                 .gpio           = AP81_GPIO_LED_AOSS,
76                 .active_low     = 1,
77         }, {
78                 .name           = "ap81:green:wlan",
79                 .gpio           = AP81_GPIO_LED_WLAN,
80                 .active_low     = 1,
81         }, {
82                 .name           = "ap81:green:power",
83                 .gpio           = AP81_GPIO_LED_POWER,
84                 .active_low     = 1,
85         }
86 };
87
88 static struct gpio_button ap81_gpio_buttons[] __initdata = {
89         {
90                 .desc           = "sw1",
91                 .type           = EV_KEY,
92                 .code           = BTN_0,
93                 .threshold      = 5,
94                 .gpio           = AP81_GPIO_BTN_SW1,
95                 .active_low     = 1,
96         } , {
97                 .desc           = "sw4",
98                 .type           = EV_KEY,
99                 .code           = BTN_1,
100                 .threshold      = 5,
101                 .gpio           = AP81_GPIO_BTN_SW4,
102                 .active_low     = 1,
103         }
104 };
105
106 static void __init ap81_setup(void)
107 {
108         u8 *mac = (u8 *) KSEG1ADDR(0x1fff1000);
109
110         ar71xx_set_mac_base(mac);
111         ar71xx_add_device_mdio(0x0);
112
113         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
114         ar71xx_eth0_data.phy_mask = 0xf;
115         ar71xx_eth0_data.speed = SPEED_100;
116         ar71xx_eth0_data.duplex = DUPLEX_FULL;
117         ar71xx_eth0_data.has_ar8216 = 1;
118
119         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
120         ar71xx_eth1_data.phy_mask = 0x10;
121
122         ar71xx_add_device_eth(0);
123         ar71xx_add_device_eth(1);
124
125         ar71xx_add_device_usb();
126
127         ar71xx_add_device_m25p80(&ap81_flash_data);
128
129         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio),
130                                         ap81_leds_gpio);
131
132         ar71xx_add_device_gpio_buttons(-1, AP81_BUTTONS_POLL_INTERVAL,
133                                         ARRAY_SIZE(ap81_gpio_buttons),
134                                         ap81_gpio_buttons);
135
136         ar91xx_add_device_wmac();
137 }
138
139 MIPS_MACHINE(AR71XX_MACH_AP81, "Atheros AP81", ap81_setup);