From 0541667e097b302fd97b4fce606336f4c7cab67f Mon Sep 17 00:00:00 2001
From: Patrick Yavitz <pyavitz@xxxxx.com>
Date: Wed, 11 Oct 2023 11:34:54 -0400
Subject: [PATCH] v2: arch: arm64: dts: amlogic: meson-g12b-waveshare-cm4-io-base-b

https://www.waveshare.com/wiki/CM4-IO-BASE-B

Fan, RTC and USB support
RTC requires rtc pcf85063 driver
Fan requires hwmon emc2305 driver

Signed-off-by: Patrick Yavitz <pyavitz@xxxxx.com>
---
 arch/arm64/boot/dts/amlogic/Makefile          |  1 +
 .../meson-g12b-waveshare-cm4-io-base-b.dts    | 66 +++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 arch/arm64/boot/dts/amlogic/meson-g12b-waveshare-cm4-io-base-b.dts

diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile
index 1e83933a11ab..f9e43e0d0464 100644
--- a/arch/arm64/boot/dts/amlogic/Makefile
+++ b/arch/arm64/boot/dts/amlogic/Makefile
@@ -20,6 +20,7 @@ dtb-$(CONFIG_ARCH_MESON) += meson-g12b-odroid-n2l.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-g12b-s922x-bananapi-m2s.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-g12b-s922x-khadas-vim3.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-g12b-ugoos-am6.dtb
+dtb-$(CONFIG_ARCH_MESON) += meson-g12b-waveshare-cm4-io-base-b.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-gxbb-kii-pro.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-gxbb-nanopi-k2.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-gxbb-nexbox-a95x.dtb
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-waveshare-cm4-io-base-b.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-waveshare-cm4-io-base-b.dts
new file mode 100644
index 000000000000..2c988290d48a
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-waveshare-cm4-io-base-b.dts
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2023 Patrick Yavitz <pyavitz@xxxxx.com>
+ */
+
+/dts-v1/;
+
+#include "meson-g12b-bananapi-cm4-cm4io.dts"
+
+/ {
+	compatible = "bananapi,bpi-cm4io", "bananapi,bpi-cm4", "amlogic,a311d", "amlogic,g12b";
+	model = "Waveshare CM4-IO-BASE-B with BPI-CM4 Module";
+
+	aliases {
+		rtc0 = &rtc;
+	};
+};
+
+&i2c1 {
+	rtc: rtc@51 {
+		compatible = "nxp,pcf85063a";
+		reg = <0x51>;
+		wakeup-source;
+	};
+
+	fanctrl: emc2305@2f {
+		compatible = "smsc,emc2305";
+		reg = <0x2f>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		#cooling-cells = <0x02>;
+		wakeup-source;
+	};
+};
+
+&cpu_thermal {
+	trips {
+		fanmid0: fanmid0 {
+			temperature = <60000>;
+			hysteresis = <2000>;
+			type = "active";
+		};
+	
+		fanmax0: fanmax0 {
+			temperature = <65000>;
+			hysteresis = <2000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map0 {
+			trip = <&fanmid0>;
+			cooling-device = <&fanctrl 2 6>;
+		};
+
+		map1 {
+			trip = <&fanmax0>;
+			cooling-device = <&fanctrl 7 THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+&usb {
+	dr_mode = "host";
+};
-- 
2.39.2

