diff options
-rwxr-xr-x | target/linux/ar71xx/base-files/etc/board.d/01_leds | 6 | ||||
-rwxr-xr-x | target/linux/ar71xx/base-files/etc/board.d/02_network | 5 | ||||
-rw-r--r-- | target/linux/ar71xx/base-files/etc/diag.sh | 1 | ||||
-rwxr-xr-x | target/linux/ar71xx/base-files/lib/ar71xx.sh | 3 | ||||
-rwxr-xr-x | target/linux/ar71xx/base-files/lib/upgrade/platform.sh | 1 | ||||
-rw-r--r-- | target/linux/ar71xx/config-4.4 | 1 | ||||
-rw-r--r-- | target/linux/ar71xx/config-4.9 | 1 | ||||
-rw-r--r-- | target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt | 11 | ||||
-rw-r--r-- | target/linux/ar71xx/files/arch/mips/ath79/Makefile | 1 | ||||
-rw-r--r-- | target/linux/ar71xx/files/arch/mips/ath79/mach-rut9xx.c | 191 | ||||
-rw-r--r-- | target/linux/ar71xx/files/arch/mips/ath79/machtypes.h | 1 | ||||
-rw-r--r-- | target/linux/ar71xx/generic/config-default | 3 | ||||
-rw-r--r-- | target/linux/ar71xx/image/generic.mk | 42 |
13 files changed, 267 insertions, 0 deletions
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 f2d66b2986..02f3ad911a 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -595,6 +595,12 @@ re450) ucidef_set_led_wlan "wlan2g" "WLAN 2.4 GHz" "$board:blue:wlan2g" "phy1tpt" ucidef_set_led_wlan "wlan5g" "WLAN 5 GHz" "$board:blue:wlan5g" "phy0tpt" ;; +rut900) + ucidef_set_led_netdev "wan" "WAN" "$board:green:wan" "eth1" + ucidef_set_led_switch "lan1" "LAN1" "$board:green:lan1" "switch0" "0x10" + ucidef_set_led_switch "lan2" "LAN2" "$board:green:lan2" "switch0" "0x08" + ucidef_set_led_switch "lan3" "LAN3" "$board:green:lan3" "switch0" "0x04" + ;; smart-300) ucidef_set_led_netdev "wan" "WAN" "nc-link:green:wan" "eth0" ucidef_set_led_switch "lan1" "LAN1" "nc-link:green:lan1" "switch0" "0x04" 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 461b72f4d7..675c1f7718 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -428,6 +428,11 @@ ar71xx_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "1:wan" "2:lan" ;; + rut900) + ucidef_set_interfaces_lan_wan "eth0.1" "eth1" + ucidef_add_switch "switch0" \ + "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" + ;; tellstick-znet-lite) ucidef_set_interface_wan "eth0" ucidef_set_interface_raw "wlan" "wlan0" "dhcp" diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 63a9ebc1ec..1dece96f84 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -40,6 +40,7 @@ get_status_led() { db120|\ dr342|\ dr344|\ + rut900|\ tew-632brp|\ tl-wr942n-v1|\ wpj344|\ diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 1de9d02965..1419579d83 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -995,6 +995,9 @@ ar71xx_board_detect() { *"RouterStation Pro") name="routerstation-pro" ;; + *"RUT900") + name="rut900" + ;; *"RW2458N") name="rw2458n" ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 3bfedf82da..86d0476790 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -387,6 +387,7 @@ platform_check_image() { onion-omega|\ oolite|\ re450|\ + rut900|\ smart-300|\ som9331|\ tellstick-znet-lite|\ diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4 index c5bcc4061a..1dc7127bfb 100644 --- a/target/linux/ar71xx/config-4.4 +++ b/target/linux/ar71xx/config-4.4 @@ -165,6 +165,7 @@ CONFIG_ATH79=y # CONFIG_ATH79_MACH_RBSPI is not set # CONFIG_ATH79_MACH_RBSXTLITE is not set # CONFIG_ATH79_MACH_RE450 is not set +# CONFIG_ATH79_MACH_RUT9XX is not set # CONFIG_ATH79_MACH_RW2458N is not set # CONFIG_ATH79_MACH_SC1750 is not set # CONFIG_ATH79_MACH_SC300M is not set diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9 index 8815edf343..78393b13f4 100644 --- a/target/linux/ar71xx/config-4.9 +++ b/target/linux/ar71xx/config-4.9 @@ -163,6 +163,7 @@ CONFIG_ATH79=y # CONFIG_ATH79_MACH_RBSPI is not set # CONFIG_ATH79_MACH_RBSXTLITE is not set # CONFIG_ATH79_MACH_RE450 is not set +# CONFIG_ATH79_MACH_RUT9XX is not set # CONFIG_ATH79_MACH_RW2458N is not set # CONFIG_ATH79_MACH_SC1750 is not set # CONFIG_ATH79_MACH_SC300M is not set diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt index 43096463c2..2b7e086e2c 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt @@ -1281,6 +1281,17 @@ config ATH79_MACH_RE450 select ATH79_DEV_M25P80 select ATH79_DEV_WMAC +config ATH79_MACH_RUT9XX + bool "Teltonika RUT900 series support" + select SOC_AR934X + select ATH79_DEV_ETH + select ATH79_DEV_GPIO_BUTTONS + select ATH79_DEV_LEDS_GPIO + select ATH79_DEV_M25P80 + select ATH79_DEV_USB + select ATH79_DEV_WMAC + select GPIO_PCA953X + config ATH79_MACH_RW2458N bool "Redwave RW2458N board support" select SOC_AR724X diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile index 53edaac712..4f3bb97e33 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile @@ -174,6 +174,7 @@ obj-$(CONFIG_ATH79_MACH_RB95X) += mach-rb95x.o obj-$(CONFIG_ATH79_MACH_RBSPI) += mach-rbspi.o obj-$(CONFIG_ATH79_MACH_RBSXTLITE) += mach-rbsxtlite.o obj-$(CONFIG_ATH79_MACH_RE450) += mach-re450.o +obj-$(CONFIG_ATH79_MACH_RUT9XX) += mach-rut9xx.o obj-$(CONFIG_ATH79_MACH_RW2458N) += mach-rw2458n.o obj-$(CONFIG_ATH79_MACH_SC1750) += mach-sc1750.o obj-$(CONFIG_ATH79_MACH_SC300M) += mach-sc300m.o diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rut9xx.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-rut9xx.c new file mode 100644 index 0000000000..43a2a78c67 --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rut9xx.c @@ -0,0 +1,191 @@ +/* + * Teltonika RUT900 series boards support + * + * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com> + * + * 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 <linux/gpio.h> +#include <linux/i2c.h> +#include <linux/i2c-algo-bit.h> +#include <linux/i2c-gpio.h> +#include <linux/platform_data/pca953x.h> +#include <linux/platform_device.h> + +#include <asm/mach-ath79/ath79.h> +#include <asm/mach-ath79/ar71xx_regs.h> + +#include "common.h" +#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 RUT9XX_GPIO_LED_LAN1 14 +#define RUT9XX_GPIO_LED_LAN2 13 +#define RUT9XX_GPIO_LED_LAN3 22 +#define RUT9XX_GPIO_LED_WAN 1 + +#define RUT9XX_PCA9539_GPIO_BASE 32 +#define RUT9XX_PCA9539_GPIO_SIGNAL1 (0 + RUT9XX_PCA9539_GPIO_BASE) +#define RUT9XX_PCA9539_GPIO_SIGNAL2 (1 + RUT9XX_PCA9539_GPIO_BASE) +#define RUT9XX_PCA9539_GPIO_SIGNAL3 (2 + RUT9XX_PCA9539_GPIO_BASE) +#define RUT9XX_PCA9539_GPIO_SIGNAL4 (3 + RUT9XX_PCA9539_GPIO_BASE) +#define RUT9XX_PCA9539_GPIO_SIGNAL5 (4 + RUT9XX_PCA9539_GPIO_BASE) +#define RUT9XX_PCA9539_GPIO_STATUS_R (5 + RUT9XX_PCA9539_GPIO_BASE) +#define RUT9XX_PCA9539_GPIO_STATUS_G (6 + RUT9XX_PCA9539_GPIO_BASE) + +#define RUT9XX_GPIO_BTN_RESET 15 + +#define RUT9XX_GPIO_I2C_SCK 16 +#define RUT9XX_GPIO_I2C_SDA 17 + +#define RUT9XX_GPIO_EXT_LNA0 2 + +#define RUT9XX_WMAC_CALDATA_OFFSET 0x1000 + +#define RUT9XX_KEYS_POLL_INTERVAL 20 +#define RUT9XX_KEYS_DEBOUNCE_INTERVAL (3 * RUT9XX_KEYS_POLL_INTERVAL) + +static struct gpio_led rut900_leds_gpio[] __initdata = { + { + .name = "rut900:green:lan1", + .gpio = RUT9XX_GPIO_LED_LAN1, + .active_low = 1, + }, { + .name = "rut900:green:lan2", + .gpio = RUT9XX_GPIO_LED_LAN2, + .active_low = 1, + }, { + .name = "rut900:green:lan3", + .gpio = RUT9XX_GPIO_LED_LAN3, + .active_low = 1, + }, { + .name = "rut900:green:signal1", + .gpio = RUT9XX_PCA9539_GPIO_SIGNAL1, + .active_low = 0, + }, { + .name = "rut900:green:signal2", + .gpio = RUT9XX_PCA9539_GPIO_SIGNAL2, + .active_low = 0, + }, { + .name = "rut900:green:signal3", + .gpio = RUT9XX_PCA9539_GPIO_SIGNAL3, + .active_low = 0, + }, { + .name = "rut900:green:signal4", + .gpio = RUT9XX_PCA9539_GPIO_SIGNAL4, + .active_low = 0, + }, { + .name = "rut900:green:signal5", + .gpio = RUT9XX_PCA9539_GPIO_SIGNAL5, + .active_low = 0, + }, { + .name = "rut900:green:status", + .gpio = RUT9XX_PCA9539_GPIO_STATUS_G, + .active_low = 0, + }, { + .name = "rut900:green:wan", + .gpio = RUT9XX_GPIO_LED_WAN, + .active_low = 1, + }, { + .name = "rut900:red:status", + .gpio = RUT9XX_PCA9539_GPIO_STATUS_R, + .active_low = 0, + }, +}; + +static struct gpio_keys_button rut900_gpio_keys[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = RUT9XX_KEYS_DEBOUNCE_INTERVAL, + .gpio = RUT9XX_GPIO_BTN_RESET, + .active_low = 1, + }, +}; + +static struct i2c_gpio_platform_data rut900_i2c_gpio_data = { + .sda_pin = RUT9XX_GPIO_I2C_SDA, + .scl_pin = RUT9XX_GPIO_I2C_SCK, + .udelay = 10, +}; + +static struct platform_device rut900_i2c_device = { + .name = "i2c-gpio", + .id = 0, + .dev = { + .platform_data = &rut900_i2c_gpio_data, + }, +}; + +static struct pca953x_platform_data rut9xx_pca9539_data = { + .gpio_base = RUT9XX_PCA9539_GPIO_BASE, + .irq_base = -1, +}; + +static struct i2c_board_info rut900_i2c_devs[] __initdata = { + { + I2C_BOARD_INFO("pca9539", 0x74), + .platform_data = &rut9xx_pca9539_data, + }, +}; + +static void __init rut900_setup(void) +{ + u8 *art = (u8 *) KSEG1ADDR(0x1f030000); + u8 *mac = (u8 *) KSEG1ADDR(0x1f020000); + u8 wlan_mac[ETH_ALEN]; + + ath79_register_m25p80(NULL); + + ath79_register_mdio(1, 0x0); + + ath79_switch_data.phy4_mii_en = 1; + ath79_switch_data.phy_poll_mask = 0xf1; + + /* LAN */ + ath79_eth1_data.duplex = DUPLEX_FULL; + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0); + ath79_register_eth(1); + + /* WAN */ + ath79_eth0_data.duplex = DUPLEX_FULL; + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev; + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; + ath79_eth0_data.phy_mask = BIT(4); + ath79_eth0_data.speed = SPEED_100; + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1); + ath79_register_eth(0); + + platform_device_register(&rut900_i2c_device); + i2c_register_board_info(0, rut900_i2c_devs, + ARRAY_SIZE(rut900_i2c_devs)); + + /* Disable JTAG (enables GPIO0-3) */ + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(rut900_leds_gpio), + rut900_leds_gpio); + + ath79_register_gpio_keys_polled(-1, RUT9XX_KEYS_POLL_INTERVAL, + ARRAY_SIZE(rut900_gpio_keys), + rut900_gpio_keys); + + ath79_wmac_set_ext_lna_gpio(0, RUT9XX_GPIO_EXT_LNA0); + + ath79_init_mac(wlan_mac, mac, 2); + ath79_register_wmac(art + RUT9XX_WMAC_CALDATA_OFFSET, wlan_mac); + + ath79_register_usb(); +} + +MIPS_MACHINE(ATH79_MACH_RUT9XX, "RUT900", "Teltonika RUT900", rut900_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h index 06fa4768c1..40ac034388 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h @@ -202,6 +202,7 @@ enum ath79_mach_type { ATH79_MACH_RB_SXTLITE2ND, /* Mikrotik RouterBOARD SXT Lite 2nD */ ATH79_MACH_RB_SXTLITE5ND, /* Mikrotik RouterBOARD SXT Lite 5nD */ ATH79_MACH_RE450, /* TP-LINK RE450 */ + ATH79_MACH_RUT9XX, /* Teltonika RUT900 series */ ATH79_MACH_RW2458N, /* Redwave RW2458N */ ATH79_MACH_SC1750, /* Abicom SC1750 */ ATH79_MACH_SC300M, /* Abicom SC300M */ diff --git a/target/linux/ar71xx/generic/config-default b/target/linux/ar71xx/generic/config-default index 5d236b2e69..15116f5500 100644 --- a/target/linux/ar71xx/generic/config-default +++ b/target/linux/ar71xx/generic/config-default @@ -122,6 +122,7 @@ CONFIG_ATH79_MACH_PQI_AIR_PEN=y CONFIG_ATH79_MACH_QIHOO_C301=y CONFIG_ATH79_MACH_R602N=y CONFIG_ATH79_MACH_RE450=y +CONFIG_ATH79_MACH_RUT9XX=y CONFIG_ATH79_MACH_RW2458N=y CONFIG_ATH79_MACH_SC1750=y CONFIG_ATH79_MACH_SC300M=y @@ -183,6 +184,8 @@ CONFIG_ATH79_MACH_ZCN_1523H=y CONFIG_ATH79_NVRAM=y CONFIG_ATH79_PCI_ATH9K_FIXUP=y CONFIG_BLK_MQ_PCI=y +CONFIG_GPIO_PCA953X=y +# CONFIG_GPIO_PCA953X_IRQ is not set CONFIG_HW_HAS_PCI=y # CONFIG_LEDS_WNDR3700_USB is not set CONFIG_MYLOADER=y diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk index f1efebc523..3fbfca35e0 100644 --- a/target/linux/ar71xx/image/generic.mk +++ b/target/linux/ar71xx/image/generic.mk @@ -7,6 +7,15 @@ define Build/alfa-network-rootfs-header @mv $@.new $@ endef +define Build/append-md5sum-bin + $(STAGING_DIR_HOST)/bin/mkhash md5 $@ | sed 's/../\\\\x&/g' |\ + xargs echo -ne >> $@ +endef + +define Build/append-string + echo -n $(1) >> $@ +endef + define Build/mkbuffaloimg $(STAGING_DIR_HOST)/bin/mkbuffaloimg -B $(BOARDNAME) \ -R $$(($(subst k, * 1024,$(ROOTFS_SIZE)))) \ @@ -68,6 +77,17 @@ define Build/seama-seal $(call Build/seama,-s $@.seama $(1)) endef +define Build/teltonika-fw-fake-checksum + # Teltonika U-Boot web based firmware upgrade/recovery routine compares + # 16 bytes from md5sum1[16] field in TP-Link v1 header (offset: 76 bytes + # from begin of the firmware file) with 16 bytes stored just before + # 0xdeadc0de marker. Values are only compared, MD5 sum is not verified. + let \ + offs="$$(stat -c%s $@) - 20"; \ + dd if=$@ bs=1 count=16 skip=76 |\ + dd of=$@ bs=1 count=16 seek=$$offs conv=notrunc +endef + define Build/uImageHiWiFi # Field ih_name needs to start with "tw150v1" mkimage -A $(LINUX_KARCH) \ @@ -620,6 +640,28 @@ define Device/r602n endef TARGET_DEVICES += r602n +define Device/rut900 + DEVICE_TITLE := Teltonika RUT900 + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 -uboot-envtools + BOARDNAME := RUT900 + SUPPORTED_DEVICES := rut900 + IMAGE_SIZE := 15552k + MTDPARTS := spi0.0:128k(u-boot)ro,64k(config)ro,64k(art)ro,15552k(firmware),576k(event-log)ro + TPLINK_HWID := 0x35000001 + TPLINK_HWREV := 0x1 + TPLINK_HEADER_VERSION := 1 + KERNEL := kernel-bin | patch-cmdline | lzma | tplink-v1-header + KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | uImage lzma + IMAGES := sysupgrade.bin factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs |\ + pad-rootfs | teltonika-fw-fake-checksum | append-string master |\ + append-md5sum-bin | check-size $$$$(IMAGE_SIZE) + IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) |\ + append-rootfs | pad-rootfs | append-metadata |\ + check-size $$$$(IMAGE_SIZE) +endef +TARGET_DEVICES += rut900 + define Device/mc-mac1200r $(Device/tplink-8mlzma) DEVICE_TITLE := Mercury MAC1200R |