* [PATCH v3 0/3] i2c: spacemit: add reset support
@ 2025-12-30 14:29 Encrow Thorne
2025-12-30 15:06 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Encrow Thorne
2026-01-08 5:24 ` (subset) [PATCH v3 0/3] i2c: spacemit: add reset support Yixun Lan
0 siblings, 2 replies; 13+ messages in thread
From: Encrow Thorne @ 2025-12-30 14:29 UTC (permalink / raw)
To: Troy Mitchell, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yixun Lan, Philipp Zabel, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti
Cc: Troy Mitchell, Guodong Xu, linux-i2c, devicetree, linux-riscv,
spacemit, linux-kernel, Encrow Thorne
Add reset support for the K1 I2C driver. A reset ensures that the
controller starts in a clean and known state.
Reset ensures that the I2C hardware is in a clean state. We cannot assume
that no program used I2C before the kernel booted.
Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
---
Changes in v3:
- Move reset property in dt-bindings.
- Use devm_reset_control_get_optional_exclusive_deasserted() instead.
- Rebase to v6.19-rc1.
- Link to v2: https://lore.kernel.org/r/20251219-i2c-reset-v2-0-ad201a602e74@gmail.com
Changes in v2:
- Replace reset property in dt-bindings.
- Use devm_reset_control_get_optional_exclusive_deasserted() instead.
- Rebase to v6.19-rc1.
- Link to v1: https://lore.kernel.org/r/20251119-i2c-k1_reset-support-v1-0-0e9e82bf9b65@gmail.com
---
Encrow Thorne (3):
dt-bindings: i2c: spacemit: add optional resets
i2c: k1: add reset support
riscv: dts: spacemit: add reset property
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml | 3 +++
arch/riscv/boot/dts/spacemit/k1.dtsi | 8 ++++++++
drivers/i2c/busses/i2c-k1.c | 7 +++++++
3 files changed, 18 insertions(+)
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251218-i2c-reset-a7be139213de
Best regards,
--
Encrow Thorne <jyc0019@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets
2025-12-30 14:29 [PATCH v3 0/3] i2c: spacemit: add reset support Encrow Thorne
@ 2025-12-30 15:06 ` Encrow Thorne
2025-12-30 15:06 ` [PATCH 2/3] i2c: k1: add reset support Encrow Thorne
` (2 more replies)
2026-01-08 5:24 ` (subset) [PATCH v3 0/3] i2c: spacemit: add reset support Yixun Lan
1 sibling, 3 replies; 13+ messages in thread
From: Encrow Thorne @ 2025-12-30 15:06 UTC (permalink / raw)
To: jyc0019
Cc: alex, andi.shyti, aou, conor+dt, devicetree, dlan, guodong,
krzk+dt, linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer,
pjw, robh, spacemit, troy.mitchell, troymitchell988
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
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/3] i2c: k1: add reset support
2025-12-30 15:06 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Encrow Thorne
@ 2025-12-30 15:06 ` Encrow Thorne
2025-12-30 15:06 ` [PATCH 3/3] riscv: dts: spacemit: add reset property Encrow Thorne
2026-01-05 18:44 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Rob Herring (Arm)
2 siblings, 0 replies; 13+ messages in thread
From: Encrow Thorne @ 2025-12-30 15:06 UTC (permalink / raw)
To: jyc0019
Cc: alex, andi.shyti, aou, conor+dt, devicetree, dlan, guodong,
krzk+dt, linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer,
pjw, robh, spacemit, troy.mitchell, troymitchell988
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/3] riscv: dts: spacemit: add reset property
2025-12-30 15:06 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Encrow Thorne
2025-12-30 15:06 ` [PATCH 2/3] i2c: k1: add reset support Encrow Thorne
@ 2025-12-30 15:06 ` Encrow Thorne
2026-01-07 14:22 ` Andi Shyti
2026-01-05 18:44 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Rob Herring (Arm)
2 siblings, 1 reply; 13+ messages in thread
From: Encrow Thorne @ 2025-12-30 15:06 UTC (permalink / raw)
To: jyc0019
Cc: alex, andi.shyti, aou, conor+dt, devicetree, dlan, guodong,
krzk+dt, linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer,
pjw, robh, spacemit, troy.mitchell, troymitchell988
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
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 3/3] riscv: dts: spacemit: add reset property
2025-12-30 15:06 ` [PATCH 3/3] riscv: dts: spacemit: add reset property Encrow Thorne
@ 2026-01-07 14:22 ` Andi Shyti
2026-01-07 16:23 ` Encrow Thorne
0 siblings, 1 reply; 13+ messages in thread
From: Andi Shyti @ 2026-01-07 14:22 UTC (permalink / raw)
To: Encrow Thorne
Cc: alex, aou, conor+dt, devicetree, dlan, guodong, krzk+dt,
linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer, pjw, robh,
spacemit, troy.mitchell, troymitchell988
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] riscv: dts: spacemit: add reset property
2026-01-07 14:22 ` Andi Shyti
@ 2026-01-07 16:23 ` Encrow Thorne
2026-01-07 17:51 ` Andi Shyti
0 siblings, 1 reply; 13+ messages in thread
From: Encrow Thorne @ 2026-01-07 16:23 UTC (permalink / raw)
To: Andi Shyti
Cc: alex, aou, conor+dt, devicetree, dlan, guodong, krzk+dt,
linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer, pjw, robh,
spacemit, troy.mitchell, troymitchell988
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] riscv: dts: spacemit: add reset property
2026-01-07 16:23 ` Encrow Thorne
@ 2026-01-07 17:51 ` Andi Shyti
0 siblings, 0 replies; 13+ messages in thread
From: Andi Shyti @ 2026-01-07 17:51 UTC (permalink / raw)
To: Encrow Thorne
Cc: alex, aou, conor+dt, devicetree, dlan, guodong, krzk+dt,
linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer, pjw, robh,
spacemit, troy.mitchell, troymitchell988
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets
2025-12-30 15:06 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Encrow Thorne
2025-12-30 15:06 ` [PATCH 2/3] i2c: k1: add reset support Encrow Thorne
2025-12-30 15:06 ` [PATCH 3/3] riscv: dts: spacemit: add reset property Encrow Thorne
@ 2026-01-05 18:44 ` Rob Herring (Arm)
2 siblings, 0 replies; 13+ messages in thread
From: Rob Herring (Arm) @ 2026-01-05 18:44 UTC (permalink / raw)
To: Encrow Thorne
Cc: guodong, devicetree, krzk+dt, aou, palmer, spacemit, linux-riscv,
conor+dt, pjw, troy.mitchell, p.zabel, linux-i2c, troymitchell988,
dlan, linux-kernel, andi.shyti, alex
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: (subset) [PATCH v3 0/3] i2c: spacemit: add reset support
2025-12-30 14:29 [PATCH v3 0/3] i2c: spacemit: add reset support Encrow Thorne
2025-12-30 15:06 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Encrow Thorne
@ 2026-01-08 5:24 ` Yixun Lan
1 sibling, 0 replies; 13+ messages in thread
From: Yixun Lan @ 2026-01-08 5:24 UTC (permalink / raw)
To: Troy Mitchell, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Philipp Zabel, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Encrow Thorne
Cc: Yixun Lan, Troy Mitchell, Guodong Xu, linux-i2c, devicetree,
linux-riscv, spacemit, linux-kernel
On Tue, 30 Dec 2025 22:29:01 +0800, Encrow Thorne wrote:
> Add reset support for the K1 I2C driver. A reset ensures that the
> controller starts in a clean and known state.
>
> Reset ensures that the I2C hardware is in a clean state. We cannot assume
> that no program used I2C before the kernel booted.
>
>
> [...]
Applied, thanks!
[3/3] riscv: dts: spacemit: add reset property
https://github.com/spacemit-com/linux/commit/91c444d4285c07dbf2e6e4bf954d9a0282157f1f
Best regards,
--
Yixun Lan
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/3] i2c: spacemit: add reset support
@ 2025-11-19 11:46 Encrow Thorne
2025-11-19 11:46 ` [PATCH 2/3] i2c: k1: " Encrow Thorne
0 siblings, 1 reply; 13+ messages in thread
From: Encrow Thorne @ 2025-11-19 11:46 UTC (permalink / raw)
To: Troy Mitchell, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yixun Lan, Philipp Zabel, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti
Cc: Troy Mitchell, linux-i2c, devicetree, linux-riscv, spacemit,
linux-kernel, Encrow Thorne
Add reset control to SpacemiT K1 I2C.
Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
---
Encrow Thorne (3):
dt-bindings: i2c: spacemit: add optional resets
i2c: k1: add reset support
riscv: dts: spacemit: add reset property
Documentation/devicetree/bindings/i2c/spacemit,k1-i2c.yaml | 3 +++
arch/riscv/boot/dts/spacemit/k1.dtsi | 2 ++
drivers/i2c/busses/i2c-k1.c | 11 +++++++++++
3 files changed, 16 insertions(+)
---
base-commit: 8fec172c82c2b5f6f8e47ab837c1dc91ee3d1b87
change-id: 20251104-i2c-k1_reset-support-12784e17bf83
Best regards,
--
Encrow Thorne <jyc0019@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 2/3] i2c: k1: add reset support
2025-11-19 11:46 [PATCH " Encrow Thorne
@ 2025-11-19 11:46 ` Encrow Thorne
2025-11-19 12:08 ` Troy Mitchell
2025-12-11 7:35 ` Guodong Xu
0 siblings, 2 replies; 13+ messages in thread
From: Encrow Thorne @ 2025-11-19 11:46 UTC (permalink / raw)
To: Troy Mitchell, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yixun Lan, Philipp Zabel, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti
Cc: Troy Mitchell, linux-i2c, devicetree, linux-riscv, spacemit,
linux-kernel, Encrow Thorne
Add reset control handling to the K1 I2C driver.
Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
---
drivers/i2c/busses/i2c-k1.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
index 6b918770e612..64d817d8315d 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 */
@@ -113,6 +114,7 @@ struct spacemit_i2c_dev {
void __iomem *base;
int irq;
u32 clock_freq;
+ struct reset_control *resets;
struct i2c_msg *msgs;
u32 msg_num;
@@ -571,6 +573,15 @@ 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");
+ i2c->resets = devm_reset_control_get_optional(dev, NULL);
+ if (IS_ERR(i2c->resets))
+ return dev_err_probe(dev, PTR_ERR(i2c->resets),
+ "failed to get reset\n");
+
+ reset_control_assert(i2c->resets);
+ udelay(2);
+ reset_control_deassert(i2c->resets);
+
spacemit_i2c_reset(i2c);
i2c_set_adapdata(&i2c->adapt, i2c);
--
2.25.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 2/3] i2c: k1: add reset support
2025-11-19 11:46 ` [PATCH 2/3] i2c: k1: " Encrow Thorne
@ 2025-11-19 12:08 ` Troy Mitchell
2025-12-11 7:35 ` Guodong Xu
1 sibling, 0 replies; 13+ messages in thread
From: Troy Mitchell @ 2025-11-19 12:08 UTC (permalink / raw)
To: Encrow Thorne, Troy Mitchell, Andi Shyti, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Yixun Lan, Philipp Zabel,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti
Cc: Troy Mitchell, linux-i2c, devicetree, linux-riscv, spacemit,
linux-kernel
Hi Encrow,
On Wed, Nov 19, 2025 at 07:46:44PM +0800, Encrow Thorne wrote:
> Add reset control handling to the K1 I2C driver.
>
> Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
> ---
> drivers/i2c/busses/i2c-k1.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
> index 6b918770e612..64d817d8315d 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 */
> @@ -113,6 +114,7 @@ struct spacemit_i2c_dev {
> void __iomem *base;
> int irq;
> u32 clock_freq;
> + struct reset_control *resets;
>
> struct i2c_msg *msgs;
> u32 msg_num;
> @@ -571,6 +573,15 @@ 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");
>
> + i2c->resets = devm_reset_control_get_optional(dev, NULL);
> + if (IS_ERR(i2c->resets))
> + return dev_err_probe(dev, PTR_ERR(i2c->resets),
> + "failed to get reset\n");
Please align.
> +
> + reset_control_assert(i2c->resets);
> + udelay(2);
This seems to be a very small value. If this
has been verified multiple times?
- Troy
> + reset_control_deassert(i2c->resets);
> +
> spacemit_i2c_reset(i2c);
>
> i2c_set_adapdata(&i2c->adapt, i2c);
>
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH 2/3] i2c: k1: add reset support
2025-11-19 11:46 ` [PATCH 2/3] i2c: k1: " Encrow Thorne
2025-11-19 12:08 ` Troy Mitchell
@ 2025-12-11 7:35 ` Guodong Xu
2025-12-16 5:21 ` Encrow Thorne
1 sibling, 1 reply; 13+ messages in thread
From: Guodong Xu @ 2025-12-11 7:35 UTC (permalink / raw)
To: jyc0019
Cc: alex, andi.shyti, aou, conor+dt, devicetree, dlan, krzk+dt,
linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer, pjw, robh,
spacemit, troy.mitchell, troymitchell988
On Wed, Nov 19, 2025 at 07:46:44PM +0800, Encrow Thorne wrote:
> Add reset control handling to the K1 I2C driver.
>
> Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
> ---
> drivers/i2c/busses/i2c-k1.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
> index 6b918770e612..64d817d8315d 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 */
> @@ -113,6 +114,7 @@ struct spacemit_i2c_dev {
> void __iomem *base;
> int irq;
> u32 clock_freq;
> + struct reset_control *resets;
Thanks for the patch! A few suggestions to simplify this:
The reset_control structure doesn't need to be stored in the device
struct since the devm API automatically manages the resource lifecycle.
>
> struct i2c_msg *msgs;
> u32 msg_num;
> @@ -571,6 +573,15 @@ static int spacemit_i2c_probe(struct platform_device *pdev)
Please use a local variable in the probe function instead:
struct reset_control *rst;
> if (IS_ERR(clk))
> return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock");
>
> + i2c->resets = devm_reset_control_get_optional(dev, NULL);
There is a new API, I would suggest this:
rst = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
> + if (IS_ERR(i2c->resets))
> + return dev_err_probe(dev, PTR_ERR(i2c->resets),
> + "failed to get reset\n");
> +
> + reset_control_assert(i2c->resets);
> + udelay(2);
> + reset_control_deassert(i2c->resets);
> +
Why you need to call assert() then deassert()?
Wouldn't the single API fit?
Best regards,
Guodong
> spacemit_i2c_reset(i2c);
>
> i2c_set_adapdata(&i2c->adapt, i2c);
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH 2/3] i2c: k1: add reset support
2025-12-11 7:35 ` Guodong Xu
@ 2025-12-16 5:21 ` Encrow Thorne
0 siblings, 0 replies; 13+ messages in thread
From: Encrow Thorne @ 2025-12-16 5:21 UTC (permalink / raw)
To: Guodong Xu
Cc: alex, andi.shyti, aou, conor+dt, devicetree, dlan, krzk+dt,
linux-i2c, linux-kernel, linux-riscv, p.zabel, palmer, pjw, robh,
spacemit, troy.mitchell, troymitchell988
On Thu, Dec 11, 2025 at 03:35:26PM +0800, Guodong Xu wrote:
> On Wed, Nov 19, 2025 at 07:46:44PM +0800, Encrow Thorne wrote:
> > Add reset control handling to the K1 I2C driver.
> >
> > Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
> > ---
> > drivers/i2c/busses/i2c-k1.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
> > index 6b918770e612..64d817d8315d 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 */
> > @@ -113,6 +114,7 @@ struct spacemit_i2c_dev {
> > void __iomem *base;
> > int irq;
> > u32 clock_freq;
> > + struct reset_control *resets;
>
> Thanks for the patch! A few suggestions to simplify this:
>
> The reset_control structure doesn't need to be stored in the device
> struct since the devm API automatically manages the resource lifecycle.
>
> >
> > struct i2c_msg *msgs;
> > u32 msg_num;
> > @@ -571,6 +573,15 @@ static int spacemit_i2c_probe(struct platform_device *pdev)
>
> Please use a local variable in the probe function instead:
>
> struct reset_control *rst;
>
> > if (IS_ERR(clk))
> > return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock");
> >
> > + i2c->resets = devm_reset_control_get_optional(dev, NULL);
>
> There is a new API, I would suggest this:
> rst = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
>
>
> > + if (IS_ERR(i2c->resets))
> > + return dev_err_probe(dev, PTR_ERR(i2c->resets),
> > + "failed to get reset\n");
> > +
> > + reset_control_assert(i2c->resets);
> > + udelay(2);
> > + reset_control_deassert(i2c->resets);
> > +
>
> Why you need to call assert() then deassert()?
> Wouldn't the single API fit?
>
Good point.
Thank you for your suggestions, I will fix them in v2.
- Encrow
> Best regards,
> Guodong
>
> > spacemit_i2c_reset(i2c);
> >
> > i2c_set_adapdata(&i2c->adapt, i2c);
> >
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-01-08 5:25 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-30 14:29 [PATCH v3 0/3] i2c: spacemit: add reset support Encrow Thorne
2025-12-30 15:06 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Encrow Thorne
2025-12-30 15:06 ` [PATCH 2/3] i2c: k1: add reset support Encrow Thorne
2025-12-30 15:06 ` [PATCH 3/3] riscv: dts: spacemit: add reset property Encrow Thorne
2026-01-07 14:22 ` Andi Shyti
2026-01-07 16:23 ` Encrow Thorne
2026-01-07 17:51 ` Andi Shyti
2026-01-05 18:44 ` [PATCH 1/3] dt-bindings: i2c: spacemit: add optional resets Rob Herring (Arm)
2026-01-08 5:24 ` (subset) [PATCH v3 0/3] i2c: spacemit: add reset support Yixun Lan
-- strict thread matches above, loose matches on Subject: below --
2025-11-19 11:46 [PATCH " Encrow Thorne
2025-11-19 11:46 ` [PATCH 2/3] i2c: k1: " Encrow Thorne
2025-11-19 12:08 ` Troy Mitchell
2025-12-11 7:35 ` Guodong Xu
2025-12-16 5:21 ` Encrow Thorne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox