[OpenWrt-Devel] [PATCH 3/3] ar71xx: add support for Cisco Meraki Z1 Cloud Managed Teleworker Gateway

Christian Lamparter chunkeey at googlemail.com
Thu Apr 7 17:56:56 EDT 2016


From: Chris Blake <chrisrblake93 at gmail.com>

This patch adds support for Cisco's Z1.
Detailed instructions for the flashing the device can
be found in the OpenWrt wiki:
<https://wiki.openwrt.org/toh/meraki/z1>

Signed-off-by: Chris Blake <chrisrblake93 at gmail.com>
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   4 +
 .../linux/ar71xx/base-files/etc/board.d/02_network |   6 +
 target/linux/ar71xx/base-files/etc/diag.sh         |   3 +
 .../etc/hotplug.d/firmware/10-ath9k-eeprom         |  20 +++
 .../etc/uci-defaults/03_network-switchX-migration  |   1 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
 .../base-files/lib/preinit/05_set_iface_mac_ar71xx |   4 +
 .../ar71xx/base-files/lib/upgrade/merakinand.sh    |  61 ++++++--
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   6 +-
 target/linux/ar71xx/config-4.1                     |   1 +
 target/linux/ar71xx/config-4.4                     |   1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  12 ++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../linux/ar71xx/files/arch/mips/ath79/mach-z1.c   | 164 +++++++++++++++++++++
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/Makefile                 |  20 +++
 target/linux/ar71xx/nand/profiles/meraki.mk        |  14 +-
 .../818-MIPS-ath79-add-nu801-led-driver.patch      |   2 +-
 .../818-MIPS-ath79-add-nu801-led-driver.patch      |   2 +-
 19 files changed, 305 insertions(+), 21 deletions(-)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-z1.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 708ebb9..b3e5fce 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -763,6 +763,10 @@ wzr-hp-g300nh)
 	ucidef_set_led_usbdev "usb" "USB" "buffalo:blue:usb" "1-1"
 	;;
 
+z1)
+	ucidef_set_led_netdev "wlan1" "WLAN1" "z1:blue:tricolor0" "wlan1"
+	;;
+
 zcn-1523h-2)
 	ucidef_set_led_netdev "lan1" "lan1" "zcn-1523h:green:lan1" "eth0"
 	;;
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 bd488a2..83d00ac 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -510,6 +510,12 @@ wndr3700)
 	ucidef_add_switch_port_attr "switch0" 5 led 2
 	;;
 
+z1)
+	ucidef_set_interfaces_lan_wan "eth0" "eth1"
+	ucidef_add_switch "switch0" \
+		"0 at eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
+	;;
+
 *)
 	ucidef_set_interfaces_lan_wan "eth0" "eth1"
 	;;
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index a2251d1..4ef5192 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -400,6 +400,9 @@ get_status_led() {
 	wrt160nl)
 		status_led="wrt160nl:blue:wps"
 		;;
+	z1)
+		status_led="z1:green:tricolor0"
+		;;
 	zcn-1523h-2 | zcn-1523h-5)
 		status_led="zcn-1523h:amber:init"
 		;;
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 3b0229d..3141625 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -73,6 +73,16 @@ case "$FIRMWARE" in
 		ath9k_eeprom_extract "caldata" 4096 2048
 		ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
 		;;
+	z1)
+		. /lib/upgrade/nand.sh
+
+		if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
+			ath9k_ubi_eeprom_extract "caldata" 4096 2048
+		else
+			ath9k_eeprom_extract "origcaldata" 4096 2048
+		fi
+		ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2)
+		;;
 	*)
 		ath9k_eeprom_die "board $board is not supported yet"
 		;;
@@ -100,6 +110,16 @@ case "$FIRMWARE" in
 		ath9k_eeprom_extract "caldata" 20480 2048
 		ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
 		;;
