[PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets

Encrow Thorne posted 3 patches 1 month, 1 week ago
Only 1 patches received!
[PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets
Posted by Encrow Thorne 1 month, 1 week ago
The I2C controller requires a reset to ensure it starts from a clean state.

Add the 'resets' property to support this hardware requirement.

Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
---
 Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml b/Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
index b7220fff2235..5896fb120501 100644
--- a/Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
+++ b/Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml
@@ -41,6 +41,9 @@ properties:
     default: 400000
     maximum: 3300000
 
+  resets:
+    maxItems: 1
+
 required:
   - compatible
   - reg
-- 
2.25.1
Re: [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets
Posted by Rob Herring (Arm) 1 month ago
On Tue, 30 Dec 2025 23:06:51 +0800, Encrow Thorne wrote:
> The I2C controller requires a reset to ensure it starts from a clean state.
> 
> Add the 'resets' property to support this hardware requirement.
> 
> Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
> Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
> ---
>  Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml | 3 +++
>  1 file changed, 3 insertions(+)
> 

Acked-by: Rob Herring (Arm) <robh@kernel.org>
[PATCH 2/3] i2c: k1: add reset support
Posted by Encrow Thorne 1 month, 1 week ago
The K1 I2C controller provides a reset line that needs to be deasserted
before the controller can be accessed.

Add reset support to the driver to ensure the controller starts in the
required state.

Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
---
 drivers/i2c/busses/i2c-k1.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
index d42c03ef5db5..23661c7ddb67 100644
--- a/drivers/i2c/busses/i2c-k1.c
+++ b/drivers/i2c/busses/i2c-k1.c
@@ -10,6 +10,7 @@
  #include <linux/module.h>
  #include <linux/of_address.h>
  #include <linux/platform_device.h>
+ #include <linux/reset.h>
 
 /* spacemit i2c registers */
 #define SPACEMIT_ICR		 0x0		/* Control register */
@@ -534,6 +535,7 @@ static int spacemit_i2c_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *of_node = pdev->dev.of_node;
 	struct spacemit_i2c_dev *i2c;
+	struct reset_control *rst;
 	int ret;
 
 	i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
@@ -578,6 +580,11 @@ static int spacemit_i2c_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock");
 
+	rst = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
+	if (IS_ERR(rst))
+		return dev_err_probe(dev, PTR_ERR(rst),
+				     "failed to acquire deasserted reset\n");
+
 	spacemit_i2c_reset(i2c);
 
 	i2c_set_adapdata(&i2c->adapt, i2c);
-- 
2.25.1
[PATCH 3/3] riscv: dts: spacemit: add reset property
Posted by Encrow Thorne 1 month, 1 week ago
Add resets property to K1 I2C node.
---
 arch/riscv/boot/dts/spacemit/k1.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
index 7818ca4979b6..085987643638 100644
--- a/arch/riscv/boot/dts/spacemit/k1.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
@@ -367,6 +367,7 @@ i2c0: i2c@d4010800 {
 				 <&syscon_apbc CLK_TWSI0_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI0>;
 			interrupts = <36>;
 			status = "disabled";
 		};
@@ -380,6 +381,7 @@ i2c1: i2c@d4011000 {
 				 <&syscon_apbc CLK_TWSI1_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI1>;
 			interrupts = <37>;
 			status = "disabled";
 		};
@@ -393,6 +395,7 @@ i2c2: i2c@d4012000 {
 				 <&syscon_apbc CLK_TWSI2_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI2>;
 			interrupts = <38>;
 			status = "disabled";
 		};
@@ -406,6 +409,7 @@ i2c4: i2c@d4012800 {
 				 <&syscon_apbc CLK_TWSI4_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI4>;
 			interrupts = <40>;
 			status = "disabled";
 		};
@@ -419,6 +423,7 @@ i2c5: i2c@d4013800 {
 				 <&syscon_apbc CLK_TWSI5_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI5>;
 			interrupts = <41>;
 			status = "disabled";
 		};
@@ -443,6 +448,7 @@ i2c6: i2c@d4018800 {
 				 <&syscon_apbc CLK_TWSI6_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI6>;
 			interrupts = <70>;
 			status = "disabled";
 		};
@@ -546,6 +552,7 @@ i2c7: i2c@d401d000 {
 				 <&syscon_apbc CLK_TWSI7_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI7>;
 			interrupts = <18>;
 			status = "disabled";
 		};
@@ -559,6 +566,7 @@ i2c8: i2c@d401d800 {
 				 <&syscon_apbc CLK_TWSI8_BUS>;
 			clock-names = "func", "bus";
 			clock-frequency = <400000>;
+			resets = <&syscon_apbc RESET_TWSI8>;
 			interrupts = <19>;
 			status = "disabled";
 		};
-- 
2.25.1
Re: [PATCH 3/3] riscv: dts: spacemit: add reset property
Posted by Andi Shyti 1 month ago
Hi Encrow,

On Tue, Dec 30, 2025 at 11:06:53PM +0800, Encrow Thorne wrote:
> Add resets property to K1 I2C node.
> ---
>  arch/riscv/boot/dts/spacemit/k1.dtsi | 8 ++++++++
>  1 file changed, 8 insertions(+)

how is this patch formatted?

Andi
Re: [PATCH 3/3] riscv: dts: spacemit: add reset property
Posted by Encrow Thorne 1 month ago
On Wed, Jan 07, 2026 at 03:22:42PM +0100, Andi Shyti wrote:
  Hi Andi,
> Hi Encrow,
> 
> On Tue, Dec 30, 2025 at 11:06:53PM +0800, Encrow Thorne wrote:
> > Add resets property to K1 I2C node.
> > ---
> >  arch/riscv/boot/dts/spacemit/k1.dtsi | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> 
> how is this patch formatted?
> 
  Sorry, I forgot to add the version number when I resent it.

  The initial sending process was interrupted, so I
  manually regenerated the patches using git format-patch 
  and sent them again.I have verified locally that the 
  entire patch series applies cleanly.

  Please let me know if you find any other formatting issues.

  Encrow
> Andi
Re: [PATCH 3/3] riscv: dts: spacemit: add reset property
Posted by Andi Shyti 1 month ago
Hi Encrow,

On Thu, Jan 08, 2026 at 12:23:43AM +0800, Encrow Thorne wrote:
> On Wed, Jan 07, 2026 at 03:22:42PM +0100, Andi Shyti wrote:
>   Hi Andi,
> > Hi Encrow,
> > 
> > On Tue, Dec 30, 2025 at 11:06:53PM +0800, Encrow Thorne wrote:
> > > Add resets property to K1 I2C node.
> > > ---
> > >  arch/riscv/boot/dts/spacemit/k1.dtsi | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > 
> > how is this patch formatted?
> > 
>   Sorry, I forgot to add the version number when I resent it.

you also forgot the tag section :-)

No worries, I took patch 1 and 2 into i2c/i2c-host branch.

Thanks,
Andi
  • [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets