OCOTP register access needs the  OCOTP clock to be
running and this code peeks into this register region,
so it needs to ensure the clock is active. Otherwise,
this will affect the second kernel startup of kexec.

Signed-off-by: Xiaolei Wang <[email protected]>
Signed-off-by: Bruce Ashfield <[email protected]>
---
 arch/arm/mach-imx/common.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-imx/common.c b/arch/arm/mach-imx/common.c
index 5368497ac0db..f04195982ef9 100644
--- a/arch/arm/mach-imx/common.c
+++ b/arch/arm/mach-imx/common.c
@@ -13,6 +13,7 @@
 #include <linux/of_address.h>
 #include <linux/of_net.h>
 #include <linux/slab.h>
+#include <linux/clk.h>
 
 #include "hardware.h"
 
@@ -52,6 +53,7 @@ void __init imx6_enet_mac_init(const char *enet_compat, const 
char *ocotp_compat
        u32 macaddr1_high = 0;
        u8 *macaddr;
        int i, id;
+       struct clk *clk;
 
        for (i = 0; i < 2; i++) {
                enet_np = of_find_compatible_node(from, NULL, enet_compat);
@@ -79,12 +81,21 @@ void __init imx6_enet_mac_init(const char *enet_compat, 
const char *ocotp_compat
                        goto put_ocotp_node;
                }
 
+               clk = of_clk_get_by_name(ocotp_np, NULL);
+               if (!clk)
+                       goto put_ocotp_node;
+
+               clk_prepare_enable(clk);
+
                macaddr_low = readl_relaxed(base + OCOTP_MACn(1));
                if (id)
                        macaddr1_high = readl_relaxed(base + OCOTP_MACn(2));
                else
                        macaddr_high = readl_relaxed(base + OCOTP_MACn(0));
 
+               clk_disable_unprepare(clk);
+               clk_put(clk);
+
                newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
                if (!newmac)
                        goto put_ocotp_node;
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13110): 
https://lists.yoctoproject.org/g/linux-yocto/message/13110
Mute This Topic: https://lists.yoctoproject.org/mt/101570009/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to