mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-02-28 02:01:50 +00:00
platform: generic: mips p8700: use SBI bitfield manipulator macros
Switch to GENMASK, EXTRACT_BITFIELD, INSERT_BITFIELD Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260223-for-upstream-eyeq7h-v3-16-621d004d1a21@mobileye.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
committed by
Anup Patel
parent
bdec423074
commit
76ecd8f37a
@@ -68,26 +68,13 @@ extern const struct p8700_cm_info *p8700_cm_info;
|
|||||||
|
|
||||||
#define MIPSCONFIG5_MTW 4
|
#define MIPSCONFIG5_MTW 4
|
||||||
|
|
||||||
#define GEN_MASK(h, l) (((1ul << ((h) + 1 - (l))) - 1) << (l))
|
/* mhartID structure */
|
||||||
#define EXT(val, mask) (((val) & (mask)) >> (__builtin_ffs(mask) - 1))
|
#define P8700_HARTID_CLUSTER GENMASK(19, 16)
|
||||||
|
#define P8700_HARTID_CORE GENMASK(11, 4)
|
||||||
/*
|
#define P8700_HARTID_HART GENMASK(3, 0)
|
||||||
* We allocate the number of bits to encode clusters, cores, and harts
|
#define cpu_cluster(i) EXTRACT_FIELD(i, P8700_HARTID_CLUSTER)
|
||||||
* from the original mhartid to a new dense index.
|
#define cpu_core(i) EXTRACT_FIELD(i, P8700_HARTID_CORE)
|
||||||
*/
|
#define cpu_hart(i) EXTRACT_FIELD(i, P8700_HARTID_HART)
|
||||||
#define NUM_OF_BITS_FOR_CLUSTERS 4
|
|
||||||
#define NUM_OF_BITS_FOR_CORES 12
|
|
||||||
#define NUM_OF_BITS_FOR_HARTS 4
|
|
||||||
|
|
||||||
/* To get the field from new/hashed mhartid */
|
|
||||||
#define NEW_CLUSTER_SHIFT (NUM_OF_BITS_FOR_CORES + NUM_OF_BITS_FOR_HARTS)
|
|
||||||
#define NEW_CLUSTER_MASK ((1 << NUM_OF_BITS_FOR_CLUSTERS) - 1)
|
|
||||||
#define NEW_CORE_SHIFT NUM_OF_BITS_FOR_HARTS
|
|
||||||
#define NEW_CORE_MASK ((1 << NUM_OF_BITS_FOR_CORES) - 1)
|
|
||||||
#define NEW_HART_MASK ((1 << NUM_OF_BITS_FOR_HARTS) - 1)
|
|
||||||
#define cpu_cluster(i) (((i) >> NEW_CLUSTER_SHIFT) & NEW_CLUSTER_MASK)
|
|
||||||
#define cpu_core(i) (((i) >> NEW_CORE_SHIFT) & NEW_CORE_MASK)
|
|
||||||
#define cpu_hart(i) ((i) & NEW_HART_MASK)
|
|
||||||
|
|
||||||
#define CPC_OFFSET (0x8000)
|
#define CPC_OFFSET (0x8000)
|
||||||
|
|
||||||
@@ -172,7 +159,7 @@ extern const struct p8700_cm_info *p8700_cm_info;
|
|||||||
#define CPC_Cx_CMD_RESET 0x4
|
#define CPC_Cx_CMD_RESET 0x4
|
||||||
|
|
||||||
#define CPC_Cx_STAT_CONF 0x0008
|
#define CPC_Cx_STAT_CONF 0x0008
|
||||||
#define CPC_Cx_STAT_CONF_SEQ_STATE GEN_MASK(22, 19)
|
#define CPC_Cx_STAT_CONF_SEQ_STATE GENMASK(22, 19)
|
||||||
#define CPC_Cx_STAT_CONF_SEQ_STATE_U5 6
|
#define CPC_Cx_STAT_CONF_SEQ_STATE_U5 6
|
||||||
#define CPC_Cx_STAT_CONF_SEQ_STATE_U6 7
|
#define CPC_Cx_STAT_CONF_SEQ_STATE_U6 7
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ static void eyeq7h_init_clusters(void)
|
|||||||
sbi_dprintf("Use %d clusters\n", num_clusters);
|
sbi_dprintf("Use %d clusters\n", num_clusters);
|
||||||
/* Power up other clusters in the platform. */
|
/* Power up other clusters in the platform. */
|
||||||
for (int i = 1; i < num_clusters; i++) {
|
for (int i = 1; i < num_clusters; i++) {
|
||||||
eyeq7h_power_up_other_cluster(i << NEW_CLUSTER_SHIFT);
|
eyeq7h_power_up_other_cluster(INSERT_FIELD(0, P8700_HARTID_CLUSTER, i));
|
||||||
}
|
}
|
||||||
eyeq7h_active_clusters = num_clusters;
|
eyeq7h_active_clusters = num_clusters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void mips_p8700_power_up_other_cluster(u32 hartid)
|
|||||||
for (int i = 100; i > 0; i--) {
|
for (int i = 100; i > 0; i--) {
|
||||||
u32 stat = read_cpc_cm_stat_conf(hartid);
|
u32 stat = read_cpc_cm_stat_conf(hartid);
|
||||||
|
|
||||||
stat = EXT(stat, CPC_Cx_STAT_CONF_SEQ_STATE);
|
stat = EXTRACT_FIELD(stat, CPC_Cx_STAT_CONF_SEQ_STATE);
|
||||||
if (stat == CPC_Cx_STAT_CONF_SEQ_STATE_U5)
|
if (stat == CPC_Cx_STAT_CONF_SEQ_STATE_U5)
|
||||||
return;
|
return;
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
@@ -67,7 +67,7 @@ static bool mips_hart_reached_state(void *arg)
|
|||||||
struct mips_boot_params *p = arg;
|
struct mips_boot_params *p = arg;
|
||||||
u32 stat = read_cpc_co_stat_conf(p->hartid);
|
u32 stat = read_cpc_co_stat_conf(p->hartid);
|
||||||
|
|
||||||
stat = EXT(stat, CPC_Cx_STAT_CONF_SEQ_STATE);
|
stat = EXTRACT_FIELD(stat, CPC_Cx_STAT_CONF_SEQ_STATE);
|
||||||
return stat == p->target_state;
|
return stat == p->target_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user