LFU-126-12 i.MX8: Moved Power on JR resource to jobring driver.
authorGaurav Jain <gaurav.jain@nxp.com>
Mon, 17 May 2021 04:09:31 +0000 (09:39 +0530)
committerGaurav Jain <gaurav.jain@nxp.com>
Wed, 19 May 2021 05:08:11 +0000 (10:38 +0530)
u-boot power domain driver API is used to power on JR.
so that u-boot framework will automatically
power off JR resource before booting into kernel.

Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
arch/arm/mach-imx/imx8/cpu.c
board/freescale/imx8dxl_phantom_mek/spl.c
board/freescale/imx8qm_mek/spl.c
board/freescale/imx8qxp_mek/spl.c
drivers/crypto/fsl/jr.c

index 2eba5eb..4697c6e 100644 (file)
@@ -109,10 +109,6 @@ int arch_misc_init(void)
        struct udevice *dev;
        int node, ret;
 
-       /* Request seco for JR2 access.JR0, JR1 will be assigned to seco for imx8 */
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2, SC_PM_PW_MODE_ON);
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2_OUT, SC_PM_PW_MODE_ON);
-
        node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "fsl,sec-v4.0");
 
        ret = uclass_get_device_by_of_offset(UCLASS_MISC, node, &dev);
index c14a24c..7b78452 100644 (file)
@@ -16,7 +16,6 @@
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <bootm.h>
-#include <asm/arch/sci/sci.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -33,12 +32,7 @@ void spl_board_init(void)
        }
        device_probe(dev);
 
-       /* Request seco for JR2 access.JR0, JR1 will be assigned to seco for imx8 */
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2, SC_PM_PW_MODE_ON);
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2_OUT, SC_PM_PW_MODE_ON);
-
        uclass_find_first_device(UCLASS_MISC, &dev);
-
        for (; dev; uclass_find_next_device(&dev)) {
                if (device_probe(dev))
                        continue;
index a2c7b87..adfe511 100644 (file)
@@ -17,7 +17,6 @@
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <bootm.h>
-#include <asm/arch/sci/sci.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,12 +33,7 @@ void spl_board_init(void)
        }
        device_probe(dev);
 
-       /* Request seco for JR2 access.JR0, JR1 will be assigned to seco for imx8 */
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2, SC_PM_PW_MODE_ON);
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2_OUT, SC_PM_PW_MODE_ON);
-
        uclass_find_first_device(UCLASS_MISC, &dev);
-
        for (; dev; uclass_find_next_device(&dev)) {
                if (device_probe(dev))
                        continue;
index 8be64fe..1fdc3fc 100644 (file)
@@ -49,12 +49,7 @@ void spl_board_init(void)
        }
        device_probe(dev);
 
-       /* Request seco for JR2 access.JR0, JR1 will be assigned to seco for imx8 */
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2, SC_PM_PW_MODE_ON);
-       sc_pm_set_resource_power_mode(-1, SC_R_CAAM_JR2_OUT, SC_PM_PW_MODE_ON);
-
        uclass_find_first_device(UCLASS_MISC, &dev);
-
        for (; dev; uclass_find_next_device(&dev)) {
                if (device_probe(dev))
                        continue;
index b02e347..bdbc7d4 100644 (file)
@@ -25,6 +25,7 @@
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <dm/device-internal.h>
+#include <power-domain.h>
 
 #define CIRC_CNT(head, tail, size)     (((head) - (tail)) & (size - 1))
 #define CIRC_SPACE(head, tail, size)   CIRC_CNT((tail), (head) + 1, (size))
@@ -778,6 +779,25 @@ int sec_init(void)
        return sec_init_idx(0);
 }
 
+#ifdef CONFIG_ARCH_IMX8
+static int jr_power_on(int subnode)
+{
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+       struct udevice __maybe_unused jr_dev;
+       struct power_domain pd;
+
+       dev_set_ofnode(&jr_dev, offset_to_ofnode(subnode));
+
+       /* Need to power on Job Ring before access it */
+       if (!power_domain_get(&jr_dev, &pd)) {
+               if (power_domain_on(&pd))
+                       return -EINVAL;
+       }
+#endif
+       return 0;
+}
+#endif
+
 #if CONFIG_IS_ENABLED(DM)
 static int caam_jr_probe(struct udevice *dev)
 {
@@ -810,6 +830,11 @@ static int caam_jr_probe(struct udevice *dev)
                                jr_node = jr_node >> 4;
                        }
                        caam->jrid = jr_node - 1;
+#ifdef CONFIG_ARCH_IMX8
+                       ret = jr_power_on(subnode);
+                       if (ret)
+                               return ret;
+#endif
                        break;
                }
        }