Commit a31de1e8 authored by Manish Pandey's avatar Manish Pandey Committed by TrustedFirmware Code Review
Browse files

Merge changes from topic "zynqmp-new-apis" into integration

* changes:
  xilinx: zynqmp: Add support for Error Management
  zynqmp:pm: Adds new zynqmp-pm api SMC call for efuse
  zynqmp : pm : Adds new zynqmp-pm api SMC call for register access
parents 484752f3 504925f9
......@@ -350,4 +350,10 @@
#define AFIFM6_WRCTRL U(13)
#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 */
......@@ -65,6 +65,10 @@ unsigned int pm_get_shutdown_scope(void)
PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4); \
}
#define EM_PACK_PAYLOAD1(pl, arg0) { \
pl[0] = (uint16_t)(0xE) << 16 | (uint16_t)arg0; \
}
/**
* pm_self_suspend() - PM call for processor to suspend itself
* @nid Node id of the processor or subsystem
......@@ -1546,3 +1550,101 @@ 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);
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;
}
/**
* pm_efuse_access() - To program or read efuse bits.
*
* This function provides access to the xilskey library to program/read
* efuse bits.
*
* address_low: lower 32-bit Linear memory space address
* address_high: higher 32-bit Linear memory space address
*
* value: Returned output value
*
* @return Returns status, either success or error+reason
*
*/
enum pm_ret_status pm_efuse_access(uint32_t address_high,
uint32_t address_low,
uint32_t *value)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMU */
PM_PACK_PAYLOAD3(payload, PM_EFUSE_ACCESS, address_high, address_low);
return pm_ipi_send_sync(primary_proc, payload, value, 1);
}
enum pm_ret_status em_set_action(unsigned int *value)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMU */
EM_PACK_PAYLOAD1(payload, EM_SET_ACTION);
return pm_ipi_send_sync(primary_proc, payload, value, 1);
}
enum pm_ret_status em_remove_action(unsigned int *value)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMU */
EM_PACK_PAYLOAD1(payload, EM_REMOVE_ACTION);
return pm_ipi_send_sync(primary_proc, payload, value, 1);
}
enum pm_ret_status em_send_errors(unsigned int *value)
{
uint32_t payload[PAYLOAD_ARG_CNT];
/* Send request to the PMU */
EM_PACK_PAYLOAD1(payload, EM_SEND_ERRORS);
return pm_ipi_send_sync(primary_proc, payload, value, 1);
}
......@@ -28,6 +28,11 @@ enum pm_query_id {
PM_QID_CLOCK_GET_MAX_DIVISOR,
};
enum pm_register_access_id {
CONFIG_REG_WRITE,
CONFIG_REG_READ,
};
/**********************************************************
* System-level API function declarations
**********************************************************/
......@@ -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,
uint32_t address_low,
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_pll_param param_id,
......@@ -186,5 +196,10 @@ enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode);
enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode);
enum pm_ret_status pm_efuse_access(uint32_t address_high,
uint32_t address_low, uint32_t *value);
enum pm_ret_status em_set_action(unsigned int *value);
enum pm_ret_status em_remove_action(unsigned int *value);
enum pm_ret_status em_send_errors(unsigned int *value);
#endif /* PM_API_SYS_H */
/*
* 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
*/
......@@ -33,6 +33,7 @@
#define PM_STATE_CPU_IDLE 0x0U
#define PM_STATE_SUSPEND_TO_RAM 0xFU
#define EM_FUNID_NUM_MASK 0xF0000U
/*********************************************************************
* Enum definitions
********************************************************************/
......@@ -97,6 +98,9 @@ enum pm_api_id {
PM_PLL_GET_PARAMETER,
PM_PLL_SET_MODE,
PM_PLL_GET_MODE,
/* PM Register Access API */
PM_REGISTER_ACCESS,
PM_EFUSE_ACCESS,
PM_API_MAX
};
......@@ -320,4 +324,13 @@ enum pm_clock_div_id {
PM_CLOCK_DIV1_ID,
};
/**
* EM API IDs
*/
enum em_api_id {
EM_SET_ACTION = 1,
EM_REMOVE_ACTION,
EM_SEND_ERRORS,
};
#endif /* PM_DEFS_H */
......@@ -606,8 +606,78 @@ 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));
}
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);
}
case PM_EFUSE_ACCESS:
{
uint32_t value;
ret = pm_efuse_access(pm_arg[0], pm_arg[1], &value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
}
default:
WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK);
}
}
/**
* em_smc_handler() - SMC handler for EM-API calls coming from EL1/EL2.
* @smc_fid - Function Identifier
* @x1 - x4 - Arguments
* @cookie - Unused
* @handler - Pointer to caller's context structure
*
* @return - Unused
*
* Determines that smc_fid is valid and supported EM SMC Function ID from the
* list of em_api_ids, otherwise completes the request with
* the unknown SMC Function ID
*
* The SMC calls for EM service are forwarded from SIP Service SMC handler
* function with rt_svc_handle signature
*/
uint64_t em_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
uint64_t x4, void *cookie, void *handle, uint64_t flags)
{
enum pm_ret_status ret;
switch (smc_fid & FUNCID_NUM_MASK) {
/* EM API Functions */
case EM_SET_ACTION:
{
uint32_t value;
ret = em_set_action(&value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
}
case EM_REMOVE_ACTION:
{
uint32_t value;
ret = em_remove_action(&value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
}
case EM_SEND_ERRORS:
{
uint32_t value;
ret = em_send_errors(&value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
}
default:
WARN("Unimplemented EM Service Call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK);
}
}
/*
* Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
......@@ -14,4 +14,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
uint64_t x4, void *cookie, void *handle,
uint64_t flags);
uint64_t em_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
uint64_t x4, void *cookie, void *handle,
uint64_t flags);
#endif /* PM_SVC_MAIN_H */
/*
* 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
*/
......@@ -25,6 +25,9 @@
#define PM_FID_MASK 0xf000u
#define PM_FID_VALUE 0u
#define IPI_FID_VALUE 0x1000u
#define EM_FID_MASK 0xf0000u
#define EM_FID_VALUE 0xE0000u
#define is_em_fid(_fid) (((_fid) & EM_FID_MASK) == EM_FID_VALUE)
#define is_pm_fid(_fid) (((_fid) & PM_FID_MASK) == PM_FID_VALUE)
#define is_ipi_fid(_fid) (((_fid) & PM_FID_MASK) == IPI_FID_VALUE)
......@@ -61,8 +64,12 @@ uintptr_t sip_svc_smc_handler(uint32_t smc_fid,
void *handle,
u_register_t flags)
{
/* Let EM SMC handler deal with EM-related requests */
if (is_em_fid(smc_fid)) {
return em_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle,
flags);
} else if (is_pm_fid(smc_fid)) {
/* Let PM SMC handler deal with PM-related requests */
if (is_pm_fid(smc_fid)) {
return pm_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle,
flags);
}
......
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