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_BUTTONS_POLL_INTERVAL 20
36 #ifdef CONFIG_MTD_PARTITIONS
37 static struct mtd_partition tl_mr3x20_partitions
[] = {
42 .mask_flags
= MTD_WRITEABLE
,
55 .mask_flags
= MTD_WRITEABLE
,
62 #define tl_mr3x20_num_partitions ARRAY_SIZE(tl_mr3x20_partitions)
64 #define tl_mr3x20_partitions NULL
65 #define tl_mr3x20_num_partitions 0
66 #endif /* CONFIG_MTD_PARTITIONS */
68 static struct flash_platform_data tl_mr3x20_flash_data
= {
69 .parts
= tl_mr3x20_partitions
,
70 .nr_parts
= tl_mr3x20_num_partitions
,
73 static struct gpio_led tl_mr3x20_leds_gpio
[] __initdata
= {
75 .name
= "tl-mr3x20:green:system",
76 .gpio
= TL_MR3X20_GPIO_LED_SYSTEM
,
79 .name
= "tl-mr3x20:green:qss",
80 .gpio
= TL_MR3X20_GPIO_LED_QSS
,
83 .name
= "tl-mr3x20:green:3g",
84 .gpio
= TL_MR3X20_GPIO_LED_3G
,
89 static struct gpio_button tl_mr3x20_gpio_buttons
[] __initdata
= {
95 .gpio
= TL_MR3X20_GPIO_BTN_RESET
,
100 .code
= KEY_WPS_BUTTON
,
102 .gpio
= TL_MR3X20_GPIO_BTN_QSS
,
107 static void __init
tl_mr3x20_setup(void)
109 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
110 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
112 /* enable power for the USB port */
113 gpio_request(TL_MR3X20_GPIO_USB_POWER
, "USB power");
114 gpio_direction_output(TL_MR3X20_GPIO_USB_POWER
, 1);
116 ar71xx_add_device_m25p80(&tl_mr3x20_flash_data
);
118 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio
),
119 tl_mr3x20_leds_gpio
);
121 ar71xx_add_device_gpio_buttons(-1, TL_MR3X20_BUTTONS_POLL_INTERVAL
,
122 ARRAY_SIZE(tl_mr3x20_gpio_buttons
),
123 tl_mr3x20_gpio_buttons
);
125 ar71xx_eth1_data
.has_ar7240_switch
= 1;
126 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac
, 0);
127 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac
, 1);
130 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
131 ar71xx_eth0_data
.speed
= SPEED_100
;
132 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
135 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
136 ar71xx_eth1_data
.speed
= SPEED_1000
;
137 ar71xx_eth1_data
.duplex
= DUPLEX_FULL
;
139 ar71xx_add_device_mdio(0x0);
140 ar71xx_add_device_eth(1);
141 ar71xx_add_device_eth(0);
143 ar71xx_add_device_usb();
145 ap91_pci_init(ee
, mac
);
147 MIPS_MACHINE(AR71XX_MACH_TL_MR3420
, "TL-MR3420", "TP-LINK TL-MR3420",
150 MIPS_MACHINE(AR71XX_MACH_TL_MR3220
, "TL-MR3220", "TP-LINK TL-MR3220",