arm64: zynqmp: Convert invoke_smc() to xilinx_pm_request()
authorMichal Simek <michal.simek@xilinx.com>
Fri, 4 Oct 2019 13:35:45 +0000 (15:35 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 24 Oct 2019 11:37:01 +0000 (13:37 +0200)
Remove macros which use PM_SIP_SVC offset and convert invoke_smc() to
xilinx_pm_request() which do calculation with PM_SIP_SVC already.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/mach-zynqmp/cpu.c
board/xilinx/zynqmp/cmds.c
drivers/firmware/firmware-zynqmp.c
drivers/fpga/zynqmppl.c
include/zynqmp_firmware.h

index 8a2677b8a9b80488acf526bb9d9a42a8c91f8a47..b90d08bbdd4eacdb72c1a2f1040da6b0fd87f2f9 100644 (file)
@@ -151,9 +151,6 @@ unsigned int zynqmp_get_silicon_version(void)
        return ZYNQMP_CSU_VERSION_SILICON;
 }
 
-#define ZYNQMP_MMIO_READ       0xC2000014
-#define ZYNQMP_MMIO_WRITE      0xC2000013
-
 static int zynqmp_mmio_rawwrite(const u32 address,
                      const u32 mask,
                      const u32 value)
@@ -187,8 +184,8 @@ int zynqmp_mmio_write(const u32 address,
                return zynqmp_mmio_rawwrite(address, mask, value);
 #if defined(CONFIG_ZYNQMP_FIRMWARE)
        else
-               return invoke_smc(ZYNQMP_MMIO_WRITE, address, mask,
-                                 value, 0, NULL);
+               return xilinx_pm_request(PM_MMIO_WRITE, address, mask,
+                                        value, 0, NULL);
 #endif
 
        return -EINVAL;
@@ -208,8 +205,8 @@ int zynqmp_mmio_read(const u32 address, u32 *value)
        else {
                u32 ret_payload[PAYLOAD_ARG_CNT];
 
-               ret = invoke_smc(ZYNQMP_MMIO_READ, address, 0, 0,
-                                0, ret_payload);
+               ret = xilinx_pm_request(PM_MMIO_READ, address, 0, 0,
+                                       0, ret_payload);
                *value = ret_payload[1];
        }
 #endif
index f53a1b63bea6c3a4a43e06e4ba2d3149a57fe898..d3bb57a2e94aca71ebbbf78662acfa9af6fa95eb 100644 (file)
@@ -51,8 +51,8 @@ static int do_zynqmp_verify_secure(cmd_tbl_t *cmdtp, int flag, int argc,
                                   (ulong)(key_ptr + KEY_PTR_LEN));
        }
 
-       ret = invoke_smc(ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD, src_lo, src_hi,
-                        key_lo, key_hi, ret_payload);
+       ret = xilinx_pm_request(PM_SECURE_IMAGE, src_lo, src_hi,
+                               key_lo, key_hi, ret_payload);
        if (ret) {
                printf("Failed: secure op status:0x%x\n", ret);
        } else {
index d11740ac772d3f04b70dea9ac12764694257b924..adcef15e22aa115e719e6b27a4872cbc9c73c935 100644 (file)
@@ -54,7 +54,7 @@ static int send_req(const u32 *req, size_t req_len, u32 *res, size_t res_maxlen)
        if (IS_ENABLED(CONFIG_SPL_BUILD))
                return ipi_req(req, req_len, res, res_maxlen);
 
-       return invoke_smc(req[0] + PM_SIP_SVC, 0, 0, 0, 0, res);
+       return xilinx_pm_request(req[0], 0, 0, 0, 0, res);
 }
 
 unsigned int zynqmp_firmware_version(void)
@@ -147,8 +147,8 @@ U_BOOT_DRIVER(zynqmp_power) = {
 };
 #endif
 
