[OpenWrt-Devel] [PATCH] ar71xx: add support for GL.iNet GL-X1200

Chuanhong Guo gch981213 at gmail.com
Fri Apr 12 12:16:04 EDT 2019


Hi!
I'd also suggest switching to ath79 as there is nothing preventing
ath79 to work correctly on this router and I doubt if any maintainer
wants to touch ar71xx anymore.
Here is some code review anyway:

On Thu, Apr 11, 2019 at 10:09 AM wellnw <guilin.wang at gl-inet.com> wrote:
>
> This patch adds supports for GL-X1200.
>
> Specification:
>     - SOC: QCA9563 (775MHz)
>     - Flash: 16 MiB (W25Q128FVSG)
>     - RAM: 128 MiB DDR2
>     - Ethernet: 4x 1Gbps LAN + 1x 1Gbps WAN
>     - Wireless: QCA9563(2.4GHz) and QCA9886(5GHz)
>     - SIM: 2x SIM card slots
>     - MicroSD: 1x microSD slot
>     - Antenna: 2x external 5dBi antennas
>     - USB: 1x USB 2.0 port
>     - Button: 1x reset button
>     - LED: 16x LEDs (3x GPIO controllable)
>     - UART: 1x UART on PCB (JP1: 3.3V, RX, TX, GND)

Flashing instruction is missing in the commit message.
It's still helpful to mention it even if it's simply "upload generated
file to firmware upgrade page."

