]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
pinctrl: spacemit: add clock support for K1 SoC
authorYixun Lan <dlan@gentoo.org>
Wed, 16 Apr 2025 00:15:28 +0000 (08:15 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 23 Apr 2025 08:39:03 +0000 (10:39 +0200)
For SpacemiT K1 SoC's pinctrl, explicitly acquiring clocks in
the driver instead of relying on bootloader or default hardware
settings to enable it.

Signed-off-by: Yixun Lan <dlan@gentoo.org>
Reviewed-by: Alex Elder <elder@riscstar.com>
Link: https://lore.kernel.org/20250416-02-k1-pinctrl-clk-v2-2-2b5fcbd4183c@gentoo.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/spacemit/pinctrl-k1.c

index 67e867b04a02ea1887d93aedfdea5bda037f88b1..9996b1c4a07e72f2a3832b759feddcd4e07f2159 100644 (file)
@@ -2,6 +2,7 @@
 /* Copyright (c) 2024 Yixun Lan <dlan@gentoo.org> */
 
 #include <linux/bits.h>
+#include <linux/clk.h>
 #include <linux/cleanup.h>
 #include <linux/io.h>
 #include <linux/of.h>
@@ -721,6 +722,7 @@ static int spacemit_pinctrl_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct spacemit_pinctrl *pctrl;
+       struct clk *func_clk, *bus_clk;
        const struct spacemit_pinctrl_data *pctrl_data;
        int ret;
 
@@ -739,6 +741,14 @@ static int spacemit_pinctrl_probe(struct platform_device *pdev)
        if (IS_ERR(pctrl->regs))
                return PTR_ERR(pctrl->regs);
 
+       func_clk = devm_clk_get_enabled(dev, "func");
+       if (IS_ERR(func_clk))
+               return dev_err_probe(dev, PTR_ERR(func_clk), "failed to get func clock\n");
+
+       bus_clk = devm_clk_get_enabled(dev, "bus");
+       if (IS_ERR(bus_clk))
+               return dev_err_probe(dev, PTR_ERR(bus_clk), "failed to get bus clock\n");
+
        pctrl->pdesc.name = dev_name(dev);
        pctrl->pdesc.pins = pctrl_data->pins;
        pctrl->pdesc.npins = pctrl_data->npins;