[source] ar71xx: add support for gl-ar300m

LEDE Commits lede-commits at lists.infradead.org
Tue Jul 19 15:20:28 PDT 2016


jow pushed a commit to source.git, branch master:
https://git.lede-project.org/?p=source.git;a=commitdiff;h=d963ddf0424a551e5fadd561c934bfdb5d198764

commit d963ddf0424a551e5fadd561c934bfdb5d198764
Author: Zhao Gang <gang.zhao.42 at gmail.com>
AuthorDate: Fri Jul 15 10:00:04 2016 +0000

    ar71xx: add support for gl-ar300m
    
    This add initial support for gl-ar300m router.
    Product page: http://www.gl-inet.com/ar300m/
    
    Signed-off-by: Zhao Gang <gang.zhao.42 at gmail.com>
---
 package/boot/uboot-envtools/files/ar71xx           |   1 +
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   4 +
 .../linux/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.4                     |   1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  10 ++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../ar71xx/files/arch/mips/ath79/mach-gl-ar300m.c  | 182 +++++++++++++++++++++
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/generic.mk               |  10 ++
 12 files changed, 218 insertions(+)

diff --git a/package/boot/uboot-envtools/files/ar71xx b/package/boot/uboot-envtools/files/ar71xx
index b45c1a2..a075020 100644
--- a/package/boot/uboot-envtools/files/ar71xx
+++ b/package/boot/uboot-envtools/files/ar71xx
@@ -22,6 +22,7 @@ carambola2 | \
 cr3000 | \
 cr5000 | \
 eap300v2 | \
+gl-ar300m | \
 hornet-ub | \
 hornet-ub-x2 | \
 jwap230 | \
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 77bed5b..1254c71 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -262,6 +262,10 @@ gl-ar300)
 	ucidef_set_led_wlan "wlan" "WLAN" "gl_ar300:wlan" "phy0tpt"
 	;;
 
+gl-ar300m)
+	ucidef_set_led_wlan "wlan" "WLAN" "gl-ar300m:wlan" "phy0tpt"
+	;;
+
 gl-domino)
 	ucidef_set_led_wlan "wlan" "WLAN" "domino:blue:wlan" "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 667d228..301304a 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -391,6 +391,7 @@ alfa-ap96 |\
 alfa-nx |\
 ap83 |\
 gl-ar150 |\
+gl-ar300m |\
 gl-domino |\
 gl-inet |\
 jwap003 |\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index f517f9ba..71ebf89 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -451,6 +451,9 @@ set_state() {
 	done)
 		status_led_on
 		case $(ar71xx_board_name) in
+		gl-ar300m)
+			fw_printenv lc >/dev/null 2>&1 && fw_setenv "bootcount" 0
+			;;
 		qihoo-c301)
 			local n=$(fw_printenv activeregion | cut -d = -f 2)
 			fw_setenv "image${n}trynum" 0
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 4eed64b..d1c92c9 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -536,6 +536,9 @@ ar71xx_board_detect() {
 	*"GL AR300")
 		name="gl-ar300"
 		;;
