Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: imx8m: Enable OCOTP clock for imx8mm before reading registers

Commit 836fb30949d9 ("soc: imx8m: Enable OCOTP clock before reading the
register") added configuration to enable the OCOTP clock before
attempting to read from the associated registers.

This same kexec issue is present with the imx8m SoCs that use the
imx8mm_soc_uid function (e.g. imx8mp). This requires the imx8mm_soc_uid
function to configure the OCOTP clock before accessing the associated
registers. This change implements the same clock enable functionality
that is present in the imx8mq_soc_revision function for the
imx8mm_soc_uid function.

Signed-off-by: Nathan Rossi <nathan.rossi@digi.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Fixes: 836fb30949d9 ("soc: imx8m: Enable OCOTP clock before reading the register")
Signed-off-by: Shawn Guo <shawnguo@kernel.org>

authored by

Nathan Rossi and committed by
Shawn Guo
9d1e8275 161af16c

+10
+10
drivers/soc/imx/soc-imx8m.c
··· 100 100 { 101 101 void __iomem *ocotp_base; 102 102 struct device_node *np; 103 + struct clk *clk; 103 104 u32 offset = of_machine_is_compatible("fsl,imx8mp") ? 104 105 IMX8MP_OCOTP_UID_OFFSET : 0; 105 106 ··· 110 109 111 110 ocotp_base = of_iomap(np, 0); 112 111 WARN_ON(!ocotp_base); 112 + clk = of_clk_get_by_name(np, NULL); 113 + if (IS_ERR(clk)) { 114 + WARN_ON(IS_ERR(clk)); 115 + return; 116 + } 117 + 118 + clk_prepare_enable(clk); 113 119 114 120 soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset); 115 121 soc_uid <<= 32; 116 122 soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset); 117 123 124 + clk_disable_unprepare(clk); 125 + clk_put(clk); 118 126 iounmap(ocotp_base); 119 127 of_node_put(np); 120 128 }