diff mbox series

[RFC:] ath79: port dragino ms14 to DTS

Message ID 20210922145920.1020069-1-karlp@etactica.com
State Needs Review / ACK
Headers show
Series [RFC:] ath79: port dragino ms14 to DTS | expand

Commit Message

Karl Palsson Sept. 22, 2021, 2:59 p.m. UTC
Changes:
* Dropped buttons. There's only one physical button, and it
  isn't wired up to be functional as per schematic.  Didn't work
  in ar71xx either.
* partition layout was always wrong.  uboot env was actually last
  portion of uboot partition.

Missing (RFC):
* link detection on eth0 (lan) doesn't work.  This worked in 19.07 w/
  ar71xx, and "swconfig dev switch0 show" correctly shows the link state
  changing for port 1 when I pull the cable.
  eth0 is simply permanently up.  Hints?  Link detection works perfectly
  well for eth1 (wan)

  From schematic and inspection, the old "wan" port (left hand side
  looking at the ports is "P4" on the ar9331, and the old "lan" port
  (right ahnd side) is "P0"

I'm stuck here on getting link detection.  Poking things like gmac
config and port switching is just stabbing in the dark, and I'm getting
nowhere with it.

Same as before:
* usb works
* leds work (wan led toggles with wan/eth1 link state, lan led is
  permanently up, but can be toggled manually)
* wifi works
* all interfaces have same MACs as before, and wan/lan are same physical
  locations as before.

Signed-off-by: Karl Palsson <karlp@etactica.com>
---
 package/boot/uboot-envtools/files/ath79       |   1 +
 .../linux/ath79/dts/ar9331_dragino_ms14.dts   | 152 ++++++++++++++++++
 .../generic/base-files/etc/board.d/01_leds    |   4 +
 target/linux/ath79/image/generic.mk           |   9 ++
 4 files changed, 166 insertions(+)
 create mode 100644 target/linux/ath79/dts/ar9331_dragino_ms14.dts
diff mbox series

Patch

diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79
index 91ba587bf8..d0b24d68dc 100644
--- a/package/boot/uboot-envtools/files/ath79
+++ b/package/boot/uboot-envtools/files/ath79
@@ -22,6 +22,7 @@  allnet,all-wap02860ac|\
 arduino,yun|\
 buffalo,bhr-4grv2|\
 devolo,magic-2-wifi|\
+dragino,ms14|\
 engenius,eap1200h|\
 engenius,eap300-v2|\
 engenius,eap350-v1|\
diff --git a/target/linux/ath79/dts/ar9331_dragino_ms14.dts b/target/linux/ath79/dts/ar9331_dragino_ms14.dts
new file mode 100644
index 0000000000..e7772ac383
--- /dev/null
+++ b/target/linux/ath79/dts/ar9331_dragino_ms14.dts
@@ -0,0 +1,152 @@ 
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "ar9331.dtsi"
+
+/ {
+	model = "Dragino MS14";
+	compatible = "dragino,ms14", "qca,ar9331";
+
+	/* label serial is at hexdump -v -e '1/1 "%c"' -s $((0x904)) -n 11 /dev/mtd6 (art partition) */
+
+	aliases {
+		led-boot = &led_sys;
+		led-failsafe = &led_sys;
+		led-upgrade = &led_sys;
+		serial0 = &uart;
+	};
+
+	/*
+	 * The physical switch on board is nominally connected to 
+	 * GPIO11, "jumpstart" but has no pullup from the factory
+	 * and consequently doesn't actually work.
+	 * See ms14_schematic_v2.2.pdf
+	 * Swapping R7 and R215 will "fix" it.
+	keys {
+		compatible = "gpio-keys";
+		jumpstart {
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
+		};
+	};
+	*/
+
+
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&switch_led_disable_pins>;
+
+		lan {
+			label = "red:lan";
+			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+		};
+
+		wan {
+			label = "red:wan";
+			gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
+		};
+
+		wlan {
+			label = "red:wlan";
+			gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "phy0tpt";
+		};
+
+		led_sys: sys {
+			label = "red:sys";
+			gpios = <&gpio 28 GPIO_ACTIVE_HIGH>;
+		};
+
+	};
+};
+
+&uart {
+	status = "okay";
+};
+
+&usb {
+	dr_mode = "host";
+	status = "okay";
+};
+
+&usb_phy {
+	status = "okay";
+};
+
+&eth0 {
+	status = "okay";
+	nvmem-cells = <&macaddr_art_0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&eth1 {
+	status = "okay";
+	nvmem-cells = <&macaddr_art_6>;
+	nvmem-cell-names = "mac-address";
+};
+
+&spi {
+	num-chipselects = <1>;
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		spi-max-frequency = <50000000>;
+		reg = <0>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			uboot {
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			uboot-env {
+				reg = <0x30000 0x10000>;
+			};
+
+			firmware {
+				compatible = "denx,uimage";
+				reg = <0x40000 0xfb0000>;
+			};
+
+			art: art {
+				reg = <0xff0000 0x10000>;
+				read-only;
+			};
+		};
+	};
+};
+
+&wmac {
+	status = "okay";
+	mtd-cal-data = <&art 0x1000>;
+	nvmem-cells = <&macaddr_art_1002>;
+	nvmem-cell-names = "mac-address";
+};
+
+&art {
+	compatible = "nvmem-cells";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	macaddr_art_0: macaddr@0 {
+		reg = <0x0 0x6>;
+	};
+
+	macaddr_art_6: macaddr@6 {
+		reg = <0x6 0x6>;
+	};
+
+	macaddr_art_1002: macaddr@1002 {
+		reg = <0x1002 0x6>;
+	};
+};
+
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
index ffc6f3086e..70e14e3488 100644
--- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
@@ -195,6 +195,10 @@  dlink,dap-1365-a1)
 dlink,dir-859-a1)
 	ucidef_set_led_switch "internet" "WAN" "green:internet" "switch0" "0x20"
 	;;
+dragino,ms14)
+	ucidef_set_led_netdev "lan" "LAN" "red:lan" "eth0"
+	ucidef_set_led_netdev "wan" "WAN" "red:wan" "eth1"
+	;;
 engenius,ens202ext-v1|\
 engenius,enstationac-v1)
 	ucidef_set_rssimon "wlan0" "200000" "1"
diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk
index d8db054312..496c17aab7 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -1022,6 +1022,15 @@  define Device/dlink_dir-859-a1
 endef
 TARGET_DEVICES += dlink_dir-859-a1
 
+define Device/dragino_ms14
+  SOC := ar9331
+  DEVICE_TITLE := Dragino MS14
+  DEVICE_PACKAGES := kmod-usb-chipidea2
+  IMAGE_SIZE := 16000k
+  SUPPORTED_DEVICES += dragino2
+endef
+TARGET_DEVICES += dragino_ms14
+
 define Device/elecom_wrc-1750ghbk2-i
   SOC := qca9563
   DEVICE_VENDOR := ELECOM