Commit d716f045 authored by Kalyani Akula's avatar Kalyani Akula Committed by Manish Pandey
Browse files

zynqmp : pm : Adds new zynqmp-pm api SMC call for register access



This patch adds new zynqmp-pm api to provide read/write access to
CSU or PMU global registers.
Signed-off-by: default avatarKalyani Akula <kalyania@xilinx.com>
Signed-off-by: default avatarRajan Vaja <rajan.vaja@xilinx.com>
Change-Id: I4fd52eb732fc3e6a8bccd96cad7dc090b2161042
parent 484752f3
...@@ -350,4 +350,10 @@ ...@@ -350,4 +350,10 @@
#define AFIFM6_WRCTRL U(13) #define AFIFM6_WRCTRL U(13)
#define FABRIC_WIDTH U(3) #define FABRIC_WIDTH U(3)
/* CSUDMA Module Base Address*/
#define CSUDMA_BASE 0xFFC80000
/* RSA-CORE Module Base Address*/
#define RSA_CORE_BASE 0xFFCE0000
#endif /* ZYNQMP_DEF_H */ #endif /* ZYNQMP_DEF_H */
...@@ -1546,3 +1546,48 @@ enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode) ...@@ -1546,3 +1546,48 @@ enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode)
PM_PACK_PAYLOAD2(payload, PM_PLL_GET_MODE, nid); PM_PACK_PAYLOAD2(payload, PM_PLL_GET_MODE, nid);
return pm_ipi_send_sync(primary_proc, payload, mode, 1); return pm_ipi_send_sync(primary_proc, payload, mode, 1);
} }
/**
* pm_register_access() - PM API for register read/write access data
*
* @register_access_id Register_access_id which says register read/write
*
* @address Address of the register to be accessed
*
* @mask Mask value to be used while writing value
*
* @value Value to be written to register
*
* @out Returned output data
*
* This function returns requested data.
*
* @return Returns status, either success or error+reason
*/
enum pm_ret_status pm_register_access(unsigned int register_access_id,
unsigned int address,
unsigned int mask,
unsigned int value,
unsigned int *out)
{
enum pm_ret_status ret;
if (((ZYNQMP_CSU_BASEADDR & address) != ZYNQMP_CSU_BASEADDR) &&
((CSUDMA_BASE & address) != CSUDMA_BASE) &&
((RSA_CORE_BASE & address) != RSA_CORE_BASE) &&
((PMU_GLOBAL_BASE & address) != PMU_GLOBAL_BASE))
return PM_RET_ERROR_ACCESS;
switch (register_access_id) {
case CONFIG_REG_WRITE:
ret = pm_mmio_write(address, mask, value);
break;
case CONFIG_REG_READ:
ret = pm_mmio_read(address, out);
break;
default:
ret = PM_RET_ERROR_ARGS;
WARN("Unimplemented register_access call\n\r");
}
return ret;
}
...@@ -28,6 +28,11 @@ enum pm_query_id { ...@@ -28,6 +28,11 @@ enum pm_query_id {
PM_QID_CLOCK_GET_MAX_DIVISOR, PM_QID_CLOCK_GET_MAX_DIVISOR,
}; };
enum pm_register_access_id {
CONFIG_REG_WRITE,
CONFIG_REG_READ,
};
/********************************************************** /**********************************************************
* System-level API function declarations * System-level API function declarations
**********************************************************/ **********************************************************/
...@@ -175,6 +180,11 @@ enum pm_ret_status pm_fpga_read(uint32_t reg_numframes, ...@@ -175,6 +180,11 @@ enum pm_ret_status pm_fpga_read(uint32_t reg_numframes,
enum pm_ret_status pm_aes_engine(uint32_t address_high, enum pm_ret_status pm_aes_engine(uint32_t address_high,
uint32_t address_low, uint32_t address_low,
uint32_t *value); uint32_t *value);
enum pm_ret_status pm_register_access(unsigned int register_access_id,
unsigned int address,
unsigned int mask,
unsigned int value,
unsigned int *out);
enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid, enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
enum pm_pll_param param_id, enum pm_pll_param param_id,
......
/* /*
* Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -97,6 +97,8 @@ enum pm_api_id { ...@@ -97,6 +97,8 @@ enum pm_api_id {
PM_PLL_GET_PARAMETER, PM_PLL_GET_PARAMETER,
PM_PLL_SET_MODE, PM_PLL_SET_MODE,
PM_PLL_GET_MODE, PM_PLL_GET_MODE,
/* PM Register Access API */
PM_REGISTER_ACCESS,
PM_API_MAX PM_API_MAX
}; };
......
...@@ -606,6 +606,15 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3, ...@@ -606,6 +606,15 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32)); SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32));
} }
case PM_REGISTER_ACCESS:
{
uint32_t value;
ret = pm_register_access(pm_arg[0], pm_arg[1], pm_arg[2],
pm_arg[3], &value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
}
default: default:
WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid); WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK); SMC_RET1(handle, SMC_UNK);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment