[OpenWrt-Devel,2/3] mvebu: add support for BUFFALO LS42x

Message ID 20150714214825.GA12854@makrotopia.org
State Deferred
Headers show

Commit Message

Daniel Golle July 14, 2015, 9:48 p.m.
This adds support for the BUFFALO LinkStation LS421DE aka. LS-M 88f6710
aka. Yanagi, a dual-bay SATA-II gigE NAS box featuring the Marvell
Armada-370 88F6710 SoC. It comes with 512 MB NAND flash, a tiny 1 MB
SPI NOR flash for U-Boot and 512 MB DDR SDRAM. It got an on-board
USB 3.0 host controller wired to a USB 3.0 socket at the front as
well as the in-SoC USB 2.0 host wired to a port on the back of the
device.
Still missing/not working:
 * poweroff/reset
 * Wake-on-LAN
 * easy and non-intrusive way to flash via factory ROM

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 target/linux/mvebu/base-files/etc/diag.sh          |   3 +
 target/linux/mvebu/base-files/lib/mvebu.sh         |   3 +
 .../arm/boot/dts/armada-370-buffalo-yanagi.dts     | 383 +++++++++++++++++++++
 target/linux/mvebu/image/Makefile                  |   1 +
 .../patches-4.0/006-build_buffalo_yanagi_dts.patch |  14 +
 target/linux/mvebu/profiles/buffalo.mk             |  23 ++
 6 files changed, 427 insertions(+)
 create mode 100644 target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-yanagi.dts
 create mode 100644 target/linux/mvebu/patches-4.0/006-build_buffalo_yanagi_dts.patch
 create mode 100644 target/linux/mvebu/profiles/buffalo.mk

Patch

diff --git a/target/linux/mvebu/base-files/etc/diag.sh b/target/linux/mvebu/base-files/etc/diag.sh
index 6534ac3..53c45a3 100644
--- a/target/linux/mvebu/base-files/etc/diag.sh
+++ b/target/linux/mvebu/base-files/etc/diag.sh
@@ -9,6 +9,9 @@  get_status_led() {
 	armada-xp-linksys-mamba)
 		status_led="mamba:white:power"
 		;;
+	armada-370-buffalo-yanagi)
+		status_led="yanagi:white:power"
+		;;
 	esac
 }
 
diff --git a/target/linux/mvebu/base-files/lib/mvebu.sh b/target/linux/mvebu/base-files/lib/mvebu.sh
index 3edfa6b..1c6b0fa 100755
--- a/target/linux/mvebu/base-files/lib/mvebu.sh
+++ b/target/linux/mvebu/base-files/lib/mvebu.sh
@@ -19,6 +19,9 @@  mvebu_board_detect() {
 	*"Globalscale Mirabox")
 		name="mirabox"
 		;;
+	*"BUFFALO LS42x")
+		name="armada-370-buffalo-yanagi"
+		;;
 	*"Marvell Armada 370 Reference Design")
 		name="armada-370-rd"
 		;;
