From: Chris Blake Date: Sat, 30 Sep 2017 16:14:58 +0000 (-0500) Subject: mpc85xx: Add Aerohive HiveAP-330 Access Point X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=f2b7d9dc1ca3d33f14961cf2885639f4f9e8965e;p=openwrt%2Fstaging%2Flynxis.git mpc85xx: Add Aerohive HiveAP-330 Access Point The following adds the Aerohive HiveAP-330 Access Point to LEDE under the mpc85xx/p1020 subtarget. Hardware: - SoC: Freescale P1020NSE2DFB - NAND: Intel JS28F512M29EWH 64MB - Memory: 2x ProMOS V59C1G01168QBJ3 128MB (Total of 256MB) - 2.4GHz WiFi: Atheros AR9390-AL1A - 5.0GHz WiFi: Atheros AR9390-AL1A - Eth1: Atheros AR8035-A PoE - Eth2: Atheros AR8035-A - TPM: Atmel AT97SC3204 - LED Driver: TI LP5521 Flashing: 1. Hook into UART (9600 baud) and enter U-Boot. You may need to enter a password of administrator or AhNf?d@ta06 if prompted. 2. Once in U-Boot, tftp boot the initramfs image: dhcp; tftpboot 0x1000000 192.168.1.101:lede- mpc85xx-p1020-hiveap-330-initramfs.zImage; tftpboot 0x6000000 192.168.1.101:lede-mpc85xx-p1020-hiveap-330.fdt; bootm 0x1000000 - 0x6000000; 3. Once booted, scp over the sysupgrade file and sysupgrade the device to flash LEDE to the NAND. sysupgrade /tmp/lede-mpc85xx-p1020-hiveap-330-sysupgrade.img Signed-off-by: Chris Blake --- diff --git a/target/linux/mpc85xx/base-files/etc/board.d/02_network b/target/linux/mpc85xx/base-files/etc/board.d/02_network index 511b56b1cc..1fedb7962e 100755 --- a/target/linux/mpc85xx/base-files/etc/board.d/02_network +++ b/target/linux/mpc85xx/base-files/etc/board.d/02_network @@ -10,6 +10,9 @@ board_config_update board=$(board_name) case "$board" in +hiveap-330) + ucidef_set_interfaces_lan_wan "eth1" "eth0" + ;; tl-wdr4900-v1) ucidef_add_switch "switch0" \ "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan" diff --git a/target/linux/mpc85xx/base-files/etc/diag.sh b/target/linux/mpc85xx/base-files/etc/diag.sh index b269427a51..7261795197 100644 --- a/target/linux/mpc85xx/base-files/etc/diag.sh +++ b/target/linux/mpc85xx/base-files/etc/diag.sh @@ -5,11 +5,14 @@ . /lib/functions/leds.sh get_status_led() { - case $(board_name) in - tl-wdr4900-v1) - status_led="tp-link:blue:system" - ;; - esac + case $(board_name) in + hiveap-330) + status_led="hiveap-330:green:tricolor0" + ;; + tl-wdr4900-v1) + status_led="tp-link:blue:system" + ;; +esac } set_state() { diff --git a/target/linux/mpc85xx/base-files/lib/mpc85xx.sh b/target/linux/mpc85xx/base-files/lib/mpc85xx.sh index 1a2a671e28..065589f18f 100755 --- a/target/linux/mpc85xx/base-files/lib/mpc85xx.sh +++ b/target/linux/mpc85xx/base-files/lib/mpc85xx.sh @@ -13,6 +13,9 @@ mpc85xx_board_detect() { model=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /model/ {print $2}' /proc/cpuinfo) case "$model" in + *"HiveAP-330") + name="hiveap-330" + ;; *"TL-WDR4900 v1") name="tl-wdr4900-v1" ;; diff --git a/target/linux/mpc85xx/base-files/lib/preinit/05_set_iface_mac_mcp85xx b/target/linux/mpc85xx/base-files/lib/preinit/05_set_iface_mac_mcp85xx new file mode 100644 index 0000000000..cecaee86b0 --- /dev/null +++ b/target/linux/mpc85xx/base-files/lib/preinit/05_set_iface_mac_mcp85xx @@ -0,0 +1,17 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/functions/system.sh + +preinit_set_mac_address() { + case $(board_name) in + hiveap-330) + mac_wan=$(mtd_get_mac_binary hw-info 0) + [ -n "$mac_wan" ] && ifconfig eth0 hw ether "$mac_wan" + mac_lan=$(macaddr_add $(mtd_get_mac_binary hw-info 0) +1) + [ -n "$mac_lan" ] && ifconfig eth1 hw ether "$mac_lan" + ;; + esac +} + +boot_hook_add preinit_main preinit_set_mac_address diff --git a/target/linux/mpc85xx/base-files/lib/upgrade/platform.sh b/target/linux/mpc85xx/base-files/lib/upgrade/platform.sh index 65b3674769..9e3a3d661a 100755 --- a/target/linux/mpc85xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/mpc85xx/base-files/lib/upgrade/platform.sh @@ -4,6 +4,10 @@ PART_NAME=firmware +get_magic_long_at() { + (get_image "$1" | dd bs=4 count=1 skip="$2" | hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev/null +} + tplink_get_hwid() { local part @@ -28,6 +32,29 @@ platform_check_image() { [ "$#" -gt 1 ] && return 1 case $board in + hiveap-330) + local init_magic=$(get_magic_long_at "$1" "65536") + local root_magic=$(get_magic_long_at "$1" "131072") + local kernel_magic=$(get_magic_long_at "$1" "10551296") + + [ "$magic" != "d00dfeed" ] && { + echo "Invalid dtb image type." + return 1 + } + [ "$init_magic" != "27051956" ] && { + echo "Invalid initramfs image type." + return 1 + } + [ "$root_magic" != "68737173" ] && { + echo "Invalid rootfs image type." + return 1 + } + [ "$kernel_magic" != "27051956" ] && { + echo "Invalid kernel image type." + return 1 + } + return 0 + ;; tl-wdr4900-v1) [ "$magic" != "01000000" ] && { echo "Invalid image type." diff --git a/target/linux/mpc85xx/config-4.9 b/target/linux/mpc85xx/config-4.9 index 9086ba9177..46950e70c8 100644 --- a/target/linux/mpc85xx/config-4.9 +++ b/target/linux/mpc85xx/config-4.9 @@ -25,6 +25,7 @@ CONFIG_ARCH_SUSPEND_POSSIBLE=y CONFIG_ARCH_USE_BUILTIN_BSWAP=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_ASN1=y +CONFIG_AT803X_PHY=y CONFIG_AUDIT_ARCH=y CONFIG_BLK_MQ_PCI=y CONFIG_BOOKE=y @@ -81,6 +82,7 @@ CONFIG_E500=y CONFIG_EARLY_PRINTK=y CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y +CONFIG_EEPROM_LEGACY=y CONFIG_ENABLE_MUST_CHECK=y # CONFIG_EPAPR_BOOT is not set CONFIG_ETHERNET_PACKET_MANGLE=y @@ -161,6 +163,7 @@ CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y # CONFIG_HAVE_SETUP_PER_CPU_AREA is not set CONFIG_HAVE_SYSCALL_TRACEPOINTS=y CONFIG_HAVE_VIRT_CPU_ACCOUNTING=y +CONFIG_HIVEAP_330=y CONFIG_HW_RANDOM=y CONFIG_HZ=250 # CONFIG_HZ_100 is not set @@ -168,6 +171,7 @@ CONFIG_HZ_250=y CONFIG_HZ_PERIODIC=y CONFIG_I2C=y CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y CONFIG_I2C_MPC=y CONFIG_INITRAMFS_SOURCE="" CONFIG_IOMMU_HELPER=y @@ -180,17 +184,16 @@ CONFIG_ISA_DMA_API=y CONFIG_KERNEL_GZIP=y CONFIG_KERNEL_START=0xc0000000 # CONFIG_KSI8560 is not set +CONFIG_LEDS_LP5521=y +CONFIG_LEDS_LP55XX_COMMON=y CONFIG_LEGACY_PTYS=y CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOWMEM_CAM_NUM=3 CONFIG_LOWMEM_SIZE=0x30000000 CONFIG_LXT_PHY=y -CONFIG_LZO_COMPRESS=y -CONFIG_LZO_DECOMPRESS=y # CONFIG_MATH_EMULATION is not set CONFIG_MDIO_BOARDINFO=y -# CONFIG_MFD_MAX77620 is not set CONFIG_MIGRATION=y # CONFIG_MMIO_NVRAM is not set CONFIG_MODULES_USE_ELF_RELA=y @@ -207,8 +210,8 @@ CONFIG_MPIC_TIMER=y # CONFIG_MPIC_U3_HT_IRQS is not set # CONFIG_MPIC_WEIRD is not set CONFIG_MPILIB=y -# CONFIG_MTD_CFI is not set CONFIG_MTD_M25P80=y +CONFIG_MTD_PHYSMAP=y CONFIG_MTD_SPI_NOR=y # CONFIG_MVME2500 is not set # CONFIG_NEED_DMA_MAP_STATE is not set diff --git a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/hiveap-330.dts b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/hiveap-330.dts new file mode 100644 index 0000000000..7900c40c7e --- /dev/null +++ b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/hiveap-330.dts @@ -0,0 +1,227 @@ +/* + * Aerohive HiveAP-330 Device Tree Source + * + * Copyright (C) 2017 Chris Blake + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +/include/ "fsl/p1020si-pre.dtsi" +/ { + model = "Aerohive HiveAP-330"; + compatible = "aerohive,hiveap-330"; + + chosen { + bootargs = "console=ttyS0,9600"; + bootargs-override = "console=ttyS0,9600 noinitrd"; + }; + + memory { + device_type = "memory"; + }; + + board_lbc: lbc: localbus@ffe05000 { + reg = <0 0xffe05000 0 0x1000>; + ranges = <0x0 0x0 0x0 0xec000000 0x4000000>; + + nor@0,0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "cfi-flash"; + reg = <0x0 0x0 0x4000000>; + bank-width = <2>; + device-width = <1>; + + partition@0 { + reg = <0x0 0x40000>; + label = "dtb"; + }; + + partition@40000 { + reg = <0x40000 0x40000>; + label = "initramfs"; + }; + + partition@80000 { + reg = <0x80000 0x27c0000>; + label = "rootfs"; + }; + + partition@2840000 { + reg = <0x2840000 0x800000>; + label = "kernel"; + }; + + partition@3040000 { + reg = <0x3040000 0xec0000>; + label = "stock-jffs2"; + read-only; + }; + + partition@3f00000 { + reg = <0x3f00000 0x20000>; + label = "hw-info"; + read-only; + }; + + partition@3f20000 { + reg = <0x3f20000 0x20000>; + label = "boot-info"; + read-only; + }; + + partition@3f40000 { + reg = <0x3f40000 0x20000>; + label = "boot-info-backup"; + read-only; + }; + + partition@3f60000 { + reg = <0x3f60000 0x20000>; + label = "u-boot-env"; + }; + + partition@3f80000 { + reg = <0x3f80000 0x80000>; + label = "u-boot"; + read-only; + }; + + firmware@0 { + reg = <0x0 0x3040000>; + label = "firmware"; + }; + }; + }; + + board_soc: soc: soc@ffe00000 { + ranges = <0x0 0x0 0xffe00000 0x100000>; + + i2c@3100 { + tpm@29 { + compatible = "atmel,at97sc3204t"; + reg = <0x29>; + }; + + lp5521@32 { + compatible = "national,lp5521"; + reg = <0x32>; + clock-mode = /bits/ 8 <2>; + chan0 { + chan-name = "hiveap-330:red:tricolor0"; + led-cur = /bits/ 8 <0x2f>; + max-cur = /bits/ 8 <0x5f>; + }; + chan1 { + chan-name = "hiveap-330:green:tricolor0"; + led-cur = /bits/ 8 <0x2f>; + max-cur = /bits/ 8 <0x5f>; + }; + chan2 { + chan-name = "hiveap-330:blue:tricolor0"; + led-cur = /bits/ 8 <0x2f>; + max-cur = /bits/ 8 <0x5f>; + }; + }; + + /* Most likely SoC boot config */ + eeprom@51 { + compatible = "eeprom"; + reg = <0x51>; + }; + }; + + mdio@24000 { + phy0: ethernet-phy@0 { + interrupts = <3 1 0 0>; + reg = <0x1>; + }; + + phy1: ethernet-phy@1 { + interrupts = <2 1 0 0>; + reg = <0x2>; + }; + }; + + mdio@25000 { + status = "disabled"; + }; + + mdio@26000 { + status = "disabled"; + }; + + enet0: ethernet@b0000 { + status = "okay"; + phy-handle = <&phy0>; + phy-connection-type = "rgmii-id"; + + }; + + enet1: ethernet@b1000 { + status = "disabled"; + }; + + enet2: ethernet@b2000 { + status = "okay"; + phy-handle = <&phy1>; + phy-connection-type = "rgmii-id"; + }; + + gpio0: gpio-controller@fc00 { + }; + + usb@22000 { + phy_type = "ulpi"; + dr_mode = "host"; + }; + + usb@23000 { + status = "disabled"; + }; + }; + + pci0: pcie@ffe09000 { + reg = <0x0 0xffe09000 0x0 0x1000>; + ranges = <0x2000000 0x0 0xa0000000 0x0 0xa0000000 0x0 0x20000000 + 0x1000000 0x0 0x00000000 0x0 0xffc30000 0x0 0x10000>; + pcie@0 { + ranges = <0x2000000 0x0 0xa0000000 + 0x2000000 0x0 0xa0000000 + 0x0 0x20000000 + + 0x1000000 0x0 0x0 + 0x1000000 0x0 0x0 + 0x0 0x100000>; + }; + }; + + pci1: pcie@ffe0a000 { + reg = <0x0 0xffe0a000 0x0 0x1000>; + ranges = <0x2000000 0x0 0xc0000000 0x0 0xc0000000 0x0 0x20000000 + 0x1000000 0x0 0x00000000 0x0 0xffc20000 0x0 0x10000>; + pcie@0 { + ranges = <0x2000000 0x0 0xc0000000 + 0x2000000 0x0 0xc0000000 + 0x0 0x20000000 + + 0x1000000 0x0 0x0 + 0x1000000 0x0 0x0 + 0x0 0x100000>; + }; + }; + + buttons { + compatible = "gpio-keys"; + + reset { + label = "Reset button"; + gpios = <&gpio0 8 1>; /* active low */ + linux,code = <0x198>; /* KEY_RESTART */ + }; + }; +}; +/include/ "fsl/p1020si-post.dtsi" diff --git a/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/hiveap-330.c b/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/hiveap-330.c new file mode 100644 index 0000000000..f325b32ce6 --- /dev/null +++ b/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/hiveap-330.c @@ -0,0 +1,89 @@ +/* + * Aerohive HiveAP-330 Board Setup + * + * Copyright (C) 2017 Chris Blake + * + * Based on: + * mpc85xx_rdb.c: + * MPC85xx RDB Board Setup + * Copyright 2013 Freescale Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "smp.h" + +#include "mpc85xx.h" + +void __init hiveap_330_pic_init(void) +{ + struct mpic *mpic; + + mpic = mpic_alloc(NULL, 0, + MPIC_BIG_ENDIAN | + MPIC_SINGLE_DEST_CPU, + 0, 256, " OpenPIC "); + + BUG_ON(mpic == NULL); + mpic_init(mpic); +} + +/* + * Setup the architecture + */ +static void __init hiveap_330_setup_arch(void) +{ + if (ppc_md.progress) + ppc_md.progress("hiveap_330_setup_arch()", 0); + + mpc85xx_smp_init(); + + fsl_pci_assign_primary(); + + printk(KERN_INFO "HiveAP-330 board from Aerohive\n"); +} + +machine_arch_initcall(hiveap_330, mpc85xx_common_publish_devices); + +/* + * Called very early, device-tree isn't unflattened + */ +static int __init hiveap_330_probe(void) +{ + if (of_machine_is_compatible("aerohive,hiveap-330")) + return 1; + return 0; +} + +define_machine(hiveap_330) { + .name = "P1020 RDB", + .probe = hiveap_330_probe, + .setup_arch = hiveap_330_setup_arch, + .init_IRQ = hiveap_330_pic_init, +#ifdef CONFIG_PCI + .pcibios_fixup_bus = fsl_pcibios_fixup_bus, + .pcibios_fixup_phb = fsl_pcibios_fixup_phb, +#endif + .get_irq = mpic_get_irq, + .calibrate_decr = generic_calibrate_decr, + .progress = udbg_progress, +}; diff --git a/target/linux/mpc85xx/image/Makefile b/target/linux/mpc85xx/image/Makefile index 25a9b070c5..4738dcf122 100644 --- a/target/linux/mpc85xx/image/Makefile +++ b/target/linux/mpc85xx/image/Makefile @@ -21,7 +21,18 @@ endef zImage:=$(BIN_DIR)/$(IMG_PREFIX)-zImage -DTS_TARGETS = fsl/p1010rdb-pa tl-wdr4900-v1 fsl/p1020rdb +DTS_TARGETS = hiveap-330 fsl/p1010rdb-pa tl-wdr4900-v1 fsl/p1020rdb + +define Build/empty-initramfs + -mkdir $(KDIR_TMP)/empty-initramfs; \ + cd $(KDIR_TMP)/empty-initramfs; \ + find . | cpio -o -H newc | gzip -9n > $(KDIR_TMP)/empty-initramfs.gpio.gz + + -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T ramdisk \ + -C gzip -n "empty initramfs" \ + -d $(KDIR_TMP)/empty-initramfs.gpio.gz \ + $(KDIR_TMP)/$(IMG_PREFIX)-empty-initramfs.image +endef define Image/BuildKernel cp $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage @@ -35,6 +46,21 @@ define Image/BuildKernel/Initramfs ifeq ($(SUBTARGET),generic) cp $(KDIR)/cuImage.tl-wdr4900-v1-initramfs $(BIN_DIR)/$(IMG_PREFIX)-tl-wdr4900-v1-initramfs.uImage endif +ifeq ($(SUBTARGET),p1020) + cp $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-hiveap-330-initramfs.zImage +endif +endef + +define Image/Build/Aerohive + $(call Build/empty-initramfs) +ifeq ($(2),hiveap-330) + ( \ + dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(2).fdt bs=256k conv=sync; \ + dd if=$(KDIR_TMP)/$(IMG_PREFIX)-empty-initramfs.image bs=256k conv=sync; \ + dd if=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=40704k conv=sync; \ + dd if=$(KDIR)/zImage conv=sync; \ + ) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-sysupgrade.img +endif endef define Image/Build/TPLINK @@ -50,6 +76,10 @@ define Image/Build/TPLINK -o $(call sysupname,$(1),$(2)) endef +define Image/Build/Profile/hiveap-330 + $(call Image/Build/Aerohive,$(1),hiveap-330) +endef + define Image/Build/Profile/TLWDR4900 $(call Image/Build/TPLINK,$(1),tl-wdr4900-v1,cuImage.tl-wdr4900-v1,0x49000001,1,16Mppc) endef diff --git a/target/linux/mpc85xx/p1020/profiles/aerohive.mk b/target/linux/mpc85xx/p1020/profiles/aerohive.mk new file mode 100644 index 0000000000..0f5ace6c39 --- /dev/null +++ b/target/linux/mpc85xx/p1020/profiles/aerohive.mk @@ -0,0 +1,16 @@ +# +# Copyright (C) 2017 Chris Blake +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define Profile/hiveap-330 + NAME:=Aerohive HiveAP-330 + PACKAGES:=kmod-usb-storage kmod-ath9k wpad-mini kmod-tpm-i2c-atmel +endef + +define Profile/hiveap-330/Description + Package set optimized for the Aerohive HiveAP-330. +endef +$(eval $(call Profile,hiveap-330)) diff --git a/target/linux/mpc85xx/patches-4.9/101-powerpc-85xx-hiveap-330-support.patch b/target/linux/mpc85xx/patches-4.9/101-powerpc-85xx-hiveap-330-support.patch new file mode 100644 index 0000000000..ece8c7d80e --- /dev/null +++ b/target/linux/mpc85xx/patches-4.9/101-powerpc-85xx-hiveap-330-support.patch @@ -0,0 +1,30 @@ +--- a/arch/powerpc/platforms/85xx/Kconfig ++++ b/arch/powerpc/platforms/85xx/Kconfig +@@ -48,6 +48,17 @@ config BSC9132_QDS + and dual StarCore SC3850 DSP cores. + Manufacturer : Freescale Semiconductor, Inc + ++config HIVEAP_330 ++ bool "Aerohive HiveAP-330" ++ select DEFAULT_UIMAGE ++ select ARCH_REQUIRE_GPIOLIB ++ select GPIO_MPC8XXX ++ help ++ This option enables support for the Aerohive HiveAP-330 board. ++ ++ This board is a Concurrent Dual-Band wireless access point with a ++ Freescale P1020 SoC. ++ + config MPC8540_ADS + bool "Freescale MPC8540 ADS" + select DEFAULT_UIMAGE +--- a/arch/powerpc/platforms/85xx/Makefile ++++ b/arch/powerpc/platforms/85xx/Makefile +@@ -9,6 +9,7 @@ obj-y += common.o + obj-$(CONFIG_BSC9131_RDB) += bsc913x_rdb.o + obj-$(CONFIG_BSC9132_QDS) += bsc913x_qds.o + obj-$(CONFIG_C293_PCIE) += c293pcie.o ++obj-$(CONFIG_HIVEAP_330) += hiveap-330.o + obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o + obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o + obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o