ar71xx: add support for YunCore CPE870
authorPiotr Dymacz <pepe2k@gmail.com>
Fri, 7 Oct 2016 23:17:04 +0000 (01:17 +0200)
committerJohn Crispin <john@phrozen.org>
Mon, 21 Nov 2016 09:05:40 +0000 (10:05 +0100)
YunCore CPE870 is an outdoor CPE/AP based on Atheros AR9341.
Short specification:

- 535/400/200 MHz (CPU/DDR/AHB)
- 2x 10/100 Mbps Ethernet, passive PoE support
- 64/128 MB of RAM (DDR2)
- 8 MB of FLASH
- 2T2R 2.4 GHz with external PA (SKY65174-21), up to 30 dBm
- internal 14 dBi panel antenna
- 8x LED, 1x button
- UART (JP1) header on PCB

Flash instruction (do it under U-Boot, using UART):

1. tftp 0x80060000 lede-ar71xx-generic-cpe870-squashfs-sysupgrade.bin
2. erase 0x9f020000 +$filesize
3. cp.b $fileaddr 0x9f020000 $filesize
4. setenv bootcmd "bootm 0x9f020000"
5. saveenv && reset

Vendor firmware access (login/password): Admin/5up

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
target/linux/ar71xx/base-files/etc/board.d/01_leds
target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/config-4.4
target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
target/linux/ar71xx/files/arch/mips/ath79/Makefile
target/linux/ar71xx/files/arch/mips/ath79/mach-cpe870.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/image/generic.mk

index c348b4fbda7045177d28e0c12503d4606abb5269..2cf72d61d3891c7de7636d3c19c0d0ca4b590ed7 100755 (executable)
@@ -58,6 +58,7 @@ ap147-010)
        ucidef_set_led_wlan "wlan2g" "WLAN 2.4 GHz" "ap147:green:wlan-2g" "phy0tpt"
        ;;
 ap90q|\
+cpe870|\
 dr531)
        ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0"
        ucidef_set_led_netdev "wan" "WAN" "$board:green:wan" "eth1"
@@ -66,6 +67,14 @@ dr531)
        ap90q)
                ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt"
                ;;
+       cpe870)
+               ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt"
+               ucidef_set_rssimon "wlan0" "200000" "1"
+               ucidef_set_led_rssi "rssilow" "RSSILOW" "$board:green:link1" "wlan0" "1" "100" "0" "13"
+               ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "$board:green:link2" "wlan0" "26" "100" "-25" "13"
+               ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "$board:green:link3" "wlan0" "51" "100" "-50" "13"
+               ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "$board:green:link4" "wlan0" "76" "100" "-75" "13"
+               ;;
        esac
        ;;
 bhr-4grv2)
index 0ef5a52a0515d397a55862b5764c215d0375ddb2..e619749609f40c37f1d48995e0d06621f5703d95 100644 (file)
@@ -48,6 +48,7 @@ get_status_led() {
                status_led="$board:green:power"
                ;;
        ap90q|\
+       cpe870|\
        gl-inet)
                status_led="$board:green:lan"
                ;;
index 16ee2eb5788b33101799ee53ff85e113906a17f5..0d4c1e0a4968fbdc46888a3e5340dd649e37c480 100755 (executable)
@@ -526,6 +526,9 @@ ar71xx_board_detect() {
                name="cpe510"
                tplink_pharos_board_detect
                ;;
+       *CPE870)
+               name="cpe870"
+               ;;
        *CR3000)
                name="cr3000"
                ;;
