2 * AVM FRITZ!WLAN Repeater 450E board support
4 * Copyright (C) 2018 David Bauer <mail@david-bauer.net>
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/init.h>
12 #include <linux/ath9k_platform.h>
13 #include <linux/etherdevice.h>
14 #include <linux/gpio.h>
15 #include <linux/platform_device.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/platform_data/mdio-gpio.h>
20 #include <linux/platform_data/phy-at803x.h>
21 #include <linux/spi/spi_gpio.h>
22 #include <linux/spi/74x164.h>
24 #include <asm/mach-ath79/ath79.h>
25 #include <asm/mach-ath79/ar71xx_regs.h>
29 #include "dev-gpio-buttons.h"
30 #include "dev-leds-gpio.h"
31 #include "dev-m25p80.h"
34 #include "machtypes.h"
36 #define FRITZ450E_GPIO_LED_POWER 14
37 #define FRITZ450E_GPIO_LED_LAN 13
38 #define FRITZ450E_GPIO_LED_WLAN 15
39 #define FRITZ450E_GPIO_LED_RSSI2 16
40 #define FRITZ450E_GPIO_LED_RSSI3 17
41 #define FRITZ450E_GPIO_LED_RSSI4 18
43 #define FRITZ450E_GPIO_BTN_WPS 4
44 #define FRITZ450E_KEYS_POLL_INTERVAL 20 /* msecs */
45 #define FRITZ450E_KEYS_DEBOUNCE_INTERVAL (3 * FRITZ450E_KEYS_POLL_INTERVAL)
47 #define FRITZ450E_PHY_ADDRESS 0
48 #define FRITZ450E_GPIO_PHY_RESET 11
49 #define FRITZ450E_GPIO_MDIO_CLK 12
50 #define FRITZ450E_GPIO_MDIO_DATA 19
52 #define FRITZ450E_OFFSET_URLADER_WIFI_MAC_REVERSE 0x1979
55 static struct mtd_partition fritz450E_flash_partitions
[] = {
60 .mask_flags
= MTD_WRITEABLE
,
69 .mask_flags
= MTD_WRITEABLE
,
74 .mask_flags
= MTD_WRITEABLE
,
78 static struct flash_platform_data fritz450E_flash_data
= {
79 .parts
= fritz450E_flash_partitions
,
80 .nr_parts
= ARRAY_SIZE(fritz450E_flash_partitions
),
83 static struct gpio_led fritz450E_leds_gpio
[] __initdata
= {
85 .name
= "fritz450e:green:lan",
86 .gpio
= FRITZ450E_GPIO_LED_LAN
,
89 .name
= "fritz450e:green:rssi2",
90 .gpio
= FRITZ450E_GPIO_LED_RSSI2
,
93 .name
= "fritz450e:green:rssi3",
94 .gpio
= FRITZ450E_GPIO_LED_RSSI3
,
97 .name
= "fritz450e:green:rssi4",
98 .gpio
= FRITZ450E_GPIO_LED_RSSI4
,
101 .name
= "fritz450e:green:wlan",
102 .gpio
= FRITZ450E_GPIO_LED_WLAN
,
105 .name
= "fritz450e:green:power",
106 .gpio
= FRITZ450E_GPIO_LED_POWER
,
111 static struct gpio_keys_button fritz450E_gpio_keys
[] __initdata
= {
113 .desc
= "WPS Button",
115 .code
= KEY_WPS_BUTTON
,
116 .debounce_interval
= FRITZ450E_KEYS_DEBOUNCE_INTERVAL
,
117 .gpio
= FRITZ450E_GPIO_BTN_WPS
,
122 static struct at803x_platform_data fritz450E_at803x_data
= {
123 .disable_smarteee
= 1,
125 .reset_gpio
= FRITZ450E_GPIO_PHY_RESET
,
128 static struct mdio_board_info fritz450E_mdio_info
[] = {
130 .bus_id
= "ag71xx-mdio.1",
131 .phy_addr
= FRITZ450E_PHY_ADDRESS
,
132 .platform_data
= &fritz450E_at803x_data
,
136 static void __init
fritz450E_setup(void) {
137 u8
*urlader
= (u8
*) KSEG1ADDR(0x1f000000);
138 u8 wifi_mac
[ETH_ALEN
];
140 ath79_register_m25p80(&fritz450E_flash_data
);
142 gpio_request_one(FRITZ450E_GPIO_MDIO_CLK
, GPIOF_OUT_INIT_HIGH
, "MDC Pull-UP");
143 gpio_request_one(FRITZ450E_GPIO_MDIO_DATA
, GPIOF_OUT_INIT_HIGH
, "MDIO Pull-UP");
144 gpio_request_one(FRITZ450E_GPIO_PHY_RESET
, GPIOF_OUT_INIT_HIGH
, "PHY reset");
146 /* Register PHY device */
147 mdiobus_register_board_info(fritz450E_mdio_info
,
148 ARRAY_SIZE(fritz450E_mdio_info
));
150 /* Initialize Ethernet */
151 ath79_extract_mac_reverse(urlader
+ FRITZ450E_OFFSET_URLADER_WIFI_MAC_REVERSE
, wifi_mac
);
152 ath79_init_mac(ath79_eth0_data
.mac_addr
, wifi_mac
, -2);
154 ath79_register_mdio(1, ~BIT(FRITZ450E_PHY_ADDRESS
));
155 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio1_device
.dev
;
156 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_SGMII
;
157 ath79_eth0_data
.phy_mask
= BIT(FRITZ450E_PHY_ADDRESS
);
158 ath79_eth0_data
.enable_sgmii_fixup
= 1;
159 ath79_eth0_pll_data
.pll_1000
= 0x03000000;
160 ath79_eth0_pll_data
.pll_100
= 0x00000101;
161 ath79_eth0_pll_data
.pll_10
= 0x00001313;
162 ath79_register_eth(0);
164 /* Initialize 2.4GHz WiFi */
165 ath79_register_wmac_simple();
167 /* Register GPIO buttons */
168 ath79_register_gpio_keys_polled(-1, FRITZ450E_KEYS_POLL_INTERVAL
,
169 ARRAY_SIZE(fritz450E_gpio_keys
),
170 fritz450E_gpio_keys
);
173 ath79_register_leds_gpio(-1, ARRAY_SIZE(fritz450E_leds_gpio
),
174 fritz450E_leds_gpio
);
177 MIPS_MACHINE(ATH79_MACH_FRITZ450E
, "FRITZ450E",
178 "AVM FRITZ!WLAN Repeater 450E", fritz450E_setup
);