Root/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr1043nd.c

1/*
2 * TP-LINK TL-WR1043ND board support
3 *
4 * Copyright (C) 2009 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/mtd/mtd.h>
12#include <linux/mtd/partitions.h>
13#include <linux/platform_device.h>
14#include <linux/rtl8366rb.h>
15#include <asm/mach-ar71xx/ar71xx.h>
16
17#include "machtype.h"
18#include "devices.h"
19#include "dev-m25p80.h"
20#include "dev-ar913x-wmac.h"
21#include "dev-gpio-buttons.h"
22#include "dev-leds-gpio.h"
23#include "dev-usb.h"
24
25#define TL_WR1043ND_GPIO_LED_USB 1
26#define TL_WR1043ND_GPIO_LED_SYSTEM 2
27#define TL_WR1043ND_GPIO_LED_QSS 5
28#define TL_WR1043ND_GPIO_LED_WLAN 9
29
30#define TL_WR1043ND_GPIO_BTN_RESET 3
31#define TL_WR1043ND_GPIO_BTN_QSS 7
32
33#define TL_WR1043ND_GPIO_RTL8366_SDA 18
34#define TL_WR1043ND_GPIO_RTL8366_SCK 19
35
36#define TL_WR1043ND_BUTTONS_POLL_INTERVAL 20
37
38#ifdef CONFIG_MTD_PARTITIONS
39static struct mtd_partition tl_wr1043nd_partitions[] = {
40    {
41        .name = "u-boot",
42        .offset = 0,
43        .size = 0x020000,
44        .mask_flags = MTD_WRITEABLE,
45    } , {
46        .name = "kernel",
47        .offset = 0x020000,
48        .size = 0x140000,
49    } , {
50        .name = "rootfs",
51        .offset = 0x160000,
52        .size = 0x690000,
53    } , {
54        .name = "art",
55        .offset = 0x7f0000,
56        .size = 0x010000,
57        .mask_flags = MTD_WRITEABLE,
58    } , {
59        .name = "firmware",
60        .offset = 0x020000,
61        .size = 0x7d0000,
62    }
63};
64#endif /* CONFIG_MTD_PARTITIONS */
65
66static struct flash_platform_data tl_wr1043nd_flash_data = {
67#ifdef CONFIG_MTD_PARTITIONS
68    .parts = tl_wr1043nd_partitions,
69    .nr_parts = ARRAY_SIZE(tl_wr1043nd_partitions),
70#endif
71};
72
73static struct gpio_led tl_wr1043nd_leds_gpio[] __initdata = {
74    {
75        .name = "tl-wr1043nd:green:usb",
76        .gpio = TL_WR1043ND_GPIO_LED_USB,
77        .active_low = 1,
78    }, {
79        .name = "tl-wr1043nd:green:system",
80        .gpio = TL_WR1043ND_GPIO_LED_SYSTEM,
81        .active_low = 1,
82    }, {
83        .name = "tl-wr1043nd:green:qss",
84        .gpio = TL_WR1043ND_GPIO_LED_QSS,
85        .active_low = 0,
86    }, {
87        .name = "tl-wr1043nd:green:wlan",
88        .gpio = TL_WR1043ND_GPIO_LED_WLAN,
89        .active_low = 1,
90    }
91};
92
93static struct gpio_button tl_wr1043nd_gpio_buttons[] __initdata = {
94    {
95        .desc = "reset",
96        .type = EV_KEY,
97        .code = BTN_0,
98        .threshold = 3,
99        .gpio = TL_WR1043ND_GPIO_BTN_RESET,
100        .active_low = 1,
101    }, {
102        .desc = "qss",
103        .type = EV_KEY,
104        .code = BTN_1,
105        .threshold = 3,
106        .gpio = TL_WR1043ND_GPIO_BTN_QSS,
107        .active_low = 1,
108    }
109};
110
111static struct rtl8366rb_platform_data tl_wr1043nd_rtl8366rb_data = {
112    .gpio_sda = TL_WR1043ND_GPIO_RTL8366_SDA,
113    .gpio_sck = TL_WR1043ND_GPIO_RTL8366_SCK,
114};
115
116static struct platform_device tl_wr1043nd_rtl8366rb_device = {
117    .name = RTL8366RB_DRIVER_NAME,
118    .id = -1,
119    .dev = {
120        .platform_data = &tl_wr1043nd_rtl8366rb_data,
121    }
122};
123
124static void __init tl_wr1043nd_setup(void)
125{
126    u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
127    u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
128
129    ar71xx_set_mac_base(mac);
130
131    ar71xx_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
132    ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
133    ar71xx_eth0_data.speed = SPEED_1000;
134    ar71xx_eth0_data.duplex = DUPLEX_FULL;
135    ar71xx_eth0_pll_data.pll_1000 = 0x1a000000;
136
137    ar71xx_add_device_eth(0);
138
139    ar71xx_add_device_usb();
140
141    ar71xx_add_device_m25p80(&tl_wr1043nd_flash_data);
142
143    ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio),
144                    tl_wr1043nd_leds_gpio);
145
146    platform_device_register(&tl_wr1043nd_rtl8366rb_device);
147
148    ar71xx_add_device_gpio_buttons(-1, TL_WR1043ND_BUTTONS_POLL_INTERVAL,
149                    ARRAY_SIZE(tl_wr1043nd_gpio_buttons),
150                    tl_wr1043nd_gpio_buttons);
151
152    ar913x_add_device_wmac(eeprom, mac);
153}
154
155MIPS_MACHINE(AR71XX_MACH_TL_WR1043ND, "TL-WR1043ND", "TP-LINK TL-WR1043ND",
156         tl_wr1043nd_setup);
157

Archive Download this file



interactive