mvebu: add support for Buffalo LinkStation LS220DE
authorDaniel González Cabanelas <dgcbueu@gmail.com>
Mon, 20 Feb 2023 23:43:55 +0000 (00:43 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 26 Feb 2023 21:22:48 +0000 (22:22 +0100)
The Buffalo LinkStation LS220DE is a dual bay NAS, based on Marvell
Armada 370

Hardware:
   SoC:         Marvell Armada 88F6707
   CPU:         Cortex-A9 800 MHz, 1 core
   Flash 1:     SPI-NOR 1 MiB (U-Boot)
   Flash 2:     NAND 512 MiB (OS)
   RAM:         DDR3 256 MiB
   Ethernet:    1x 1GbE
   USB:         1x 2.0
   SATA:        2x 3Gb/s
   LEDs/Input:  5x / 2x (1x button, 1x slide-switch)
   Fan:         1x casing

Flash instructions, from hard drive:
  1. Get access to the "boot" partition at the hard drive where the stock
     firmware is installed. It can be done with acp-commander or by
     plugging the hard drive to a computer.
  2. Backup the stock uImage:
         mv /boot/uImage.buffalo /boot/uImage.buffalo.bak
  3. Move and rename the Openwrt initramfs image to the boot partition:
         mv openwrt-initramfs-kernel.bin /boot/uImage.buffalo
  4. Power on the Linkstation with the hardrive inside. Now Openwrt will
     boot, but still not installed.
  5. Connect via ssh to OpenWrt:
         ssh root@192.168.1.1
  6. Rename boot files inside boot partition
         mount -t ext3 /dev/sda1 /mnt
         mv /mnt/uImage.buffalo /mnt/uImage.buffalo.openwrt.bak
         mv /mnt/initrd.buffalo /mnt/initrd.buffalo.bak
  7. Format ubi partitions at the NAND flash ("kernel_ubi" and "ubi"):
         ubiformat /dev/mtd0 -y
         ubidetach -p /dev/mtd1
         ubiformat /dev/mtd1 -y
  8. Flash the sysupgrade image:
         sysupgrade -n openwrt-squashfs-sysupgrade.bin
  9. Wait until it finish, the device will reboot with OpenWrt installed
     on the NAND flash.

Restore the stock firmware:
  1. Take the hard drive used for the installation and restore boot backup
     files to their original names:
         mount -t ext3 /dev/sda1 /mnt
         mv /mnt/uImage.buffalo.bak /mnt/uImage.buffalo
         mv /mnt/initrd.buffalo.bak /mnt/initrd.buffalo
  2. Boot from the hard drive and perform a stock firmware update using
     the Buffalo utility. The NAND will be restored to the original
     state.

Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
package/boot/uboot-envtools/files/mvebu
target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network
target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh
target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-ls220de.dts [new file with mode: 0644]
target/linux/mvebu/image/Makefile
target/linux/mvebu/image/cortexa9.mk
target/linux/mvebu/patches-5.15/105-power-reset-linkstation-poweroff-add-ls220de.patch [new file with mode: 0644]

index cc1c648f246a5c39cad9fe94056bc8d1ba59604d..63b5132608a694d1da0b7277ce1d8505c0d2b27b 100644 (file)
@@ -13,6 +13,7 @@ touch /etc/config/ubootenv
 board=$(board_name)
 
 case "$board" in
+buffalo,ls220de|\
 buffalo,ls421de)
        ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000"
        ;;
index c613a3cd603ec8c3d1de92471676cde6aa88e79f..d2229fe6bfbc329dde7c22700c5f489a205c1ecf 100644 (file)
@@ -61,6 +61,7 @@ mvebu_setup_macs()
        local label_mac=""
 
        case "$board" in
+       buffalo,ls220de|\
        buffalo,ls421de)
                lan_mac=$(mtd_get_mac_ascii u-boot-env eth1addr)
                ;;
index 18b978d43705ceb3059e962930364ded1dee5314..9019c1aeff5c1fa6ff14d5d4a70551194dbdc69d 100755 (executable)
@@ -25,6 +25,13 @@ platform_check_image() {
 
 platform_do_upgrade() {
        case "$(board_name)" in
+       buffalo,ls220de)
+               # Kernel UBI volume name must be "boot"
+               CI_KERNPART=boot
+               CI_KERN_UBIPART=ubi_kernel
+               CI_ROOT_UBIPART=ubi
+               nand_do_upgrade "$1"
+               ;;
        buffalo,ls421de)
                nand_do_upgrade "$1"
                ;;