+	z1)
+		. /lib/upgrade/nand.sh
+
+		if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
+			ath9k_ubi_eeprom_extract "caldata" 86016 4096
+		else
+			ath9k_eeprom_extract "origcaldata" 86016 4096
+		fi
+		ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3)
+		;;
 	*)
 		ath9k_eeprom_die "board $board is not supported yet"
 		;;
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration b/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration
index aa0e1b4..ee8f63b 100644
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration
@@ -78,6 +78,7 @@ whr-hp-g300n|\
 whr-hp-gn|\
 wzr-hp-ag300h|\
 wzr-hp-g450h|\
+z1|\
 ew-dorin|\
 ew-dorin-router)
 	migrate_switch_name "eth0" "switch0"
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 6b8550a..1d87b66 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -1030,6 +1030,9 @@ ar71xx_board_detect() {
 	*WHR-HP-G300N)
 		name="whr-hp-g300n"
 		;;
+	*Z1)
+		name="z1"
+		;;
 	*ZCN-1523H-2)
 		name="zcn-1523h-2"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx
index 39da309..60e2787 100644
--- a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx
+++ b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx
@@ -49,6 +49,10 @@ preinit_set_mac_address() {
 		wrt160nl)
 			fetch_mac_from_mtd nvram lan_hwaddr wan_hwaddr
 			;;
+		z1)
+			mac_lan=$(mtd_get_mac_binary_ubi board-config 102)
+			[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
+			;;
 	esac
 }
 
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh
index cc7a86c..78cde20 100644
--- a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2015 Chris Blake <chrisrblake93 at gmail.com>
+# Copyright (C) 2015-2016 Chris Blake <chrisrblake93 at gmail.com>
 #
 # Custom upgrade script for Meraki NAND devices (ex. MR18)
 # Based on dir825.sh and stock nand functions
@@ -14,34 +14,52 @@ get_magic_at() {
 	dd bs=1 count=2 skip=$pos if=$mtddev 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
 }
 
-mr18_is_caldata_valid() {
-	local mtddev=$1
+meraki_is_caldata_valid() {
+	local board=$1
+	local mtddev=$2
 	local magic
 
-	magic=$(get_magic_at $mtddev 4096)
-	[ "$magic" != "0202" ] && return 0
+	case "$board" in
+	"mr18")
+		magic=$(get_magic_at $mtddev 4096)
+		[ "$magic" != "0202" ] && return 0
+
+		magic=$(get_magic_at $mtddev 20480)
+		[ "$magic" != "0202" ] && return 0
 
-	magic=$(get_magic_at $mtddev 20480)
-	[ "$magic" != "0202" ] && return 0
+		magic=$(get_magic_at $mtddev 36864)
+		[ "$magic" != "0202" ] && return 0
+
+		return 1
+		;;
+	"z1")
+		magic=$(get_magic_at $mtddev 4096)
+		[ "$magic" != "0202" ] && return 0
 
-	magic=$(get_magic_at $mtddev 36864)
-	[ "$magic" != "0202" ] && return 0
+		magic=$(get_magic_at $mtddev 86016)
+		[ "$magic" != "a55a" ] && return 0
 
-	return 1
+		return 1
+		;;
+	*)
+		return 1
+		;;
+	esac
 }
 
 merakinand_copy_caldata() {
 	local cal_src=$1
 	local cal_dst=$2
-	local ubidev=$( nand_find_ubi $CI_UBIPART )
+	local ubidev="$(nand_find_ubi $CI_UBIPART)"
 	local board_name="$(cat /tmp/sysinfo/board_name)"
 	local rootfs_size="$(ubinfo /dev/ubi0 -N rootfs_data | grep "Size" | awk '{ print $6 }')"
 
 	# Setup partitions using board name, in case of future platforms
 	case "$board_name" in
-	"mr18")
+	"mr18"|\
+	"z1")
 		# Src is MTD
