From f478ec2007b93b87fba606eae49688753281c85f Mon Sep 17 00:00:00 2001 From: Chris Blake Date: Wed, 16 Nov 2016 09:38:07 -0600 Subject: [PATCH] apm821xx: Add support for the Cisco Meraki MX60/MX60W This patch adds support for the Cisco Meraki MX60/MX60W Security Appliance. Flashing information can be found at https://github.com/riptidewave93/LEDE-MX60 Specs are as follows: AppliedMicro APM82181 SoC at 800MHz 1GiB NAND - Samsung K9K8G08U0D 512MB DDR RAM - 4x Nanya NT5TU128M8GE-AC Atheros AR8327-BL1A Gigabit Ethernet Switch 1x USB 2.0 Port More info can be found at https://wiki.openwrt.org/toh/meraki/mx60 Cc: Christian Lamparter Signed-off-by: Chris Blake --- .../apm821xx/base-files/etc/board.d/01_leds | 8 + .../base-files/etc/board.d/02_network | 3 +- target/linux/apm821xx/base-files/etc/diag.sh | 15 +- .../linux/apm821xx/base-files/lib/apm821xx.sh | 4 + .../lib/preinit/05_set_iface_mac_apm821xx | 3 +- .../base-files/lib/upgrade/merakinand.sh | 9 +- .../base-files/lib/upgrade/platform.sh | 6 +- target/linux/apm821xx/config-4.4 | 1 + target/linux/apm821xx/dts/MX60.dts | 186 ++++++++++++++++++ target/linux/apm821xx/image/Makefile | 32 +++ ...-add-meraki-mx60-buckminster-support.patch | 32 +++ 11 files changed, 283 insertions(+), 16 deletions(-) create mode 100644 target/linux/apm821xx/dts/MX60.dts create mode 100644 target/linux/apm821xx/patches-4.4/203-add-meraki-mx60-buckminster-support.patch diff --git a/target/linux/apm821xx/base-files/etc/board.d/01_leds b/target/linux/apm821xx/base-files/etc/board.d/01_leds index 38cfbdcd7a..ad9bef9c09 100755 --- a/target/linux/apm821xx/base-files/etc/board.d/01_leds +++ b/target/linux/apm821xx/base-files/etc/board.d/01_leds @@ -16,6 +16,14 @@ mr24) ucidef_set_led_wlan "wlan4" "WLAN4" "mr24:green:wifi4" "phy0tpt" ;; +mx60) + ucidef_set_led_switch "wan" "WAN" "mx60:green:wan" "switch0" "0x20" + ucidef_set_led_switch "lan1" "LAN1" "mx60:green:lan1" "switch0" "0x10" + ucidef_set_led_switch "lan2" "LAN2" "mx60:green:lan2" "switch0" "0x08" + ucidef_set_led_switch "lan3" "LAN3" "mx60:green:lan3" "switch0" "0x04" + ucidef_set_led_switch "lan4" "LAN4" "mx60:green:lan4" "switch0" "0x02" + ;; + mbl) ucidef_set_led_ide "sata" "SATA" "mbl:blue:power" ;; diff --git a/target/linux/apm821xx/base-files/etc/board.d/02_network b/target/linux/apm821xx/base-files/etc/board.d/02_network index 3a25709a2a..90a8c1a8d2 100755 --- a/target/linux/apm821xx/base-files/etc/board.d/02_network +++ b/target/linux/apm821xx/base-files/etc/board.d/02_network @@ -9,11 +9,12 @@ board_config_update board=$(apm821xx_board_name) case "$board" in -mbl | \ +mbl|\ mr24) ucidef_set_interface_lan "eth0" ;; +mx60|\ wndr4700) ucidef_add_switch "switch0" \ "0@eth0" "4:lan" "3:lan" "2:lan" "1:lan" "5:wan" diff --git a/target/linux/apm821xx/base-files/etc/diag.sh b/target/linux/apm821xx/base-files/etc/diag.sh index 3ddd21d844..3e480f1fe4 100755 --- a/target/linux/apm821xx/base-files/etc/diag.sh +++ b/target/linux/apm821xx/base-files/etc/diag.sh @@ -4,17 +4,14 @@ . /lib/apm821xx.sh get_status_led() { - case $(apm821xx_board_name) in - mbl) - status_led="mbl:green:power" - ;; - - mr24) - status_led="mr24:green:power" - ;; + local board=$(apm821xx_board_name) + case $board in + mbl|\ + mr24|\ + mx60|\ wndr4700) - status_led="wndr4700:green:power" + status_led="$board:green:power" ;; *) diff --git a/target/linux/apm821xx/base-files/lib/apm821xx.sh b/target/linux/apm821xx/base-files/lib/apm821xx.sh index 78fe452184..98f6ee92ab 100755 --- a/target/linux/apm821xx/base-files/lib/apm821xx.sh +++ b/target/linux/apm821xx/base-files/lib/apm821xx.sh @@ -14,6 +14,10 @@ apm821xx_board_detect() { name="mr24" ;; + *"Meraki MX60/MX60W Security Appliance") + name="mx60" + ;; + *"MyBook Live"*) name="mbl" ;; diff --git a/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx b/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx index 5dc7175730..750af042e1 100644 --- a/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx +++ b/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx @@ -4,7 +4,8 @@ preinit_set_mac_address() { case $(apm821xx_board_name) in - mr24) + mr24|\ + mx60) mac_lan=$(mtd_get_mac_binary_ubi board-config 102) [ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan" ;; diff --git a/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh b/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh index 5861d97f12..f025082e76 100755 --- a/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh +++ b/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh @@ -15,7 +15,8 @@ merakinand_do_kernel_check() { # What is our kernel magic string? case "$board_name" in - "mr24") + "mr24"|\ + "mx60") [ "$image_magic_word" == "8e73ed8a" ] && { echo "pass" && return 0 } @@ -33,7 +34,8 @@ merakinand_do_platform_check() { local kernel_magic="$(merakinand_do_kernel_check $1 $2)" case "$board_name" in - "mr24") + "mr24"|\ + "mx60") [ "$control_length" = 0 -o "$file_type" != "squashfs" -o "$kernel_magic" != "pass" ] && { echo "Invalid sysupgrade file for $board_name" return 1 @@ -54,7 +56,8 @@ merakinand_do_upgrade() { # Do we need to do any platform tweaks? case "$board_name" in - "mr24") + "mr24"|\ + "mx60") nand_do_upgrade $1 ;; *) diff --git a/target/linux/apm821xx/base-files/lib/upgrade/platform.sh b/target/linux/apm821xx/base-files/lib/upgrade/platform.sh index 5559767a26..ca6aa8d4be 100755 --- a/target/linux/apm821xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/apm821xx/base-files/lib/upgrade/platform.sh @@ -16,7 +16,8 @@ platform_check_image() { return $?; ;; - mr24) + mr24|\ + mx60) merakinand_do_platform_check $board "$1" return $?; ;; @@ -38,7 +39,8 @@ platform_pre_upgrade() { local board=$(apm821xx_board_name) case "$board" in - mr24) + mr24|\ + mx60) merakinand_do_upgrade "$1" ;; diff --git a/target/linux/apm821xx/config-4.4 b/target/linux/apm821xx/config-4.4 index 1515dda73b..797cdaeb82 100644 --- a/target/linux/apm821xx/config-4.4 +++ b/target/linux/apm821xx/config-4.4 @@ -35,6 +35,7 @@ CONFIG_AUDIT_ARCH=y # CONFIG_BAMBOO is not set CONFIG_BCH=y # CONFIG_BLUESTONE is not set +CONFIG_BUCKMINSTER=y CONFIG_BOOKE=y CONFIG_BOOKE_WDT=y CONFIG_BOUNCE=y diff --git a/target/linux/apm821xx/dts/MX60.dts b/target/linux/apm821xx/dts/MX60.dts new file mode 100644 index 0000000000..4ec0043f32 --- /dev/null +++ b/target/linux/apm821xx/dts/MX60.dts @@ -0,0 +1,186 @@ +/* + * Device Tree Source for Meraki MX60/MX60W (Buckminster) + * + * Copyright (C) 2016 Chris Blake + * + * Based on Cisco Meraki DTS extracted from release wired-12-217818 + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without + * any warranty of any kind, whether express or implied. + */ + +/dts-v1/; + +#include "apm82181.dtsi" + +/ { + model = "Meraki MX60/MX60W Security Appliance"; + compatible = "meraki,buckminster"; + + aliases { + serial0 = &UART1; + }; + + chosen { + linux,stdout-path = "/plb/opb/serial@ef600400"; + }; + +}; + +&CRYPTO { + status = "okay"; +}; + +&PKA { + status = "okay"; +}; + +&TRNG { + status = "okay"; +}; + +&USBOTG0 { + status = "okay"; + dr_mode = "host"; +}; + +&EBC0 { + /* Buckminster has 1GiB of NAND */ + ndfc@1,0 { + status = "okay"; + nand { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x00000000 0x00100000>; + read-only; + }; + + partition@100000 { + label = "u-boot-env"; + reg = <0x00100000 0x00100000>; + read-only; + }; + + partition@200000 { + label = "oops"; + reg = <0x00200000 0x00040000>; + }; + + partition@240000 { + label = "ubi"; + reg = <0x00240000 0x3fdc0000>; + }; + + all { + label = "all"; + reg = <0x00000000 0x40000000>; + }; + }; + }; +}; + +&UART1 { + status = "okay"; +}; + +&GPIO0 { + status = "okay"; +}; + +&IIC0 { + status = "okay"; +}; + +&EMAC0 { + status = "okay"; + phy-handle = <&phy0>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + phy0: ethernet-phy@0 { + device_type = "ethernet-phy"; + reg = <0>; + qca,ar8327-initvals = < + 0x0010 0x40000000 + 0x0624 0x007f7f7f + 0x0004 0x07a00000 /* PAD0_MODE */ + 0x000c 0x01000000 /* PAD6_MODE */ + 0x007c 0x0000007e /* PORT0_STATUS */ + >; + }; + }; +}; + +&POB0 { + gpio-leds { + compatible = "gpio-leds"; + + power-green { + label = "mx60:green:power"; + gpios = <&GPIO0 18 GPIO_ACTIVE_LOW>; + }; + + power-orange { + label = "mx60:orange:power"; + gpios = <&GPIO0 19 GPIO_ACTIVE_LOW>; + }; + + wan-green { + label = "mx60:green:wan"; + gpios = <&GPIO0 17 GPIO_ACTIVE_LOW>; + }; + + wan-orange { + label = "mx60:orange:wan"; + gpios = <&GPIO0 15 GPIO_ACTIVE_LOW>; + }; + + lan1 { + label = "mx60:green:lan1"; + gpios = <&GPIO0 20 GPIO_ACTIVE_LOW>; + }; + + lan2 { + label = "mx60:green:lan2"; + gpios = <&GPIO0 21 GPIO_ACTIVE_LOW>; + }; + + lan3 { + label = "mx60:green:lan3"; + gpios = <&GPIO0 22 GPIO_ACTIVE_LOW>; + }; + + lan4 { + label = "mx60:green:lan4"; + gpios = <&GPIO0 23 GPIO_ACTIVE_LOW>; + }; + }; + + gpio_keys_polled { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <60>; /* 3 * 20 = 60ms */ + autorepeat; + + button@1 { + label = "Reset button"; + linux,code = ; + gpios = <&GPIO0 16 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&PCIE0 { + /* Leave this enabled as u-boot on the MX60 will disable it for us */ + status = "okay"; +}; + +&MSI { + status = "okay"; +}; diff --git a/target/linux/apm821xx/image/Makefile b/target/linux/apm821xx/image/Makefile index c032c54416..48eef643e1 100644 --- a/target/linux/apm821xx/image/Makefile +++ b/target/linux/apm821xx/image/Makefile @@ -84,6 +84,38 @@ define Device/mr24 endef TARGET_DEVICES += mr24 +define Device/mx60 + DEVICE_TITLE := Cisco Meraki MX60 + DEVICE_PACKAGES := kmod-spi-gpio swconfig kmod-usb-ledtrig-usbport \ + kmod-usb-dwc2 kmod-usb-storage block-mount + DEVICE_PROFILE := MX60 + DEVICE_DTS := MX60 + BLOCKSIZE := 63k + IMAGES := sysupgrade.tar + DTB_SIZE := 64512 + # The kernel size will need to match the offset defined in mkmerakifw.c, + # otherwise the final image will fail to boot. This is set within the + # MX60 kernel header definition which is found at + # ./tools/firmware-utils/src/mkmerakifw.c, line 103~ + KERNEL_SIZE := 2984k + IMAGE_SIZE := 1021m + KERNEL := kernel-bin | gzip | uImage gzip | MerakiAdd-dtb | MerakiNAND + KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux | gzip | uImage gzip | \ + check-size $$(KERNEL_SIZE) | \ + MerakiAdd-dtb | pad-to 2047k | MerakiAdd-initramfs | \ + MerakiNAND + IMAGE/sysupgrade.tar := sysupgrade-tar + UBINIZE_OPTS := -E 5 +endef +TARGET_DEVICES += mx60 + +define Device/mx60w +$(Device/mx60) + DEVICE_TITLE := Cisco Meraki MX60W + DEVICE_PACKAGES += kmod-ath9k wpad-mini +endef +TARGET_DEVICES += mx60w + define Build/create-uImage-dtb # flat_dt target expect FIT image - which WNDR4700's uboot doesn't support -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) \ diff --git a/target/linux/apm821xx/patches-4.4/203-add-meraki-mx60-buckminster-support.patch b/target/linux/apm821xx/patches-4.4/203-add-meraki-mx60-buckminster-support.patch new file mode 100644 index 0000000000..5ecb7bc9e5 --- /dev/null +++ b/target/linux/apm821xx/patches-4.4/203-add-meraki-mx60-buckminster-support.patch @@ -0,0 +1,32 @@ +--- a/arch/powerpc/platforms/44x/Kconfig ++++ b/arch/powerpc/platforms/44x/Kconfig +@@ -30,6 +30,19 @@ + help + This option enables support for the APM APM821xx Evaluation board. + ++config BUCKMINSTER ++ bool "Buckminster" ++ depends on 44x ++ default n ++ select APM821xx ++ select PCI_MSI ++ select PPC4xx_MSI ++ select PPC4xx_PCI_EXPRESS ++ select IBM_EMAC_RGMII ++ select 460EX ++ help ++ This option enables support for the Cisco Meraki MX60/MX60W (Buckminster) Security Appliance ++ + config EBONY + bool "Ebony" + depends on 44x +--- a/arch/powerpc/platforms/44x/ppc44x_simple.c ++++ b/arch/powerpc/platforms/44x/ppc44x_simple.c +@@ -63,6 +63,7 @@ + "amcc,sequoia", + "amcc,taishan", + "amcc,yosemite", ++ "meraki,buckminster", + "meraki,ikarem", + "mosaixtech,icon" + }; -- 2.30.2