2 * TP-LINK TL-MR3220/3420 board support
4 * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
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.
11 #include <linux/gpio.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
15 #include <asm/mach-ar71xx/ar71xx.h>
19 #include "dev-m25p80.h"
20 #include "dev-ap91-pci.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
25 #define TL_MR3X20_GPIO_LED_QSS 0
26 #define TL_MR3X20_GPIO_LED_SYSTEM 1
27 #define TL_MR3X20_GPIO_LED_3G 8
29 #define TL_MR3X20_GPIO_BTN_RESET 11
30 #define TL_MR3X20_GPIO_BTN_QSS 12
32 #define TL_MR3X20_GPIO_USB_POWER 6
34 #define TL_MR3X20_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define TL_MR3X20_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3X20_KEYS_POLL_INTERVAL)
37 #ifdef CONFIG_MTD_PARTITIONS
38 static struct mtd_partition tl_mr3x20_partitions[] = {
43 .mask_flags = MTD_WRITEABLE,
56 .mask_flags = MTD_WRITEABLE,
63 #define tl_mr3x20_num_partitions ARRAY_SIZE(tl_mr3x20_partitions)
65 #define tl_mr3x20_partitions NULL
66 #define tl_mr3x20_num_partitions 0
67 #endif /* CONFIG_MTD_PARTITIONS */
69 static struct flash_platform_data tl_mr3x20_flash_data = {
70 .parts = tl_mr3x20_partitions,
71 .nr_parts = tl_mr3x20_num_partitions,
74 static struct gpio_led tl_mr3x20_leds_gpio[] __initdata = {
76 .name = "tl-mr3x20:green:system",
77 .gpio = TL_MR3X20_GPIO_LED_SYSTEM,
80 .name = "tl-mr3x20:green:qss",
81 .gpio = TL_MR3X20_GPIO_LED_QSS,
84 .name = "tl-mr3x20:green:3g",
85 .gpio = TL_MR3X20_GPIO_LED_3G,
90 static struct gpio_keys_button tl_mr3x20_gpio_keys[] __initdata = {
95 .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
96 .gpio = TL_MR3X20_GPIO_BTN_RESET,
101 .code = KEY_WPS_BUTTON,
102 .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
103 .gpio = TL_MR3X20_GPIO_BTN_QSS,
108 static void __init tl_mr3x20_setup(void)
110 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
111 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
113 /* enable power for the USB port */
114 gpio_request(TL_MR3X20_GPIO_USB_POWER, "USB power");
115 gpio_direction_output(TL_MR3X20_GPIO_USB_POWER, 1);
117 ar71xx_add_device_m25p80(&tl_mr3x20_flash_data);
119 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
120 tl_mr3x20_leds_gpio);
122 ar71xx_register_gpio_keys_polled(-1, TL_MR3X20_KEYS_POLL_INTERVAL,
123 ARRAY_SIZE(tl_mr3x20_gpio_keys),
124 tl_mr3x20_gpio_keys);
126 ar71xx_eth1_data.has_ar7240_switch = 1;
127 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
128 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
131 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
132 ar71xx_eth0_data.speed = SPEED_100;
133 ar71xx_eth0_data.duplex = DUPLEX_FULL;
134 ar71xx_eth0_data.phy_mask = BIT(4);
137 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
138 ar71xx_eth1_data.speed = SPEED_1000;
139 ar71xx_eth1_data.duplex = DUPLEX_FULL;
141 ar71xx_add_device_mdio(0x0);
142 ar71xx_add_device_eth(1);
143 ar71xx_add_device_eth(0);
145 ar71xx_add_device_usb();
147 ap91_pci_init(ee, mac);
150 static void __init tl_mr3220_setup(void)
153 ap91_pci_setup_wmac_led_pin(1);
156 MIPS_MACHINE(AR71XX_MACH_TL_MR3220, "TL-MR3220", "TP-LINK TL-MR3220",
159 static void __init tl_mr3420_setup(void)
162 ap91_pci_setup_wmac_led_pin(0);
165 MIPS_MACHINE(AR71XX_MACH_TL_MR3420, "TL-MR3420", "TP-LINK TL-MR3420",