-		mtd_src=$(find_mtd_chardev $cal_src)
+		mtd_src="$(find_mtd_chardev $cal_src)"
 		[ -n "$mtd_src" ] || {
 			echo "no mtd device found for partition $cal_src"
 			exit 1
@@ -56,12 +74,12 @@ merakinand_copy_caldata() {
 			exit 1
 		}
 
-		mr18_is_caldata_valid "$mtd_src" && {
+		meraki_is_caldata_valid "$board_name" "$mtd_src" && {
 			echo "no valid calibration data found in $cal_src"
 			exit 1
 		}
 
-		mr18_is_caldata_valid "/dev/$mtd_dst" && {
+		meraki_is_caldata_valid "$board_name" "/dev/$mtd_dst" && {
 			echo "Copying calibration data from $cal_src to $cal_dst..."
 			dd if="$mtd_src" of=/tmp/caldata.tmp 2>/dev/null
 			ubiupdatevol "/dev/$mtd_dst" /tmp/caldata.tmp
@@ -89,6 +107,11 @@ merakinand_do_kernel_check() {
 			echo "pass" && return 0
 		}
 		;;
+	"z1")
+		[ "$image_magic_word" == "4d495053" ] && {
+			echo "pass" && return 0
+		}
+		;;
 	esac
 
 	exit 1
@@ -102,7 +125,8 @@ merakinand_do_platform_check() {
 	local kernel_magic="$(merakinand_do_kernel_check $1 $2)"
 
 	case "$board_name" in
-	"mr18")
+	"mr18"|\
+	"z1")
 		[ "$control_length" = 0 -o "$file_type" != "squashfs" -o "$kernel_magic" != "pass" ] && {
 			echo "Invalid sysupgrade file for $board_name"
 			return 1
@@ -128,6 +152,11 @@ merakinand_do_upgrade() {
 		merakinand_copy_caldata "odm-caldata" "caldata"
 		nand_do_upgrade $1
 		;;
+	"z1")
+		# Check and create UBI caldata if it's invalid
+		merakinand_copy_caldata "origcaldata" "caldata"
+		nand_do_upgrade $1
+		;;
 	*)
 		echo "Unsupported device $board_name";
 		exit 1
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 923e02b..a02837c 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -453,7 +453,8 @@ platform_check_image() {
 		}
 		return 0
 		;;
-	mr18)
+	mr18 | \
+	z1 )
 		merakinand_do_platform_check $board $1
 		return $?;
 		;;
@@ -524,7 +525,8 @@ platform_pre_upgrade() {
 	wndr4300 )
 		nand_do_upgrade "$1"
 		;;
-	mr18)
+	mr18 | \
+	z1 )
 		merakinand_do_upgrade "$1"
 		;;
 	esac
diff --git a/target/linux/ar71xx/config-4.1 b/target/linux/ar71xx/config-4.1
index d6ad850..050db75 100644
--- a/target/linux/ar71xx/config-4.1
+++ b/target/linux/ar71xx/config-4.1
@@ -186,6 +186,7 @@ CONFIG_ATH79_MACH_WZR_HP_AG300H=y
 CONFIG_ATH79_MACH_WZR_HP_G300NH=y
 CONFIG_ATH79_MACH_WZR_HP_G300NH2=y
 CONFIG_ATH79_MACH_WZR_HP_G450H=y
+CONFIG_ATH79_MACH_Z1=y
 CONFIG_ATH79_MACH_ZCN_1523H=y
 CONFIG_ATH79_NVRAM=y
 CONFIG_ATH79_PCI_ATH9K_FIXUP=y
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 49cecc5..0692b54 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -189,6 +189,7 @@ CONFIG_ATH79_MACH_WZR_HP_AG300H=y
 CONFIG_ATH79_MACH_WZR_HP_G300NH=y
 CONFIG_ATH79_MACH_WZR_HP_G300NH2=y
 CONFIG_ATH79_MACH_WZR_HP_G450H=y
+CONFIG_ATH79_MACH_Z1=y
 CONFIG_ATH79_MACH_ZCN_1523H=y
 CONFIG_ATH79_NVRAM=y
 CONFIG_ATH79_PCI_ATH9K_FIXUP=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index f47f1b9..962f99a 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1433,6 +1433,18 @@ config ATH79_MACH_MYNET_REXT
 	select ATH79_DEV_WMAC
 	select ATH79_NVRAM
 