diff --git a/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-ls220de.dts b/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-ls220de.dts
new file mode 100644 (file)
index 0000000..3de9ac5
--- /dev/null
@@ -0,0 +1,380 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT)
+/*
+ * Device Tree file for Buffalo LinkStation LS220DE
+ *
+ * Copyright (C) 2023 Daniel González Cabanelas <dgcbueu@gmail.com>
+ */
+
+/dts-v1/;
+
+#include "armada-370.dtsi"
+#include "mvebu-linkstation-fan.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+       model = "Buffalo LinkStation LS220DE";
+       compatible = "buffalo,ls220de", "marvell,armada370", "marvell,armada-370-xp";
+
+       aliases {
+               led-boot = &led_boot;
+               led-failsafe = &led_failsafe;
+               led-running = &led_power;
+               led-upgrade = &led_upgrade;
+       };
+
+       chosen {
+               bootargs = "earlycon";
+               stdout-path = "serial0:115200n8";
+               append-rootblock = "nullparameter="; /* override the bootloader args */
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x00000000 0x10000000>; /* 256 MB */
+       };
+
+       soc {
+               ranges = <MBUS_ID(0xf0, 0x01) 0 0xd0000000 0x100000
+                         MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000
+                         MBUS_ID(0x09, 0x01) 0 0xf1100000 0x10000>;
+       };
+
+       system_fan: gpio_fan {
+               gpios = <&gpio0 13 GPIO_ACTIVE_HIGH
+                        &gpio0 14 GPIO_ACTIVE_HIGH>;
+               alarm-gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
+
+               #cooling-cells = <2>;
+       };
+
+       thermal-zones {
+               hdd-thermal {
+                       polling-delay = <20000>;
+                       polling-delay-passive = <2000>;
+
+                       thermal-sensors = <&hdd0_temp>; /* only one drivetemp sensor is supported */
+
+                       trips {
+                               hdd_alert1: trip1 {
+                                       temperature = <34000>;
+                                       hysteresis = <2000>;
+                                       type = "active";
+                               };
+                               hdd_alert2: trip2 {
+                                       temperature = <40000>;
+                                       hysteresis = <2000>;
+                                       type = "active";
+                               };
+                               hdd_alert3: trip3 {
+                                       temperature = <45000>;
+                                       hysteresis = <2000>;
+                                       type = "passive";
+                               };
+                               hdd_hot {
+                                       temperature = <50000>;
+                                       hysteresis = <2000>;
+                                       type = "hot";
+                               };
+                               hdd_crit {
+                                       temperature = <60000>;
+                                       hysteresis = <2000>;
+                                       type = "critical";
+                               };
+                       };
+
+                       cooling-maps {
+                               map1 {
+                                       trip = <&hdd_alert1>;
+                                       cooling-device = <&system_fan THERMAL_NO_LIMIT 1>;
+                               };
+                               map2 {
+                                       trip = <&hdd_alert2>;
+                                       cooling-device = <&system_fan 2 2>;
+                               };
+                               map3 {
+                                       trip = <&hdd_alert3>;
+                                       cooling-device = <&system_fan 3 THERMAL_NO_LIMIT>;
+                               };
+                       };
+               };
+       };
+
+       gpio_keys {
+               compatible = "gpio-keys";
+               pinctrl-0 = <&pmx_buttons>;
+               pinctrl-names = "default";
+
+               power {
+                       label = "Power Switch";
+                       linux,code = <KEY_POWER>;
+                       linux,input-type = <EV_SW>;
+                       gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
+               };
+
+               function {
+                       label = "Function Button";
+                       linux,code = <KEY_CONFIG>;
+                       gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       gpio_leds {
+               compatible = "gpio-leds";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pmx_leds1 &pmx_leds2>;
+
+               indicator_red {
+                       function = LED_FUNCTION_INDICATOR;
+                       color = <LED_COLOR_ID_RED>;
+                       gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
+                       panic-indicator;
+               };
+
+               led_power: power_white {
+                       label = "white:power";
+                       function = LED_FUNCTION_POWER;
+                       color = <LED_COLOR_ID_WHITE>;
+                       gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
+                       default-state = "on";
+               };
+
+               led_failsafe: power_red {
+                       label = "red:power";
+                       function = LED_FUNCTION_POWER;
+                       color = <LED_COLOR_ID_RED>;
+                       gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_upgrade: power_orange {
+                       label = "amber:power";
+                       function = LED_FUNCTION_POWER;
+                       color = <LED_COLOR_ID_AMBER>;
+                       gpios = <&gpio1 25 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_boot: indicator_white {
+                       label = "white:indicator";
+                       function = LED_FUNCTION_INDICATOR;
+                       color = <LED_COLOR_ID_WHITE>;
+                       gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>;
+               };
+
+               hdd1_red {
+                       function = LED_FUNCTION_DISK;
+                       color = <LED_COLOR_ID_RED>;
+                       gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "ata1";
+                       function-enumerator = <1>;
+               };
+
+               hdd2_red {
+                       function = LED_FUNCTION_DISK;
+                       color = <LED_COLOR_ID_RED>;
+                       gpios = <&gpio1 30 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "ata2";
+                       function-enumerator = <2>;
+               };
+       };
+
+       regulators {
+               compatible = "simple-bus";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               pinctrl-0 = <&pmx_power_hdd1 &pmx_power_hdd2>;
+               pinctrl-names = "default";
+
+               sata1_power: regulator@1 {
+                       compatible = "regulator-fixed";
+                       reg = <1>;
+                       regulator-name = "HDD1";
+                       regulator-min-microvolt = <12000000>;
+                       regulator-max-microvolt = <12000000>;
+                       startup-delay-us = <2000000>;
+                       enable-active-high;
+                       regulator-always-on;
+                       regulator-boot-on;
+                       gpio = <&gpio0 8 GPIO_ACTIVE_HIGH>;
+               };
+
+               sata2_power: regulator@2 {
+                       compatible = "regulator-fixed";
+                       reg = <2>;
+                       regulator-name = "HDD2";
+                       regulator-min-microvolt = <12000000>;
+                       regulator-max-microvolt = <12000000>;
+                       startup-delay-us = <4000000>;
+                       enable-active-high;
+                       regulator-always-on;
+                       regulator-boot-on;
+                       gpio = <&gpio0 2 GPIO_ACTIVE_HIGH>;
+               };
+       };
+};
+
+&coherencyfab {
+       broken-idle;
+};
+
+&eth1 {
+       pinctrl-0 = <&ge1_rgmii_pins>;
+       pinctrl-names = "default";
+       status = "okay";
+       phy-handle = <&ethphy0>;
+       phy-connection-type = "rgmii-id";
+};
+
+&mdio {
+       pinctrl-0 = <&mdio_pins>;
+       pinctrl-names = "default";
+
+       ethphy0: ethernet-phy@0 { /* Marvell 88E1318 */
+               reg = <0>;
+               marvell,reg-init = <0x3 0x10 0xf000 0x091A>, /* LED function */
+                                  <0x3 0x11 0x0000 0x4401>, /* LED polarity */
+                                  <0x3 0x12 0x0000 0x4905>; /* LED timer */
+               #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 = "ubi_kernel";
+                               reg = <0x00000000 0x02000000>; /* 32 MiB */
+                       };
+
+                       partition@2000000 {
+                               label = "ubi";
+                               reg = <0x02000000 0x1df00000>; /* 479 MiB */
+                       };
+               };
+       };
+};
+
+&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>;
+       };
+};
+
+&spi0 {
+       status = "okay";
+       pinctrl-0 = <&spi0_pins2>;
+       pinctrl-names = "default";
+
+       spi-flash@0 {
+               compatible = "mxicy,mx25l8005", "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <50000000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               reg = <0x00000 0xf0000>; /* 960 KiB*/
+                               label = "u-boot";
+                               read-only;
+                       };
+                       partition@f0000 {
+                               reg = <0xf0000 0x10000>; /* 64 KiB */
+                               label = "u-boot-env";
+                       };
+               };
+       };
+};
+
+&pmsu {
+       pinctrl-0 = <&pmx_power_cpu>;
+       pinctrl-names = "default";
+};
+
+&uart0 {
+       status = "okay";
+};
+
+&usb0 {
+       status = "okay";
+};
+
+&pinctrl {
+       pmx_power_hdd2: pmx-power-hdd2 {
+               marvell,pins = "mpp2";
+               marvell,function = "gpio";
+       };
+
+       pmx_power_cpu: pmx-power-cpu {
+               marvell,pins = "mpp4";
+               marvell,function = "vdd";
+       };
+
+       pmx_power_hdd1: pmx-power-hdd1 {
+               marvell,pins = "mpp8";
+               marvell,function = "gpio";
+       };
+
+       pmx_fan_lock: pmx-fan-lock {
+               marvell,pins = "mpp10";
+               marvell,function = "gpio";
+       };
+
+       pmx_hdd_present: pmx-hdd-present {
+               marvell,pins = "mpp11", "mpp12";
+               marvell,function = "gpio";
+       };
+
+       pmx_fan_high: pmx-fan-high {
+               marvell,pins = "mpp13";
+               marvell,function = "gpio";
+       };
+
+       pmx_fan_low: pmx-fan-low {
+               marvell,pins = "mpp14";
+               marvell,function = "gpio";
+       };
+
+       pmx_buttons: pmx-buttons {
+               marvell,pins = "mpp15", "mpp16";
+               marvell,function = "gpio";
+       };
+
+       pmx_leds1: pmx-leds {
+               marvell,pins = "mpp7", "mpp54", "mpp59", "mpp61";
+               marvell,function = "gpo";
+       };
+
+       pmx_leds2: pmx-leds {
+               marvell,pins = "mpp55", "mpp57", "mpp62";
+               marvell,function = "gpio";
+       };
+};
index b0498d34c9320cd27857d4434583409453550d73..57129d2dcb89130862fdebb2706dc5fa7661b4c9 100644 (file)
@@ -53,6 +53,16 @@ define Build/buffalo-kernel-jffs2
        rm -rf $(KDIR)/kernel_jffs2 $@.fakerd
 endef
 
