From: Mina Hui-Min Chou <minachou@andestech.com>
To: <pjw@kernel.org>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
<alex@ghiti.fr>, <conor@kernel.org>, <jic23@kernel.org>,
<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<geert+renesas@glider.be>, <magnus.damm@gmail.com>,
<prabhakar.mahadev-lad.rj@bp.renesas.com>,
<linux-riscv@lists.infradead.org>, <devicetree@vger.kernel.org>,
<linux-renesas-soc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <randolph@andestech.com>, <cyyang772@andestech.com>,
<tim609@andestech.com>, <minachou@andestech.com>,
<az70021@gmail.com>
Subject: [PATCH v2 05/19] cache: ax45mp_cache: standardize macro naming for LLC and L1D registers
Date: Fri, 13 Nov 2026 15:11:29 +0800 [thread overview]
Message-ID: <20261113071143.1446167-6-minachou@andestech.com> (raw)
In-Reply-To: <20261113071143.1446167-1-minachou@andestech.com>
Rename macros to follow a consistent naming convention:
ANDES_{LLC|L1D}_{REG_}CCTL_{operation}_{target}
- LLC or L1D: which cache level
- REG_: present for register offset macros
- CCTL: cache control operation
- target: C0 for core 0 base, BY_CORE(n) for per-core variants
This is a mechanical rename with no functional change:
- ANDES_LLC_REG_C0_* -> ANDES_LLC_REG_CCTL_*_C0
- ANDES_LLC_REG_CN_* -> ANDES_LLC_REG_CCTL_*_BY_CORE(n)
- ANDES_CCTL_L1D_* -> ANDES_L1D_CCTL_*
- ANDES_CCTL_LLC_* -> ANDES_LLC_CCTL_*
- Use GENMASK(3, 0) instead of 0xf for ANDES_LLC_CCTL_STATUS_MASK_C0
Signed-off-by: Mina Hui-Min Chou <minachou@andestech.com>
---
drivers/cache/ax45mp_cache.c | 55 ++++++++++++++++++------------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/drivers/cache/ax45mp_cache.c b/drivers/cache/ax45mp_cache.c
index b3d6f6a11cfc..61730e218afa 100644
--- a/drivers/cache/ax45mp_cache.c
+++ b/drivers/cache/ax45mp_cache.c
@@ -16,34 +16,33 @@
/* LLC registers */
#define ANDES_LLC_REG_CTL_OFFSET 0x8
+#define ANDES_LLC_REG_CCTL_CMD_OFFSET_C0 0x40
+#define ANDES_LLC_REG_CCTL_ACC_OFFSET_C0 0x48
+#define ANDES_LLC_REG_CCTL_STATUS_OFFSET_C0 0x80
-#define ANDES_LLC_REG_C0_CMD_OFFSET 0x40
-#define ANDES_LLC_REG_C0_ACC_OFFSET 0x48
-#define ANDES_LLC_REG_STATUS_OFFSET 0x80
-
-/* D-cache operation */
-#define ANDES_CCTL_L1D_VA_INVAL 0 /* Invalidate an L1 cache entry */
-#define ANDES_CCTL_L1D_VA_WB 1 /* Write-back an L1 cache entry */
+/* L1 D-cache operation */
+#define ANDES_L1D_CCTL_VA_INVAL 0x0 /* Invalidate an L1 cache entry */
+#define ANDES_L1D_CCTL_VA_WB 0x1 /* Write-back an L1 cache entry */
/* LLC CCTL status */
-#define ANDES_CCTL_LLC_STATUS_IDLE 0
+#define ANDES_LLC_CCTL_STATUS_IDLE 0x0
/* LLC CCTL status cores mask */
-#define ANDES_CCTL_LLC_STATUS_C0_MASK 0xf
+#define ANDES_LLC_CCTL_STATUS_MASK_C0 GENMASK(3, 0)
/* LLC operation */
-#define ANDES_CCTL_LLC_PA_INVAL 0x8 /* Invalidate an LLC entry */
-#define ANDES_CCTL_LLC_PA_WB 0x9 /* Write-back an LLC entry */
+#define ANDES_LLC_CCTL_PA_INVAL 0x8 /* Invalidate an LLC entry */
+#define ANDES_LLC_CCTL_PA_WB 0x9 /* Write-back an LLC entry */
-#define ANDES_LLC_REG_PER_CORE_OFFSET 0x10
-#define ANDES_CCTL_LLC_STATUS_PER_CORE_OFFSET 4
+#define ANDES_LLC_REG_CCTL_CORE_OFFSET 0x10
+#define ANDES_LLC_CCTL_STATUS_MASK_CORE_OFFSET 0x4
-#define ANDES_LLC_REG_CN_CMD_OFFSET(n) \
- (ANDES_LLC_REG_C0_CMD_OFFSET + ((n) * ANDES_LLC_REG_PER_CORE_OFFSET))
-#define ANDES_LLC_REG_CN_ACC_OFFSET(n) \
- (ANDES_LLC_REG_C0_ACC_OFFSET + ((n) * ANDES_LLC_REG_PER_CORE_OFFSET))
-#define ANDES_CCTL_LLC_STATUS_CN_MASK(n) \
- (ANDES_CCTL_LLC_STATUS_C0_MASK << ((n) * ANDES_CCTL_LLC_STATUS_PER_CORE_OFFSET))
+#define ANDES_LLC_REG_CCTL_CMD_OFFSET_BY_CORE(n) \
+ (ANDES_LLC_REG_CCTL_CMD_OFFSET_C0 + ((n) * ANDES_LLC_REG_CCTL_CORE_OFFSET))
+#define ANDES_LLC_REG_CCTL_ACC_OFFSET_BY_CORE(n) \
+ (ANDES_LLC_REG_CCTL_ACC_OFFSET_C0 + ((n) * ANDES_LLC_REG_CCTL_CORE_OFFSET))
+#define ANDES_LLC_CCTL_STATUS_MASK_BY_CORE(n) \
+ (ANDES_LLC_CCTL_STATUS_MASK_C0 << ((n) * ANDES_LLC_CCTL_STATUS_MASK_CORE_OFFSET))
#define ANDES_CACHE_LINE_SIZE 64
@@ -57,7 +56,7 @@ static struct andes_priv andes_priv;
/* LLC operations */
static inline uint32_t andes_cpu_llc_get_cctl_status(void)
{
- return readl(andes_priv.llc_base + ANDES_LLC_REG_STATUS_OFFSET);
+ return readl(andes_priv.llc_base + ANDES_LLC_REG_CCTL_STATUS_OFFSET_C0);
}
static void andes_cpu_cache_operation(unsigned long start, unsigned long end,
@@ -73,11 +72,11 @@ static void andes_cpu_cache_operation(unsigned long start, unsigned long end,
csr_write(CSR_UCCTLCOMMAND, l1_op);
pa = virt_to_phys((void *)start);
- writel(pa, base + ANDES_LLC_REG_CN_ACC_OFFSET(mhartid));
- writel(llc_op, base + ANDES_LLC_REG_CN_CMD_OFFSET(mhartid));
+ writel(pa, base + ANDES_LLC_REG_CCTL_ACC_OFFSET_BY_CORE(mhartid));
+ writel(llc_op, base + ANDES_LLC_REG_CCTL_CMD_OFFSET_BY_CORE(mhartid));
while ((andes_cpu_llc_get_cctl_status() &
- ANDES_CCTL_LLC_STATUS_CN_MASK(mhartid)) !=
- ANDES_CCTL_LLC_STATUS_IDLE)
+ ANDES_LLC_CCTL_STATUS_MASK_BY_CORE(mhartid)) !=
+ ANDES_LLC_CCTL_STATUS_IDLE)
;
start += line_size;
@@ -87,15 +86,15 @@ static void andes_cpu_cache_operation(unsigned long start, unsigned long end,
/* Write-back L1 and LLC entry */
static inline void andes_cpu_dcache_wb_range(unsigned long start, unsigned long end)
{
- andes_cpu_cache_operation(start, end, ANDES_CCTL_L1D_VA_WB,
- ANDES_CCTL_LLC_PA_WB);
+ andes_cpu_cache_operation(start, end, ANDES_L1D_CCTL_VA_WB,
+ ANDES_LLC_CCTL_PA_WB);
}
/* Invalidate the L1 and LLC entry */
static inline void andes_cpu_dcache_inval_range(unsigned long start, unsigned long end)
{
- andes_cpu_cache_operation(start, end, ANDES_CCTL_L1D_VA_INVAL,
- ANDES_CCTL_LLC_PA_INVAL);
+ andes_cpu_cache_operation(start, end, ANDES_L1D_CCTL_VA_INVAL,
+ ANDES_LLC_CCTL_PA_INVAL);
}
static void andes_dma_cache_inv(phys_addr_t paddr, size_t size)
--
2.34.1
next prev parent reply other threads:[~2026-11-13 7:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 7:11 [PATCH v2 00/19] riscv: andes: make the LLC driver and cache errata generic Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 01/19] cache: ax45mp_cache: use __initconst for ax45mp_cmo_ops Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 02/19] cache: ax45mp_cache: rename AX45MP-specific identifiers to generic ANDES Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 03/19] cache: ax45mp_cache: rename L2 identifiers to LLC Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 04/19] cache: ax45mp_cache: add shared header for Andes CSRs Mina Hui-Min Chou
2026-11-13 7:11 ` Mina Hui-Min Chou [this message]
2026-11-13 7:11 ` [PATCH v2 06/19] cache: ax45mp_cache: rename ax45mp_cache.c to andes_llcache.c Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 07/19] cache: andes_llcache: clean up cache inv/wback functions Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 08/19] cache: andes_llcache: use u32 and fix the cache-line-size error message Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 09/19] cache: andes_llcache: write the full physical address for CCTL Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 10/19] cache: andes_llcache: register cache ops only when the errata needs them Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 11/19] cache: andes_llcache: use the hart ID to index the CCTL registers Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 12/19] dt-bindings: cache: andestech: update schema for generic LLC support Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 13/19] dt-bindings: cache: rename andestech,ax45mp-cache to andestech,llcache Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 14/19] cache: andes_llcache: add generic andestech,llcache compatible Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 15/19] MAINTAINERS: Add maintainer for Andes cache driver Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 16/19] riscv: errata: andes: allow ERRATA_ANDES_CMO on all Andes SoCs Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 17/19] riscv: errata: andes: generalize cache errata for Andes cores Mina Hui-Min Chou
2026-11-13 7:11 ` [PATCH v2 18/19] riscv: errata: andes: limit the IOCP workaround to RZ/Five Mina Hui-Min Chou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261113071143.1446167-6-minachou@andestech.com \
--to=minachou@andestech.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=az70021@gmail.com \
--cc=conor+dt@kernel.org \
--cc=conor@kernel.org \
--cc=cyyang772@andestech.com \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=magnus.damm@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=randolph@andestech.com \
--cc=robh@kernel.org \
--cc=tim609@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®