mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-08-12 15:37:03 +02:00
fix(zynqmp): resolve misra R15.6 warnings
MISRA Violation: MISRA-C:2012 R.15.6 - The body of an iteration-statement or a selection-statement shall be a compound statement. Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@xilinx.com> Change-Id: I0fc8eeac0e592f00297a1ac42a1ba3df1144733b
This commit is contained in:
parent
5bcbd2de12
commit
eb0d2b1772
@ -69,8 +69,9 @@ static inline int is_ipi_mb_within_range(uint32_t local, uint32_t remote)
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
if (remote >= ipi_total || local >= ipi_total)
|
||||
if (remote >= ipi_total || local >= ipi_total) {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -88,12 +89,13 @@ int ipi_mb_validate(uint32_t local, uint32_t remote, unsigned int is_secure)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!is_ipi_mb_within_range(local, remote))
|
||||
if (!is_ipi_mb_within_range(local, remote)) {
|
||||
ret = -EINVAL;
|
||||
else if (IPI_IS_SECURE(local) && !is_secure)
|
||||
} else if (IPI_IS_SECURE(local) && !is_secure) {
|
||||
ret = -EPERM;
|
||||
else if (IPI_IS_SECURE(remote) && !is_secure)
|
||||
} else if (IPI_IS_SECURE(remote) && !is_secure) {
|
||||
ret = -EPERM;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -141,11 +143,13 @@ int ipi_mb_enquire_status(uint32_t local, uint32_t remote)
|
||||
uint32_t status;
|
||||
|
||||
status = mmio_read_32(IPI_REG_BASE(local) + IPI_OBR_OFFSET);
|
||||
if (status & IPI_BIT_MASK(remote))
|
||||
if (status & IPI_BIT_MASK(remote)) {
|
||||
ret |= IPI_MB_STATUS_SEND_PENDING;
|
||||
}
|
||||
status = mmio_read_32(IPI_REG_BASE(local) + IPI_ISR_OFFSET);
|
||||
if (status & IPI_BIT_MASK(remote))
|
||||
if (status & IPI_BIT_MASK(remote)) {
|
||||
ret |= IPI_MB_STATUS_RECV_PENDING;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -123,10 +123,11 @@ static int get_fsbl_endian(const struct xfsbl_partition *partition)
|
||||
|
||||
flags >>= FSBL_FLAGS_ENDIAN_SHIFT;
|
||||
|
||||
if (flags == FSBL_FLAGS_ENDIAN_BE)
|
||||
if (flags == FSBL_FLAGS_ENDIAN_BE) {
|
||||
return SPSR_E_BIG;
|
||||
else
|
||||
} else {
|
||||
return SPSR_E_LITTLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,30 +227,33 @@ enum fsbl_handoff fsbl_atf_handover(entry_point_info_t *bl32,
|
||||
if (target_secure == FSBL_FLAGS_SECURE) {
|
||||
image = bl32;
|
||||
|
||||
if (target_estate == FSBL_FLAGS_ESTATE_A32)
|
||||
if (target_estate == FSBL_FLAGS_ESTATE_A32) {
|
||||
bl32->spsr = SPSR_MODE32(MODE32_svc, SPSR_T_ARM,
|
||||
target_endianness,
|
||||
DISABLE_ALL_EXCEPTIONS);
|
||||
else
|
||||
} else {
|
||||
bl32->spsr = SPSR_64(MODE_EL1, MODE_SP_ELX,
|
||||
DISABLE_ALL_EXCEPTIONS);
|
||||
}
|
||||
} else {
|
||||
image = bl33;
|
||||
|
||||
if (target_estate == FSBL_FLAGS_ESTATE_A32) {
|
||||
if (target_el == FSBL_FLAGS_EL2)
|
||||
if (target_el == FSBL_FLAGS_EL2) {
|
||||
target_el = MODE32_hyp;
|
||||
else
|
||||
} else {
|
||||
target_el = MODE32_sys;
|
||||
}
|
||||
|
||||
bl33->spsr = SPSR_MODE32(target_el, SPSR_T_ARM,
|
||||
target_endianness,
|
||||
DISABLE_ALL_EXCEPTIONS);
|
||||
} else {
|
||||
if (target_el == FSBL_FLAGS_EL2)
|
||||
if (target_el == FSBL_FLAGS_EL2) {
|
||||
target_el = MODE_EL2;
|
||||
else
|
||||
} else {
|
||||
target_el = MODE_EL1;
|
||||
}
|
||||
|
||||
bl33->spsr = SPSR_64(target_el, MODE_SP_ELX,
|
||||
DISABLE_ALL_EXCEPTIONS);
|
||||
@ -262,10 +266,11 @@ enum fsbl_handoff fsbl_atf_handover(entry_point_info_t *bl32,
|
||||
target_el);
|
||||
image->pc = ATFHandoffParams->partition[i].entry_point;
|
||||
|
||||
if (target_endianness == SPSR_E_BIG)
|
||||
if (target_endianness == SPSR_E_BIG) {
|
||||
EP_SET_EE(image->h.attr, EP_EE_BIG);
|
||||
else
|
||||
} else {
|
||||
EP_SET_EE(image->h.attr, EP_EE_LITTLE);
|
||||
}
|
||||
}
|
||||
|
||||
return FSBL_HANDOFF_SUCCESS;
|
||||
|
@ -154,14 +154,16 @@ static enum pm_ret_status pm_ipi_buff_read(const struct pm_proc *proc,
|
||||
value++;
|
||||
}
|
||||
#if IPI_CRC_CHECK
|
||||
for (j = 0; j < PAYLOAD_ARG_CNT; j++)
|
||||
for (j = 0; j < PAYLOAD_ARG_CNT; j++) {
|
||||
response_payload[j] = mmio_read_32(buffer_base +
|
||||
(j * PAYLOAD_ARG_SIZE));
|
||||
}
|
||||
|
||||
if (response_payload[PAYLOAD_CRC_POS] !=
|
||||
calculate_crc(response_payload, IPI_W0_TO_W6_SIZE))
|
||||
calculate_crc(response_payload, IPI_W0_TO_W6_SIZE)) {
|
||||
NOTICE("ERROR in CRC response payload value:0x%x\n",
|
||||
response_payload[PAYLOAD_CRC_POS]);
|
||||
}
|
||||
#endif
|
||||
|
||||
return mmio_read_32(buffer_base);
|
||||
@ -186,22 +188,25 @@ void pm_ipi_buff_read_callb(unsigned int *value, size_t count)
|
||||
IPI_BUFFER_TARGET_LOCAL_OFFSET +
|
||||
IPI_BUFFER_REQ_OFFSET;
|
||||
|
||||
if (count > IPI_BUFFER_MAX_WORDS)
|
||||
if (count > IPI_BUFFER_MAX_WORDS) {
|
||||
count = IPI_BUFFER_MAX_WORDS;
|
||||
}
|
||||
|
||||
for (i = 0; i <= count; i++) {
|
||||
*value = mmio_read_32(buffer_base + (i * PAYLOAD_ARG_SIZE));
|
||||
value++;
|
||||
}
|
||||
#if IPI_CRC_CHECK
|
||||
for (j = 0; j < PAYLOAD_ARG_CNT; j++)
|
||||
for (j = 0; j < PAYLOAD_ARG_CNT; j++) {
|
||||
response_payload[j] = mmio_read_32(buffer_base +
|
||||
(j * PAYLOAD_ARG_SIZE));
|
||||
}
|
||||
|
||||
if (response_payload[PAYLOAD_CRC_POS] !=
|
||||
calculate_crc(response_payload, IPI_W0_TO_W6_SIZE))
|
||||
calculate_crc(response_payload, IPI_W0_TO_W6_SIZE)) {
|
||||
NOTICE("ERROR in CRC response payload value:0x%x\n",
|
||||
response_payload[PAYLOAD_CRC_POS]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -226,8 +231,9 @@ enum pm_ret_status pm_ipi_send_sync(const struct pm_proc *proc,
|
||||
bakery_lock_get(&pm_secure_lock);
|
||||
|
||||
ret = pm_ipi_send_common(proc, payload, IPI_BLOCKING);
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
ret = ERROR_CODE_MASK & (pm_ipi_buff_read(proc, value, count));
|
||||
|
||||
@ -253,10 +259,11 @@ uint32_t pm_ipi_irq_status(const struct pm_proc *proc)
|
||||
|
||||
ret = ipi_mb_enquire_status(proc->ipi->local_ipi_id,
|
||||
proc->ipi->remote_ipi_id);
|
||||
if (ret & IPI_MB_STATUS_RECV_PENDING)
|
||||
if (ret & IPI_MB_STATUS_RECV_PENDING) {
|
||||
return 1;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if IPI_CRC_CHECK
|
||||
|
@ -47,10 +47,11 @@ unsigned int zynqmp_get_uart_clk(void)
|
||||
{
|
||||
unsigned int ver = zynqmp_get_silicon_ver();
|
||||
|
||||
if (ver == ZYNQMP_CSU_VERSION_QEMU)
|
||||
if (ver == ZYNQMP_CSU_VERSION_QEMU) {
|
||||
return 133000000;
|
||||
else
|
||||
} else {
|
||||
return 100000000;
|
||||
}
|
||||
}
|
||||
|
||||
#if LOG_LEVEL >= LOG_LEVEL_NOTICE
|
||||
@ -232,8 +233,9 @@ static char *zynqmp_get_silicon_idcode_name(void)
|
||||
chipid[0] = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_IDCODE_OFFSET);
|
||||
chipid[1] = mmio_read_32(EFUSE_BASEADDR + EFUSE_IPDISABLE_OFFSET);
|
||||
#else
|
||||
if (pm_get_chipid(chipid) != PM_RET_SUCCESS)
|
||||
if (pm_get_chipid(chipid) != PM_RET_SUCCESS) {
|
||||
return "XCZUUNKN";
|
||||
}
|
||||
#endif
|
||||
|
||||
id = chipid[0] & (ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK |
|
||||
@ -243,8 +245,9 @@ static char *zynqmp_get_silicon_idcode_name(void)
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) {
|
||||
if (zynqmp_devices[i].id == id &&
|
||||
zynqmp_devices[i].ver == (ver & ZYNQMP_CSU_VERSION_MASK))
|
||||
zynqmp_devices[i].ver == (ver & ZYNQMP_CSU_VERSION_MASK)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= ARRAY_SIZE(zynqmp_devices)) {
|
||||
@ -255,11 +258,13 @@ static char *zynqmp_get_silicon_idcode_name(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (!zynqmp_devices[i].evexists)
|
||||
if (!zynqmp_devices[i].evexists) {
|
||||
return zynqmp_devices[i].name;
|
||||
}
|
||||
|
||||
if (ver & ZYNQMP_PL_STATUS_MASK)
|
||||
if (ver & ZYNQMP_PL_STATUS_MASK) {
|
||||
return zynqmp_devices[i].name;
|
||||
}
|
||||
|
||||
len = strlen(zynqmp_devices[i].name) - 2;
|
||||
for (j = 0; j < strlen(name); j++) {
|
||||
@ -345,8 +350,9 @@ unsigned int zynqmp_get_bootmode(void)
|
||||
|
||||
ret = pm_mmio_read(CRL_APB_BOOT_MODE_USER, &r);
|
||||
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
r = mmio_read_32(CRL_APB_BOOT_MODE_USER);
|
||||
}
|
||||
|
||||
return r & CRL_APB_BOOT_MODE_MASK;
|
||||
}
|
||||
@ -373,8 +379,9 @@ unsigned int plat_get_syscnt_freq2(void)
|
||||
{
|
||||
unsigned int ver = zynqmp_get_silicon_ver();
|
||||
|
||||
if (ver == ZYNQMP_CSU_VERSION_QEMU)
|
||||
if (ver == ZYNQMP_CSU_VERSION_QEMU) {
|
||||
return 65000000;
|
||||
else
|
||||
} else {
|
||||
return mmio_read_32(IOU_SCNTRS_BASEFREQ);
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ static int zynqmp_pwr_domain_on(u_register_t mpidr)
|
||||
|
||||
VERBOSE("%s: mpidr: 0x%lx\n", __func__, mpidr);
|
||||
|
||||
if (cpu_id == -1)
|
||||
if (cpu_id == -1) {
|
||||
return PSCI_E_INTERN_FAIL;
|
||||
|
||||
}
|
||||
proc = pm_get_proc(cpu_id);
|
||||
|
||||
/* Check the APU proc status before wakeup */
|
||||
@ -63,9 +63,10 @@ static void zynqmp_pwr_domain_off(const psci_power_state_t *target_state)
|
||||
unsigned int cpu_id = plat_my_core_pos();
|
||||
const struct pm_proc *proc = pm_get_proc(cpu_id);
|
||||
|
||||
for (size_t i = 0; i <= PLAT_MAX_PWR_LVL; i++)
|
||||
for (size_t i = 0; i <= PLAT_MAX_PWR_LVL; i++) {
|
||||
VERBOSE("%s: target_state->pwr_domain_state[%lu]=%x\n",
|
||||
__func__, i, target_state->pwr_domain_state[i]);
|
||||
}
|
||||
|
||||
/* Prevent interrupts from spuriously waking up this cpu */
|
||||
gicv2_cpuif_disable();
|
||||
@ -106,9 +107,10 @@ static void zynqmp_pwr_domain_suspend(const psci_power_state_t *target_state)
|
||||
|
||||
static void zynqmp_pwr_domain_on_finish(const psci_power_state_t *target_state)
|
||||
{
|
||||
for (size_t i = 0; i <= PLAT_MAX_PWR_LVL; i++)
|
||||
for (size_t i = 0; i <= PLAT_MAX_PWR_LVL; i++) {
|
||||
VERBOSE("%s: target_state->pwr_domain_state[%lu]=%x\n",
|
||||
__func__, i, target_state->pwr_domain_state[i]);
|
||||
}
|
||||
plat_arm_gic_pcpu_init();
|
||||
gicv2_cpuif_enable();
|
||||
}
|
||||
@ -118,9 +120,10 @@ static void zynqmp_pwr_domain_suspend_finish(const psci_power_state_t *target_st
|
||||
unsigned int cpu_id = plat_my_core_pos();
|
||||
const struct pm_proc *proc = pm_get_proc(cpu_id);
|
||||
|
||||
for (size_t i = 0; i <= PLAT_MAX_PWR_LVL; i++)
|
||||
for (size_t i = 0; i <= PLAT_MAX_PWR_LVL; i++) {
|
||||
VERBOSE("%s: target_state->pwr_domain_state[%lu]=%x\n",
|
||||
__func__, i, target_state->pwr_domain_state[i]);
|
||||
}
|
||||
|
||||
/* Clear the APU power control register for this cpu */
|
||||
pm_client_wakeup(proc);
|
||||
@ -149,8 +152,9 @@ static void __dead2 zynqmp_system_off(void)
|
||||
pm_system_shutdown(PMF_SHUTDOWN_TYPE_SHUTDOWN,
|
||||
pm_get_shutdown_scope());
|
||||
|
||||
while (1)
|
||||
while (1) {
|
||||
wfi();
|
||||
}
|
||||
}
|
||||
|
||||
static void __dead2 zynqmp_system_reset(void)
|
||||
@ -162,8 +166,9 @@ static void __dead2 zynqmp_system_reset(void)
|
||||
pm_system_shutdown(PMF_SHUTDOWN_TYPE_RESET,
|
||||
pm_get_shutdown_scope());
|
||||
|
||||
while (1)
|
||||
while (1) {
|
||||
wfi();
|
||||
}
|
||||
}
|
||||
|
||||
int zynqmp_validate_power_state(unsigned int power_state,
|
||||
@ -176,14 +181,15 @@ int zynqmp_validate_power_state(unsigned int power_state,
|
||||
assert(req_state);
|
||||
|
||||
/* Sanity check the requested state */
|
||||
if (pstate == PSTATE_TYPE_STANDBY)
|
||||
if (pstate == PSTATE_TYPE_STANDBY) {
|
||||
req_state->pwr_domain_state[MPIDR_AFFLVL0] = PLAT_MAX_RET_STATE;
|
||||
else
|
||||
} else {
|
||||
req_state->pwr_domain_state[MPIDR_AFFLVL0] = PLAT_MAX_OFF_STATE;
|
||||
|
||||
}
|
||||
/* We expect the 'state id' to be zero */
|
||||
if (psci_get_pstate_id(power_state))
|
||||
if (psci_get_pstate_id(power_state)) {
|
||||
return PSCI_E_INVALID_PARAMS;
|
||||
}
|
||||
|
||||
return PSCI_E_SUCCESS;
|
||||
}
|
||||
|
@ -2446,16 +2446,17 @@ enum pm_ret_status pm_api_clock_get_num_clocks(unsigned int *nclocks)
|
||||
*/
|
||||
void pm_api_clock_get_name(unsigned int clock_id, char *name)
|
||||
{
|
||||
if (clock_id == CLK_MAX)
|
||||
if (clock_id == CLK_MAX) {
|
||||
memcpy(name, END_OF_CLK, sizeof(END_OF_CLK) > CLK_NAME_LEN ?
|
||||
CLK_NAME_LEN : sizeof(END_OF_CLK));
|
||||
else if (!pm_clock_valid(clock_id))
|
||||
} else if (!pm_clock_valid(clock_id)) {
|
||||
memset(name, 0, CLK_NAME_LEN);
|
||||
else if (clock_id < CLK_MAX_OUTPUT_CLK)
|
||||
} else if (clock_id < CLK_MAX_OUTPUT_CLK) {
|
||||
memcpy(name, clocks[clock_id].name, CLK_NAME_LEN);
|
||||
else
|
||||
} else {
|
||||
memcpy(name, ext_clocks[clock_id - CLK_MAX_OUTPUT_CLK].name,
|
||||
CLK_NAME_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2480,24 +2481,28 @@ enum pm_ret_status pm_api_clock_get_topology(unsigned int clock_id,
|
||||
unsigned int i;
|
||||
uint16_t typeflags;
|
||||
|
||||
if (!pm_clock_valid(clock_id))
|
||||
if (!pm_clock_valid(clock_id)) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
|
||||
return PM_RET_ERROR_NOTSUPPORTED;
|
||||
|
||||
}
|
||||
|
||||
memset(topology, 0, CLK_TOPOLOGY_PAYLOAD_LEN);
|
||||
clock_nodes = *clocks[clock_id].nodes;
|
||||
num_nodes = clocks[clock_id].num_nodes;
|
||||
|
||||
/* Skip parent till index */
|
||||
if (index >= num_nodes)
|
||||
if (index >= num_nodes) {
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3U; i++) {
|
||||
if ((index + i) == num_nodes)
|
||||
if ((index + i) == num_nodes) {
|
||||
break;
|
||||
}
|
||||
|
||||
topology[i] = clock_nodes[index + i].type;
|
||||
topology[i] |= clock_nodes[index + i].clkflags <<
|
||||
CLK_CLKFLAGS_SHIFT;
|
||||
@ -2531,11 +2536,13 @@ enum pm_ret_status pm_api_clock_get_fixedfactor_params(unsigned int clock_id,
|
||||
uint8_t num_nodes;
|
||||
unsigned int type, i;
|
||||
|
||||
if (!pm_clock_valid(clock_id))
|
||||
if (!pm_clock_valid(clock_id)) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
|
||||
return PM_RET_ERROR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
clock_nodes = *clocks[clock_id].nodes;
|
||||
num_nodes = clocks[clock_id].num_nodes;
|
||||
@ -2550,8 +2557,9 @@ enum pm_ret_status pm_api_clock_get_fixedfactor_params(unsigned int clock_id,
|
||||
}
|
||||
|
||||
/* Clock is not fixed clock */
|
||||
if (i == num_nodes)
|
||||
if (i == num_nodes) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
@ -2580,27 +2588,33 @@ enum pm_ret_status pm_api_clock_get_parents(unsigned int clock_id,
|
||||
unsigned int i;
|
||||
int32_t *clk_parents;
|
||||
|
||||
if (!pm_clock_valid(clock_id))
|
||||
if (!pm_clock_valid(clock_id)) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
|
||||
return PM_RET_ERROR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
clk_parents = *clocks[clock_id].parents;
|
||||
if (clk_parents == NULL)
|
||||
if (clk_parents == NULL) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
memset(parents, 0, CLK_PARENTS_PAYLOAD_LEN);
|
||||
|
||||
/* Skip parent till index */
|
||||
for (i = 0; i < index; i++)
|
||||
if (clk_parents[i] == CLK_NA_PARENT)
|
||||
for (i = 0; i < index; i++) {
|
||||
if (clk_parents[i] == CLK_NA_PARENT) {
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
parents[i] = clk_parents[index + i];
|
||||
if (clk_parents[index + i] == CLK_NA_PARENT)
|
||||
if (clk_parents[index + i] == CLK_NA_PARENT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
@ -2619,8 +2633,9 @@ enum pm_ret_status pm_api_clock_get_parents(unsigned int clock_id,
|
||||
enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id,
|
||||
uint32_t *attr)
|
||||
{
|
||||
if (clock_id >= CLK_MAX)
|
||||
if (clock_id >= CLK_MAX) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Clock valid bit */
|
||||
*attr = pm_clock_valid(clock_id);
|
||||
@ -2648,8 +2663,9 @@ enum pm_ret_status pm_api_clock_get_max_divisor(enum clock_id clock_id,
|
||||
uint32_t i;
|
||||
struct pm_clock_node *nodes;
|
||||
|
||||
if (clock_id >= CLK_MAX_OUTPUT_CLK)
|
||||
if (clock_id >= CLK_MAX_OUTPUT_CLK) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
nodes = *clocks[clock_id].nodes;
|
||||
for (i = 0; i < clocks[clock_id].num_nodes; i++) {
|
||||
@ -2738,8 +2754,9 @@ struct pm_pll *pm_clock_get_pll(enum clock_id clock_id)
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(pm_plls); i++) {
|
||||
if (pm_plls[i].cid == clock_id)
|
||||
if (pm_plls[i].cid == clock_id) {
|
||||
return &pm_plls[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -2798,12 +2815,14 @@ struct pm_pll *pm_clock_get_pll_by_related_clk(enum clock_id clock_id)
|
||||
*/
|
||||
enum pm_ret_status pm_clock_pll_enable(struct pm_pll *pll)
|
||||
{
|
||||
if (!pll)
|
||||
if (!pll) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Set the PLL mode according to the buffered mode value */
|
||||
if (pll->mode == PLL_FRAC_MODE)
|
||||
if (pll->mode == PLL_FRAC_MODE) {
|
||||
return pm_pll_set_mode(pll->nid, PM_PLL_MODE_FRACTIONAL);
|
||||
}
|
||||
|
||||
return pm_pll_set_mode(pll->nid, PM_PLL_MODE_INTEGER);
|
||||
}
|
||||
@ -2819,8 +2838,9 @@ enum pm_ret_status pm_clock_pll_enable(struct pm_pll *pll)
|
||||
*/
|
||||
enum pm_ret_status pm_clock_pll_disable(struct pm_pll *pll)
|
||||
{
|
||||
if (!pll)
|
||||
if (!pll) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
return pm_pll_set_mode(pll->nid, PM_PLL_MODE_RESET);
|
||||
}
|
||||
@ -2842,17 +2862,20 @@ enum pm_ret_status pm_clock_pll_get_state(struct pm_pll *pll,
|
||||
enum pm_ret_status status;
|
||||
enum pm_pll_mode mode;
|
||||
|
||||
if (!pll || !state)
|
||||
if (!pll || !state) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
status = pm_pll_get_mode(pll->nid, &mode);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (mode == PM_PLL_MODE_RESET)
|
||||
if (mode == PM_PLL_MODE_RESET) {
|
||||
*state = 0;
|
||||
else
|
||||
} else {
|
||||
*state = 1;
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
@ -2873,17 +2896,21 @@ enum pm_ret_status pm_clock_pll_set_parent(struct pm_pll *pll,
|
||||
enum clock_id clock_id,
|
||||
unsigned int parent_index)
|
||||
{
|
||||
if (!pll)
|
||||
if (!pll) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
if (pll->pre_src == clock_id)
|
||||
}
|
||||
if (pll->pre_src == clock_id) {
|
||||
return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_PRE_SRC,
|
||||
parent_index);
|
||||
if (pll->post_src == clock_id)
|
||||
}
|
||||
if (pll->post_src == clock_id) {
|
||||
return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_POST_SRC,
|
||||
parent_index);
|
||||
if (pll->div2 == clock_id)
|
||||
}
|
||||
if (pll->div2 == clock_id) {
|
||||
return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_DIV2,
|
||||
parent_index);
|
||||
}
|
||||
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
@ -2902,17 +2929,21 @@ enum pm_ret_status pm_clock_pll_get_parent(struct pm_pll *pll,
|
||||
enum clock_id clock_id,
|
||||
unsigned int *parent_index)
|
||||
{
|
||||
if (!pll)
|
||||
if (!pll) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
if (pll->pre_src == clock_id)
|
||||
}
|
||||
if (pll->pre_src == clock_id) {
|
||||
return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_PRE_SRC,
|
||||
parent_index);
|
||||
if (pll->post_src == clock_id)
|
||||
}
|
||||
if (pll->post_src == clock_id) {
|
||||
return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_POST_SRC,
|
||||
parent_index);
|
||||
if (pll->div2 == clock_id)
|
||||
}
|
||||
if (pll->div2 == clock_id) {
|
||||
return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_DIV2,
|
||||
parent_index);
|
||||
}
|
||||
if (pll->bypass == clock_id) {
|
||||
*parent_index = 0;
|
||||
return PM_RET_SUCCESS;
|
||||
@ -2935,8 +2966,9 @@ enum pm_ret_status pm_clock_set_pll_mode(enum clock_id clock_id,
|
||||
{
|
||||
struct pm_pll *pll = pm_clock_get_pll(clock_id);
|
||||
|
||||
if (!pll || (mode != PLL_FRAC_MODE && mode != PLL_INT_MODE))
|
||||
if (!pll || (mode != PLL_FRAC_MODE && mode != PLL_INT_MODE)) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
pll->mode = mode;
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
@ -2956,8 +2988,9 @@ enum pm_ret_status pm_clock_get_pll_mode(enum clock_id clock_id,
|
||||
{
|
||||
struct pm_pll *pll = pm_clock_get_pll(clock_id);
|
||||
|
||||
if (!pll || !mode)
|
||||
if (!pll || !mode) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
*mode = pll->mode;
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
@ -2971,11 +3004,13 @@ enum pm_ret_status pm_clock_get_pll_mode(enum clock_id clock_id,
|
||||
*/
|
||||
enum pm_ret_status pm_clock_id_is_valid(unsigned int clock_id)
|
||||
{
|
||||
if (!pm_clock_valid(clock_id))
|
||||
if (!pm_clock_valid(clock_id)) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
|
||||
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT) {
|
||||
return PM_RET_ERROR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
@ -2992,8 +3027,9 @@ uint8_t pm_clock_has_div(unsigned int clock_id, enum pm_clock_div_id div_id)
|
||||
uint32_t i;
|
||||
struct pm_clock_node *nodes;
|
||||
|
||||
if (clock_id >= CLK_MAX_OUTPUT_CLK)
|
||||
if (clock_id >= CLK_MAX_OUTPUT_CLK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
nodes = *clocks[clock_id].nodes;
|
||||
for (i = 0; i < clocks[clock_id].num_nodes; i++) {
|
||||
|
@ -35,10 +35,11 @@ static enum pm_ret_status pm_ioctl_get_rpu_oper_mode(unsigned int *mode)
|
||||
|
||||
val = mmio_read_32(ZYNQMP_RPU_GLBL_CNTL);
|
||||
val &= ZYNQMP_SLSPLIT_MASK;
|
||||
if (val == 0)
|
||||
if (val == 0) {
|
||||
*mode = PM_RPU_MODE_LOCKSTEP;
|
||||
else
|
||||
} else {
|
||||
*mode = PM_RPU_MODE_SPLIT;
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
@ -58,8 +59,9 @@ static enum pm_ret_status pm_ioctl_set_rpu_oper_mode(unsigned int mode)
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
if (mmio_read_32(CRL_APB_RST_LPD_TOP) & CRL_APB_RPU_AMBA_RESET)
|
||||
if (mmio_read_32(CRL_APB_RST_LPD_TOP) & CRL_APB_RPU_AMBA_RESET) {
|
||||
return PM_RET_ERROR_ACCESS;
|
||||
}
|
||||
|
||||
val = mmio_read_32(ZYNQMP_RPU_GLBL_CNTL);
|
||||
|
||||
@ -94,21 +96,23 @@ static enum pm_ret_status pm_ioctl_config_boot_addr(enum pm_node_id nid,
|
||||
{
|
||||
unsigned int rpu_cfg_addr, val;
|
||||
|
||||
if (nid == NODE_RPU_0)
|
||||
if (nid == NODE_RPU_0) {
|
||||
rpu_cfg_addr = ZYNQMP_RPU0_CFG;
|
||||
else if (nid == NODE_RPU_1)
|
||||
} else if (nid == NODE_RPU_1) {
|
||||
rpu_cfg_addr = ZYNQMP_RPU1_CFG;
|
||||
else
|
||||
} else {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
val = mmio_read_32(rpu_cfg_addr);
|
||||
|
||||
if (value == PM_RPU_BOOTMEM_LOVEC)
|
||||
if (value == PM_RPU_BOOTMEM_LOVEC) {
|
||||
val &= ~ZYNQMP_VINITHI_MASK;
|
||||
else if (value == PM_RPU_BOOTMEM_HIVEC)
|
||||
} else if (value == PM_RPU_BOOTMEM_HIVEC) {
|
||||
val |= ZYNQMP_VINITHI_MASK;
|
||||
else
|
||||
} else {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
mmio_write_32(rpu_cfg_addr, val);
|
||||
|
||||
@ -130,12 +134,13 @@ static enum pm_ret_status pm_ioctl_config_tcm_comb(unsigned int value)
|
||||
|
||||
val = mmio_read_32(ZYNQMP_RPU_GLBL_CNTL);
|
||||
|
||||
if (value == PM_RPU_TCM_SPLIT)
|
||||
if (value == PM_RPU_TCM_SPLIT) {
|
||||
val &= ~ZYNQMP_TCM_COMB_MASK;
|
||||
else if (value == PM_RPU_TCM_COMB)
|
||||
} else if (value == PM_RPU_TCM_COMB) {
|
||||
val |= ZYNQMP_TCM_COMB_MASK;
|
||||
else
|
||||
} else {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
mmio_write_32(ZYNQMP_RPU_GLBL_CNTL, val);
|
||||
|
||||
@ -155,8 +160,9 @@ static enum pm_ret_status pm_ioctl_set_tapdelay_bypass(unsigned int type,
|
||||
unsigned int value)
|
||||
{
|
||||
if ((value != PM_TAPDELAY_BYPASS_ENABLE &&
|
||||
value != PM_TAPDELAY_BYPASS_DISABLE) || type >= PM_TAPDELAY_MAX)
|
||||
value != PM_TAPDELAY_BYPASS_DISABLE) || type >= PM_TAPDELAY_MAX) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
return pm_mmio_write(IOU_TAPDLY_BYPASS, TAP_DELAY_MASK, value << type);
|
||||
}
|
||||
@ -178,8 +184,9 @@ static enum pm_ret_status pm_ioctl_set_sgmii_mode(enum pm_node_id nid,
|
||||
unsigned int val, mask, shift;
|
||||
enum pm_ret_status ret;
|
||||
|
||||
if (value != PM_SGMII_DISABLE && value != PM_SGMII_ENABLE)
|
||||
if (value != PM_SGMII_DISABLE && value != PM_SGMII_ENABLE) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
switch (nid) {
|
||||
case NODE_ETH_0:
|
||||
@ -206,8 +213,9 @@ static enum pm_ret_status pm_ioctl_set_sgmii_mode(enum pm_node_id nid,
|
||||
mask = SGMII_SD_MASK << SGMII_SD_OFFSET * shift;
|
||||
val = SGMII_PCS_SD_1 << SGMII_SD_OFFSET * shift;
|
||||
ret = pm_mmio_write(IOU_GEM_CTRL, mask, val);
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Set the GEM to SGMII mode */
|
||||
mask = GEM_CLK_CTRL_MASK << GEM_CLK_CTRL_OFFSET * shift;
|
||||
@ -248,11 +256,13 @@ static enum pm_ret_status pm_ioctl_sd_dll_reset(enum pm_node_id nid,
|
||||
case PM_DLL_RESET_ASSERT:
|
||||
case PM_DLL_RESET_PULSE:
|
||||
ret = pm_mmio_write(ZYNQMP_SD_DLL_CTRL, mask, val);
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (type == PM_DLL_RESET_ASSERT)
|
||||
if (type == PM_DLL_RESET_ASSERT) {
|
||||
break;
|
||||
}
|
||||
mdelay(1);
|
||||
/* Fallthrough */
|
||||
case PM_DLL_RESET_RELEASE:
|
||||
@ -310,31 +320,44 @@ static enum pm_ret_status pm_ioctl_sd_set_tapdelay(enum pm_node_id nid,
|
||||
ret = pm_mmio_write(ZYNQMP_SD_ITAP_DLY,
|
||||
(ZYNQMP_SD_ITAPCHGWIN_MASK << shift),
|
||||
(ZYNQMP_SD_ITAPCHGWIN << shift));
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
goto reset_release;
|
||||
if (value == 0)
|
||||
}
|
||||
|
||||
if (value == 0) {
|
||||
ret = pm_mmio_write(ZYNQMP_SD_ITAP_DLY,
|
||||
(ZYNQMP_SD_ITAPDLYENA_MASK <<
|
||||
shift), 0);
|
||||
else
|
||||
} else {
|
||||
ret = pm_mmio_write(ZYNQMP_SD_ITAP_DLY,
|
||||
(ZYNQMP_SD_ITAPDLYENA_MASK <<
|
||||
shift), (ZYNQMP_SD_ITAPDLYENA <<
|
||||
shift));
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
}
|
||||
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
goto reset_release;
|
||||
}
|
||||
|
||||
ret = pm_mmio_write(ZYNQMP_SD_ITAP_DLY,
|
||||
(ZYNQMP_SD_ITAPDLYSEL_MASK << shift),
|
||||
(value << shift));
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
goto reset_release;
|
||||
}
|
||||
|
||||
ret = pm_mmio_write(ZYNQMP_SD_ITAP_DLY,
|
||||
(ZYNQMP_SD_ITAPCHGWIN_MASK << shift), 0);
|
||||
} else if (type == PM_TAPDELAY_OUTPUT) {
|
||||
ret = pm_mmio_write(ZYNQMP_SD_OTAP_DLY,
|
||||
(ZYNQMP_SD_OTAPDLYENA_MASK << shift), 0);
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
goto reset_release;
|
||||
}
|
||||
|
||||
ret = pm_mmio_write(ZYNQMP_SD_OTAP_DLY,
|
||||
(ZYNQMP_SD_OTAPDLYSEL_MASK << shift),
|
||||
(value << shift));
|
||||
@ -401,8 +424,9 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_data
|
||||
|
||||
/* Get PLL node ID using PLL clock ID */
|
||||
status = pm_clock_get_pll_node_id(pll, &pll_nid);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return pm_pll_set_parameter(pll_nid, PM_PLL_PARAM_DATA, data);
|
||||
}
|
||||
@ -425,8 +449,9 @@ static enum pm_ret_status pm_ioctl_get_pll_frac_data
|
||||
|
||||
/* Get PLL node ID using PLL clock ID */
|
||||
status = pm_clock_get_pll_node_id(pll, &pll_nid);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return pm_pll_get_parameter(pll_nid, PM_PLL_PARAM_DATA, data);
|
||||
}
|
||||
@ -444,8 +469,9 @@ static enum pm_ret_status pm_ioctl_get_pll_frac_data
|
||||
static enum pm_ret_status pm_ioctl_write_ggs(unsigned int index,
|
||||
unsigned int value)
|
||||
{
|
||||
if (index >= GGS_NUM_REGS)
|
||||
if (index >= GGS_NUM_REGS) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
return pm_mmio_write(GGS_BASEADDR + (index << 2),
|
||||
0xFFFFFFFFU, value);
|
||||
@ -464,8 +490,9 @@ static enum pm_ret_status pm_ioctl_write_ggs(unsigned int index,
|
||||
static enum pm_ret_status pm_ioctl_read_ggs(unsigned int index,
|
||||
unsigned int *value)
|
||||
{
|
||||
if (index >= GGS_NUM_REGS)
|
||||
if (index >= GGS_NUM_REGS) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
return pm_mmio_read(GGS_BASEADDR + (index << 2), value);
|
||||
}
|
||||
@ -483,8 +510,9 @@ static enum pm_ret_status pm_ioctl_read_ggs(unsigned int index,
|
||||
static enum pm_ret_status pm_ioctl_write_pggs(unsigned int index,
|
||||
unsigned int value)
|
||||
{
|
||||
if (index >= PGGS_NUM_REGS)
|
||||
if (index >= PGGS_NUM_REGS) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
return pm_mmio_write(PGGS_BASEADDR + (index << 2),
|
||||
0xFFFFFFFFU, value);
|
||||
@ -521,13 +549,15 @@ static enum pm_ret_status pm_ioctl_afi(unsigned int index,
|
||||
0xFF419000U,
|
||||
};
|
||||
|
||||
if (index >= ARRAY_SIZE(regarr))
|
||||
if (index >= ARRAY_SIZE(regarr)) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
if (index < AFIFM6_WRCTRL)
|
||||
if (index < AFIFM6_WRCTRL) {
|
||||
mask = FABRIC_WIDTH;
|
||||
else
|
||||
} else {
|
||||
mask = 0xf00;
|
||||
}
|
||||
|
||||
return pm_mmio_write(regarr[index], mask, value);
|
||||
}
|
||||
@ -545,8 +575,9 @@ static enum pm_ret_status pm_ioctl_afi(unsigned int index,
|
||||
static enum pm_ret_status pm_ioctl_read_pggs(unsigned int index,
|
||||
unsigned int *value)
|
||||
{
|
||||
if (index >= PGGS_NUM_REGS)
|
||||
if (index >= PGGS_NUM_REGS) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
return pm_mmio_read(PGGS_BASEADDR + (index << 2), value);
|
||||
}
|
||||
@ -565,16 +596,18 @@ static enum pm_ret_status pm_ioctl_ulpi_reset(void)
|
||||
|
||||
ret = pm_mmio_write(CRL_APB_BOOT_PIN_CTRL, CRL_APB_BOOT_PIN_MASK,
|
||||
ZYNQMP_ULPI_RESET_VAL_HIGH);
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Drive ULPI assert for atleast 1ms */
|
||||
mdelay(1);
|
||||
|
||||
ret = pm_mmio_write(CRL_APB_BOOT_PIN_CTRL, CRL_APB_BOOT_PIN_MASK,
|
||||
ZYNQMP_ULPI_RESET_VAL_LOW);
|
||||
if (ret != PM_RET_SUCCESS)
|
||||
if (ret != PM_RET_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Drive ULPI de-assert for atleast 1ms */
|
||||
mdelay(1);
|
||||
|
@ -2549,17 +2549,20 @@ enum pm_ret_status pm_api_pinctrl_get_num_func_groups(unsigned int fid,
|
||||
int i = 0;
|
||||
uint16_t *grps;
|
||||
|
||||
if (fid >= MAX_FUNCTION)
|
||||
if (fid >= MAX_FUNCTION) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
*ngroups = 0;
|
||||
|
||||
grps = *pinctrl_functions[fid].groups;
|
||||
if (grps == NULL)
|
||||
if (grps == NULL) {
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
|
||||
while (grps[i++] != (uint16_t)END_OF_GROUPS)
|
||||
while (grps[i++] != (uint16_t)END_OF_GROUPS) {
|
||||
(*ngroups)++;
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
@ -2574,10 +2577,11 @@ enum pm_ret_status pm_api_pinctrl_get_num_func_groups(unsigned int fid,
|
||||
*/
|
||||
void pm_api_pinctrl_get_function_name(unsigned int fid, char *name)
|
||||
{
|
||||
if (fid >= MAX_FUNCTION)
|
||||
if (fid >= MAX_FUNCTION) {
|
||||
memcpy(name, END_OF_FUNCTION, FUNCTION_NAME_LEN);
|
||||
else
|
||||
} else {
|
||||
memcpy(name, pinctrl_functions[fid].name, FUNCTION_NAME_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2605,24 +2609,29 @@ enum pm_ret_status pm_api_pinctrl_get_function_groups(unsigned int fid,
|
||||
unsigned int i;
|
||||
uint16_t *grps;
|
||||
|
||||
if (fid >= MAX_FUNCTION)
|
||||
if (fid >= MAX_FUNCTION) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
memset(groups, END_OF_GROUPS, GROUPS_PAYLOAD_LEN);
|
||||
|
||||
grps = *pinctrl_functions[fid].groups;
|
||||
if (grps == NULL)
|
||||
if (grps == NULL) {
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
|
||||
/* Skip groups till index */
|
||||
for (i = 0; i < index; i++)
|
||||
if (grps[i] == (uint16_t)END_OF_GROUPS)
|
||||
for (i = 0; i < index; i++) {
|
||||
if (grps[i] == (uint16_t)END_OF_GROUPS) {
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_GROUPS_PER_RESP; i++) {
|
||||
groups[i] = grps[index + i];
|
||||
if (groups[i] == (uint16_t)END_OF_GROUPS)
|
||||
if (groups[i] == (uint16_t)END_OF_GROUPS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
@ -2653,24 +2662,29 @@ enum pm_ret_status pm_api_pinctrl_get_pin_groups(unsigned int pin,
|
||||
unsigned int i;
|
||||
uint16_t *grps;
|
||||
|
||||
if (pin >= MAX_PIN)
|
||||
if (pin >= MAX_PIN) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
memset(groups, END_OF_GROUPS, GROUPS_PAYLOAD_LEN);
|
||||
|
||||
grps = *zynqmp_pin_groups[pin].groups;
|
||||
if (!grps)
|
||||
if (grps == NULL) {
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
|
||||
/* Skip groups till index */
|
||||
for (i = 0; i < index; i++)
|
||||
if (grps[i] == (uint16_t)END_OF_GROUPS)
|
||||
for (i = 0; i < index; i++) {
|
||||
if (grps[i] == (uint16_t)END_OF_GROUPS) {
|
||||
return PM_RET_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_GROUPS_PER_RESP; i++) {
|
||||
groups[i] = grps[index + i];
|
||||
if (groups[i] == (uint16_t)END_OF_GROUPS)
|
||||
if (groups[i] == (uint16_t)END_OF_GROUPS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return PM_RET_SUCCESS;
|
||||
|
@ -306,10 +306,11 @@ enum pm_ret_status pm_req_suspend(enum pm_node_id target,
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD5(payload, PM_REQ_SUSPEND, target, ack, latency, state);
|
||||
if (ack == REQ_ACK_BLOCKING)
|
||||
if (ack == REQ_ACK_BLOCKING) {
|
||||
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||
else
|
||||
} else {
|
||||
return pm_ipi_send(primary_proc, payload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,10 +346,11 @@ enum pm_ret_status pm_req_wakeup(enum pm_node_id target,
|
||||
PM_PACK_PAYLOAD5(payload, PM_REQ_WAKEUP, target, encoded_address,
|
||||
encoded_address >> 32, ack);
|
||||
|
||||
if (ack == REQ_ACK_BLOCKING)
|
||||
if (ack == REQ_ACK_BLOCKING) {
|
||||
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||
else
|
||||
} else {
|
||||
return pm_ipi_send(primary_proc, payload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,10 +369,11 @@ enum pm_ret_status pm_force_powerdown(enum pm_node_id target,
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD3(payload, PM_FORCE_POWERDOWN, target, ack);
|
||||
|
||||
if (ack == REQ_ACK_BLOCKING)
|
||||
if (ack == REQ_ACK_BLOCKING) {
|
||||
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||
else
|
||||
} else {
|
||||
return pm_ipi_send(primary_proc, payload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -459,10 +462,11 @@ enum pm_ret_status pm_req_node(enum pm_node_id nid,
|
||||
|
||||
PM_PACK_PAYLOAD5(payload, PM_REQ_NODE, nid, capabilities, qos, ack);
|
||||
|
||||
if (ack == REQ_ACK_BLOCKING)
|
||||
if (ack == REQ_ACK_BLOCKING) {
|
||||
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||
else
|
||||
} else {
|
||||
return pm_ipi_send(primary_proc, payload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -486,10 +490,11 @@ enum pm_ret_status pm_set_requirement(enum pm_node_id nid,
|
||||
PM_PACK_PAYLOAD5(payload, PM_SET_REQUIREMENT, nid, capabilities, qos,
|
||||
ack);
|
||||
|
||||
if (ack == REQ_ACK_BLOCKING)
|
||||
if (ack == REQ_ACK_BLOCKING) {
|
||||
return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||
else
|
||||
} else {
|
||||
return pm_ipi_send(primary_proc, payload);
|
||||
}
|
||||
}
|
||||
|
||||
/* Miscellaneous API functions */
|
||||
@ -689,8 +694,9 @@ enum pm_ret_status pm_aes_engine(uint32_t address_high,
|
||||
void pm_get_callbackdata(uint32_t *data, size_t count)
|
||||
{
|
||||
/* Return if interrupt is not from PMU */
|
||||
if (!pm_ipi_irq_status(primary_proc))
|
||||
if (!pm_ipi_irq_status(primary_proc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
pm_ipi_buff_read_callb(data, count);
|
||||
pm_ipi_irq_clear(primary_proc);
|
||||
@ -1070,21 +1076,24 @@ static enum pm_ret_status pm_clock_gate(unsigned int clock_id,
|
||||
|
||||
/* Check if clock ID is valid and return an error if it is not */
|
||||
status = pm_clock_id_is_valid(clock_id);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (enable)
|
||||
if (enable) {
|
||||
api_id = PM_CLOCK_ENABLE;
|
||||
else
|
||||
} else {
|
||||
api_id = PM_CLOCK_DISABLE;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD2(payload, api_id, clock_id);
|
||||
status = pm_ipi_send_sync(primary_proc, payload, NULL, 0);
|
||||
|
||||
/* If action fails due to the lack of permissions filter the error */
|
||||
if (status == PM_RET_ERROR_ACCESS)
|
||||
if (status == PM_RET_ERROR_ACCESS) {
|
||||
status = PM_RET_SUCCESS;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -1105,8 +1114,9 @@ enum pm_ret_status pm_clock_enable(unsigned int clock_id)
|
||||
|
||||
/* First try to handle it as a PLL */
|
||||
pll = pm_clock_get_pll(clock_id);
|
||||
if (pll)
|
||||
if (pll) {
|
||||
return pm_clock_pll_enable(pll);
|
||||
}
|
||||
|
||||
/* It's an on-chip clock, PMU should configure clock's gate */
|
||||
return pm_clock_gate(clock_id, 1);
|
||||
@ -1128,8 +1138,9 @@ enum pm_ret_status pm_clock_disable(unsigned int clock_id)
|
||||
|
||||
/* First try to handle it as a PLL */
|
||||
pll = pm_clock_get_pll(clock_id);
|
||||
if (pll)
|
||||
if (pll) {
|
||||
return pm_clock_pll_disable(pll);
|
||||
}
|
||||
|
||||
/* It's an on-chip clock, PMU should configure clock's gate */
|
||||
return pm_clock_gate(clock_id, 0);
|
||||
@ -1159,8 +1170,9 @@ enum pm_ret_status pm_clock_getstate(unsigned int clock_id,
|
||||
|
||||
/* Check if clock ID is a valid on-chip clock */
|
||||
status = pm_clock_id_is_valid(clock_id);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD2(payload, PM_CLOCK_GETSTATE, clock_id);
|
||||
@ -1190,13 +1202,15 @@ enum pm_ret_status pm_clock_setdivider(unsigned int clock_id,
|
||||
|
||||
/* Get PLL node ID using PLL clock ID */
|
||||
status = pm_clock_get_pll_node_id(clock_id, &nid);
|
||||
if (status == PM_RET_SUCCESS)
|
||||
if (status == PM_RET_SUCCESS) {
|
||||
return pm_pll_set_parameter(nid, PM_PLL_PARAM_FBDIV, divider);
|
||||
}
|
||||
|
||||
/* Check if clock ID is a valid on-chip clock */
|
||||
status = pm_clock_id_is_valid(clock_id);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (div0 == (divider & div0)) {
|
||||
div_id = PM_CLOCK_DIV0_ID;
|
||||
@ -1233,21 +1247,24 @@ enum pm_ret_status pm_clock_getdivider(unsigned int clock_id,
|
||||
|
||||
/* Get PLL node ID using PLL clock ID */
|
||||
status = pm_clock_get_pll_node_id(clock_id, &nid);
|
||||
if (status == PM_RET_SUCCESS)
|
||||
if (status == PM_RET_SUCCESS) {
|
||||
return pm_pll_get_parameter(nid, PM_PLL_PARAM_FBDIV, divider);
|
||||
}
|
||||
|
||||
/* Check if clock ID is a valid on-chip clock */
|
||||
status = pm_clock_id_is_valid(clock_id);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (pm_clock_has_div(clock_id, PM_CLOCK_DIV0_ID)) {
|
||||
/* Send request to the PMU to get div0 */
|
||||
PM_PACK_PAYLOAD3(payload, PM_CLOCK_GETDIVIDER, clock_id,
|
||||
PM_CLOCK_DIV0_ID);
|
||||
status = pm_ipi_send_sync(primary_proc, payload, &val, 1);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
*divider = val;
|
||||
}
|
||||
|
||||
@ -1256,8 +1273,9 @@ enum pm_ret_status pm_clock_getdivider(unsigned int clock_id,
|
||||
PM_PACK_PAYLOAD3(payload, PM_CLOCK_GETDIVIDER, clock_id,
|
||||
PM_CLOCK_DIV1_ID);
|
||||
status = pm_ipi_send_sync(primary_proc, payload, &val, 1);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
*divider |= val << 16;
|
||||
}
|
||||
|
||||
@ -1313,13 +1331,15 @@ enum pm_ret_status pm_clock_setparent(unsigned int clock_id,
|
||||
|
||||
/* First try to handle it as a PLL */
|
||||
pll = pm_clock_get_pll_by_related_clk(clock_id);
|
||||
if (pll)
|
||||
if (pll) {
|
||||
return pm_clock_pll_set_parent(pll, clock_id, parent_index);
|
||||
}
|
||||
|
||||
/* Check if clock ID is a valid on-chip clock */
|
||||
status = pm_clock_id_is_valid(clock_id);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD3(payload, PM_CLOCK_SETPARENT, clock_id, parent_index);
|
||||
@ -1345,13 +1365,15 @@ enum pm_ret_status pm_clock_getparent(unsigned int clock_id,
|
||||
|
||||
/* First try to handle it as a PLL */
|
||||
pll = pm_clock_get_pll_by_related_clk(clock_id);
|
||||
if (pll)
|
||||
if (pll) {
|
||||
return pm_clock_pll_get_parent(pll, clock_id, parent_index);
|
||||
}
|
||||
|
||||
/* Check if clock ID is a valid on-chip clock */
|
||||
status = pm_clock_id_is_valid(clock_id);
|
||||
if (status != PM_RET_SUCCESS)
|
||||
if (status != PM_RET_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD2(payload, PM_CLOCK_GETPARENT, clock_id);
|
||||
@ -1614,12 +1636,14 @@ enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
|
||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||
|
||||
/* Check if given node ID is a PLL node */
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL)
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Check if parameter ID is valid and return an error if it's not */
|
||||
if (param_id >= PM_PLL_PARAM_MAX)
|
||||
if (param_id >= PM_PLL_PARAM_MAX) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD4(payload, PM_PLL_SET_PARAMETER, nid, param_id, value);
|
||||
@ -1642,12 +1666,14 @@ enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
|
||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||
|
||||
/* Check if given node ID is a PLL node */
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL)
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Check if parameter ID is valid and return an error if it's not */
|
||||
if (param_id >= PM_PLL_PARAM_MAX)
|
||||
if (param_id >= PM_PLL_PARAM_MAX) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD3(payload, PM_PLL_GET_PARAMETER, nid, param_id);
|
||||
@ -1672,12 +1698,14 @@ enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode)
|
||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||
|
||||
/* Check if given node ID is a PLL node */
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL)
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Check if PLL mode is valid */
|
||||
if (mode >= PM_PLL_MODE_MAX)
|
||||
if (mode >= PM_PLL_MODE_MAX) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD3(payload, PM_PLL_SET_MODE, nid, mode);
|
||||
@ -1697,8 +1725,9 @@ enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode)
|
||||
uint32_t payload[PAYLOAD_ARG_CNT];
|
||||
|
||||
/* Check if given node ID is a PLL node */
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL)
|
||||
if (nid < NODE_APLL || nid > NODE_IOPLL) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
/* Send request to the PMU */
|
||||
PM_PACK_PAYLOAD2(payload, PM_PLL_GET_MODE, nid);
|
||||
@ -1733,8 +1762,9 @@ enum pm_ret_status pm_register_access(unsigned int register_access_id,
|
||||
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))
|
||||
((PMU_GLOBAL_BASE & address) != PMU_GLOBAL_BASE)) {
|
||||
return PM_RET_ERROR_ACCESS;
|
||||
}
|
||||
|
||||
switch (register_access_id) {
|
||||
case CONFIG_REG_WRITE:
|
||||
|
@ -188,8 +188,9 @@ static void pm_client_set_wakeup_sources(void)
|
||||
* If NODE_EXTERN could not be set as wake source, proceed with
|
||||
* standard suspend (no one will wake the system otherwise)
|
||||
*/
|
||||
if (ret == PM_RET_SUCCESS)
|
||||
if (ret == PM_RET_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
zeromem(&pm_wakeup_nodes_set, sizeof(pm_wakeup_nodes_set));
|
||||
@ -198,8 +199,9 @@ static void pm_client_set_wakeup_sources(void)
|
||||
uint32_t base_irq = reg_num << ISENABLER_SHIFT;
|
||||
uint32_t reg = mmio_read_32(isenabler1 + (reg_num << 2));
|
||||
|
||||
if (!reg)
|
||||
if (!reg) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (reg) {
|
||||
enum pm_node_id node;
|
||||
@ -208,8 +210,9 @@ static void pm_client_set_wakeup_sources(void)
|
||||
idx = __builtin_ctz(lowest_set);
|
||||
irq = base_irq + idx;
|
||||
|
||||
if (irq > IRQ_MAX)
|
||||
if (irq > IRQ_MAX) {
|
||||
break;
|
||||
}
|
||||
|
||||
node = irq_to_pm_node(irq);
|
||||
reg &= ~lowest_set;
|
||||
@ -231,8 +234,9 @@ static void pm_client_set_wakeup_sources(void)
|
||||
*/
|
||||
const struct pm_proc *pm_get_proc(unsigned int cpuid)
|
||||
{
|
||||
if (cpuid < ARRAY_SIZE(pm_procs_all))
|
||||
if (cpuid < ARRAY_SIZE(pm_procs_all)) {
|
||||
return &pm_procs_all[cpuid];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -246,8 +250,9 @@ const struct pm_proc *pm_get_proc(unsigned int cpuid)
|
||||
const struct pm_proc *pm_get_proc_by_node(enum pm_node_id nid)
|
||||
{
|
||||
for (size_t i = 0; i < ARRAY_SIZE(pm_procs_all); i++) {
|
||||
if (nid == pm_procs_all[i].node_id)
|
||||
if (nid == pm_procs_all[i].node_id) {
|
||||
return &pm_procs_all[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -261,8 +266,9 @@ const struct pm_proc *pm_get_proc_by_node(enum pm_node_id nid)
|
||||
static unsigned int pm_get_cpuid(enum pm_node_id nid)
|
||||
{
|
||||
for (size_t i = 0; i < ARRAY_SIZE(pm_procs_all); i++) {
|
||||
if (pm_procs_all[i].node_id == nid)
|
||||
if (pm_procs_all[i].node_id == nid) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return UNDEFINED_CPUID;
|
||||
}
|
||||
@ -280,8 +286,9 @@ void pm_client_suspend(const struct pm_proc *proc, unsigned int state)
|
||||
{
|
||||
bakery_lock_get(&pm_client_secure_lock);
|
||||
|
||||
if (state == PM_STATE_SUSPEND_TO_RAM)
|
||||
if (state == PM_STATE_SUSPEND_TO_RAM) {
|
||||
pm_client_set_wakeup_sources();
|
||||
}
|
||||
|
||||
/* Set powerdown request */
|
||||
mmio_write_32(APU_PWRCTL, mmio_read_32(APU_PWRCTL) | proc->pwrdn_mask);
|
||||
@ -320,8 +327,9 @@ void pm_client_wakeup(const struct pm_proc *proc)
|
||||
{
|
||||
unsigned int cpuid = pm_get_cpuid(proc->node_id);
|
||||
|
||||
if (cpuid == UNDEFINED_CPUID)
|
||||
if (cpuid == UNDEFINED_CPUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
bakery_lock_get(&pm_client_secure_lock);
|
||||
|
||||
@ -336,8 +344,9 @@ void pm_client_wakeup(const struct pm_proc *proc)
|
||||
enum pm_ret_status pm_set_suspend_mode(uint32_t mode)
|
||||
{
|
||||
if ((mode != PM_SUSPEND_MODE_STD) &&
|
||||
(mode != PM_SUSPEND_MODE_POWER_OFF))
|
||||
(mode != PM_SUSPEND_MODE_POWER_OFF)) {
|
||||
return PM_RET_ERROR_ARGS;
|
||||
}
|
||||
|
||||
suspend_mode = mode;
|
||||
return PM_RET_SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user