ar71xx: fix button polarity on TL-WR703N and TL-WR741N v4
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / 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 "dev-eth.h"
16 #include "dev-gpio-buttons.h"
17 #include "dev-leds-gpio.h"
18 #include "dev-m25p80.h"
19 #include "pci.h"
20 #include "dev-usb.h"
21 #include "machtypes.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 static struct mtd_partition ap113_parts[] = {
33 {
34 .name = "u-boot",
35 .offset = 0,
36 .size = 0x010000,
37 .mask_flags = MTD_WRITEABLE,
38 },
39 {
40 .name = "rootfs",
41 .offset = 0x010000,
42 .size = 0x300000,
43 },
44 {
45 .name = "uImage",
46 .offset = 0x300000,
47 .size = 0x3e0000,
48 },
49 {
50 .name = "NVRAM",
51 .offset = 0x3e0000,
52 .size = 0x010000,
53 },
54 {
55 .name = "ART",
56 .offset = 0x3f0000,
57 .size = 0x010000,
58 .mask_flags = MTD_WRITEABLE,
59 },
60 };
61 #define ap113_nr_parts ARRAY_SIZE(ap113_parts)
62
63 static struct flash_platform_data ap113_flash_data = {
64 .parts = ap113_parts,
65 .nr_parts = ap113_nr_parts,
66 };
67
68 static struct gpio_led ap113_leds_gpio[] __initdata = {
69 {
70 .name = "ap113:green:usb",
71 .gpio = AP113_GPIO_LED_USB,
72 .active_low = 1,
73 },
74 {
75 .name = "ap113:green:status",
76 .gpio = AP113_GPIO_LED_STATUS,
77 .active_low = 1,
78 },
79 {
80 .name = "ap113:green:st",
81 .gpio = AP113_GPIO_LED_ST,
82 .active_low = 1,
83 }
84 };
85
86 static struct gpio_keys_button ap113_gpio_keys[] __initdata = {
87 {
88 .desc = "jumpstart button",
89 .type = EV_KEY,
90 .code = KEY_WPS_BUTTON,
91 .debounce_interval = AP113_KEYS_DEBOUNCE_INTERVAL,
92 .gpio = AP113_GPIO_BTN_JUMPSTART,
93 .active_low = 1,
94 },
95 };
96
97 static void __init ap113_setup(void)
98 {
99 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
100
101 ath79_register_m25p80(&ap113_flash_data);
102
103 ath79_register_mdio(0, ~BIT(0));
104 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
105 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
106 ath79_eth0_data.speed = SPEED_1000;
107 ath79_eth0_data.duplex = DUPLEX_FULL;
108 ath79_eth0_data.phy_mask = BIT(0);
109
110 ath79_register_eth(0);
111
112 ath79_register_gpio_keys_polled(-1, AP113_KEYS_POLL_INTERVAL,
113 ARRAY_SIZE(ap113_gpio_keys),
114 ap113_gpio_keys);
115 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap113_leds_gpio),
116 ap113_leds_gpio);
117
118 ath79_register_pci();
119
120 ath79_register_usb();
121 }
122
123 MIPS_MACHINE(ATH79_MACH_AP113, "AP113", "Atheros AP113",
124 ap113_setup);
This page took 0.049992 seconds and 5 git commands to generate.