· 9 years ago · Dec 02, 2016, 02:48 PM
1/*
2 * TP-LINK TL-WR841N/ND v9/v11 / TL-WR842N/ND v3
3 *
4 * Copyright (C) 2016 Federico Cappon <@gmail.com>
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/gpio.h>
12#include <linux/mtd/mtd.h>
13#include <linux/mtd/partitions.h>
14#include <linux/platform_device.h>
15
16#include <asm/mach-ath79/ath79.h>
17#include <asm/mach-ath79/ar71xx_regs.h>
18
19#include "common.h"
20#include "dev-eth.h"
21#include "dev-gpio-buttons.h"
22#include "dev-leds-gpio.h"
23#include "dev-m25p80.h"
24#include "dev-usb.h"
25#include "dev-wmac.h"
26#include "machtypes.h"
27
28#define TL_WA855REV1_GPIO_LED_GREEN 12
29
30#define TL_WA855REV1_GPIO_BTN_RESET 17
31
32#define TL_WR841NV9_KEYS_POLL_INTERVAL 20 /* msecs */
33#define TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV9_KEYS_POLL_INTERVAL)
34
35static struct mtd_partition tl_wa855re_v1_flash_partitions[] = {
36 {
37 .name = "u-boot",
38 .offset = 0,
39 .size = 0x0020000,
40 }, {
41 .name = "kernel",
42 .offset = 0x0020000,
43 .size = 0x00c0000,
44 }, {
45 .name = "rootfs",
46 .offset = 0x00e0000,
47 .size = 0x02d0000,
48 }, {
49 .name = "config",
50 .offset = 0x03b0000,
51 .size = 0x0040000,
52 }, {
53 .name = "art",
54 .offset = 0x03f0000,
55 .size = 0x0010000,
56 }
57};
58
59static struct flash_platform_data tl_wa855re_v1_flash_data = {
60 .parts = tl_wa855re_v1_flash_partitions,
61 .nr_parts = ARRAY_SIZE(tl_wa855re_v1_flash_partitions),
62};
63
64static struct gpio_led tl_wa855re_v1_leds_gpio[] __initdata = {
65 {
66 .name = "tp-link:green:power",
67 .gpio = TL_WA855REV1_GPIO_LED_GREEN,
68 .active_low = 0,
69 },
70};
71
72static struct gpio_keys_button tl_wa855re_v1_gpio_keys[] __initdata = {
73 {
74 .desc = "Reset button",
75 .type = EV_KEY,
76 .code = KEY_RESTART,
77 .gpio = TL_WA855REV1_GPIO_BTN_RESET,
78 .active_low = 1,
79 }
80};
81
82
83static void __init tl_ap143_setup(void)
84{
85 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
86 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
87 u8 tmpmac[ETH_ALEN];
88
89 ath79_register_m25p80(&tl_wa855re_v1_flash_data);
90
91 ath79_setup_ar933x_phy4_switch(false, false);
92
93 ath79_register_mdio(0, 0x0);
94
95 /* LAN */
96 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
97 ath79_eth0_data.duplex = DUPLEX_FULL;
98 ath79_eth0_data.speed = SPEED_100;
99 ath79_eth0_data.phy_mask = BIT(4);
100 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
101 ath79_register_eth(0);
102
103 /* WAN */
104 /*ath79_switch_data.phy4_mii_en = 1;
105 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
106 ath79_eth0_data.duplex = DUPLEX_FULL;
107 ath79_eth0_data.speed = SPEED_100;
108 ath79_eth0_data.phy_mask = BIT(4);
109 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
110 ath79_register_eth(0);*/
111
112 ath79_init_mac(tmpmac, mac, 0);
113 ath79_register_wmac(ee, tmpmac);
114}
115
116static void __init tl_wa855re_v1_setup(void)
117{
118 tl_ap143_setup();
119
120 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa855re_v1_leds_gpio),
121 tl_wa855re_v1_leds_gpio);
122
123 ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
124 ARRAY_SIZE(tl_wa855re_v1_gpio_keys),
125 tl_wa855re_v1_gpio_keys);
126}
127
128MIPS_MACHINE(ATH79_MACH_TL_WA855RE_V1, "TL-WA855RE-v1", "TP-LINK TL-WA855RE V1",
129 tl_wa855re_v1_setup);