From 2ed7fb7bf15420d80c3b272a3a887e142046b7b2 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Mon, 7 Nov 2022 15:31:43 +0000
Subject: [PATCH] overlays: i2c-sensor: Add the jc42 class of sensor

This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: https://github.com/raspberrypi/linux/issues/5234

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/README              | 13 ++++++++++++-
 .../boot/dts/overlays/i2c-sensor-common.dtsi   | 18 +++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1970,6 +1970,15 @@ Params: addr                    Set the
         int_pin                 Set the GPIO to use for interrupts (max30102
                                 only)
 
+        jc42                    Select any of the many JEDEC JC42.4-compliant
+                                temperature sensors, including:
+                                  ADT7408, AT30TS00, CAT34TS02, CAT6095,
+                                  MAX6604, MCP9804, MCP9805, MCP9808,
+                                  MCP98242, MCP98243, MCP98244, MCP9843,
+                                  SE97, SE98, STTS424(E), STTS2002, STTS3000,
+                                  TSE2002, TSE2004, TS3000, and TS3001.
+                                The default address is 0x18.
+
         lm75                    Select the Maxim LM75 temperature sensor
                                 Valid addresses 0x48-0x4f, default 0x4f
 
@@ -1982,7 +1991,9 @@ Params: addr                    Set the
                                 and blood-oxygen sensor
 
         mcp980x                 Select the Maxim MCP980x range of temperature
-                                sensors (e.g. MCP9808).
+                                sensors (i.e. MCP9800, MCP9801, MCP9802 and
+                                MCP9803). N.B. For MCP9804, MCP9805 and MCP9808,
+                                use the "jc42" option.
                                 Valid addresses are 0x18-0x1f (default 0x18)
 
         sht3x                   Select the Sensiron SHT3x temperature and
--- a/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi
+++ b/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi
@@ -337,6 +337,21 @@
 		};
 	};
 
+	fragment@22 {
+		target = <&i2cbus>;
+		__dormant__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			jc42: jc42@18 {
+				compatible = "jedec,jc-42.4-temp";
+				reg = <0x18>;
+				smbus-timeout-disable;
+			};
+		};
+	};
+
 	__overrides__ {
 		bme280 = <0>,"+0";
 		bmp085 = <0>,"+1";
@@ -361,11 +376,12 @@
 		max30102 = <0>,"+19";
 		aht10 = <0>,"+20";
 		mcp980x = <0>,"+21";
+		jc42 = <0>,"+22";
 
 		addr =  <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0",
 			<&lm75>,"reg:0", <&hdc100x>,"reg:0", <&sht3x>,"reg:0",
 			<&ds1621>,"reg:0", <&bme680>,"reg:0", <&ccs811>,"reg:0",
-			<&bh1750>,"reg:0", <&mcp980x>,"reg:0";
+			<&bh1750>,"reg:0", <&mcp980x>,"reg:0", <&jc42>,"reg:0";
 		int_pin = <&max30102>, "interrupts:0";
 	};
 };