+config ATH79_MACH_Z1
+	bool "Meraki Z1 board support"
+	select SOC_AR934X
+	select ATH79_DEV_AP9X_PCI if PCI
+	select ATH79_DEV_ETH
+	select ATH79_DEV_GPIO_BUTTONS
+	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_NFC
+	select ATH79_DEV_USB
+	select ATH79_DEV_WMAC
+	select LEDS_NU801
+
 config ATH79_MACH_ZCN_1523H
 	bool "Zcomax ZCN-1523H 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 74376b2..9686ce3 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -193,6 +193,7 @@ obj-$(CONFIG_ATH79_MACH_WZR_HP_G300NH2)	+= mach-wzr-hp-g300nh2.o
 obj-$(CONFIG_ATH79_MACH_WZR_HP_AG300H)	+= mach-wzr-hp-ag300h.o
 obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H)	+= mach-wzr-hp-g450h.o
 obj-$(CONFIG_ATH79_MACH_WZR_450HP2)	+= mach-wzr-450hp2.o
+obj-$(CONFIG_ATH79_MACH_Z1)		+= mach-z1.o
 obj-$(CONFIG_ATH79_MACH_ZCN_1523H)	+= mach-zcn-1523h.o
 obj-$(CONFIG_ATH79_MACH_CARAMBOLA2)	+= mach-carambola2.o
 obj-$(CONFIG_ATH79_MACH_NBG6716)	+= mach-nbg6716.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-z1.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-z1.c
