ar71xx: build ALFA AP96 images with default profile as well
[oweals/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-tl-wr2543n.c
1 /*
2  *  TP-LINK TL-WR2543ND board support
3  *
4  *  Copyright (C) 2011 Gabor Juhos <juhosg@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/platform_device.h>
12 #include <linux/rtl8367.h>
13 #include <asm/mach-ar71xx/ar71xx.h>
14
15 #include "machtype.h"
16 #include "devices.h"
17 #include "dev-ap91-pci.h"
18 #include "dev-m25p80.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-usb.h"
22
23 #define TL_WR2543N_GPIO_LED_WPS        0
24 #define TL_WR2543N_GPIO_LED_USB        8
25
26 #define TL_WR2543N_GPIO_BTN_RESET      11
27 #define TL_WR2543N_GPIO_BTN_WPS        12
28
29 #define TL_WR2543N_GPIO_RTL8367_SDA     1
30 #define TL_WR2543N_GPIO_RTL8367_SCK     6
31
32 #define TL_WR2543N_KEYS_POLL_INTERVAL   20      /* msecs */
33 #define TL_WR2543N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR2543N_KEYS_POLL_INTERVAL)
34
35 static const char *tl_wr2543n_part_probes[] = {
36         "tp-link",
37         NULL,
38 };
39
40 static struct flash_platform_data tl_wr2543n_flash_data = {
41         .part_probes    = tl_wr2543n_part_probes,
42         .max_read_len   = 64,
43 };
44
45 static struct gpio_led tl_wr2543n_leds_gpio[] __initdata = {
46         {
47                 .name           = "tp-link:green:usb",
48                 .gpio           = TL_WR2543N_GPIO_LED_USB,
49                 .active_low     = 1,
50         }, {
51                 .name           = "tp-link:green:wps",
52                 .gpio           = TL_WR2543N_GPIO_LED_WPS,
53                 .active_low     = 1,
54         }
55 };
56
57 static struct gpio_keys_button tl_wr2543n_gpio_keys[] __initdata = {
58         {
59                 .desc           = "reset",
60                 .type           = EV_KEY,
61                 .code           = KEY_RESTART,
62                 .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
63                 .gpio           = TL_WR2543N_GPIO_BTN_RESET,
64                 .active_low     = 1,
65         }, {
66                 .desc           = "wps",
67                 .type           = EV_KEY,
68                 .code           = KEY_WPS_BUTTON,
69                 .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
70                 .gpio           = TL_WR2543N_GPIO_BTN_WPS,
71         }
72 };
73
74 static struct rtl8367_extif_config tl_wr2543n_rtl8367_extif0_cfg = {
75         .mode = RTL8367_EXTIF_MODE_RGMII,
76         .txdelay = 1,
77         .rxdelay = 0,
78         .ability = {
79                 .force_mode = 1,
80                 .txpause = 1,
81                 .rxpause = 1,
82                 .link = 1,
83                 .duplex = 1,
84                 .speed = RTL8367_PORT_SPEED_1000,
85         },
86 };
87
88 static struct rtl8367_platform_data tl_wr2543n_rtl8367_data = {
89         .gpio_sda       = TL_WR2543N_GPIO_RTL8367_SDA,
90         .gpio_sck       = TL_WR2543N_GPIO_RTL8367_SCK,
91         .extif0_cfg     = &tl_wr2543n_rtl8367_extif0_cfg,
92 };
93
94 static struct platform_device tl_wr2543n_rtl8367_device = {
95         .name           = RTL8367_DRIVER_NAME,
96         .id             = -1,
97         .dev = {
98                 .platform_data  = &tl_wr2543n_rtl8367_data,
99         }
100 };
101
102 static void __init tl_wr2543n_setup(void)
103 {
104         u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
105         u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
106
107         ar71xx_add_device_m25p80(&tl_wr2543n_flash_data);
108         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr2543n_leds_gpio),
109                                         tl_wr2543n_leds_gpio);
110         ar71xx_register_gpio_keys_polled(-1, TL_WR2543N_KEYS_POLL_INTERVAL,
111                                          ARRAY_SIZE(tl_wr2543n_gpio_keys),
112                                          tl_wr2543n_gpio_keys);
113         ar71xx_add_device_usb();
114         ap91_pci_init(eeprom, mac);
115
116         ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, -1);
117         ar71xx_eth0_data.mii_bus_dev = &tl_wr2543n_rtl8367_device.dev;
118         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
119         ar71xx_eth0_data.speed = SPEED_1000;
120         ar71xx_eth0_data.duplex = DUPLEX_FULL;
121         ar71xx_eth0_pll_data.pll_1000 = 0x1a000000;
122
123         ar71xx_add_device_eth(0);
124
125         platform_device_register(&tl_wr2543n_rtl8367_device);
126 }
127
128 MIPS_MACHINE(AR71XX_MACH_TL_WR2543N, "TL-WR2543N", "TP-LINK TL-WR2543N/ND",
129              tl_wr2543n_setup);