[openwrt/openwrt] kirkwood: add support for ipTIME NAS1
LEDE Commits
lede-commits at lists.infradead.org
Sat Jan 29 06:51:26 PST 2022
mans0n pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/957f9adeb1f8ec5de8d73e183dec267dbc6dc8bb
commit 957f9adeb1f8ec5de8d73e183dec267dbc6dc8bb
Author: Sungbo Eo <mans0n at gorani.run>
AuthorDate: Sat Jan 1 21:00:36 2022 +0900
kirkwood: add support for ipTIME NAS1
ipTIME NAS1 is a 1-bay NAS, based on Marvell Kirkwood SoC.
Specifications:
* SoC: 88F6281
* RAM: 256 MiB
* Flash: SPI NOR 16 MiB
* SATA: 1x 3Gb/s
* Ethernet: 1x 1GbE
* USB: 1x 2.0
* Fan: 2 speed level
* UART: JP1 (115200 8N1)
* Pinout: [3V3] (TXD) (RXD) (GND)
Notes:
* There are several variants of the model name: "NAS-I", "NASI", "NAS1".
Here "NAS1" is adopted for consistent naming scheme.
* The reset button is also a USB copy button in stock FW,
but in this patch the former is the only default behavior.
Installation via web interface:
1. Flash sysupgrade image through the stock web interface.
Revert to stock firmware:
1. Perform sysupgrade with stock image.
Signed-off-by: Sungbo Eo <mans0n at gorani.run>
---
include/image-commands.mk | 5 +
.../kirkwood/base-files/etc/board.d/02_network | 5 +
.../base-files/lib/preinit/07_set_iface_mac | 4 +
.../kirkwood/base-files/lib/upgrade/platform.sh | 4 +
target/linux/kirkwood/config-5.10 | 6 +
.../files/arch/arm/boot/dts/kirkwood-nas1.dts | 231 +++++++++++++++++++++
target/linux/kirkwood/image/Makefile | 15 ++
7 files changed, 270 insertions(+)
diff --git a/include/image-commands.mk b/include/image-commands.mk
index 158af853a5..eda3fee94b 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -295,6 +295,11 @@ define Build/install-dtb
)
endef
+define Build/iptime-naspkg
+ $(STAGING_DIR_HOST)/bin/iptime-naspkg $(1) $@ $@.new
+ mv $@.new $@
+endef
+
define Build/jffs2
rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
diff --git a/target/linux/kirkwood/base-files/etc/board.d/02_network b/target/linux/kirkwood/base-files/etc/board.d/02_network
index 773730e642..df38694f40 100644
--- a/target/linux/kirkwood/base-files/etc/board.d/02_network
+++ b/target/linux/kirkwood/base-files/etc/board.d/02_network
@@ -22,6 +22,7 @@ kirkwood_setup_interfaces()
globalscale,sheevaplug|\
iom,iconnect-1.1|\
iom,ix2-200|\
+ iptime,nas1|\
netgear,readynas-duo-v2|\
raidsonic,ib-nas62x0|\
seagate,blackarmor-nas220|\
@@ -55,6 +56,10 @@ kirkwood_setup_macs()
local label_mac=""
case "$board" in
+ iptime,nas1)
+ lan_mac=$(mtd_get_mac_binary u-boot 0x3ffa8)
+ label_mac=$lan_mac
+ ;;
linksys,e4200-v2|\
linksys,ea3500|\
linksys,ea4500)
diff --git a/target/linux/kirkwood/base-files/lib/preinit/07_set_iface_mac b/target/linux/kirkwood/base-files/lib/preinit/07_set_iface_mac
index 2a52b7962f..393c540d97 100644
--- a/target/linux/kirkwood/base-files/lib/preinit/07_set_iface_mac
+++ b/target/linux/kirkwood/base-files/lib/preinit/07_set_iface_mac
@@ -27,6 +27,10 @@ preinit_set_mac_address() {
ip link set dev port3 address $(macaddr_add $mac 2) 2>/dev/null
ip link set dev port4 address $(macaddr_add $mac 3) 2>/dev/null
;;
+ iptime,nas1)
+ mac=$(mtd_get_mac_binary u-boot 0x3ffa8)
+ ip link set dev eth0 address $mac 2>/dev/null
+ ;;
esac
}
diff --git a/target/linux/kirkwood/base-files/lib/upgrade/platform.sh b/target/linux/kirkwood/base-files/lib/upgrade/platform.sh
index e2f6dec44a..9885bf7d31 100644
--- a/target/linux/kirkwood/base-files/lib/upgrade/platform.sh
+++ b/target/linux/kirkwood/base-files/lib/upgrade/platform.sh
@@ -1,6 +1,7 @@
RAMFS_COPY_BIN='fw_printenv fw_setenv strings'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
+PART_NAME=firmware
REQUIRE_IMAGE_METADATA=1
platform_check_image() {
@@ -33,6 +34,9 @@ platform_do_upgrade() {
return 1
fi
;;
+ iptime,nas1)
+ default_do_upgrade "$1"
+ ;;
linksys,e4200-v2|\
linksys,ea3500|\
linksys,ea4500)
diff --git a/target/linux/kirkwood/config-5.10 b/target/linux/kirkwood/config-5.10
index f80a7d8f20..ae9c3b0999 100644
--- a/target/linux/kirkwood/config-5.10
+++ b/target/linux/kirkwood/config-5.10
@@ -122,6 +122,7 @@ CONFIG_HARDIRQS_SW_RESEND=y
CONFIG_HAS_DMA=y
CONFIG_HAS_IOMEM=y
CONFIG_HAS_IOPORT_MAP=y
+CONFIG_HWMON=y
CONFIG_HW_RANDOM=y
CONFIG_HW_RANDOM_OMAP=y
CONFIG_HZ_FIXED=0
@@ -163,6 +164,9 @@ CONFIG_MTD_NAND_ECC_SW_HAMMING=y
# CONFIG_MTD_NAND_MARVELL is not set
CONFIG_MTD_NAND_ORION=y
CONFIG_MTD_RAW_NAND=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
+CONFIG_MTD_SPLIT_UIMAGE_FW=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_BEB_LIMIT=20
CONFIG_MTD_UBI_BLOCK=y
@@ -248,6 +252,7 @@ CONFIG_SPARSE_IRQ=y
CONFIG_SPI=y
# CONFIG_SPI_ARMADA_3700 is not set
CONFIG_SPI_MASTER=y
+CONFIG_SPI_MEM=y
CONFIG_SPI_ORION=y
CONFIG_SPLIT_PTLOCK_CPUS=999999
CONFIG_SRAM=y
@@ -259,6 +264,7 @@ CONFIG_THERMAL=y
CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
CONFIG_THERMAL_GOV_STEP_WISE=y
+CONFIG_THERMAL_HWMON=y
CONFIG_THERMAL_OF=y
CONFIG_TICK_CPU_ACCOUNTING=y
CONFIG_TIMER_OF=y
diff --git a/target/linux/kirkwood/files/arch/arm/boot/dts/kirkwood-nas1.dts b/target/linux/kirkwood/files/arch/arm/boot/dts/kirkwood-nas1.dts
new file mode 100644
index 0000000000..a8d86406b5
--- /dev/null
+++ b/target/linux/kirkwood/files/arch/arm/boot/dts/kirkwood-nas1.dts
@@ -0,0 +1,231 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6281.dtsi"
+
+/ {
+ model = "ipTIME NAS1";
+ compatible = "iptime,nas1", "marvell,kirkwood-88f6281", "marvell,kirkwood";
+
+ aliases {
+ serial0 = &uart0;
+ led-boot = &led_ready;
+ led-failsafe = &led_ready;
+ led-running = &led_ready;
+ led-upgrade = &led_ready;
+ };
+
+ chosen {
+ /*
+ * "root" argument from the stock bootloader should be ignored
+ * as it'll prevent the kernel from finding the correct rootfs.
+ */
+ bootargs-append = " console=ttyS0,115200 root=";
+ stdout-path = "serial0:115200n8";
+ };
+
+ memory at 0 {
+ device_type = "memory";
+ reg = <0x00000000 0x10000000>;
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ pinctrl-0 = <&pmx_led>;
+ pinctrl-names = "default";
+
+ hdd {
+ label = "blue:hdd";
+ gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "ata1";
+ };
+
+ usb {
+ label = "blue:usb";
+ gpios = <&gpio1 13 GPIO_ACTIVE_LOW>;
+ trigger-sources = <&ehci_port1>;
+ linux,default-trigger = "usbport";
+ };
+
+ led_ready: ready {
+ label = "blue:ready";
+ gpios = <&gpio1 14 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+
+ pinctrl-0 = <&pmx_button>;
+ pinctrl-names = "default";
+
+ reset-copy {
+ label = "Reset/Copy Button";
+ linux,code = <KEY_RESTART>;
+ gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
+ };
+
+ power {
+ label = "Power Button";
+ linux,code = <KEY_POWER>;
+ gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>;
+ };
+ };
+
+ gpio-fan {
+ compatible = "gpio-fan";
+
+ pinctrl-0 = <&pmx_fan>;
+ pinctrl-names = "default";
+ gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>,
+ <&gpio1 10 GPIO_ACTIVE_HIGH>;
+ /* We don't know the exact rpm, just use dummy values here. */
+ gpio-fan,speed-map = <0 0>, <1 1>, <2 2>;
+ #cooling-cells = <2>;
+ };
+
+ gpio-poweroff {
+ compatible = "gpio-poweroff";
+ gpios = <&pca9536 0 GPIO_ACTIVE_LOW>;
+ };
+
+ regulators {
+ compatible = "simple-bus";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pinctrl-0 = <&pmx_usb_vbus>;
+ pinctrl-names = "default";
+
+ regulator at 1 {
+ compatible = "regulator-fixed";
+ reg = <1>;
+ regulator-name = "USB Power";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ enable-active-high;
+ regulator-always-on;
+ gpio = <&gpio1 11 GPIO_ACTIVE_HIGH>;
+ };
+ };
+};
+
+&pinctrl {
+ pmx_led: pmx-led {
+ marvell,pins = "mpp35", "mpp45", "mpp46";
+ marvell,function = "gpio";
+ };
+
+ pmx_fan: pmx-fan {
+ marvell,pins = "mpp41", "mpp42";
+ marvell,function = "gpio";
+ };
+
+ pmx_usb_vbus: pmx-usb-vbus {
+ marvell,pins = "mpp43";
+ marvell,function = "gpio";
+ };
+
+ pmx_button: pmx-button {
+ marvell,pins = "mpp44", "mpp48";
+ marvell,function = "gpio";
+ };
+};
+
+&spi0 {
+ status = "okay";
+
+ flash at 0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <20000000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition at 0 {
+ label = "u-boot";
+ reg = <0x0 0x40000>;
+ read-only;
+ };
+
+ partition at 40000 {
+ compatible = "openwrt,uimage", "denx,uimage";
+ openwrt,offset = <0x400>;
+ label = "firmware";
+ reg = <0x40000 0xf80000>;
+ };
+
+ partition at fc0000 {
+ label = "config";
+ reg = <0xfc0000 0x40000>;
+ read-only;
+ };
+ };
+ };
+};
+
+&rtc {
+ status = "disabled";
+};
+
+&i2c0 {
+ status = "okay";
+
+ pca9536: gpio at 41 {
+ compatible = "nxp,pca9536";
+ reg = <0x41>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&usb0 {
+ status = "okay";
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ehci_port1: port at 1 {
+ reg = <1>;
+ #trigger-source-cells = <0>;
+ };
+};
+
+&mdio {
+ status = "okay";
+
+ ethphyb: ethernet-phy at b {
+ reg = <0x0b>;
+ };
+};
+
+ð1 {
+ status = "okay";
+};
+
+ð1port {
+ phy-handle = <ðphyb>;
+ phy-connection-type = "rgmii-id";
+};
+
+&sata {
+ status = "okay";
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+ nr-ports = <1>;
+
+ sata-port at 0 {
+ reg = <0>;
+ #thermal-sensor-cells = <0>;
+ };
+};
diff --git a/target/linux/kirkwood/image/Makefile b/target/linux/kirkwood/image/Makefile
index 4a2ca8d68e..60e8654ad3 100644
--- a/target/linux/kirkwood/image/Makefile
+++ b/target/linux/kirkwood/image/Makefile
@@ -184,6 +184,21 @@ define Device/iom_ix2-200
endef
TARGET_DEVICES += iom_ix2-200
+define Device/iptime_nas1
+ DEVICE_VENDOR := ipTIME
+ DEVICE_MODEL := NAS1
+ DEVICE_PACKAGES := kmod-ata-marvell-sata kmod-fs-ext4 \
+ kmod-gpio-button-hotplug kmod-gpio-pca953x kmod-hwmon-drivetemp \
+ kmod-hwmon-gpiofan kmod-usb-ledtrig-usbport -uboot-envtools
+ KERNEL := $$(KERNEL) | iptime-naspkg nas1
+ BLOCKSIZE := 256k
+ IMAGE_SIZE := 15872k
+ IMAGES := sysupgrade.bin
+ IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \
+ check-size | append-metadata
+endef
+TARGET_DEVICES += iptime_nas1
+
define Device/linksys
DEVICE_VENDOR := Linksys
DEVICE_PACKAGES := kmod-mwl8k wpad-basic-wolfssl kmod-gpio-button-hotplug
More information about the lede-commits
mailing list