]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i2c: k1: add reset support
authorEncrow Thorne <jyc0019@gmail.com>
Tue, 30 Dec 2025 15:06:52 +0000 (23:06 +0800)
committerAndi Shyti <andi.shyti@kernel.org>
Wed, 7 Jan 2026 17:41:26 +0000 (18:41 +0100)
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.

Signed-off-by: Encrow Thorne <jyc0019@gmail.com>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20251230150653.42097-2-jyc0019@gmail.com
drivers/i2c/busses/i2c-k1.c

index d42c03ef5db5984ea8e06b3d7eb485b4f899e616..23661c7ddb67602678a3be4e32df7905f1274c1b 100644 (file)
@@ -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);