-int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2,
-                             u32 arg3, u32 *ret_payload)
+int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
+                                    u32 arg3, u32 *ret_payload)
 {
        /*
         * Added SIP service call Function Identifier
@@ -159,7 +159,7 @@ int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2,
        if (current_el() == 3)
                return 0;
 
-       regs.regs[0] = pm_api_id;
+       regs.regs[0] = PM_SIP_SVC | api_id;
        regs.regs[1] = ((u64)arg1 << 32) | arg0;
        regs.regs[2] = ((u64)arg3 << 32) | arg2;
 
@@ -176,13 +176,6 @@ int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2,
        return regs.regs[0];
 }
 
-int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
-                                    u32 arg3, u32 *ret_payload)
-{
-       return invoke_smc(PM_SIP_SVC | api_id, arg0, arg1, arg2, arg3,
-                         ret_payload);
-}
-
 static const struct udevice_id zynqmp_firmware_ids[] = {
        { .compatible = "xlnx,zynqmp-firmware" },
        { .compatible = "xlnx,versal-firmware"},
index c2670271c8ea3ad4a9f15df1e39a65f50f951072..d129b5459c005db9e46c7d856f8c574f06c0a3f6 100644 (file)
@@ -227,11 +227,12 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize,
        buf_hi = upper_32_bits(bin_buf);
 
        if (xilfpga_old)
-               ret = invoke_smc(ZYNQMP_SIP_SVC_PM_FPGA_LOAD, buf_lo, buf_hi,
-                                (u32)(uintptr_t)bsizeptr, bstype, ret_payload);
+               ret = xilinx_pm_request(ZYNQMP_SIP_SVC_PM_FPGA_LOAD, buf_lo,
+                                       buf_hi, (u32)(uintptr_t)bsizeptr,
+                                       bstype, ret_payload);
        else
-               ret = invoke_smc(ZYNQMP_SIP_SVC_PM_FPGA_LOAD, buf_lo, buf_hi,
-                                (u32)bsize, 0, ret_payload);
+               ret = xilinx_pm_request(ZYNQMP_SIP_SVC_PM_FPGA_LOAD, buf_lo,
+                                       buf_hi, (u32)bsize, 0, ret_payload);
 
        if (ret)
                puts("PL FPGA LOAD fail\n");
@@ -272,7 +273,8 @@ static int zynqmp_loads(xilinx_desc *desc, const void *buf, size_t bsize,
        buf_lo = lower_32_bits((ulong)buf);
        buf_hi = upper_32_bits((ulong)buf);
 
-       ret = invoke_smc(ZYNQMP_SIP_SVC_PM_FPGA_LOAD, buf_lo, buf_hi,
+       ret = xilinx_pm_request(ZYNQMP_SIP_SVC_PM_FPGA_LOAD, buf_lo,
+                               buf_hi,
                         (u32)(uintptr_t)fpga_sec_info->userkey_addr,
                         flag, ret_payload);
        if (ret)
@@ -289,8 +291,8 @@ static int zynqmp_pcap_info(xilinx_desc *desc)
        int ret;
        u32 ret_payload[PAYLOAD_ARG_CNT];
 
-       ret = invoke_smc(ZYNQMP_SIP_SVC_PM_FPGA_STATUS, 0, 0, 0,
-                        0, ret_payload);
+       ret = xilinx_pm_request(ZYNQMP_SIP_SVC_PM_FPGA_STATUS, 0, 0, 0,
+                               0, ret_payload);
        if (!ret)
                printf("PCAP status\t0x%x\n", ret_payload[1]);
 
index 84090208e50c927990ebca7c2632c89e08c92b02..93d771ece26a62ba819809f636d18cb272b6ba46 100644 (file)
@@ -63,8 +63,6 @@ enum pm_api_id {
 };
 
 #define PM_SIP_SVC      0xc2000000
-#define ZYNQMP_SIP_SVC_PM_SECURE_IMG_LOAD       \
-       (PM_SIP_SVC + PM_SECURE_IMAGE)
 
 #define ZYNQMP_PM_VERSION_MAJOR         1
 #define ZYNQMP_PM_VERSION_MINOR         0
@@ -81,8 +79,6 @@ enum pm_api_id {
 
 unsigned int zynqmp_firmware_version(void);
 void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size);
-int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,
-              u32 *ret_payload);
 int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
                      u32 arg3, u32 *ret_payload);