]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: sun6i_p2wi: Add support for DM clocks and resets
authorSamuel Holland <samuel@sholland.org>
Fri, 18 Mar 2022 04:52:34 +0000 (23:52 -0500)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 4 Apr 2022 22:24:17 +0000 (23:24 +0100)
Currently, clock/reset setup for this device is handled by a
platform-specific function and is intermixed with non-DM pinctrl
setup. Use the devicetree to get clocks/resets, which disentagles
it from the pinctrl setup in preparation for moving to DM_PINCTRL.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
drivers/i2c/sun6i_p2wi.c

index 064d82a6d1f9aac05bd43fe29bd56f6b6b5b4ff1..d221323295d7a6e215ddd026b753800730ebd079 100644 (file)
  */
 
 #include <axp_pmic.h>
+#include <clk.h>
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
 #include <i2c.h>
+#include <reset.h>
 #include <time.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
@@ -180,9 +182,19 @@ static int sun6i_p2wi_probe_chip(struct udevice *bus, uint chip_addr,
 static int sun6i_p2wi_probe(struct udevice *bus)
 {
        struct sun6i_p2wi_priv *priv = dev_get_priv(bus);
+       struct reset_ctl *reset;
+       struct clk *clk;
 
        priv->base = dev_read_addr_ptr(bus);
 
+       reset = devm_reset_control_get(bus, NULL);
+       if (!IS_ERR(reset))
+               reset_deassert(reset);
+
+       clk = devm_clk_get(bus, NULL);
+       if (!IS_ERR(clk))
+               clk_enable(clk);
+
        sun6i_p2wi_init(priv->base);
 
        return 0;