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

Archive Download this file



interactive