From fd104c8bdf32868fc0086bfcb2d89b4fb8b3dc66 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 21 Nov 2015 21:24:18 +0000 Subject: [PATCH] ar71xx: add support for the devolo dLAN Hotspot MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Günther Kelleter SVN-Revision: 47554 --- .../ar71xx/base-files/etc/board.d/01_leds | 4 + .../ar71xx/base-files/etc/board.d/02_network | 1 + target/linux/ar71xx/base-files/etc/diag.sh | 3 + target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 + .../ar71xx/base-files/lib/upgrade/platform.sh | 1 + target/linux/ar71xx/config-4.1 | 1 + .../files/arch/mips/ath79/mach-dlan-hotspot.c | 117 ++++++++++++++++++ .../ar71xx/generic/profiles/devolo-dlan.mk | 13 ++ target/linux/ar71xx/image/Makefile | 2 + .../700-MIPS-ath79-openwrt-machines.patch | 23 +++- 10 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dlan-hotspot.c diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds index 952e7b88d5..e5683c0377 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -200,6 +200,10 @@ dir-825-c1) ucidef_set_led_wlan "wlan2g" "WLAN 2.4 GHz" "d-link:blue:wlan2g" "phy0tpt" ;; +dlan-hotspot) + ucidef_set_led_wlan "wlan" "WLAN" "devolo:green:wifi" "phy0tpt" + ;; + dlan-pro-500-wp) ucidef_set_led_default "power" "System Power" "devolo:green:status" "1" ucidef_set_led_netdev "lan" "Ethernet Activity" "devolo:green:eth" "br-lan" diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index fffe06b7a0..64f2054b62 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -329,6 +329,7 @@ esr900) [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac" ;; +dlan-hotspot |\ dlan-pro-500-wp) ucidef_set_interface_lan "eth0 eth1" ;; diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 8eb3512054..a8e1721b7c 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -86,6 +86,9 @@ get_status_led() { dir-835-a1) status_led="d-link:amber:power" ;; + dlan-hotspot) + status_led="devolo:green:wifi" + ;; dlan-pro-500-wp) status_led="devolo:green:wlan-2g" ;; diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index af2df8e068..5b3e76f993 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -454,6 +454,9 @@ ar71xx_board_detect() { *"DIR-835 rev. A1") name="dir-835-a1" ;; + *"dLAN Hotspot") + name="dlan-hotspot" + ;; *"dLAN pro 500 Wireless+") name="dlan-pro-500-wp" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index b97c076519..5b15405263 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -211,6 +211,7 @@ platform_check_image() { dir-615-i1 | \ dir-825-c1 | \ dir-835-a1 | \ + dlan-hotspot | \ dlan-pro-500-wp | \ dlan-pro-1200-ac | \ dragino2 | \ diff --git a/target/linux/ar71xx/config-4.1 b/target/linux/ar71xx/config-4.1 index 08e252df44..1d790b6b99 100644 --- a/target/linux/ar71xx/config-4.1 +++ b/target/linux/ar71xx/config-4.1 @@ -63,6 +63,7 @@ CONFIG_ATH79_MACH_DIR_615_C1=y CONFIG_ATH79_MACH_DIR_615_I1=y CONFIG_ATH79_MACH_DIR_825_B1=y CONFIG_ATH79_MACH_DIR_825_C1=y +CONFIG_ATH79_MACH_DLAN_HOTSPOT=y CONFIG_ATH79_MACH_DLAN_PRO_1200_AC=y CONFIG_ATH79_MACH_DLAN_PRO_500_WP=y CONFIG_ATH79_MACH_DRAGINO2=y diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-dlan-hotspot.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-dlan-hotspot.c new file mode 100644 index 0000000000..3ae46514fc --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-dlan-hotspot.c @@ -0,0 +1,117 @@ +/* + * devolo dLAN Hotspot board support + * + * Copyright (C) 2015 Torsten Schnuis + * Copyright (C) 2015 devolo AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include + +#include + +#include "dev-eth.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" +#include "dev-m25p80.h" +#include "dev-usb.h" +#include "dev-wmac.h" +#include "machtypes.h" + +#define DLAN_HOTSPOT_GPIO_LED_WIFI 0 + +#define DLAN_HOTSPOT_GPIO_BTN_RESET 11 +#define DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING 12 +#define DLAN_HOTSPOT_GPIO_BTN_WIFI 21 + +#define DLAN_HOTSPOT_GPIO_PLC_POWER 22 +#define DLAN_HOTSPOT_GPIO_PLC_RESET 20 +#define DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS 18 + +#define DLAN_HOTSPOT_KEYS_POLL_INTERVAL 20 /* msecs */ +#define DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_HOTSPOT_KEYS_POLL_INTERVAL) + +#define DLAN_HOTSPOT_ART_ADDRESS 0x1fff0000 +#define DLAN_HOTSPOT_CALDATA_OFFSET 0x00001000 +#define DLAN_HOTSPOT_MAC_ADDRESS_OFFSET 0x00001002 + +static struct gpio_led dlan_hotspot_leds_gpio[] __initdata = { + { + .name = "devolo:green:wifi", + .gpio = DLAN_HOTSPOT_GPIO_LED_WIFI, + .active_low = 0, + } +}; + +static struct gpio_keys_button dlan_hotspot_gpio_keys[] __initdata = { + { + .desc = "Reset button", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL, + .gpio = DLAN_HOTSPOT_GPIO_BTN_RESET, + .active_low = 0, + }, + { + .desc = "Pairing button", + .type = EV_KEY, + .code = BTN_0, + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL, + .gpio = DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING, + .active_low = 0, + }, + { + .desc = "WLAN button", + .type = EV_KEY, + .code = KEY_WPS_BUTTON, + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL, + .gpio = DLAN_HOTSPOT_GPIO_BTN_WIFI, + .active_low = 0, + } +}; + +static void __init dlan_hotspot_setup(void) +{ + u8 *art = (u8 *) KSEG1ADDR(DLAN_HOTSPOT_ART_ADDRESS); + u8 *cal = art + DLAN_HOTSPOT_CALDATA_OFFSET; + u8 *wifi_mac = art + DLAN_HOTSPOT_MAC_ADDRESS_OFFSET; + + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */ + ath79_setup_ar933x_phy4_switch(false, false); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_hotspot_leds_gpio), + dlan_hotspot_leds_gpio); + + ath79_register_gpio_keys_polled(-1, DLAN_HOTSPOT_KEYS_POLL_INTERVAL, + ARRAY_SIZE(dlan_hotspot_gpio_keys), + dlan_hotspot_gpio_keys); + + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_POWER, + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, + "PLC power"); + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_RESET, + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, + "PLC reset"); + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS, + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, + "PLC LEDs"); + + ath79_register_usb(); + + ath79_register_m25p80(NULL); + + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 1); + ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 2); + + ath79_register_mdio(0, 0x0); + ath79_register_eth(0); + ath79_register_eth(1); + + ath79_register_wmac(cal, wifi_mac); +} + +MIPS_MACHINE(ATH79_MACH_DLAN_HOTSPOT, "dLAN-Hotspot", + "dLAN Hotspot", dlan_hotspot_setup); diff --git a/target/linux/ar71xx/generic/profiles/devolo-dlan.mk b/target/linux/ar71xx/generic/profiles/devolo-dlan.mk index 741f5d547b..44a6869f0e 100644 --- a/target/linux/ar71xx/generic/profiles/devolo-dlan.mk +++ b/target/linux/ar71xx/generic/profiles/devolo-dlan.mk @@ -5,6 +5,19 @@ # See /LICENSE for more information. # +define Profile/dLAN_Hotspot + NAME:=devolo dLAN Hotspot + PACKAGES:=open-plc-utils open-plc-utils-chkpib open-plc-utils-getpib open-plc-utils-modpib \ + open-plc-utils-setpib open-plc-utils-hpavkey open-plc-utils-plchost \ + open-plc-utils-plctool open-plc-utils-pibdump open-plc-utils-plcstat \ + ebtables hostapd-utils wifitoggle wpad +endef + +define Profile/dLAN_Hotspot/Description + Package set optimized for the devolo dLAN Hotspot. +endef +$(eval $(call Profile,dLAN_Hotspot)) + define Profile/dLAN_pro_500_wp NAME:=devolo dLAN pro 500 Wireless+ PACKAGES:=open-plc-utils open-plc-utils-chkpib open-plc-utils-getpib open-plc-utils-modpib \ diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index 0484f0700c..d2091a9b72 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -1452,6 +1452,7 @@ cpe510_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(pation-table)ro,64k(product- eap300v2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),320k(custom),13632k(firmware),2048k(failsafe),64k(art)ro db120_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware) dgl_5500_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,15296k(firmware),192k(lang)ro,512k(my-dlink)ro,64k(mac)ro,64k(art)ro +dlan_hotspot_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(Config1)ro,64k(Config2)ro,7872k@0x40000(firmware),64k(art)ro dlan_pro_500_wp_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,64k(Config1)ro,64k(Config2)ro,7680k@0x70000(firmware),64k(art)ro dlan_pro_1200_ac_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,64k(Config1)ro,64k(Config2)ro,15872k@0x70000(firmware),64k(art)ro cameo_ap94_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,6208k(firmware),64k(caldata)ro,1600k(unknown)ro,64k@0x7f0000(caldata_copy) @@ -2292,6 +2293,7 @@ $(eval $(call SingleProfile,CameoAP94,64kraw,DIR825B1,dir-825-b1,DIR-825-B1,ttyS $(eval $(call SingleProfile,CameoAP94,64kraw,TEW673GRU,tew-673gru,TEW-673GRU,ttyS0,115200,$$(cameo_ap94_mtdlayout),$$(cameo_ap94_mtdlayout_fat),01AP94-AR7161-RT-080619-01,00AP94-AR7161-RT-080619-01)) $(eval $(call SingleProfile,CameoAP94,64kraw,DLRTDEV01,dlrtdev01,DIR-825-B1,ttyS0,115200,$$(dlrtdev_mtdlayout),$$(dlrtdev_mtdlayout_fat),01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00)) +$(eval $(call SingleProfile,dLANLzma,64k,dLAN_Hotspot,dlan-hotspot,dLAN-Hotspot,ttyATH0,115200,$$(dlan_hotspot_mtdlayout) mem=64M,KRuImage,65536)) $(eval $(call SingleProfile,dLANLzma,64k,dLAN_pro_500_wp,dlan-pro-500-wp,dLAN-pro-500-wp,ttyS0,115200,$$(dlan_pro_500_wp_mtdlayout) mem=128M,KRuImage,64k)) $(eval $(call SingleProfile,dLANLzma,64k,dLAN_pro_1200_ac,dlan-pro-1200-ac,dLAN-pro-1200-ac,ttyS0,115200,$$(dlan_pro_1200_ac_mtdlayout) mem=128M,KRuImage,64k)) diff --git a/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch index 66a3391076..ecba79fa65 100644 --- a/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch +++ b/target/linux/ar71xx/patches-4.1/700-MIPS-ath79-openwrt-machines.patch @@ -1,6 +1,6 @@ --- a/arch/mips/ath79/machtypes.h +++ b/arch/mips/ath79/machtypes.h -@@ -16,24 +16,212 @@ +@@ -16,24 +16,213 @@ enum ath79_mach_type { ATH79_MACH_GENERIC = 0, @@ -43,6 +43,7 @@ + ATH79_MACH_DIR_825_B1, /* D-Link DIR-825 rev. B1 */ + ATH79_MACH_DIR_825_C1, /* D-Link DIR-825 rev. C1 */ + ATH79_MACH_DIR_835_A1, /* D-Link DIR-835 rev. A1 */ ++ ATH79_MACH_DLAN_HOTSPOT, /* devolo dLAN Hotspot */ + ATH79_MACH_DLAN_PRO_500_WP, /* devolo dLAN pro 500 Wireless+ */ + ATH79_MACH_DLAN_PRO_1200_AC, /* devolo dLAN pro 1200+ WiFi ac*/ + ATH79_MACH_DRAGINO2, /* Dragino Version 2 */ @@ -306,7 +307,7 @@ config ATH79_MACH_AP121 bool "Atheros AP121 reference board" select SOC_AR933X -@@ -11,62 +95,1116 @@ config ATH79_MACH_AP121 +@@ -11,62 +95,1125 @@ config ATH79_MACH_AP121 select ATH79_DEV_M25P80 select ATH79_DEV_USB select ATH79_DEV_WMAC @@ -679,6 +680,15 @@ + select ATH79_DEV_USB + select ATH79_DEV_WMAC + ++config ATH79_MACH_DLAN_HOTSPOT ++ bool "devolo dLAN Hotspot support" ++ select SOC_AR933X ++ select ATH79_DEV_ETH ++ select ATH79_DEV_GPIO_BUTTONS ++ select ATH79_DEV_LEDS_GPIO ++ select ATH79_DEV_M25P80 ++ select ATH79_DEV_WMAC ++ +config ATH79_MACH_DLAN_PRO_500_WP + bool "devolo dLAN pro 500 Wireless+ support" + select SOC_AR934X @@ -1452,7 +1462,7 @@ config ATH79_MACH_UBNT_XM bool "Ubiquiti Networks XM/UniFi boards" -@@ -83,6 +1221,116 @@ config ATH79_MACH_UBNT_XM +@@ -83,6 +1230,116 @@ config ATH79_MACH_UBNT_XM Say 'Y' here if you want your kernel to support the Ubiquiti Networks XM (rev 1.0) board. @@ -1569,7 +1579,7 @@ endmenu config SOC_AR71XX -@@ -134,7 +1382,10 @@ config ATH79_DEV_DSA +@@ -134,7 +1391,10 @@ config ATH79_DEV_DSA config ATH79_DEV_ETH def_bool n @@ -1581,7 +1591,7 @@ def_bool n config ATH79_DEV_GPIO_BUTTONS -@@ -164,6 +1415,11 @@ config ATH79_PCI_ATH9K_FIXUP +@@ -164,6 +1424,11 @@ config ATH79_PCI_ATH9K_FIXUP def_bool n config ATH79_ROUTERBOOT @@ -1595,7 +1605,7 @@ endif --- a/arch/mips/ath79/Makefile +++ b/arch/mips/ath79/Makefile -@@ -38,9 +38,136 @@ obj-$(CONFIG_ATH79_ROUTERBOOT) += route +@@ -38,9 +38,137 @@ obj-$(CONFIG_ATH79_ROUTERBOOT) += route # # Machines # @@ -1620,6 +1630,7 @@ +obj-$(CONFIG_ATH79_MACH_CF_E316N_V2) += mach-cf-e316n-v2.o +obj-$(CONFIG_ATH79_MACH_CPE510) += mach-cpe510.o obj-$(CONFIG_ATH79_MACH_DB120) += mach-db120.o ++obj-$(CONFIG_ATH79_MACH_DLAN_HOTSPOT) += mach-dlan-hotspot.o +obj-$(CONFIG_ATH79_MACH_DLAN_PRO_500_WP) += mach-dlan-pro-500-wp.o +obj-$(CONFIG_ATH79_MACH_DLAN_PRO_1200_AC) += mach-dlan-pro-1200-ac.o +obj-$(CONFIG_ATH79_MACH_DGL_5500_A1) += mach-dgl-5500-a1.o -- 2.30.2