>
> Signed-off-by: wellnw <guilin.wang at gl-inet.com>
> ---
>  target/linux/ar71xx/base-files/etc/board.d/01_leds |   4 +
>  .../linux/ar71xx/base-files/etc/board.d/02_network |   4 +
>  .../etc/hotplug.d/firmware/11-ath10k-caldata       |   5 +
>  target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
>  .../ar71xx/base-files/lib/upgrade/platform.sh      |   1 +
>  target/linux/ar71xx/config-4.14                    |   1 +
>  .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  11 ++
>  target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
>  .../ar71xx/files/arch/mips/ath79/mach-gl-x1200.c   | 153 +++++++++++++++++++++
>  .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
>  target/linux/ar71xx/generic/config-default         |   1 +
>  target/linux/ar71xx/image/generic.mk               |  13 ++
>  12 files changed, 198 insertions(+)
>  create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gl-x1200.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 41dd8c5..eb455ce 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
> +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
> @@ -448,6 +448,10 @@ gl-inet)
>         ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth1"
>         ucidef_set_led_wlan "wlan" "WLAN" "$board:red:wlan" "phy0tpt"
>         ;;
> +gl-x1200)
> +       ucidef_set_led_wlan "wlan2g" "WLAN2G" "$board:green:wlan2g" "phy1tpt"
> +       ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:green:wlan5g" "phy0tpt"
> +       ;;
>  hiwifi-hc6361)
>         ucidef_set_led_netdev "inet" "INET" "hiwifi:blue:internet" "eth1"
>         ucidef_set_led_wlan "wlan" "WLAN" "hiwifi:blue:wlan-2p4" "phy0tpt"
> 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 68874e0..6fd4c25 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
> @@ -456,6 +456,10 @@ ar71xx_setup_interfaces()
>                 ucidef_add_switch "switch0" \
>                         "0 at eth0" "2:lan:2" "3:lan:1" "1:wan"
>                 ;;
> +       gl-x1200)
> +               ucidef_add_switch "switch0" \
> +                       "0 at eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
> +               ;;
>         jwap230)
>                 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
>                 ucidef_add_switch "switch0" \
> diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> index 2ded261..fd6f213 100644
> --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> @@ -187,6 +187,11 @@ case "$FIRMWARE" in
>         cf-e385ac)
>                 ath10kcal_extract "art" 20480 12064
>                 ;;
> +       gl-x1200)
> +               ath10kcal_extract "art" 20480 12064
> +               ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
> +                       /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
> +               ;;
>         esac
>         ;;
>  *)
> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> index 990683a..42902d0 100755
> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> @@ -794,6 +794,9 @@ ar71xx_board_detect() {
>         *"GL-USB150")
>                 name="gl-usb150"
>                 ;;
> +       *"GL-X1200")
> +               name="gl-x1200"
> +               ;;
>         *"HiveAP-121")
>                 name="hiveap-121"
>                 ;;
> diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> index 8173501..55be0a3 100755
> --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> @@ -273,6 +273,7 @@ platform_check_image() {
>         gl-domino|\
>         gl-mifi|\
>         gl-usb150|\
> +       gl-x1200|\
>         hiwifi-hc6361|\
>         hornet-ub-x2|\
>         jwap230|\
> diff --git a/target/linux/ar71xx/config-4.14 b/target/linux/ar71xx/config-4.14
> index 9a524fa..8f8d8ce 100644
> --- a/target/linux/ar71xx/config-4.14
> +++ b/target/linux/ar71xx/config-4.14
> @@ -130,6 +130,7 @@ CONFIG_ATH79=y
>  # CONFIG_ATH79_MACH_GL_INET is not set
>  # CONFIG_ATH79_MACH_GL_MIFI is not set
>  # CONFIG_ATH79_MACH_GL_USB150 is not set
> +# CONFIG_ATH79_MACH_GL_X1200 is not set
>  # CONFIG_ATH79_MACH_GS_MINIBOX_V32 is not set
>  # CONFIG_ATH79_MACH_GS_OOLITE_V1 is not set
>  # CONFIG_ATH79_MACH_GS_OOLITE_V5_2 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 6fd78c4..c42fa16 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> @@ -897,6 +897,17 @@ config ATH79_MACH_GL_USB150
>         select ATH79_DEV_M25P80
>         select ATH79_DEV_WMAC
>
> +config ATH79_MACH_GL_X1200
> +       bool "GL.iNet GL-X1200 support"
> +       select SOC_QCA956X
> +       select ATH79_DEV_AP9X_PCI if PCI
> +       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
> +
>  config ATH79_MACH_EAP120
>         bool "TP-LINK EAP120 support"
>         select SOC_AR934X
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> index 0265b3d..9816175 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> @@ -140,6 +140,7 @@ obj-$(CONFIG_ATH79_MACH_GL_DOMINO)          += mach-gl-domino.o
>  obj-$(CONFIG_ATH79_MACH_GL_INET)               += mach-gl-inet.o
>  obj-$(CONFIG_ATH79_MACH_GL_MIFI)               += mach-gl-mifi.o
>  obj-$(CONFIG_ATH79_MACH_GL_USB150)             += mach-gl-usb150.o
> +obj-$(CONFIG_ATH79_MACH_GL_X1200)              += mach-gl-x1200.o
>  obj-$(CONFIG_ATH79_MACH_GS_MINIBOX_V32)                += mach-gs-minibox-v32.o
>  obj-$(CONFIG_ATH79_MACH_GS_OOLITE_V1)          += mach-gs-oolite-v1.o
>  obj-$(CONFIG_ATH79_MACH_GS_OOLITE_V5_2)                += mach-gs-oolite-v5-2.o
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-x1200.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-x1200.c
> new file mode 100644
> index 0000000..ab3be3b
> --- /dev/null
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-x1200.c
> @@ -0,0 +1,153 @@
> +/*
> + * GL.iNet GL-X1200 board support
> + *
> + * Copyright (C) 2018 guilin wang <guilin.wang at gl-inet.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/init.h>
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
> +#include <linux/ath9k_platform.h>
> +#include <linux/ar8216_platform.h>
> +#include <linux/etherdevice.h>
> +
> +#include <asm/mach-ath79/ath79.h>
> +#include <asm/mach-ath79/irq.h>
> +#include <asm/mach-ath79/ar71xx_regs.h>
> +
> +#include <linux/platform_data/phy-at803x.h>
> +
> +#include "common.h"
> +#include "dev-ap9x-pci.h"
> +#include "dev-eth.h"
> +#include "dev-gpio-buttons.h"
> +#include "dev-leds-gpio.h"
> +#include "dev-spi.h"
> +#include "dev-m25p80.h"
> +#include "dev-wmac.h"
> +#include "dev-usb.h"
> +#include "machtypes.h"
> +
> +#define GL_X1200_KEYS_POLL_INTERVAL    20
> +#define GL_X1200_KEYS_DEBOUNCE_INTERVAL        (3 * GL_X1200_KEYS_POLL_INTERVAL)
> +
> +#define GL_X1200_GPIO_LED_WLAN2G        19
> +#define GL_X1200_GPIO_LED_WLAN5G        20
> +#define GL_X1200_GPIO_LED_POWER                        8
> +#define GL_X1200_GPIO_USB_POWER                        7
> +
> +#define GL_X1200_GPIO_BTN_RESET                        2
> +
> +#define GL_X1200_MAC0_OFFSET             0x0000
> +#define GL_X1200_WMAC_CALDATA_OFFSET     0x1000
> +#define GL_X1200_PCI_CALDATA_OFFSET      0x5000
> +
> +static struct spi_board_info gl_x1200_spi_info[] = {
> +       {
> +               .bus_num                = 0,
> +               .chip_select    = 0,
> +               .max_speed_hz   = 25000000,
> +               .modalias               = "m25p80",
> +               .platform_data  = NULL,
> +       },
> +};
> +
> +static struct ath79_spi_platform_data gl_x1200_spi_data = {
> +       .bus_num                        = 0,
> +       .num_chipselect     = 1,
> +};

You don't have to create all these m25p80 platform data manually.
ath79_register_m25p80 defined in dev-m25p80.c did everything for you.
GL-AR300M manually create these stuff only because it needs to
register a SPI NAND driver.

> +
> +static struct gpio_led gl_x1200_leds_gpio[] __initdata = {
> +       {
> +               .name                   = "gl-x1200:green:power",
> +               .gpio                   = GL_X1200_GPIO_LED_POWER,
> +               .default_state  = LEDS_GPIO_DEFSTATE_KEEP,
> +               .active_low             = 1,
> +       },{
> +               .name           = "gl-x1200:green:usbpower",
> +               .gpio           = GL_X1200_GPIO_USB_POWER,
> +               .active_low     = 1,
> +       },{
> +               .name           = "gl-x1200:green:wlan2g",
> +               .gpio           = GL_X1200_GPIO_LED_WLAN2G,
> +               .active_low     = 1,
> +       },{
> +               .name           = "gl-x1200:green:wlan5g",
> +               .gpio           = GL_X1200_GPIO_LED_WLAN5G,
> +               .active_low     = 0,
> +       }
> +};
> +
> +static struct gpio_keys_button gl_x1200_gpio_keys[] __initdata = {
> +       {
> +               .desc                   = "reset",
> +               .type                   = EV_KEY,
> +               .code                   = KEY_RESTART,
> +               .debounce_interval      = GL_X1200_KEYS_DEBOUNCE_INTERVAL,
> +               .gpio                   = GL_X1200_GPIO_BTN_RESET,
> +               .active_low             = 1,
> +       },
> +};
> +
> +static struct ar8327_pad_cfg gl_x1200_ar8327_pad0_cfg = {
> +       .mode = AR8327_PAD_MAC_SGMII,
> +       .sgmii_delay_en = true,
> +};
> +
> +static struct ar8327_platform_data gl_x1200_ar8327_data = {
> +       .pad0_cfg = &gl_x1200_ar8327_pad0_cfg,
> +       .port0_cfg = {
> +               .force_link = 1,
> +               .speed = AR8327_PORT_SPEED_1000,
> +               .duplex = 1,
> +               .txpause = 1,
> +               .rxpause = 1,
> +       },
> +};
> +
> +
> +static struct mdio_board_info gl_x1200_mdio0_info[] = {
> +       {
> +               .bus_id = "ag71xx-mdio.0",
> +               .mdio_addr = 0,
> +               .platform_data = &gl_x1200_ar8327_data,
> +       },
> +};
> +
> +static void __init gl_x1200_setup(void)
> +{
> +       u8 *eeprom = (u8 *) KSEG1ADDR(0x1f050000);
> +
> +       ath79_register_spi(&gl_x1200_spi_data, gl_x1200_spi_info, 1);
> +
> +       ath79_init_mac(ath79_eth0_data.mac_addr,
> +                       eeprom + GL_X1200_MAC0_OFFSET, 0);
> +
> +       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
> +       ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
> +       ath79_eth0_data.phy_mask = BIT(0);
> +
> +       mdiobus_register_board_info(gl_x1200_mdio0_info,
> +                       ARRAY_SIZE(gl_x1200_mdio0_info));
> +       ath79_register_mdio(0, 0x00);
> +       ath79_register_eth(0);
> +       ath79_register_usb();
> +
> +       ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
> +
> +       ath79_register_wmac(eeprom + GL_X1200_WMAC_CALDATA_OFFSET, NULL);
> +       ap91_pci_init(eeprom + GL_X1200_PCI_CALDATA_OFFSET, NULL);

ath79_register_pci is enough here. ap91_pci_init creates platform data
for ath9k pci cards.

> +
> +       ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_x1200_leds_gpio),
> +                       gl_x1200_leds_gpio);
> +
> +       ath79_register_gpio_keys_polled(-1, GL_X1200_KEYS_POLL_INTERVAL,
> +                       ARRAY_SIZE(gl_x1200_gpio_keys),
> +                       gl_x1200_gpio_keys);
> +}
> +
> +MIPS_MACHINE(ATH79_MACH_GL_X1200, "GL-X1200", "GL-X1200",
> +               gl_x1200_setup);
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> index 9722744..f5c3e3d 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> @@ -138,6 +138,7 @@ enum ath79_mach_type {
>         ATH79_MACH_GL_INET,                     /* GL-CONNECT GL-INET */
>         ATH79_MACH_GL_MIFI,                     /* GL-MIFI support */
>         ATH79_MACH_GL_USB150,                   /* GL.iNet GL-USB150 */
> +       ATH79_MACH_GL_X1200,                    /* GL.iNet GL-X1200 */
>         ATH79_MACH_GS_MINIBOX_V1,               /* GainStrong MiniBox V1.0 */
>         ATH79_MACH_GS_MINIBOX_V32,              /* Gainstrong MiniBox V3.2 */
>         ATH79_MACH_GS_OOLITE_V1,                /* GainStrong Oolite V1.0 */
> diff --git a/target/linux/ar71xx/generic/config-default b/target/linux/ar71xx/generic/config-default
> index 25b58ae..de7586f 100644
> --- a/target/linux/ar71xx/generic/config-default
> +++ b/target/linux/ar71xx/generic/config-default
> @@ -99,6 +99,7 @@ CONFIG_ATH79_MACH_GL_DOMINO=y
>  CONFIG_ATH79_MACH_GL_INET=y
>  CONFIG_ATH79_MACH_GL_MIFI=y
>  CONFIG_ATH79_MACH_GL_USB150=y
> +CONFIG_ATH79_MACH_GL_X1200=y
>  CONFIG_ATH79_MACH_GS_MINIBOX_V32=y
>  CONFIG_ATH79_MACH_GS_OOLITE_V1=y
>  CONFIG_ATH79_MACH_GS_OOLITE_V5_2=y
> diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
> index 30a8b34..3b16fef 100644
> --- a/target/linux/ar71xx/image/generic.mk
> +++ b/target/linux/ar71xx/image/generic.mk
> @@ -543,6 +543,19 @@ define Device/gl-usb150
>  endef
>  TARGET_DEVICES += gl-usb150
>
> +define Device/gl-x1200
> +  DEVICE_TITLE := GL.iNet GL-X1200
> +  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-storage \
> +         kmod-ath10k ath10k-firmware-qca9888
> +  BOARDNAME := GL-X1200
> +  SUPPORTED_DEVICES := gl-x1200
> +  IMAGE_SIZE := 16000k
> +  MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env),64k(art)ro,-(firmware)
> +  IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | \
> +         append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
> +endef
> +TARGET_DEVICES += gl-x1200
> +
>  define Device/lan-turtle
>    $(Device/tplink-16mlzma)
>    DEVICE_TITLE := Hak5 LAN Turtle
> --
> 2.7.4
>
>
>

Regards,
Chuanhong Guo

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list