new file mode 100644
index 0000000..552d646
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-z1.c
@@ -0,0 +1,164 @@
+/*
+ *  Cisco Meraki Z1 board support
+ *
+ *  Copyright (C) 2016 Chris Blake <chrisrblake93 at gmail.com>
+ *  Copyright (C) 2016 Christian Lamparter <chunkeey at googlemail.com>
+ *
+ *  Based on Cisco Meraki GPL Release r23-20150601 Z1 Device Config
+ *
+ *  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/platform_device.h>
+#include <linux/ath9k_platform.h>
+#include <linux/ar8216_platform.h>
+#include <linux/platform/ar934x_nfc.h>
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include <linux/leds-nu801.h>
+#include <linux/firmware.h>
+#include <linux/pci.h>
+
+#include "common.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-nfc.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "dev-ap9x-pci.h"
+#include "machtypes.h"
+
+#define Z1_GPIO_LED_POWER_ORANGE	17
+
+#define Z1_GPIO_NU801_CKI		14
+#define Z1_GPIO_NU801_SDI		15
+
+#define Z1_GPIO_XLNA0			18
+#define Z1_GPIO_XLNA1			19
+
+#define Z1_GPIO_BTN_RESET		12
+#define Z1_KEYS_POLL_INTERVAL		20  /* msecs */
+#define Z1_KEYS_DEBOUNCE_INTERVAL	(3 * Z1_KEYS_POLL_INTERVAL)
+
+#define Z1_ETH_SWITCH_PHY		0
+
+static struct gpio_led Z1_leds_gpio[] __initdata = {
+	{
+		.name = "z1:orange:power",
+		.gpio = Z1_GPIO_LED_POWER_ORANGE,
+		.active_low  = 1,
+	},
+};
+
+static struct gpio_keys_button Z1_gpio_keys[] __initdata = {
+	{
+		.desc = "reset",
+		.type = EV_KEY,
+		.code = KEY_RESTART,
+		.debounce_interval = Z1_KEYS_DEBOUNCE_INTERVAL,
+		.gpio    = Z1_GPIO_BTN_RESET,
+		.active_low  = 1,
+	},
+};
+
+static struct led_nu801_template tricolor_led_template = {
+	.device_name = "z1",
+	.name = "tricolor",
+	.num_leds = 1,
+	.cki = Z1_GPIO_NU801_CKI,
+	.sdi = Z1_GPIO_NU801_SDI,
+	.lei = -1,
+	.ndelay = 500,
+	.init_brightness = {
+		LED_OFF,
+		LED_OFF,
+		LED_OFF,
+	},
+	.default_trigger = "none",
+};
+
+static struct led_nu801_platform_data tricolor_led_data = {
+	.num_controllers = 1,
+	.template = &tricolor_led_template,
+};
+
+static struct platform_device tricolor_leds = {
+	.name = "leds-nu801",
+	.id = -1,
+	.dev.platform_data = &tricolor_led_data,
+};
+
+static struct ar8327_pad_cfg z1_ar8327_pad0_cfg = {
+	.mode = AR8327_PAD_MAC_RGMII,
+	.txclk_delay_en = true,
+	.rxclk_delay_en = true,
+	.txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
+	.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
+};
+
+static struct ar8327_platform_data z1_ar8327_data = {
+	.pad0_cfg = &z1_ar8327_pad0_cfg,
+	.port0_cfg = {
+		.force_link = 1,
+		.speed = AR8327_PORT_SPEED_1000,
+		.duplex = 1,
+		.txpause = 1,
+		.rxpause = 1,
+	},
+};
+
+static struct mdio_board_info z1_mdio0_info[] = {
+	{
+		.bus_id = "ag71xx-mdio.0",
+		.phy_addr = Z1_ETH_SWITCH_PHY,
+		.platform_data = &z1_ar8327_data,
+	},
+};
+
+static void __init z1_setup(void)
+{
+	/* NAND */
+	ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_SOFT_BCH);
+	ath79_register_nfc();
+
+	/* Eth Config */
+	ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
+				   AR934X_ETH_CFG_SW_ONLY_MODE);
+
+	/* MDIO Interface */
+	ath79_register_mdio(1, 0x0);
+	ath79_register_mdio(0, 0x0);
+	mdiobus_register_board_info(z1_mdio0_info,
+				    ARRAY_SIZE(z1_mdio0_info));
+
+	/* GMAC0 is connected to an AR8327 switch */
+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+	ath79_eth0_data.phy_mask = BIT(Z1_ETH_SWITCH_PHY);
+	ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+	ath79_eth0_pll_data.pll_1000 = 0x06000000;
+	ath79_register_eth(0);
+
+	/* XLNA */
+	ath79_wmac_set_ext_lna_gpio(0, Z1_GPIO_XLNA0);
+	ath79_wmac_set_ext_lna_gpio(1, Z1_GPIO_XLNA1);
+
+	/* LEDs and Buttons */
+	platform_device_register(&tricolor_leds);
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(Z1_leds_gpio),
+				 Z1_leds_gpio);
+	ath79_register_gpio_keys_polled(-1, Z1_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(Z1_gpio_keys),
+					Z1_gpio_keys);
+
+	/* USB */
+	ath79_register_usb();
+
+	/* Wireless */
+	ath79_register_wmac_simple();
+	ap91_pci_init_simple();
+}
+MIPS_MACHINE(ATH79_MACH_Z1, "Z1", "Meraki Z1", z1_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index 307d2df..2645894 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -247,6 +247,7 @@ enum ath79_mach_type {
 	ATH79_MACH_WZR_HP_G300NH2,	/* Buffalo WZR-HP-G300NH2 */
 	ATH79_MACH_WZR_HP_G450H,	/* Buffalo WZR-HP-G450H */
 	ATH79_MACH_WZR_450HP2,		/* Buffalo WZR-450HP2 */
+	ATH79_MACH_Z1,			/* Cisco Meraki Z1 */
 	ATH79_MACH_ZCN_1523H_2,		/* Zcomax ZCN-1523H-2-xx */
 	ATH79_MACH_ZCN_1523H_5,		/* Zcomax ZCN-1523H-5-xx */
 };
diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
index 595fba2..08aad74 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -2083,6 +2083,14 @@ define Build/MerakiNAND
 	@mv $@.new $@
 endef
 
+define Build/MerakiNAND-old
+	-$(STAGING_DIR_HOST)/bin/mkmerakifw-old \
+		-B $(BOARDNAME) -s \
+		-i $@ \
+		-o $@.new
+	@mv $@.new $@
+endef
+
 Image/Build/Netgear/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4),,-M $(5))
 
 define Image/Build/Netgear/buildkernel
@@ -2548,6 +2556,18 @@ define Device/mr18
 endef
 TARGET_DEVICES += mr18
 