+define Build/buffalo-kernel-ubifs
+       rm -rf $@-ubidir
+       mkdir -p $@-ubidir
+       mv $@ $@-ubidir/uImage.buffalo
+       touch $@
+       $(call Build/append-uImage-fakehdr, ramdisk)
+       mv $@ $@-ubidir/initrd.buffalo
+       $(STAGING_DIR_HOST)/bin/mkfs.ubifs $(KERNEL_UBIFS_OPTS) -r $@-ubidir $@
+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.
index aed1d476464cf497a7b1da46ed899391b4428c8d..56381ab5f85e5813afa8a886eff5e8aa24b22420 100644 (file)
@@ -14,6 +14,21 @@ define Device/kernel-size-migration
        Upgrade via sysupgrade mechanism is not possible, so new installation via factory style image is required.
 endef
 
+define Device/buffalo_ls220de
+  $(Device/NAND-128K)
+  DEVICE_VENDOR := Buffalo
+  DEVICE_MODEL := LinkStation LS220DE
+  KERNEL_UBIFS_OPTS = -m $$(PAGESIZE) -e 124KiB -c 172 -x none
+  KERNEL := kernel-bin | append-dtb | uImage none | buffalo-kernel-ubifs
+  KERNEL_INITRAMFS := kernel-bin | append-dtb | uImage none
+  DEVICE_DTS := armada-370-buffalo-ls220de
+  DEVICE_PACKAGES :=  \
+    kmod-hwmon-gpiofan kmod-hwmon-drivetemp kmod-linkstation-poweroff \
+    kmod-md-mod kmod-md-raid0 kmod-md-raid1 kmod-md-raid10 kmod-fs-xfs \
+    mdadm mkf2fs e2fsprogs partx-utils
+endef
+TARGET_DEVICES += buffalo_ls220de
+
 define Device/buffalo_ls421de
   $(Device/NAND-128K)
   DEVICE_VENDOR := Buffalo
diff --git a/target/linux/mvebu/patches-5.15/105-power-reset-linkstation-poweroff-add-ls220de.patch b/target/linux/mvebu/patches-5.15/105-power-reset-linkstation-poweroff-add-ls220de.patch
new file mode 100644 (file)
index 0000000..3223861
--- /dev/null
@@ -0,0 +1,15 @@
+--- a/drivers/power/reset/linkstation-poweroff.c
++++ b/drivers/power/reset/linkstation-poweroff.c
+@@ -142,6 +142,12 @@ static void linkstation_poweroff(void)
+ }
+ static const struct of_device_id ls_poweroff_of_match[] = {
++      { .compatible = "buffalo,ls220d",
++        .data = &linkstation_power_off_cfg,
++      },
++      { .compatible = "buffalo,ls220de",
++        .data = &linkstation_power_off_cfg,
++      },
+       { .compatible = "buffalo,ls421d",
+         .data = &linkstation_power_off_cfg,
+       },