ar71xx: remove hardwired interface parameters from mach-* files
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-tl-wr703n.c
1 /*
2 * TP-LINK TL-WR703N board support
3 *
4 * Copyright (C) 2011 dongyuqi <729650915@qq.com>
5 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/spi/flash.h>
15 #include <linux/gpio.h>
16
17 #include <asm/mach-ar71xx/ar71xx.h>
18
19 #include "machtype.h"
20 #include "devices.h"
21 #include "dev-ar9xxx-wmac.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-m25p80.h"
25 #include "dev-usb.h"
26
27 #define TL_WR703N_GPIO_LED_SYSTEM 27
28 #define TL_WR703N_GPIO_BTN_RESET 11
29
30 #define TL_WR703N_GPIO_USB_POWER 8
31
32 #define TL_WR703N_KEYS_POLL_INTERVAL 20 /* msecs */
33 #define TL_WR703N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR703N_KEYS_POLL_INTERVAL)
34
35 #ifdef CONFIG_MTD_PARTITIONS
36 static struct mtd_partition tl_wr703n_parts[] = {
37 {
38 .name = "u-boot",
39 .offset = 0,
40 .size = 0x020000,
41 .mask_flags = MTD_WRITEABLE,
42 }, {
43 .name = "kernel",
44 .offset = 0x020000,
45 .size = 0x100000,
46 }, {
47 .name = "rootfs",
48 .offset = 0x120000,
49 .size = 0x2d0000,
50 }, {
51 .name = "art",
52 .offset = 0x3f0000,
53 .size = 0x010000,
54 .mask_flags = MTD_WRITEABLE,
55 }, {
56 .name = "firmware",
57 .offset = 0x020000,
58 .size = 0x3d0000,
59 }
60 };
61 #define tl_wr703n_nr_parts ARRAY_SIZE(tl_wr703n_parts)
62 #else
63 #define tl_wr703n_parts NULL
64 #define tl_wr703n_nr_parts 0
65 #endif /* CONFIG_MTD_PARTITIONS */
66
67 static struct flash_platform_data tl_wr703n_flash_data = {
68 .parts = tl_wr703n_parts,
69 .nr_parts = tl_wr703n_nr_parts,
70 };
71
72 static struct gpio_led tl_wr703n_leds_gpio[] __initdata = {
73 {
74 .name = "tp-link:blue:system",
75 .gpio = TL_WR703N_GPIO_LED_SYSTEM,
76 .active_low = 1,
77 },
78 };
79
80 static struct gpio_keys_button tl_wr703n_gpio_keys[] __initdata = {
81 {
82 .desc = "reset",
83 .type = EV_KEY,
84 .code = KEY_RESTART,
85 .debounce_interval = TL_WR703N_KEYS_DEBOUNCE_INTERVAL,
86 .gpio = TL_WR703N_GPIO_BTN_RESET,
87 .active_low = 1,
88 }
89 };
90
91 static void __init tl_wr703n_setup(void)
92 {
93 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
94 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
95
96 ar71xx_add_device_m25p80(&tl_wr703n_flash_data);
97 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr703n_leds_gpio),
98 tl_wr703n_leds_gpio);
99 ar71xx_register_gpio_keys_polled(-1, TL_WR703N_KEYS_POLL_INTERVAL,
100 ARRAY_SIZE(tl_wr703n_gpio_keys),
101 tl_wr703n_gpio_keys);
102
103 gpio_request(TL_WR703N_GPIO_USB_POWER, "USB power");
104 gpio_direction_output(TL_WR703N_GPIO_USB_POWER, 1);
105 ar71xx_add_device_usb();
106
107 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
108
109 ar71xx_add_device_mdio(0, 0x0);
110 ar71xx_add_device_eth(0);
111
112 ar9xxx_add_device_wmac(ee, mac);
113 }
114
115 MIPS_MACHINE(AR71XX_MACH_TL_WR703N, "TL-WR703N", "TP-LINK TL-WR703N v1",
116 tl_wr703n_setup);