]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
firmware: zynqmp: Move permission to change config object message
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Tue, 23 May 2023 12:42:13 +0000 (14:42 +0200)
committerMichal Simek <michal.simek@amd.com>
Mon, 12 Jun 2023 11:25:01 +0000 (13:25 +0200)
Move the permission to change a config object message from
zynqmp_pmufw_load_config_object function to zynqmp_pmufw_node function
to simplify the code and check the permission only if required.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Link: https://lore.kernel.org/r/20230523124215.30915-4-stefan.herbrechtsmeier-oss@weidmueller.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
drivers/firmware/firmware-zynqmp.c

index ca3a0b55c9f57d857a4f2b93dec70ae44b7bcf25..e1abfb4cec3202bcb14e4d02d2461c59ec5e2c1c 100644 (file)
@@ -63,29 +63,32 @@ static unsigned int xpm_configobject_close[] = {
 
 int zynqmp_pmufw_config_close(void)
 {
-       zynqmp_pmufw_load_config_object(xpm_configobject_close,
-                                       sizeof(xpm_configobject_close));
-       return 0;
+       return zynqmp_pmufw_load_config_object(xpm_configobject_close,
+                                              sizeof(xpm_configobject_close));
 }
 
 int zynqmp_pmufw_node(u32 id)
 {
-       static bool skip_config;
-       int ret;
+       static bool check = true;
+       static bool permission = true;
+
+       if (check) {
+               check = false;
+
+               if (zynqmp_pmufw_node(NODE_OCM_BANK_0) == -EACCES) {
+                       printf("PMUFW:  No permission to change config object\n");
+                       permission = false;
+               }
+       }
 
-       if (skip_config)
+       if (!permission)
                return 0;
 
        /* Record power domain id */
        xpm_configobject[NODE_ID_LOCATION] = id;
 
-       ret = zynqmp_pmufw_load_config_object(xpm_configobject,
-                                             sizeof(xpm_configobject));
-
-       if (ret == -EACCES && id == NODE_OCM_BANK_0)
-               skip_config = true;
-
-       return 0;
+       return zynqmp_pmufw_load_config_object(xpm_configobject,
+                                              sizeof(xpm_configobject));
 }
 
 static int do_pm_probe(void)
@@ -250,8 +253,6 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size)
        err = xilinx_pm_request(PM_SET_CONFIGURATION, (u32)(u64)cfg_obj, 0, 0,
                                0, ret_payload);
        if (err == XST_PM_NO_ACCESS) {
-               if (((u32 *)cfg_obj)[NODE_ID_LOCATION] == NODE_OCM_BANK_0)
-                       printf("PMUFW:  No permission to change config object\n");
                return -EACCES;
        }
 
@@ -295,9 +296,6 @@ static int zynqmp_power_probe(struct udevice *dev)
               ret >> ZYNQMP_PM_VERSION_MAJOR_SHIFT,
               ret & ZYNQMP_PM_VERSION_MINOR_MASK);
 
-       if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
-               zynqmp_pmufw_node(NODE_OCM_BANK_0);
-
        return 0;
 };