diff --git a/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-yanagi.dts b/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-yanagi.dts
new file mode 100644
index 0000000..16f5a8f
--- /dev/null
+++ b/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-yanagi.dts
@@ -0,0 +1,383 @@ 
+/*
+ * Device Tree file for BUFFALO YANAGI board found in LinkStation LS42x
+ *  all information found via visual inspection of the board and wild
+ *  guessing/probing.
+ *
+ * Copyright (C) 2015, Daniel Golle <daniel@makrotopia.org>
+ * Copyright (C) 2013, Arnaud EBALARD <arno@natisbad.org>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ *     This file is distributed in the hope that it will be useful
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+#include "armada-370.dtsi"
+
+/ {
+	model = "BUFFALO LS42x"; /* Buffalo LS-M 88f6710 */
+	/* based on DB-88F6710-BP-DDR3 reference design */
+
+	compatible = "buffalo,yanagi", "buffalo,ls42x", "marvell,armada370", "marvell,armada-370-xp";
+	chosen {
+		bootargs = "console=ttyS0,115200 earlyprintk";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>; /* 512 MB */
+	};
+
+	soc {
+		ranges = <MBUS_ID(0xf0, 0x01) 0 0xd0000000 0x100000
+			  MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000>;
+
+		pcie-controller {
+			status = "okay";
+
+			/* Connected to Renesas uPD720202 USB 3.0 Host */
+			pcie@1,0 {
+				/* Port 0, Lane 0 */
+				status = "okay";
+			};
+
+			/* unpopulated miniPCIe slot */
+			pcie@2,0 {
+				/* Port 1, Lane 0 */
+				status = "disabled";
+			};
+		};
+
+		internal-regs {
+			rtc@10300 {
+				status = "disabled";
+			};
+
+			/* serial console */
+			serial@12000 {
+				status = "okay";
+			};
+
+			/* SATA interfaces */
+			sata@a0000 {
+				nr-ports = <2>;
+				status = "okay";
+			};
+
+			mdio {
+				pinctrl-0 = <&mdio_pins>;
+				pinctrl-names = "default";
+				phy0: ethernet-phy@0 { /* Marvell 88E1518 */
+					reg = <0>;
+				};
+			};
+
+			ethernet@74000 {
+				pinctrl-0 = <&ge1_rgmii_pins>;
+				pinctrl-names = "default";
+				status = "okay";
+				phy = <&phy0>;
+				phy-mode = "rgmii-id";
+			};
+
+			usb@50000 {
+				vcc-supply = <&usb_v5_regulator>;
+				status = "okay";
+			};
+
+			spi0: spi@10600 {
+				pinctrl-0 = <&spi0_pins2>;
+				pinctrl-names = "default";
+				status = "okay";
+
+				spi-flash@0 {
+					#address-cells = <1>;
+					#size-cells = <1>;
+					compatible = "mx25l8005";
+					reg = <0>; /* Chip select 0 */
+					spi-max-frequency = <50000000>;
+
+					partition@0 {
+						reg = <0x00000 0xf0000>;
+						label = "u-boot";
+						read-only;
+					};
+
+					partition@1 {
+						reg = <0xf0000 0x10000>;
+						label = "u-boot-env";
+					};
+				};
+			};
+
+			i2c@11000 {
+				compatible = "marvell,mv64xxx-i2c";
+				clock-frequency = <100000>;
+				status = "okay";
+
+				rs5c372a: rs5c372a@32 {
+					compatible = "ricoh,rs5c372a";
+					reg = <0x32>;
+				};
+			};
+
+			system-controller@18200 {
+				compatible = "marvell,armada-370-buffalo-system-controller";
+				reg = <0x18200 0x100>;
+			};
+
+			nand@d0000 {
+				status = "okay";
+				num-cs = <1>;
+				marvell,nand-keep-config;
+				marvell,nand-enable-arbiter;
+				nand-on-flash-bbt;
+
+				/* Use Hardware BCH ECC */
+				nand-ecc-strength = <4>;
+				nand-ecc-step-size = <512>;
+
+				partition@0 {
+					label = "boot";
+					reg = <0x00000000 0x02000000>;  /* 32MB */
+				};
+
+				partition@1 {
+					label = "rootfs";
+					reg = <0x02000000 0x1e000000>;  /* 480MB */
+				};
+			};
+
+			gpio_leds {
+				compatible = "gpio-leds";
+				pinctrl-names = "default";
+				pinctrl-0 = <&power_led_pins &power_led_pins2
+					     &system_led_pins &ata1_led_pins
+					     &ata2_led_pins>;
+
+				white-power-led {
+					label = "yanagi:white:power";
+					gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
+					default-state = "keep";
+				};
+
+				red-power-led {
+					label = "yanagi:red:power";
+					gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>;
+					default-state = "keep";
+				};
+
+				orange-power-led {
+					label = "yanagi:organge:power";
+					gpios = <&gpio1 25 GPIO_ACTIVE_HIGH>;
+					default-state = "keep";
+				};
+
+				white-system-led {
+					label = "yanagi:white:system";
+					gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>;
+					default-state = "keep";
+				};
+
+				red-system-led {
+					label = "yanagi:red:system";
+					gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
+					default-state = "keep";
+				};
+
+				red-ata1-led {
+					label = "yanagi:red:ata1";
+					gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>;
+					default-state = "keep";
+					linux,default-trigger = "ata1";
+				};
+
+				red-ata2-led {
+					label = "yanagi:red:ata2";
+					gpios = <&gpio1 30 GPIO_ACTIVE_HIGH>;
+					default-state = "keep";
+					linux,default-trigger = "ata2";
+				};
+			};
+
+			gpio_keys {
+				compatible = "gpio-keys";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				pinctrl-0 = <&keys_pins>;
+				pinctrl-names = "default";
+
+				power-switch {
+					label = "Power Switch";
+					linux,code = <KEY_POWER>;
+					linux,input-type = <5>;
+					gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
+				};
+
+				otb {
+					label = "OTB";
+					linux,code = <KEY_COPY>;
+					gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
+				};
+			};
+
+			gpio_fan {
+				compatible = "gpio-fan";
+				pinctrl-0 = <&fan_pins>;
+				pinctrl-names = "default";
+				gpios = <&gpio0 13 GPIO_ACTIVE_HIGH
+					 &gpio0 14 GPIO_ACTIVE_HIGH>;
+				gpio-fan,speed-map = <0    3
+						      2000 2
+						      4000 1
+						      6000 0>;
+			};
+
+			restart_poweroff {
+				compatible = "restart-poweroff";
+			};
+		};
+
+		regulators {
+			compatible = "simple-bus";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			pinctrl-0 = <&ata1_power_pin
+				     &ata2_power_pin
+				     &usb_power_pin>;
+			pinctrl-names = "default";
+
+			ata1_regulator: ata1-regulator {
+				compatible = "regulator-fixed";
+				reg = <1>;
+				regulator-name = "ATA1";
+				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>;
+			};
+
+			ata2_regulator: ata2-regulator {
+				compatible = "regulator-fixed";
+				reg = <2>;
+				regulator-name = "ATA2";
+				regulator-min-microvolt = <12000000>;
+				regulator-max-microvolt = <12000000>;
+				startup-delay-us = <4000000>;
+				enable-active-high;
+				regulator-always-on;
+				regulator-boot-on;
+				gpio = <&gpio0 9 GPIO_ACTIVE_HIGH>;
+			};
+
+			usb_v5_regulator: usb-v5-regulator {
+				compatible = "regulator-fixed";
+				regulator-name = "USB";
+				regulator-min-microvolt = <5000000>;
+				regulator-max-microvolt = <5000000>;
+				startup-delay-us = <4000000>;
+				enable-active-high;
+				regulator-always-on;
+				regulator-boot-on;
+				gpio = <&gpio0 5 GPIO_ACTIVE_HIGH>;
+			};
+		};
+	};
+};
+
+&pinctrl {
+	fan_pins: fan-pins {
+		marvell,pins = "mpp13", "mpp14";
+		marvell,function = "gpio";
+	};
+
+	keys_pins: keys-pins {
+		marvell,pins = "mpp15", "mpp16";
+		marvell,function = "gpio";
+	};
+
+	uart1_ctsrts_pins: uart1-ctsrts-pins {
+		marvell,pins = "mpp38", "mpp40";
+		marvell,function = "uart1";
+	};
+
+	power_led_pins: power-led-pins {
+		marvell,pins = "mpp54";
+		marvell,function = "gpo";
+	};
+
+	power_led_pins2: power-led-pins2 {
+		marvell,pins = "mpp55", "mpp57";
+		marvell,function = "gpio";
+	};
+
+	system_led_pins: system-led-pins {
+		marvell,pins = "mpp7", "mpp59";
+		marvell,function = "gpo";
+	};
+
+	usb_power_pin: usb-power-pin {
+		marvell,pins = "mpp5";
+		marvell,function = "gpo";
+	};
+
+	ata1_power_pin: ata1-power-pin {
+		marvell,pins = "mpp8";
+		marvell,function = "gpio";
+	};
+
+	ata2_power_pin: ata2-power-pin {
+		marvell,pins = "mpp9";
+		marvell,function = "gpo";
+	};
+
+	ata1_led_pins: ata1-led-pins {
+		marvell,pins = "mpp61";
+		marvell,function = "gpo";
+	};
+
+	ata2_led_pins: ata2-led-pins {
+		marvell,pins = "mpp62";
+		marvell,function = "gpio";
+	};
+};
diff --git a/target/linux/mvebu/image/Makefile b/target/linux/mvebu/image/Makefile
index 461e347..f66d078 100644
--- a/target/linux/mvebu/image/Makefile
+++ b/target/linux/mvebu/image/Makefile
@@ -126,6 +126,7 @@  endef
 # Boards with NAND, without subpages
 $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
 $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
