From e0db80960019c296c47690dea9052dc4960f4f99 Mon Sep 17 00:00:00 2001
From: Clarke X <1014930533@qq.com>
Date: Sat, 8 Apr 2023 11:29:16 +0800
Subject: [PATCH] overlays: Add pcf857x support

Add pcf857x overlay with related documents.

Signed-off-by: Clarke X <1014930533@qq.com>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             | 11 +++++++
 .../arm/boot/dts/overlays/pcf857x-overlay.dts | 32 +++++++++++++++++++
 3 files changed, 44 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/pcf857x-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -167,6 +167,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	ov9281.dtbo \
 	papirus.dtbo \
 	pca953x.dtbo \
+	pcf857x.dtbo \
 	pcie-32bit-dma.dtbo \
 	pibell.dtbo \
 	pifacedigital.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -3065,6 +3065,17 @@ Params: addr                    I2C addr
         xra1202                 Select the Exar XRA1202 (8 bit)
 
 
+Name:   pcf857x
+Info:   NXP PCF857x family of I2C GPIO expanders.
+Load:   dtoverlay=pcf857x,<param>=<val>
+Params: addr                    I2C address of expander. Default
+                                depends on model selected.
+        pcf8574                 Select the NXP PCF8574 (8 bit)
+        pcf8574a                Select the NXP PCF8574A (8 bit)
+        pcf8575                 Select the NXP PCF8575 (16 bit)
+        pca8574                 Select the NXP PCA8574 (8 bit)
+
+
 Name:   pcie-32bit-dma
 Info:   Force PCIe config to support 32bit DMA addresses at the expense of
         having to bounce buffers.
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/pcf857x-overlay.dts
@@ -0,0 +1,32 @@
+// Definitions for PCF857X GPIO Extender from NXP
+
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&i2c_arm>;
+		__overlay__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			pcf857x: pcf857x@0 {
+				compatible = "";
+				reg = <0x00>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				status = "okay";
+			};
+		};
+	};
+
+	__overrides__ {
+		pcf8574  = <&pcf857x>,"compatible=nxp,pcf8574",  <&pcf857x>,"reg:0=0x20";
+		pcf8574a = <&pcf857x>,"compatible=nxp,pcf8574a", <&pcf857x>,"reg:0=0x38";
+		pcf8575  = <&pcf857x>,"compatible=nxp,pcf8575",  <&pcf857x>,"reg:0=0x20";
+		pca8574  = <&pcf857x>,"compatible=nxp,pca8574", <&pcf857x>,"reg:0=0x20";
+		addr = <&pcf857x>,"reg:0";
+	};
+};
