Skip to content

Commit afc7a58

Browse files
zongboxpalmer-dabbelt
authored andcommitted
soc: sifive: ccache: define the macro for the register shifts
Define the macro for the register shifts, it could make the code be more readable Signed-off-by: Zong Li <zong.li@sifive.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20220913061817.22564-7-zong.li@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 696ab9b commit afc7a58

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

drivers/soc/sifive/sifive_ccache.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of_irq.h>
1414
#include <linux/of_address.h>
1515
#include <linux/device.h>
16+
#include <linux/bitfield.h>
1617
#include <asm/cacheinfo.h>
1718
#include <soc/sifive/sifive_ccache.h>
1819

@@ -33,6 +34,11 @@
3334
#define SIFIVE_CCACHE_DATECCFAIL_COUNT 0x168
3435

3536
#define SIFIVE_CCACHE_CONFIG 0x00
37+
#define SIFIVE_CCACHE_CONFIG_BANK_MASK GENMASK_ULL(7, 0)
38+
#define SIFIVE_CCACHE_CONFIG_WAYS_MASK GENMASK_ULL(15, 8)
39+
#define SIFIVE_CCACHE_CONFIG_SETS_MASK GENMASK_ULL(23, 16)
40+
#define SIFIVE_CCACHE_CONFIG_BLKS_MASK GENMASK_ULL(31, 24)
41+
3642
#define SIFIVE_CCACHE_WAYENABLE 0x08
3743
#define SIFIVE_CCACHE_ECCINJECTERR 0x40
3844

@@ -87,11 +93,11 @@ static void ccache_config_read(void)
8793
u32 cfg;
8894

8995
cfg = readl(ccache_base + SIFIVE_CCACHE_CONFIG);
90-
91-
pr_info("%u banks, %u ways, sets/bank=%llu, bytes/block=%llu\n",
92-
(cfg & 0xff), (cfg >> 8) & 0xff,
93-
BIT_ULL((cfg >> 16) & 0xff),
94-
BIT_ULL((cfg >> 24) & 0xff));
96+
pr_info("%llu banks, %llu ways, sets/bank=%llu, bytes/block=%llu\n",
97+
FIELD_GET(SIFIVE_CCACHE_CONFIG_BANK_MASK, cfg),
98+
FIELD_GET(SIFIVE_CCACHE_CONFIG_WAYS_MASK, cfg),
99+
BIT_ULL(FIELD_GET(SIFIVE_CCACHE_CONFIG_SETS_MASK, cfg)),
100+
BIT_ULL(FIELD_GET(SIFIVE_CCACHE_CONFIG_BLKS_MASK, cfg)));
95101

96102
cfg = readl(ccache_base + SIFIVE_CCACHE_WAYENABLE);
97103
pr_info("Index of the largest way enabled: %u\n", cfg);

0 commit comments

Comments
 (0)