]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
soc: imx8m: Enable OCOTP clock before reading the register
authorXiaolei Wang <xiaolei.wang@windriver.com>
Fri, 28 Oct 2022 04:14:18 +0000 (12:14 +0800)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 12:59:28 +0000 (13:59 +0100)
[ Upstream commit 836fb30949d9edf91d7de696a884ceeae7e426d2 ]

Commit 7d981405d0fd ("soc: imx8m: change to use platform driver") ever
removed the dependency on bootloader for enabling OCOTP clock.  It
helped to fix a kexec kernel hang issue.  But unfortunately it caused
a regression on CAAM driver and got reverted.

This is the second try to enable the OCOTP clock by directly calling
clock API instead of indirectly enabling the clock via nvmem API.

Fixes: ac34de14ac30 ("Revert "soc: imx8m: change to use platform driver"")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 19feb6cf41368e9c8237c8a6be158f161ad2f2d9)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
drivers/soc/imx/soc-imx8m.c

index cc57a384d74d201efe1f7c0dd2857419a84900e4..28144c699b0c39c0548a8f50d1b9ef44f34e155d 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/platform_device.h>
 #include <linux/arm-smccc.h>
 #include <linux/of.h>
+#include <linux/clk.h>
 
 #define REV_B1                         0x21
 
@@ -56,6 +57,7 @@ static u32 __init imx8mq_soc_revision(void)
        void __iomem *ocotp_base;
        u32 magic;
        u32 rev;
+       struct clk *clk;
 
        np = of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp");
        if (!np)
@@ -63,6 +65,13 @@ static u32 __init imx8mq_soc_revision(void)
 
        ocotp_base = of_iomap(np, 0);
        WARN_ON(!ocotp_base);
+       clk = of_clk_get_by_name(np, NULL);
+       if (!clk) {
+               WARN_ON(!clk);
+               return 0;
+       }
+
+       clk_prepare_enable(clk);
 
        /*
         * SOC revision on older imx8mq is not available in fuses so query
@@ -79,6 +88,8 @@ static u32 __init imx8mq_soc_revision(void)
        soc_uid <<= 32;
        soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
 
+       clk_disable_unprepare(clk);
+       clk_put(clk);
        iounmap(ocotp_base);
        of_node_put(np);