Commit 4db3a887 authored by Mark Dykes's avatar Mark Dykes Committed by TrustedFirmware Code Review
Browse files

Merge "GIC-600: Fix MISRA-2012 defects" into integration

parents f3be7e28 b29c350c
/* /*
* Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved. * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
#include "gicv3_private.h" #include "gicv3_private.h"
/* GIC-600 specific register offsets */ /* GIC-600 specific register offsets */
#define GICR_PWRR 0x24 #define GICR_PWRR 0x24U
#define IIDR_MODEL_ARM_GIC_600 (0x0200043b) #define IIDR_MODEL_ARM_GIC_600 U(0x0200043b)
#define IIDR_MODEL_ARM_GIC_600AE (0x0300043b) #define IIDR_MODEL_ARM_GIC_600AE U(0x0300043b)
#define IIDR_MODEL_ARM_GIC_CLAYTON (0x0400043b) #define IIDR_MODEL_ARM_GIC_CLAYTON U(0x0400043b)
/* GICR_PWRR fields */ /* GICR_PWRR fields */
#define PWRR_RDPD_SHIFT 0 #define PWRR_RDPD_SHIFT 0
...@@ -32,17 +32,17 @@ ...@@ -32,17 +32,17 @@
#define PWRR_RDGPD_SHIFT 2 #define PWRR_RDGPD_SHIFT 2
#define PWRR_RDGPO_SHIFT 3 #define PWRR_RDGPO_SHIFT 3
#define PWRR_RDPD (1 << PWRR_RDPD_SHIFT) #define PWRR_RDPD (1U << PWRR_RDPD_SHIFT)
#define PWRR_RDAG (1 << PWRR_RDAG_SHIFT) #define PWRR_RDAG (1U << PWRR_RDAG_SHIFT)
#define PWRR_RDGPD (1 << PWRR_RDGPD_SHIFT) #define PWRR_RDGPD (1U << PWRR_RDGPD_SHIFT)
#define PWRR_RDGPO (1 << PWRR_RDGPO_SHIFT) #define PWRR_RDGPO (1U << PWRR_RDGPO_SHIFT)
/* /*
* Values to write to GICR_PWRR register to power redistributor * Values to write to GICR_PWRR register to power redistributor
* for operating through the core (GICR_PWRR.RDAG = 0) * for operating through the core (GICR_PWRR.RDAG = 0)
*/ */
#define PWRR_ON (0 << PWRR_RDPD_SHIFT) #define PWRR_ON (0U << PWRR_RDPD_SHIFT)
#define PWRR_OFF (1 << PWRR_RDPD_SHIFT) #define PWRR_OFF (1U << PWRR_RDPD_SHIFT)
#if GICV3_SUPPORT_GIC600 #if GICV3_SUPPORT_GIC600
...@@ -59,10 +59,14 @@ static uint32_t gicr_read_pwrr(uintptr_t base) ...@@ -59,10 +59,14 @@ static uint32_t gicr_read_pwrr(uintptr_t base)
static void gicr_wait_group_not_in_transit(uintptr_t base) static void gicr_wait_group_not_in_transit(uintptr_t base)
{ {
uint32_t pwrr;
do {
pwrr = gicr_read_pwrr(base);
/* Check group not transitioning: RDGPD == RDGPO */ /* Check group not transitioning: RDGPD == RDGPO */
while (((gicr_read_pwrr(base) & PWRR_RDGPD) >> PWRR_RDGPD_SHIFT) != } while (((pwrr & PWRR_RDGPD) >> PWRR_RDGPD_SHIFT) !=
((gicr_read_pwrr(base) & PWRR_RDGPO) >> PWRR_RDGPO_SHIFT)) ((pwrr & PWRR_RDGPO) >> PWRR_RDGPO_SHIFT));
;
} }
static void gic600_pwr_on(uintptr_t base) static void gic600_pwr_on(uintptr_t base)
...@@ -94,7 +98,7 @@ static void gic600_pwr_off(uintptr_t base) ...@@ -94,7 +98,7 @@ static void gic600_pwr_off(uintptr_t base)
* In that case, wait as long as it's in transition, or has aborted * In that case, wait as long as it's in transition, or has aborted
* the transition altogether for any reason. * the transition altogether for any reason.
*/ */
if ((gicr_read_pwrr(base) & PWRR_RDGPD) != 0) { if ((gicr_read_pwrr(base) & PWRR_RDGPD) != 0U) {
/* Wait until group not transitioning */ /* Wait until group not transitioning */
gicr_wait_group_not_in_transit(base); gicr_wait_group_not_in_transit(base);
} }
...@@ -104,12 +108,12 @@ static uintptr_t get_gicr_base(unsigned int proc_num) ...@@ -104,12 +108,12 @@ static uintptr_t get_gicr_base(unsigned int proc_num)
{ {
uintptr_t gicr_base; uintptr_t gicr_base;
assert(gicv3_driver_data); assert(gicv3_driver_data != NULL);
assert(proc_num < gicv3_driver_data->rdistif_num); assert(proc_num < gicv3_driver_data->rdistif_num);
assert(gicv3_driver_data->rdistif_base_addrs); assert(gicv3_driver_data->rdistif_base_addrs != NULL);
gicr_base = gicv3_driver_data->rdistif_base_addrs[proc_num]; gicr_base = gicv3_driver_data->rdistif_base_addrs[proc_num];
assert(gicr_base); assert(gicr_base != 0UL);
return gicr_base; return gicr_base;
} }
...@@ -127,7 +131,7 @@ static bool gicv3_redists_need_power_mgmt(uintptr_t gicr_base) ...@@ -127,7 +131,7 @@ static bool gicv3_redists_need_power_mgmt(uintptr_t gicr_base)
((reg & IIDR_MODEL_MASK) == IIDR_MODEL_ARM_GIC_CLAYTON)); ((reg & IIDR_MODEL_MASK) == IIDR_MODEL_ARM_GIC_CLAYTON));
} }
#endif #endif /* GICV3_SUPPORT_GIC600 */
void gicv3_distif_pre_save(unsigned int proc_num) void gicv3_distif_pre_save(unsigned int proc_num)
{ {
...@@ -139,7 +143,6 @@ void gicv3_distif_post_restore(unsigned int proc_num) ...@@ -139,7 +143,6 @@ void gicv3_distif_post_restore(unsigned int proc_num)
arm_gicv3_distif_post_restore(proc_num); arm_gicv3_distif_post_restore(proc_num);
} }
/* /*
* Power off GIC-600 redistributor (if configured and detected) * Power off GIC-600 redistributor (if configured and detected)
*/ */
......
...@@ -223,10 +223,10 @@ ...@@ -223,10 +223,10 @@
#define TYPER_PPI_NUM_MASK U(0x1f) #define TYPER_PPI_NUM_MASK U(0x1f)
/* GICR_IIDR bit definitions */ /* GICR_IIDR bit definitions */
#define IIDR_PRODUCT_ID_MASK 0xff000000 #define IIDR_PRODUCT_ID_MASK U(0xff000000)
#define IIDR_VARIANT_MASK 0x000f0000 #define IIDR_VARIANT_MASK U(0x000f0000)
#define IIDR_REVISION_MASK 0x0000f000 #define IIDR_REVISION_MASK U(0x0000f000)
#define IIDR_IMPLEMENTER_MASK 0x00000fff #define IIDR_IMPLEMENTER_MASK U(0x00000fff)
#define IIDR_MODEL_MASK (IIDR_PRODUCT_ID_MASK | \ #define IIDR_MODEL_MASK (IIDR_PRODUCT_ID_MASK | \
IIDR_IMPLEMENTER_MASK) IIDR_IMPLEMENTER_MASK)
......
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