summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2023-04-03 21:33:45 +0100
committerAndre Przywara <andre.przywara@arm.com>2023-04-26 17:45:29 +0100
commitfbde260b11171f0f67afbc631e22fe26366ff448 (patch)
treeb3aba721c5abfad6d916897fc954ef18bf6bc4d7
parentb15e2cda14b3ffddebd8b40cc5c31c1c0e9cbf0d (diff)
downloadarm-trusted-firmware-fbde260b11171f0f67afbc631e22fe26366ff448.tar.gz
feat(allwinner): add function to detect H616 die variant
Allwinner provides a number of SoCs that use the same die as the H616. Some of those chips apparently use a slight variation of that die, that differs in the way the CPU cores' power and reset controls are handled. This die variation can be detected by reading the SRAM version register. Provide a predicate function that returns false if that die variant is used. Since the CPU power control code is shared for all supported SoCs, we provide an instance of this function for each SoC, as a static inline, and return true on all other SoCs. This allows to always use this function, and still let the compiler optimise away the unneeded branch for those older SoCs. This function is unused for now, but is needed in the next patch. Change-Id: I49e014b895b7e2f55b4e7dc2b3d8aa31cee711b5 Signed-off-by: Andre Przywara <andre.przywara@arm.com>
-rw-r--r--plat/allwinner/common/include/sunxi_cpucfg_ncat2.h5
-rw-r--r--plat/allwinner/common/include/sunxi_def.h1
-rw-r--r--plat/allwinner/common/sunxi_common.c2
-rw-r--r--plat/allwinner/sun50i_a64/include/sunxi_cpucfg.h5
-rw-r--r--plat/allwinner/sun50i_h6/include/sunxi_cpucfg.h5
-rw-r--r--plat/allwinner/sun50i_h616/include/sunxi_cpucfg.h7
6 files changed, 24 insertions, 1 deletions
diff --git a/plat/allwinner/common/include/sunxi_cpucfg_ncat2.h b/plat/allwinner/common/include/sunxi_cpucfg_ncat2.h
index 9478f321a..d4aec1932 100644
--- a/plat/allwinner/common/include/sunxi_cpucfg_ncat2.h
+++ b/plat/allwinner/common/include/sunxi_cpucfg_ncat2.h
@@ -28,4 +28,9 @@
#define SUNXI_AA64nAA32_REG SUNXI_CPUCFG_GEN_CTRL_REG0
#define SUNXI_AA64nAA32_OFFSET 4
+static inline bool sunxi_cpucfg_has_per_cluster_regs(void)
+{
+ return true;
+}
+
#endif /* SUNXI_CPUCFG_H */
diff --git a/plat/allwinner/common/include/sunxi_def.h b/plat/allwinner/common/include/sunxi_def.h
index c17ef9529..20f6c4986 100644
--- a/plat/allwinner/common/include/sunxi_def.h
+++ b/plat/allwinner/common/include/sunxi_def.h
@@ -20,6 +20,7 @@
#define SUNXI_SOC_H616 0x1823
#define SUNXI_SOC_R329 0x1851
+#define SUNXI_VER_BITS_MASK 0xffU
#define JEDEC_ALLWINNER_BKID 9U
#define JEDEC_ALLWINNER_MFID 0x9eU
diff --git a/plat/allwinner/common/sunxi_common.c b/plat/allwinner/common/sunxi_common.c
index 092659c0b..62f4fcbd9 100644
--- a/plat/allwinner/common/sunxi_common.c
+++ b/plat/allwinner/common/sunxi_common.c
@@ -183,5 +183,5 @@ int32_t plat_get_soc_revision(void)
{
uint32_t reg = mmio_read_32(SRAM_VER_REG);
- return reg & GENMASK_32(7, 0);
+ return reg & SUNXI_VER_BITS_MASK;
}
diff --git a/plat/allwinner/sun50i_a64/include/sunxi_cpucfg.h b/plat/allwinner/sun50i_a64/include/sunxi_cpucfg.h
index aed358572..ddd53baab 100644
--- a/plat/allwinner/sun50i_a64/include/sunxi_cpucfg.h
+++ b/plat/allwinner/sun50i_a64/include/sunxi_cpucfg.h
@@ -36,4 +36,9 @@
#define SUNXI_AA64nAA32_REG SUNXI_CPUCFG_CLS_CTRL_REG0
#define SUNXI_AA64nAA32_OFFSET 24
+static inline bool sunxi_cpucfg_has_per_cluster_regs(void)
+{
+ return true;
+}
+
#endif /* SUNXI_CPUCFG_H */
diff --git a/plat/allwinner/sun50i_h6/include/sunxi_cpucfg.h b/plat/allwinner/sun50i_h6/include/sunxi_cpucfg.h
index 58abfaa58..585c51b07 100644
--- a/plat/allwinner/sun50i_h6/include/sunxi_cpucfg.h
+++ b/plat/allwinner/sun50i_h6/include/sunxi_cpucfg.h
@@ -1 +1,6 @@
#include <sunxi_cpucfg_ncat.h>
+
+static inline bool sunxi_cpucfg_has_per_cluster_regs(void)
+{
+ return true;
+}
diff --git a/plat/allwinner/sun50i_h616/include/sunxi_cpucfg.h b/plat/allwinner/sun50i_h616/include/sunxi_cpucfg.h
index 58abfaa58..5c590e48b 100644
--- a/plat/allwinner/sun50i_h616/include/sunxi_cpucfg.h
+++ b/plat/allwinner/sun50i_h616/include/sunxi_cpucfg.h
@@ -1 +1,8 @@
+#include <plat/common/platform.h>
+
#include <sunxi_cpucfg_ncat.h>
+
+static inline bool sunxi_cpucfg_has_per_cluster_regs(void)
+{
+ return (plat_get_soc_revision() != 2);
+}