ar71xx: switch to 3.2.5
[openwrt.git] / target / linux / ar71xx / files-2.6.39 / arch / mips / ar71xx / mach-ap113.c
1 /*
2  *  Atheros AP113 board support
3  *
4  *  Copyright (C) 2011 Florian Fainelli <florian@openwrt.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  */
10
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/spi/flash.h>
14
15 #include "machtype.h"
16 #include "devices.h"
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19 #include "dev-m25p80.h"
20 #include "dev-pb9x-pci.h"
21 #include "dev-usb.h"
22
23 #define AP113_GPIO_LED_USB              0
24 #define AP113_GPIO_LED_STATUS           1
25 #define AP113_GPIO_LED_ST               11
26
27 #define AP113_GPIO_BTN_JUMPSTART        12
28
29 #define AP113_KEYS_POLL_INTERVAL        20      /* msecs */
30 #define AP113_KEYS_DEBOUNCE_INTERVAL    (3 * AP113_KEYS_POLL_INTERVAL)
31
32 #ifdef CONFIG_MTD_PARTITIONS
33 static struct mtd_partition ap113_parts[] = {
34         {
35                 .name           = "u-boot",
36                 .offset         = 0,
37                 .size           = 0x010000,
38                 .mask_flags     = MTD_WRITEABLE,
39         },
40         {
41                 .name           = "rootfs",
42                 .offset         = 0x010000,
43                 .size           = 0x300000,
44         },
45         {
46                 .name           = "uImage",
47                 .offset         = 0x300000,
48                 .size           = 0x3e0000,
49         },
50         {
51                 .name           = "NVRAM",
52                 .offset         = 0x3e0000,
53                 .size           = 0x010000,
54         },
55         {
56                 .name           = "ART",
57                 .offset         = 0x3f0000,
58                 .size           = 0x010000,
59                 .mask_flags     = MTD_WRITEABLE,
60         },
61 };
62 #define ap113_nr_parts          ARRAY_SIZE(ap113_parts)
63 #else
64 #define ap113_parts             NULL
65 #define ap113_nr_parts          0
66 #endif /* CONFIG_MTD_PARTITIONS */
67
68 static struct flash_platform_data ap113_flash_data = {
69         .parts          = ap113_parts,
70         .nr_parts       = ap113_nr_parts,
71 };
72
73 static struct gpio_led ap113_leds_gpio[] __initdata = {
74         {
75                 .name           = "ap113:green:usb",
76                 .gpio           = AP113_GPIO_LED_USB,
77                 .active_low     = 1,
78         },
79         {
80                 .name           = "ap113:green:status",
81                 .gpio           = AP113_GPIO_LED_STATUS,
82                 .active_low     = 1,
83         },
84         {
85                 .name           = "ap113:green:st",
86                 .gpio           = AP113_GPIO_LED_ST,
87                 .active_low     = 1,
88         }
89 };
90
91 static struct gpio_keys_button ap113_gpio_keys[] __initdata = {
92         {
93                 .desc           = "jumpstart button",
94                 .type           = EV_KEY,
95                 .code           = KEY_WPS_BUTTON,
96                 .debounce_interval = AP113_KEYS_DEBOUNCE_INTERVAL,
97                 .gpio           = AP113_GPIO_BTN_JUMPSTART,
98                 .active_low     = 1,
99         },
100 };
101
102 static void __init ap113_setup(void)
103 {
104         u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
105
106         ar71xx_add_device_m25p80(&ap113_flash_data);
107
108         ar71xx_add_device_mdio(0, ~BIT(0));
109         ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
110         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
111         ar71xx_eth0_data.speed = SPEED_1000;
112         ar71xx_eth0_data.duplex = DUPLEX_FULL;
113         ar71xx_eth0_data.phy_mask = BIT(0);
114
115         ar71xx_add_device_eth(0);
116
117         ar71xx_register_gpio_keys_polled(-1, AP113_KEYS_POLL_INTERVAL,
118                                          ARRAY_SIZE(ap113_gpio_keys),
119                                          ap113_gpio_keys);
120         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap113_leds_gpio),
121                                         ap113_leds_gpio);
122
123         ar71xx_add_device_usb();
124
125         pb9x_pci_init();
126 }
127
128 MIPS_MACHINE(AR71XX_MACH_AP113, "AP113", "Atheros AP113",
129              ap113_setup);