+define Device/z1
+  BOARDNAME = Z1
+  BLOCKSIZE := 64k
+  CONSOLE = ttyS0,115200
+  MTDPARTS = ar934x-nfc:128K(loader1)ro,8064K(kernel),128K(loader2)ro,8064K(recovery),114560K(ubi),128K(origcaldata)ro
+  IMAGES := sysupgrade.tar
+  KERNEL := kernel-bin | patch-cmdline | MerakiNAND-old
+  KERNEL_INITRAMFS := kernel-bin | patch-cmdline | MerakiNAND-old
+  IMAGE/sysupgrade.tar := sysupgrade-nand
+endef
+TARGET_DEVICES += z1
+
 $(eval $(call SingleProfile,NetgearNAND,64k,WNDR3700V4,wndr3700v4,WNDR3700_V4,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR3700v4,"",-H 29763948+128+128,wndr4300))
 $(eval $(call SingleProfile,NetgearNAND,64k,WNDR4300V1,wndr4300,WNDR4300,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR4300,"",-H 29763948+0+128+128+2x2+3x3,wndr4300))
 $(eval $(call SingleProfile,NetgearNAND,64k,R6100,r6100,R6100,ttyS0,115200,$$(r6100_mtdlayout),0x36303030,R6100,"",-H 29764434+0+128+128+2x2+2x2,wndr4300))
diff --git a/target/linux/ar71xx/nand/profiles/meraki.mk b/target/linux/ar71xx/nand/profiles/meraki.mk
index 2c848c9..f68f5b6 100644
--- a/target/linux/ar71xx/nand/profiles/meraki.mk
+++ b/target/linux/ar71xx/nand/profiles/meraki.mk
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2014-2015 Chris Blake (chrisrblake93 at gmail.com)
+# Copyright (C) 2014-2016 Chris Blake (chrisrblake93 at gmail.com)
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -15,3 +15,15 @@ define Profile/MR18/description
 endef
 
 $(eval $(call Profile,MR18))
+
+define Profile/Z1
+	NAME:=Meraki Z1
+	PACKAGES:=kmod-usb-core kmod-usb2 kmod-ledtrig-usbdev kmod-spi-gpio kmod-ath9k kmod-owl-loader
+endef
+
+define Profile/Z1/description
+	Package set optimized for the Cisco Meraki Z1 Teleworker Gateway.
+endef
+
+
+$(eval $(call Profile,Z1))
diff --git a/target/linux/ar71xx/patches-4.1/818-MIPS-ath79-add-nu801-led-driver.patch b/target/linux/ar71xx/patches-4.1/818-MIPS-ath79-add-nu801-led-driver.patch
index e264201..036e682 100644
--- a/target/linux/ar71xx/patches-4.1/818-MIPS-ath79-add-nu801-led-driver.patch
+++ b/target/linux/ar71xx/patches-4.1/818-MIPS-ath79-add-nu801-led-driver.patch
@@ -6,7 +6,7 @@
  
 +config LEDS_NU801
 +	tristate "LED driver for NU801 RGB LED"
-+	depends on LEDS_CLASS && ATH79_MACH_MR18
++	depends on LEDS_CLASS && (ATH79_MACH_MR18 || ATH79_MACH_Z1)
 +	help
 +	  This option enables support for NU801 RGB LED driver chips
 +	  accessed via GPIO.
diff --git a/target/linux/ar71xx/patches-4.4/818-MIPS-ath79-add-nu801-led-driver.patch b/target/linux/ar71xx/patches-4.4/818-MIPS-ath79-add-nu801-led-driver.patch
index ec9f59e..420bbff 100644
--- a/target/linux/ar71xx/patches-4.4/818-MIPS-ath79-add-nu801-led-driver.patch
+++ b/target/linux/ar71xx/patches-4.4/818-MIPS-ath79-add-nu801-led-driver.patch
@@ -6,7 +6,7 @@
  
 +config LEDS_NU801
 +	tristate "LED driver for NU801 RGB LED"
-+	depends on LEDS_CLASS && ATH79_MACH_MR18
++	depends on LEDS_CLASS && (ATH79_MACH_MR18 || ATH79_MACH_Z1)
 +	help
 +	  This option enables support for NU801 RGB LED driver chips
 +	  accessed via GPIO.
-- 
2.8.0.rc3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list