index 697b786937665d9991cd4e78066f4ec64605e626..66f630884fd2bbc8c74734fb8ffc6360d41568a2 100755 (executable)
@@ -188,6 +188,7 @@ platform_check_image() {
        cf-e380ac-v2|\
        cf-e520n|\
        cf-e530n|\
+       cpe870|\
        dgl-5500-a1|\
        dhp-1565-a1|\
        dir-505-a1|\
index 471a44d05666f78c3e566271f70f841ab2d62bda..794e7f809c59db7e636843a264ceed278f93d628 100644 (file)
@@ -69,6 +69,7 @@ CONFIG_ATH79_MACH_CF_E380AC_V2=y
 CONFIG_ATH79_MACH_CF_E520N=y
 CONFIG_ATH79_MACH_CF_E530N=y
 CONFIG_ATH79_MACH_CPE510=y
+CONFIG_ATH79_MACH_CPE870=y
 CONFIG_ATH79_MACH_CR3000=y
 CONFIG_ATH79_MACH_CR5000=y
 CONFIG_ATH79_MACH_DAP_2695_A1=y
index e9431f139e706f8b4bbd450265de427f289be91b..6daa093a012a120d2f404c1a0cb52633ed0a09ab 100644 (file)
@@ -1211,6 +1211,15 @@ config ATH79_MACH_CPE510
        select ATH79_DEV_M25P80
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_CPE870
+       bool "YunCore CPE870 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_WMAC
+
 config ATH79_MACH_TL_MR11U
        bool "TP-LINK TL-MR11U/TL-MR3040 support"
        select SOC_AR933X
index c0caccdb232f6b3f4d5f7fc166389fe13e98960b..b718d6bfd3c482a6f3eebb4ed7050bae6fb2c14e 100644 (file)
@@ -75,6 +75,7 @@ obj-$(CONFIG_ATH79_MACH_CF_E380AC_V2)         += mach-cf-e316n-v2.o
 obj-$(CONFIG_ATH79_MACH_CF_E520N)              += mach-cf-e316n-v2.o
 obj-$(CONFIG_ATH79_MACH_CF_E530N)              += mach-cf-e316n-v2.o
 obj-$(CONFIG_ATH79_MACH_CPE510)                        += mach-cpe510.o
+obj-$(CONFIG_ATH79_MACH_CPE870)                        += mach-cpe870.o
 obj-$(CONFIG_ATH79_MACH_CR3000)                        += mach-cr3000.o
 obj-$(CONFIG_ATH79_MACH_CR5000)                        += mach-cr5000.o
 obj-$(CONFIG_ATH79_MACH_DAP_2695_A1)           += mach-dap-2695-a1.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe870.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-cpe870.c
new file mode 100644 (file)
index 0000000..284cdc7
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * YunCore CPE870 board support
+ *
+ * Copyright (C) 2016 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/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 CPE870_GPIO_LED_LINK1  0
+#define CPE870_GPIO_LED_LINK2  1
+#define CPE870_GPIO_LED_LINK3  2
+#define CPE870_GPIO_LED_LINK4  3
+#define CPE870_GPIO_LED_WLAN   13
+#define CPE870_GPIO_LED_WAN    19
+#define CPE870_GPIO_LED_LAN    20
+
+#define CPE870_GPIO_BTN_RESET  16
+
+#define CPE870_KEYS_POLL_INTERVAL      20
+#define CPE870_KEYS_DEBOUNCE_INTERVAL  (3 * CPE870_KEYS_POLL_INTERVAL)
+
+static struct gpio_led cpe870_leds_gpio[] __initdata = {
+       {
+               .name           = "cpe870:green:lan",
+               .gpio           = CPE870_GPIO_LED_LAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "cpe870:green:wan",
+               .gpio           = CPE870_GPIO_LED_WAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "cpe870:green:wlan",
+               .gpio           = CPE870_GPIO_LED_WLAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "cpe870:green:link1",
+               .gpio           = CPE870_GPIO_LED_LINK1,
+               .active_low     = 1,
+       },
+       {
+               .name           = "cpe870:green:link2",
+               .gpio           = CPE870_GPIO_LED_LINK2,
+               .active_low     = 1,
+       },
+       {
+               .name           = "cpe870:green:link3",
+               .gpio           = CPE870_GPIO_LED_LINK3,
+               .active_low     = 1,
+       },
+       {
+               .name           = "cpe870:green:link4",
+               .gpio           = CPE870_GPIO_LED_LINK4,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button cpe870_gpio_keys[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = CPE870_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = CPE870_GPIO_BTN_RESET,
+               .active_low     = 1,
+       },
+};
+
+static void __init cpe870_gpio_setup(void)
+{
+       /* Disable JTAG (enables GPIO0-3) */
+       ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
+
+       ath79_gpio_direction_select(CPE870_GPIO_LED_LINK1, true);
+       ath79_gpio_direction_select(CPE870_GPIO_LED_LINK2, true);
+       ath79_gpio_direction_select(CPE870_GPIO_LED_LINK3, true);
+       ath79_gpio_direction_select(CPE870_GPIO_LED_LINK4, true);
+
+       /* Mute LEDs on boot */
+       gpio_set_value(CPE870_GPIO_LED_LAN, 1);
+       gpio_set_value(CPE870_GPIO_LED_WAN, 1);
+       gpio_set_value(CPE870_GPIO_LED_LINK1, 1);
+       gpio_set_value(CPE870_GPIO_LED_LINK2, 1);
+       gpio_set_value(CPE870_GPIO_LED_LINK3, 1);
+       gpio_set_value(CPE870_GPIO_LED_LINK4, 1);
+
+       ath79_gpio_output_select(CPE870_GPIO_LED_LINK1, 0);
+       ath79_gpio_output_select(CPE870_GPIO_LED_LINK2, 0);
+       ath79_gpio_output_select(CPE870_GPIO_LED_LINK3, 0);
+       ath79_gpio_output_select(CPE870_GPIO_LED_LINK4, 0);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe870_leds_gpio),
+                                cpe870_leds_gpio);
+
+       ath79_register_gpio_keys_polled(-1, CPE870_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(cpe870_gpio_keys),
+                                       cpe870_gpio_keys);
+}
+
+static void __init cpe870_setup(void)
+{
+       u8 *art = (u8 *) KSEG1ADDR(0x1fff1000);
+       u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
+
+       ath79_register_m25p80(NULL);
+
+       cpe870_gpio_setup();
+
+       ath79_register_mdio(1, 0x0);
+
+       ath79_switch_data.phy4_mii_en = 1;
+       ath79_switch_data.phy_poll_mask = BIT(4);
+
+       /* LAN */
+       ath79_eth1_data.duplex = DUPLEX_FULL;
+       ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+       ath79_eth1_data.speed = SPEED_1000;
+       ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
+       ath79_register_eth(1);
+
+       /* WAN */
+       ath79_eth0_data.duplex = DUPLEX_FULL;
+       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+       ath79_eth0_data.speed = SPEED_100;
+       ath79_eth0_data.phy_mask = BIT(4);
+       ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
+       ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+       ath79_register_eth(0);
+
+       ath79_register_wmac(art, NULL);
+}
+
+MIPS_MACHINE(ATH79_MACH_CPE870, "CPE870", "YunCore CPE870", cpe870_setup);
index e69cf3beced10ea85d336e1c79ed02c2b70abc73..50ecff46f5f8aa5fc7973780819537b66763ee81 100644 (file)
@@ -61,6 +61,7 @@ enum ath79_mach_type {
        ATH79_MACH_CF_E530N,                    /* COMFAST CF-E530N */
        ATH79_MACH_CPE210,                      /* TP-LINK CPE210 */
        ATH79_MACH_CPE510,                      /* TP-LINK CPE510 */
+       ATH79_MACH_CPE870,                      /* YunCore CPE870 */
        ATH79_MACH_CR3000,                      /* PowerCloud CR3000 */
        ATH79_MACH_CR5000,                      /* PowerCloud CR5000 */
        ATH79_MACH_DAP_2695_A1,                 /* D-Link DAP-2695 rev. A1 */
index 0c32cddfdd702b231c9d02348b609490850ab296..0b8a216a25bb1beb17a18bb09d1bdb9d1d8ba37d 100644 (file)
@@ -80,6 +80,16 @@ define Device/cf-e530n
 endef
 TARGET_DEVICES += cf-e530n
 
+define Device/cpe870
+  DEVICE_TITLE := YunCore CPE870
+  DEVICE_PACKAGES := rssileds
+  BOARDNAME = CPE870
+  IMAGE_SIZE = 7936k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = spi0.0:64k(u-boot)ro,64k(u-boot-env),7936k(firmware),64k(config)ro,64k(art)ro
+endef
+TARGET_DEVICES += cpe870
+
 define Device/domywifi-dw33d
   DEVICE_TITLE := DomyWifi DW33D
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-storage kmod-ledtrig-usbdev kmod-ath10k