From: Pawel Dembicki Date: Sat, 11 Dec 2021 22:23:22 +0000 (+0100) Subject: mvebu: cortexa9: Add support for Ctera C200-V2 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9149ed4f05f86e3fd0dd55c87913ced8a5a32ba4;p=openwrt%2Fstaging%2F981213.git mvebu: cortexa9: Add support for Ctera C200-V2 2-Bay NAS - maximum two 3.5" Harddisks Hardware: - SoC: Marvell 88F6707-A1 ARMv7 Processor 1,2GHz (ARMADA 370 SoC) - Ram: 1GB (2x Nanya NT5CC512M8DN-D1) - NAND Flash: 256MB (ESMT F59L2G81A-25T) - Lan: 1x GBE (Marvell 88E1318-NNB2) - Storage: 2x SATA HDD 3.5" Slot - USB: 2x USB 3.0 port (Renesas uPD720202) - Console: Internal J3 connector (1: Vcc, 2: Rx, 3: Tx, 4: GND) - LEDs: 13x GPIO controlled - Buttons: 2x GPIO controlled Known issues: - Buzzer is unused due lack of proper driver - USB1/2 usbport ledtrigger won't work (through DT) - Renesas uPD720202 requires firmware file. It's possible to find non-free binary. Please look for 'UPDATE.mem' file and put in into '/lib/firmware/renesas_usb_fw.mem' file. Installation: - Apply factory initramfs image via stock web-gui. - Do sysupgrade to make installation complete. Back to stock: - OpenWrt rootfs partition use unused space after stock firmware. - Full revert is possible. - Login via ssh and run: ## ctera_c200-v2_back_to_factory start ## . /lib/functions.sh part=$(find_mtd_part "active_bank") active_bank=$(strings "$part" | grep bank) if [ "$active_bank" = "bank1" ]; then echo "bank2" > /tmp/change_bank else echo "bank1" > /tmp/change_bank fi mtd write /tmp/change_bank active_bank reboot ## ctera_c200-v2_back_to_factory end ## Signed-off-by: Pawel Dembicki (put back-to-stock script into commit message, removed dup. SUBPAGESIZE var, added 01_leds for non-working dt-usb-port trigger) Signed-off-by: Christian Lamparter --- diff --git a/package/kernel/linux/modules/usb.mk b/package/kernel/linux/modules/usb.mk index 6f73c96a29..9671b80333 100644 --- a/package/kernel/linux/modules/usb.mk +++ b/package/kernel/linux/modules/usb.mk @@ -1712,7 +1712,8 @@ define KernelPackage/usb3 +TARGET_bcm53xx:kmod-usb-bcma \ +TARGET_bcm53xx:kmod-phy-bcm-ns-usb3 \ +TARGET_ramips_mt7621:kmod-usb-xhci-mtk \ - +(TARGET_apm821xx_nand&&LINUX_5_10):kmod-usb-xhci-pci-renesas + +(TARGET_apm821xx_nand&&LINUX_5_10):kmod-usb-xhci-pci-renesas \ + +TARGET_mvebu_cortexa9:kmod-usb-xhci-pci-renesas KCONFIG:= \ CONFIG_USB_PCI=y \ CONFIG_USB_XHCI_PCI \ diff --git a/target/linux/mvebu/config-5.10 b/target/linux/mvebu/config-5.10 index a3fcbeb699..33cb8cce88 100644 --- a/target/linux/mvebu/config-5.10 +++ b/target/linux/mvebu/config-5.10 @@ -337,6 +337,9 @@ CONFIG_PJ4B_ERRATA_4742=y CONFIG_PL310_ERRATA_753970=y CONFIG_PLAT_ORION=y CONFIG_PM_OPP=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_GPIO=y +# CONFIG_POWER_RESET_QNAP is not set CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=11 CONFIG_PWM=y CONFIG_PWM_SYSFS=y diff --git a/target/linux/mvebu/cortexa9/base-files/etc/board.d/01_leds b/target/linux/mvebu/cortexa9/base-files/etc/board.d/01_leds index 381596d85d..161d111ea7 100644 --- a/target/linux/mvebu/cortexa9/base-files/etc/board.d/01_leds +++ b/target/linux/mvebu/cortexa9/base-files/etc/board.d/01_leds @@ -11,6 +11,10 @@ board=$(board_name) boardname="${board##*,}" case "$board" in +ctera,c200-v2 + ucidef_set_led_usbport "usb2" "USB2" "green:usb-2" "usb1-port1" "usb2-port1" + ucidef_set_led_usbport "usb3" "USB3" "green:usb-1" "usb1-port2" "usb2-port2" + ;; kobol,helios4) ucidef_set_led_usbport "USB" "USB" "helios4:green:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1" "usb5-port1" ;; diff --git a/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network b/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network index ad61dbea43..36769e8c18 100644 --- a/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network +++ b/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network @@ -12,6 +12,9 @@ mvebu_setup_interfaces() local board="$1" case "$board" in + ctera,c200-v2) + ucidef_set_interface_lan "eth0" "dhcp" + ;; cznic,turris-omnia) ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4" "eth2" ;; @@ -58,6 +61,10 @@ mvebu_setup_macs() buffalo,ls421de) lan_mac=$(mtd_get_mac_ascii u-boot-env eth1addr) ;; + ctera,c200-v2) + label_mac=$(mtd_get_mac_ascii dev_params mac) + lan_mac=$label_mac + ;; linksys,wrt1200ac|\ linksys,wrt1900ac-v2|\ linksys,wrt1900acs|\ diff --git a/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh index 5e69374837..030e66e699 100755 --- a/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh +++ b/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh @@ -3,7 +3,7 @@ # Copyright (C) 2016 LEDE-Project.org # -RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_BIN='fw_printenv fw_setenv strings' RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' REQUIRE_IMAGE_METADATA=1 @@ -26,6 +26,17 @@ platform_do_upgrade() { buffalo,ls421de) nand_do_upgrade "$1" ;; + ctera,c200-v2) + part=$(find_mtd_part "active_bank") + + if [ -n "$part" ]; then + CI_KERNPART="$(strings $part | grep bank)" + nand_do_upgrade "$1" + else + echo "active_bank partition missed!" + return 1 + fi + ;; cznic,turris-omnia|\ kobol,helios4|\ solidrun,clearfog-base-a1|\ diff --git a/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-c200-v2.dts b/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-c200-v2.dts new file mode 100644 index 0000000000..c1c227a5e9 --- /dev/null +++ b/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-c200-v2.dts @@ -0,0 +1,426 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT) +/* + * Device Tree file for Ctera C200-V2 + * + * Copyright (C) 2021 Pawel Dembicki + */ + +/dts-v1/; + +#include "armada-370.dtsi" +#include +#include +#include +#include + +/ { + model = "Ctera C200 V2"; + compatible = "ctera,c200-v2", "marvell,armada370", "marvell,armada-370-xp"; + + aliases { + led-boot = &led_status_green; + led-failsafe = &led_status_red; + led-running = &led_status_green; + led-upgrade = &led_status_red; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + stdout-path = "serial0:115200n8"; + }; + + memory { + device_type = "memory"; + reg = <0x00000000 0x40000000>; /* 1024 MB */ + }; + + soc { + ranges = ; + }; + + thermal-zones { + ethphy-thermal { + polling-delay = <20000>; + polling-delay-passive = <2000>; + + thermal-sensors = <ðphy0>; + + trips { + ethphy_alert1: trip1 { + temperature = <65000>; + hysteresis = <4000>; + type = "passive"; + }; + + ethphy_crit: trip2 { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&pmx_buttons>; + pinctrl-names = "default"; + + power { + label = "Power Button"; + linux,code = ; + gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>; + }; + + reset { + label = "Reset Button"; + linux,code = ; + gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; + }; + + usb1 { + label = "USB1 Button"; + linux,code = ; + gpios = <&gpio1 0 GPIO_ACTIVE_LOW>; + }; + + usb2 { + label = "USB2 Button"; + linux,code = ; + gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-poweroff { + compatible = "gpio-poweroff"; + pinctrl-0 = <&pmx_poweroff>; + pinctrl-names = "default"; + gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&pmx_leds1 &pmx_leds2>; + pinctrl-names = "default"; + + led-0 { + function = LED_FUNCTION_USB; + function-enumerator = <2>; + color = ; + gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; + }; + + led-1 { + function = LED_FUNCTION_USB; + function-enumerator = <2>; + color = ; + gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; + linux,default-trigger = "usbport"; + trigger-sources = <&usb1_port 1>, <&usb2_port 1>; + }; + + led-2 { + function = LED_FUNCTION_USB; + function-enumerator = <1>; + color = ; + gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; + }; + + led-3 { + function = LED_FUNCTION_USB; + function-enumerator = <1>; + color = ; + gpios = <&gpio0 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "usbport"; + trigger-sources = <&usb1_port 2>, <&usb2_port 2>; + }; + + led-4 { + function = LED_FUNCTION_DISK; + function-enumerator = <2>; + color = ; + gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; + linux,default-trigger = "ata2"; + }; + + led-5 { + function = LED_FUNCTION_DISK; + function-enumerator = <1>; + color = ; + gpios = <&gpio1 18 GPIO_ACTIVE_LOW>; + }; + + led-6 { + function = LED_FUNCTION_DISK; + function-enumerator = <2>; + color = ; + gpios = <&gpio1 19 GPIO_ACTIVE_LOW>; + }; + + led-7 { + function = LED_FUNCTION_INDICATOR; + color = ; + gpios = <&gpio1 20 GPIO_ACTIVE_HIGH>; + }; + + led-8 { + function = LED_FUNCTION_DISK_ERR; + color = ; + gpios = <&gpio1 21 GPIO_ACTIVE_LOW>; + }; + + led-9 { + function = LED_FUNCTION_DISK_ERR; + color = ; + gpios = <&gpio1 23 GPIO_ACTIVE_LOW>; + }; + + led_status_red: led-10 { + label = "red:status"; + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&gpio1 24 GPIO_ACTIVE_LOW>; + }; + + led-11 { + function = LED_FUNCTION_DISK; + function-enumerator = <1>; + color = ; + gpios = <&gpio1 25 GPIO_ACTIVE_LOW>; + linux,default-trigger = "ata1"; + }; + + led_status_green: led-12 { + label = "green:status"; + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&gpio1 26 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&coherencyfab { + broken-idle; +}; + +ð1 { + pinctrl-0 = <&ge1_rgmii_pins>; + pinctrl-names = "default"; + status = "okay"; + phy-handle = <ðphy0>; + phy-connection-type = "rgmii-id"; +}; + +&i2c0 { + pinctrl-0 = <&i2c0_pins>; + pinctrl-names = "default"; + clock-frequency = <100000>; + status = "okay"; + + hwmon@2a { + compatible = "nuvoton,nct7802"; + reg = <0x2a>; + }; + + rtc@30 { + compatible = "sii,s35390a"; + reg = <0x30>; + }; +}; + +&mdio { + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + + ethphy0: ethernet-phy@0 { /* Marvell 88E1318 */ + reg = <0>; + #thermal-sensor-cells = <0>; + }; +}; + +&nand_controller { + status = "okay"; + + nand@0 { + reg = <0>; + label = "pxa3xx_nand-0"; + nand-rb = <0>; + marvell,nand-keep-config; + nand-on-flash-bbt; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "uboot"; + reg = <0x0000000 0x200000>; + read-only; + }; + + partition@200000 { + label = "certificate"; + reg = <0x0200000 0x100000>; + read-only; + }; + + partition@300000 { + label = "preset_cfg"; + reg = <0x0300000 0x100000>; + read-only; + }; + + partition@400000 { + label = "dev_params"; + reg = <0x0400000 0x100000>; + read-only; + }; + partition@500000 { + label = "active_bank"; + reg = <0x0500000 0x0100000>; + }; + + partition@600000 { + label = "magic"; + reg = <0x0600000 0x0100000>; + read-only; + }; + + partition@700000 { + label = "bank1"; + reg = <0x0700000 0x2800000>; + }; + + partition@2f00000 { + label = "bank2"; + reg = <0x2f00000 0x2800000>; + }; + + /* 0x5700000-0x5a00000 undefined in vendor firmware */ + + partition@5a00000 { + label = "reserved"; + reg = <0x5a00000 0x2000000>; + }; + + partition@7a00000 { + label = "ubi"; + reg = <0x7a00000 0x8600000>; + }; + }; + }; +}; + +&pciec { + status = "okay"; + + pcie@1,0 { + pinctrl-0 = <&pmx_pcie>; + pinctrl-names = "default"; + status = "okay"; + reset-gpios = <&gpio1 27 GPIO_ACTIVE_LOW>; + + /* -[0000:00]---01.0-[01]----00.0 */ + /* usbport trigger won't work */ + bridge@0,1 { + compatible = "pci11ab,6710"; + reg = <0x3800 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + + usb@1,0 { + /* Renesas uPD720202 */ + compatible = "pci1912,0015"; + reg = <0x1000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + + usb1_port: port@1 { + reg = <1>; + #trigger-source-cells = <1>; + }; + + usb2_port: port@2 { + reg = <2>; + #trigger-source-cells = <1>; + }; + }; + }; + }; +}; + +&pinctrl { + pmx_poweroff: pmx-poweroff { + marvell,pins = "mpp7"; + marvell,function = "gpo"; + }; + + pmx_power_cpu: pmx-power-cpu { + marvell,pins = "mpp4"; + marvell,function = "vdd"; + }; + + pmx_buttons: pmx-buttons { + marvell,pins = "mpp6", "mpp10", "mpp14", "mpp32"; + marvell,function = "gpio"; + }; + + pmx_leds1: pmx-leds1 { + marvell,pins = "mpp47"; + marvell,function = "gpo"; + }; + + pmx_leds2: pmx-leds2 { + marvell,pins = "mpp12", "mpp13", "mpp15", "mpp16", "mpp50", "mpp51", + "mpp52", "mpp53", "mpp55", "mpp56", "mpp57", "mpp58"; + marvell,function = "gpio"; + }; + + pmx_pcie: pmx-pcie { + marvell,pins = "mpp59"; + marvell,function = "gpio"; + }; + + /* this gpio is connected to the pin of buzzer + * leave it as is due lack of proper driver + */ + pmx_buzzer: pmx-buzzer { + marvell,pins = "mpp63"; + marvell,function = "gpio"; + }; +}; + +&pmsu { + pinctrl-0 = <&pmx_power_cpu>; + pinctrl-names = "default"; +}; + +&rtc { + status = "disabled"; +}; + +&sata { + nr-ports = <2>; + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + hdd0_temp: sata-port@0 { + reg = <0>; + #thermal-sensor-cells = <0>; + }; + + hdd1_temp: sata-port@1 { + reg = <1>; + #thermal-sensor-cells = <0>; + }; +}; + +&uart0 { + status = "okay"; +}; diff --git a/target/linux/mvebu/image/Makefile b/target/linux/mvebu/image/Makefile index 9220c6c9f1..44e66a5f87 100644 --- a/target/linux/mvebu/image/Makefile +++ b/target/linux/mvebu/image/Makefile @@ -51,6 +51,63 @@ define Build/buffalo-kernel-jffs2 rm -rf $(KDIR)/kernel_jffs2 $@.fakerd endef +# Some info about Ctera firmware: +# 1. It's simple tar file (GNU standard), but it must have ".firm" suffix. +# 2. It contains two images: kernel and romdisk. Both are required. +# 3. Every image has header and trailer file. +# 4. The struct of tar firmware is: header kernel trailer header romdisk trailer +# 5. In header file are some strings used to describe image. It was decoded from +# factory image. +# 6. Version format in header file is restricted by Original FW. +# 7. Trailer file contains MD5 sum string of header and image file. +# 8. Firmware file must have <=24MB size. + +define Build/ctera-firmware + mkdir -p $@.tmp + + # Prepare header and trailer file for kernel + echo "# CTera firmware information file" > $@.tmp/header + echo "image_type=kernel" >> $@.tmp/header + echo "arch=ARM" >> $@.tmp/header + echo "board=2Drive_A" >> $@.tmp/header + echo "version=5.5.165.61499" >> $@.tmp/header + echo "kernel_cmd=console=ttyS0,115200 earlycon" >> $@.tmp/header + echo "date=$$(date $(if $(SOURCE_DATE_EPOCH),-d@$(SOURCE_DATE_EPOCH)))" \ + >> $@.tmp/header + + cp $@ $@.tmp/kernel + + echo "MD5=$$(cat $@.tmp/header $@.tmp/kernel | $(MKHASH) md5)" \ + > $@.tmp/trailer + + tar $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \ + -H gnu -C $@.tmp -cf $@.tar header kernel trailer + + # Prepare header and trailer file for fake romdisk + echo "# CTera firmware information file" > $@.tmp/header + echo "image_type=romdisk" >> $@.tmp/header + echo "initrd=yes" >> $@.tmp/header + echo "arch=ARM" >> $@.tmp/header + echo "board=2Drive_A" >> $@.tmp/header + echo "version=5.5.165.61499" >> $@.tmp/header + echo "date=$$(date $(if $(SOURCE_DATE_EPOCH),-d@$(SOURCE_DATE_EPOCH)))" \ + >> $@.tmp/header + + rm -f $@ + touch $@ + $(call Build/append-uImage-fakehdr, ramdisk) + cp $@ $@.tmp/romdisk + + echo "MD5=$$(cat $@.tmp/header $@.tmp/romdisk | $(MKHASH) md5)" \ + > $@.tmp/trailer + + tar $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \ + -H gnu -C $@.tmp -rf $@.tar header romdisk trailer + + mv $@.tar $@ + rm -rf $@.tmp +endef + define Build/sdcard-img SIGNATURE="$(IMG_PART_SIGNATURE)" \ ./gen_mvebu_sdcard_img.sh $@ \ diff --git a/target/linux/mvebu/image/cortexa9.mk b/target/linux/mvebu/image/cortexa9.mk index 3f227259ee..06252670ab 100644 --- a/target/linux/mvebu/image/cortexa9.mk +++ b/target/linux/mvebu/image/cortexa9.mk @@ -31,6 +31,24 @@ define Device/buffalo_ls421de endef TARGET_DEVICES += buffalo_ls421de +define Device/ctera_c200-v2 + PAGESIZE := 2048 + SUBPAGESIZE := 512 + BLOCKSIZE := 128k + DEVICE_VENDOR := Ctera + DEVICE_MODEL := C200 + DEVICE_VARIANT := V2 + SOC := armada-370 + KERNEL := kernel-bin | append-dtb | uImage none | ctera-firmware + KERNEL_IN_UBI := + KERNEL_SUFFIX := -factory.firm + DEVICE_PACKAGES := \ + kmod-gpio-button-hotplug kmod-hwmon-drivetemp kmod-hwmon-nct7802 \ + kmod-rtc-s35390a kmod-usb3 kmod-usb-ledtrig-usbport + IMAGES := sysupgrade.bin +endef +TARGET_DEVICES += ctera_c200-v2 + define Device/cznic_turris-omnia DEVICE_VENDOR := CZ.NIC DEVICE_MODEL := Turris Omnia