[PATCH v3] cn913x: add support for iEi Puzzle-M901/Puzzle-M902
Adrian Schmutzler
mail at adrianschmutzler.de
Sun Jul 4 05:59:44 PDT 2021
Hi,
> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of eveans2002 at gmail.com
> Sent: Freitag, 2. Juli 2021 13:16
> To: openwrt-devel at lists.openwrt.org
> Cc: Ian Chang <ianchang at ieiworld.com>
> Subject: [PATCH v3] cn913x: add support for iEi Puzzle-M901/Puzzle-M902
This goes into mvebu target, so the commit title prefix should be "mvebu:"!
Further comments below.
>
> From: Ian Chang <ianchang at ieiworld.com>
>
> Hardware specification
> ----------------------
> * CN9130 SoC, Quad-core ARMv8 Cortex-72 @ 2200 MHz
> * 4 GB DDR
> * 4 GB eMMC
> * mmcblk0
> - mmcblk0p1 64M kernel_1
> - mmcblk0p2 64M kernel_2
> - mmcblk0p3 512M rootfs_1
> - mmcblk0p4 512M rootfs_2
> - mmcblk0p5 512M Reserved
> - mmcblk0p6 64M Reserved
> - mmcblk0p7 1.8G rootfs_data
>
> * 4 MB (SPI Flash)
> * 6 x 2.5 Gigabit ports (Puzzle-M901)
> - External PHY with 6 ports (AQR112R)
> * 6 x 2.5 Gigabit ports (Puzzle-M902)
> - External PHY with 6 ports (AQR112R)
> 3 x 10 Gigabit ports (Puzzle-M902)
> - External PHY with 3 ports (AQR113R)
>
> * 4 x Front panel LED
> * 1 x USB 3.0
> * Reset button on Rear panel
> * UART (115200 8N1,header on PCB)
>
> Flash instructions:
> The original firmware is based on OpenWrt.
> Flash firmware using LuCI and CLI
>
> Signed-off-by: Ian Chang <ianchang at ieiworld.com>
> ---
> .../base-files/etc/board.d/02_network | 6 +
> .../cortexa72/base-files/lib/upgrade/emmc.sh | 40 +++
> .../base-files/lib/upgrade/platform.sh | 8 +
> .../boot/dts/marvell/cn9130-puzzle-m901.dts | 216 ++++++++++++++++
> .../boot/dts/marvell/cn9130-puzzle-m902.dts | 236 ++++++++++++++++++
> .../arm64/boot/dts/marvell/cn9130-puzzle.dtsi | 37 +++
> .../boot/dts/marvell/cn9131-puzzle-m901.dts | 153 ++++++++++++
> .../boot/dts/marvell/cn9131-puzzle-m902.dts | 136 ++++++++++
> .../boot/dts/marvell/cn9132-puzzle-m902.dts | 209 ++++++++++++++++
> target/linux/mvebu/image/cortexa72.mk | 20 ++
> 10 files changed, 1061 insertions(+)
> create mode 100644 target/linux/mvebu/cortexa72/base-
> files/lib/upgrade/emmc.sh
> create mode 100644
> target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9130-puzzle-
> m901.dts
> create mode 100644
> target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9130-puzzle-
> m902.dts
> create mode 100644
> target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9130-puzzle.dtsi
> create mode 100644
> target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9131-puzzle-
> m901.dts
> create mode 100644
> target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9131-puzzle-
> m902.dts
> create mode 100644
> target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9132-puzzle-
> m902.dts
>
> diff --git a/target/linux/mvebu/cortexa72/base-
> files/etc/board.d/02_network b/target/linux/mvebu/cortexa72/base-
> files/etc/board.d/02_network
> index 9ab3c8174d..f3c3cda977 100755
> --- a/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network
> +++ b/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network
> @@ -21,6 +21,12 @@ marvell,armada8040-db)
> marvell,armada7040-db)
> ucidef_set_interfaces_lan_wan "eth0 eth2" "eth1"
> ;;
> +iei,cn9131-puzzle-m901)
> + ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
> + ;;
> +iei,cn9132-puzzle-m902)
> + ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5 eth10
> eth11 eth12" "eth0"
> + ;;
Please take care of alphabetic sorting. These should be moved before the various marvell... entries.
> *)
> ucidef_set_interface_lan "eth0"
> ;;
> diff --git a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
> b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
> new file mode 100644
> index 0000000000..bd7eea5c22
> --- /dev/null
> +++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
> @@ -0,0 +1,40 @@
> +platform_do_upgrade_emmc() {
> + local board=$(board_name)
> + local diskdev partdev
> +
> + export_bootdevice && export_partdevice diskdev 0 || {
> + v "Unable to determine upgrade device"
> + return 1
Broken indent
> + }
> +
> + sync
> +
> + if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
> + get_partitions "/dev/$diskdev" bootdisk
> +
> + v "Extract boot sector from the image"
> + get_image_dd "$1" of=/tmp/image.bs count=1 bs=512b
> +
> + get_partitions /tmp/image.bs image
> + fi
> +
> + #iterate over each partition from the image and write it to the boot
> disk
> + while read part start size; do
> + if export_partdevice partdev $part; then
> + if [ "$partdev" = "mmcblk0p2" ]; then
> + v "Writing image mmcblk0p3 for
> /dev/$partdev $start $size"
> + get_image_dd "$1" of="/dev/mmcblk0p3"
> ibs="512" obs=1M skip="$start" count="$size" conv=fsync
> + elif [ "$partdev" = "mmcblk0p1" ]; then
> + v "Writing image mmcblk0p1 for
> /dev/$partdev $start $size"
> + get_image_dd "$1" of="/dev/$partdev"
> ibs="512" obs=1M skip="$start" count="$size" conv=fsync
> + fi
> + else
> + v "Unable to find partition $part device, skipped."
> + fi
> + done < /tmp/partmap.image
> +
> + v "Writing new UUID to /dev/$diskdev..."
> + get_image_dd "$1" of="/dev/$diskdev" bs=1 skip=440 count=4
> seek=440
> +conv=fsync
> +
> + sleep 1
> +}
> diff --git a/target/linux/mvebu/cortexa72/base-
> files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa72/base-
> files/lib/upgrade/platform.sh
> index 04ea634097..ea01b11be8 100755
> --- a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh
> @@ -9,6 +9,8 @@ REQUIRE_IMAGE_METADATA=1
>
> platform_check_image() {
> case "$(board_name)" in
> + iei,cn9131-puzzle-m901|\
> + iei,cn9132-puzzle-m902|\
> marvell,armada8040-mcbin-doubleshot|\
> marvell,armada8040-mcbin-singleshot)
> platform_check_image_sdcard "$1"
> @@ -25,6 +27,10 @@ platform_do_upgrade() {
> marvell,armada8040-mcbin-singleshot)
> platform_do_upgrade_sdcard "$1"
> ;;
> + iei,cn9131-puzzle-m901|\
> + iei,cn9132-puzzle-m902)
> + platform_do_upgrade_emmc "$1"
> + ;;
Sorting ...
> *)
> default_do_upgrade "$1"
> ;;
> @@ -32,6 +38,8 @@ platform_do_upgrade() { }
> platform_copy_config() {
> case "$(board_name)" in
> + iei,cn9131-puzzle-m901|\
> + iei,cn9132-puzzle-m902|\
> marvell,armada8040-mcbin-doubleshot|\
> marvell,armada8040-mcbin-singleshot)
> platform_copy_config_sdcard
> diff --git a/target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9130-
> puzzle-m901.dts
> b/target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9130-puzzle-
> m901.dts
> new file mode 100644
> index 0000000000..8e2ba97697
> --- /dev/null
> +++ b/target/linux/mvebu/files/arch/arm64/boot/dts/marvell/cn9130-
> puzzle
> +++ -m901.dts
> @@ -0,0 +1,216 @@
> +// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT)
> +/*
> + * Copyright (C) 2019 Marvell International Ltd.
> + *
> + * Device tree for the CN9130-DB board.
> + */
> +
> +#include "cn9130-puzzle.dtsi"
> +
> +#include <dt-bindings/gpio/gpio.h>
> +
> +/ {
> + model = "iEi Puzzle-M901";
> +
> + chosen {
> + stdout-path = "serial0:115200n8";
> + };
> +
> + aliases {
> + i2c0 = &cp0_i2c0;
> + ethernet0 = &cp0_eth0;
> + ethernet1 = &cp0_eth1;
> + ethernet2 = &cp0_eth2;
> + gpio1 = &cp0_gpio1;
> + gpio2 = &cp0_gpio2;
> + spi1 = &cp0_spi0;
> + spi2 = &cp0_spi1;
> + serial1 = &cp0_uart0;
> + };
> +
> + memory at 00000000 {
> + device_type = "memory";
> + reg = <0x0 0x0 0x0 0x80000000>;
> + };
> +
> +};
> +
> +&uart0 {
> + status = "okay";
> +};
> +
> +&cp0_uart0 {
> + status = "okay";
> +};
> +
> +/* on-board eMMC - U9 */
> +&ap_sdhci0 {
> + pinctrl-names = "default";
> + bus-width = <8>;
> + status = "okay";
> + mmc-ddr-1_8v;
> + mmc-hs400-1_8v;
> + /* vqmmc-supply = <&ap0_reg_sd_vccq>; */ };
What about these commented entries? Can they be removed?
> +
> +&cp0_crypto {
> + status = "okay";
> +};
> +
> +&cp0_xmdio {
> + status = "okay";
> + phy0: ethernet-phy at 0 {
> + compatible = "ethernet-phy-ieee802.3-c45";
> + reg = <2>;
> + };
> + phy1: ethernet-phy at 1 {
> + compatible = "ethernet-phy-ieee802.3-c45";
> + reg = <0>;
> + };
> + phy2: ethernet-phy at 2 {
> + compatible = "ethernet-phy-ieee802.3-c45";
> + reg = <8>;
> + };
> +};
> +
> +&cp0_ethernet {
> + status = "okay";
> +};
> +
> +/* SLM-1521-V2, CON9 */
> +&cp0_eth0 {
> + status = "okay";
> + phy-mode = "2500base-x";
> + phys = <&cp0_comphy2 0>;
> + /* phy = <&phy0>; */
See above? Can this be removed? (I won't comment again on all the other cases below ...)
> + managed = "in-band-status";
> +};
[...]
> --- a/target/linux/mvebu/image/cortexa72.mk
> +++ b/target/linux/mvebu/image/cortexa72.mk
> @@ -43,3 +43,23 @@ define Device/marvell_macchiatobin-singleshot
> SUPPORTED_DEVICES := marvell,armada8040-mcbin-singleshot
> endef
> TARGET_DEVICES += marvell_macchiatobin-singleshot
> +
> +define Device/iei_cn9131-puzzle-m901
The device name does not contain cn9131, so please remove that from the definition here and also from the compatible in the DTS.
> + $(call Device/Default-arm64)
> + DEVICE_VENDOR := iEi
> + DEVICE_MODEL := Puzzle-M901
> + DEVICE_DTS := cn9131-puzzle-m901
You should be able to define SOC := cn9131 instead and drop DEVICE_DTS if you name the node as required.
> + IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip |
> +append-metadata
> + SUPPORTED_DEVICES := iei,cn9131-puzzle-m901 endef TARGET_DEVICES
This should be dropped (after the matching compatible has been chosen).
> +=
> +iei_cn9131-puzzle-m901
> +
> +define Device/iei_cn9132-puzzle-m902
See above.
Best
Adrian
> + $(call Device/Default-arm64)
> + DEVICE_VENDOR := iEi
> + DEVICE_MODEL := Puzzle-M902
> + DEVICE_DTS := cn9132-puzzle-m902
> + IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip |
> +append-metadata
> + SUPPORTED_DEVICES := iei,cn9132-puzzle-m902 endef TARGET_DEVICES
> +=
> +iei_cn9132-puzzle-m902
> --
> 2.17.1
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20210704/7e823974/attachment-0001.sig>
More information about the openwrt-devel
mailing list