+$(eval $(call NANDProfile,370-LS-M,armada-370-buffalo-yanagi,128KiB,2048))
 $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
 $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
 $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
diff --git a/target/linux/mvebu/patches-4.0/006-build_buffalo_yanagi_dts.patch b/target/linux/mvebu/patches-4.0/006-build_buffalo_yanagi_dts.patch
new file mode 100644
index 0000000..881fc07
--- /dev/null
+++ b/target/linux/mvebu/patches-4.0/006-build_buffalo_yanagi_dts.patch
@@ -0,0 +1,14 @@ 
+Index: linux-4.0.5/arch/arm/boot/dts/Makefile
+===================================================================
+--- linux-4.0.5.orig/arch/arm/boot/dts/Makefile
++++ linux-4.0.5/arch/arm/boot/dts/Makefile
+@@ -616,7 +616,8 @@ dtb-$(CONFIG_MACH_ARMADA_370) += \
+ 	armada-370-netgear-rn102.dtb \
+ 	armada-370-netgear-rn104.dtb \
+ 	armada-370-rd.dtb \
+-	armada-370-synology-ds213j.dtb
++	armada-370-synology-ds213j.dtb \
++	armada-370-buffalo-yanagi.dtb
+ dtb-$(CONFIG_MACH_ARMADA_375) += \
+ 	armada-375-db.dtb
+ dtb-$(CONFIG_MACH_ARMADA_38X) += \
diff --git a/target/linux/mvebu/profiles/buffalo.mk b/target/linux/mvebu/profiles/buffalo.mk
new file mode 100644
index 0000000..ca5ae9e
--- /dev/null
+++ b/target/linux/mvebu/profiles/buffalo.mk
@@ -0,0 +1,23 @@ 
+#
+# Copyright (C) 2013-2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/370-LS-M
+  NAME:=Buffalo LS42x series
+  DEVICE_TYPE:=nas
+  PACKAGES:= \
+	kmod-mmc kmod-mvsdio kmod-usb2 kmod-usb3 kmod-usb-storage \
+	kmod-ata-core kmod-ata-marvell-sata \
+	kmod-i2c-core kmod-i2c-mv64xxx kmod-rtc-rs5c372 \
+	kmod-thermal-armada kmod-hwmon-gpiofan \
+	kmod-button-hotplug
+endef
+
+define Profile/370-LS-M/Description
+ Package set compatible with BUFFALO LS42x NAS devices
+endef
+
+$(eval $(call Profile,370-LS-M))