+	*"GL-AR300M")
+		name="gl-ar300m"
+		;;
 	*"EnGenius EPG5000")
 		name="epg5000"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 119537e..c5cb4ab 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -233,6 +233,7 @@ platform_check_image() {
 	ew-dorin-router | \
 	gl-ar150 | \
 	gl-ar300 | \
+	gl-ar300m | \
 	gl-domino | \
 	hiwifi-hc6361 | \
 	hornet-ub-x2 | \
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 6605558..1cae660 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -89,6 +89,7 @@ CONFIG_ATH79_MACH_EW_DORIN=y
 CONFIG_ATH79_MACH_F9K1115V2=y
 CONFIG_ATH79_MACH_GL_AR150=y
 CONFIG_ATH79_MACH_GL_AR300=y
+CONFIG_ATH79_MACH_GL_AR300M=y
 CONFIG_ATH79_MACH_GL_DOMINO=y
 CONFIG_ATH79_MACH_GL_INET=y
 CONFIG_ATH79_MACH_GS_MINIBOX_V1=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index b0eada1..a5c673c 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -604,6 +604,16 @@ config ATH79_MACH_GL_AR300
 	select ATH79_DEV_USB
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_GL_AR300M
+	bool "GL_AR300M support"
+	select SOC_QCA953X
+	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_GL_DOMINO
 	bool "DOMINO support"
 	select SOC_AR933X
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
index 390b17d..a49384a 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -93,6 +93,7 @@ obj-$(CONFIG_ATH79_MACH_ESR1750)	+= mach-esr1750.o
 obj-$(CONFIG_ATH79_MACH_F9K1115V2)	+= mach-f9k1115v2.o
 obj-$(CONFIG_ATH79_MACH_GL_AR150)   += mach-gl-ar150.o
 obj-$(CONFIG_ATH79_MACH_GL_AR300)	+= mach-gl-ar300.o
+obj-$(CONFIG_ATH79_MACH_GL_AR300M)	+= mach-gl-ar300m.o
 obj-$(CONFIG_ATH79_MACH_GL_DOMINO)		+= mach-gl-domino.o
 obj-$(CONFIG_ATH79_MACH_GL_INET)	+= mach-gl-inet.o
 obj-$(CONFIG_ATH79_MACH_GS_MINIBOX_V1)	+= mach-gs-minibox-v1.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar300m.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar300m.c
new file mode 100644
index 0000000..d0f993c
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar300m.c
@@ -0,0 +1,182 @@
+/*
+ *  GLI AR300M(D) board support
+ *
+ *  Copyright (C) 2011 dongyuqi <729650915 at qq.com>
+ *  Copyright (C) 2011-2012 Gabor Juhos <juhosg at openwrt.org>
+ *  Copyright (C) 2013 alzhao <alzhao at gmail.com>
+ *  Copyright (C) 2014 Michel Stempin <michel.stempin at wanadoo.fr>
+ *
+ *  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/pci.h>
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.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-m25p80.h"
+#include "dev-usb.h"
+#include "dev-spi.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+#include "pci.h"
+
+#define GL_AR300M_GPIO_LED_USB		2
+#define GL_AR300M_GPIO_LED_WLAN		14
+#define GL_AR300M_GPIO_LED_LAN		13
+#define GL_AR300M_GPIO_LED_SYSTEM	12
+#define GL_AR300M_GPIO_BTN_RESET	3
+#define GL_AR300M_GPIO_BTN_LEFT		0
+#define GL_AR300M_GPIO_BTN_RIGHT	1
+
+#define GL_AR300M_KEYS_POLL_INTERVAL        20  /* msecs */
+#define GL_AR300M_KEYS_DEBOUNCE_INTERVAL    (3 * GL_AR300M_KEYS_POLL_INTERVAL)
+
+#define GL_AR300M_MAC0_OFFSET   0
+#define GL_AR300M_MAC1_OFFSET   6
+#define GL_AR300M_WMAC_CALDATA_OFFSET   0x1000
+#define GL_AR300M_PCIE_CALDATA_OFFSET   0x5000
+
+static struct gpio_led gl_ar300m_leds_gpio[] __initdata = {
+    {
+        .name = "gl-ar300m:usb",
+        .gpio = GL_AR300M_GPIO_LED_USB,
+        .active_low = 0,
+        .default_state = 1,
+    },
+    {
+        .name = "gl-ar300m:wlan",
+        .gpio = GL_AR300M_GPIO_LED_WLAN,
+        .active_low = 1,
+    },
+    {
+        .name = "gl-ar300m:lan",
+        .gpio = GL_AR300M_GPIO_LED_LAN,
+        .active_low = 1,
+    },
+    {
+        .name = "gl-ar300m:system",
+        .gpio = GL_AR300M_GPIO_LED_SYSTEM,
+        .active_low = 1,
+        .default_state = 1,
+    },
+};
+
+static struct gpio_keys_button gl_ar300m_gpio_keys[] __initdata = {
+    {
+        .desc = "reset",
+        .type = EV_KEY,
+        .code = KEY_RESTART,
+        .debounce_interval = GL_AR300M_KEYS_DEBOUNCE_INTERVAL,
+        .gpio = GL_AR300M_GPIO_BTN_RESET,
+        .active_low = 1,
+    },
+    {
+        .desc = "button right",
+        .type = EV_KEY,
+        .code = BTN_0,
+        .debounce_interval = GL_AR300M_KEYS_DEBOUNCE_INTERVAL,
+        .gpio = GL_AR300M_GPIO_BTN_LEFT,
+        .active_low = 0,
+    },
+    {
+        .desc = "button left",
+        .type = EV_KEY,
+        .code = BTN_1,
+        .debounce_interval = GL_AR300M_KEYS_DEBOUNCE_INTERVAL,
+        .gpio = GL_AR300M_GPIO_BTN_RIGHT,
+        .active_low = 0,
+    },
+};
+
+static struct ath79_spi_controller_data gl_ar300m_spi0_cdata =
+{
+    .cs_type    = ATH79_SPI_CS_TYPE_INTERNAL,
+    .is_flash   = true,
+    .cs_line    = 0,
+};
+
+static struct ath79_spi_controller_data gl_ar300m_spi1_cdata =
+{
+    .cs_type    = ATH79_SPI_CS_TYPE_INTERNAL,
+    .is_flash   = false,
+    .cs_line    = 1,
+};
+
+static struct spi_board_info gl_ar300m_spi_info[] = {
+    {
+        .bus_num    = 0,
+        .chip_select    = 0,
+        .max_speed_hz   = 25000000,
+        .modalias   = "m25p80",
+        .controller_data = &gl_ar300m_spi0_cdata,
+        .platform_data  = NULL,
+    },
+    {
+        .bus_num    = 0,
+        .chip_select    = 1,
+        .max_speed_hz   = 25000000,
+        .modalias   = "ath79-spinand",
+        .controller_data = &gl_ar300m_spi1_cdata,
+        .platform_data  = NULL,
+    }
+};
+
+static struct ath79_spi_platform_data gl_ar300m_spi_data = {
+    .bus_num        = 0,
+    .num_chipselect     = 2,
+};
+
+static void __init gl_ar300m_setup(void)
+{
+    u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+    u8 tmpmac[ETH_ALEN];
+
+    ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
+    ath79_register_spi(&gl_ar300m_spi_data, gl_ar300m_spi_info, 2);
+
+    /* register gpio LEDs and keys */
+    ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar300m_leds_gpio),
+                 gl_ar300m_leds_gpio);
+    ath79_register_gpio_keys_polled(-1, GL_AR300M_KEYS_POLL_INTERVAL,
+                    ARRAY_SIZE(gl_ar300m_gpio_keys),
+                    gl_ar300m_gpio_keys);
+
+    ath79_register_mdio(0, 0x0);
+
+    /* WAN */
+    ath79_init_mac(ath79_eth0_data.mac_addr, art + GL_AR300M_MAC0_OFFSET, 0);
+    ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+    ath79_eth0_data.speed = SPEED_100;
+    ath79_eth0_data.duplex = DUPLEX_FULL;
+    ath79_eth0_data.phy_mask = BIT(4);
+    ath79_register_eth(0);
+
+    /* LAN */
+    ath79_init_mac(ath79_eth1_data.mac_addr, art + GL_AR300M_MAC1_OFFSET, 0);
+    ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+    ath79_eth1_data.speed = SPEED_1000;
+    ath79_eth1_data.duplex = DUPLEX_FULL;
+    ath79_switch_data.phy_poll_mask |= BIT(4);
+    ath79_switch_data.phy4_mii_en = 1;
+    ath79_register_eth(1);
+
+    ath79_init_mac(tmpmac, art + GL_AR300M_WMAC_CALDATA_OFFSET + 2, 0);
+    ath79_register_wmac(art + GL_AR300M_WMAC_CALDATA_OFFSET, tmpmac);
+
+    /* enable usb */
+    ath79_register_usb();
+    /* enable pci */
+    ath79_register_pci();
+}
+
+MIPS_MACHINE(ATH79_MACH_GL_AR300M, "GL-AR300M", "GL-AR300M",
+         gl_ar300m_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 7dd60ac..3e52ee4 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -86,6 +86,7 @@ enum ath79_mach_type {
 	ATH79_MACH_F9K1115V2,		/* Belkin AC1750DB */
 	ATH79_MACH_GL_AR150,    	/* GL-AR150 support */
 	ATH79_MACH_GL_AR300,		/* GL-AR300 */
+	ATH79_MACH_GL_AR300M,		/* GL-AR300M */
 	ATH79_MACH_GL_DOMINO,		/* Domino */
 	ATH79_MACH_GL_INET,		/* GL-CONNECT GL-INET */
 	ATH79_MACH_GS_MINIBOX_V1,	/* Gainstrong MiniBox V1.0 */
diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
index cbb47f5..b417a3f 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -57,6 +57,16 @@ define Device/gl-ar300
 endef
 TARGET_DEVICES += gl-ar300
 
+define Device/gl-ar300m
+  DEVICE_TITLE := GL AR300M
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 uboot-envtools
+  BOARDNAME = GL-AR300M
+  IMAGE_SIZE = 16000k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env),16000k(firmware),64k(art)ro
+endef
+TARGET_DEVICES += gl-ar300m
+
 define Device/gl-domino
   DEVICE_TITLE := GL Domino Pi
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2



More information about the lede-commits mailing list