Skip to content

Commit 5186da6

Browse files
cmuellneravpatel
authored andcommitted
platform: generic: allwinner: sun20i-d1: Remove duplicated CSR definitions
All T-Head CSRs are already defined in thead/c9xx_encoding.h. Let's reuse the values from there instead of redefining them with a slightly different name. Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Reviewed-by: Anup Patel <anup@brainfault.org>
1 parent 3b2f89e commit 5186da6

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

platform/generic/allwinner/sun20i-d1.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,40 +33,31 @@
3333
#define RISCV_CFG_BGR_REG 0xd0c
3434
#define PPU_BGR_REG 0x1ac
3535

36-
/*
37-
* CSRs
38-
*/
39-
40-
#define CSR_MXSTATUS 0x7c0
41-
#define CSR_MHCR 0x7c1
42-
#define CSR_MCOR 0x7c2
43-
#define CSR_MHINT 0x7c5
44-
4536
static unsigned long csr_mxstatus;
4637
static unsigned long csr_mhcr;
4738
static unsigned long csr_mhint;
4839

4940
static void sun20i_d1_csr_save(void)
5041
{
5142
/* Save custom CSRs. */
52-
csr_mxstatus = csr_read(CSR_MXSTATUS);
53-
csr_mhcr = csr_read(CSR_MHCR);
54-
csr_mhint = csr_read(CSR_MHINT);
43+
csr_mxstatus = csr_read(THEAD_C9XX_CSR_MXSTATUS);
44+
csr_mhcr = csr_read(THEAD_C9XX_CSR_MHCR);
45+
csr_mhint = csr_read(THEAD_C9XX_CSR_MHINT);
5546

5647
/* Flush and disable caches. */
57-
csr_write(CSR_MCOR, 0x22);
58-
csr_write(CSR_MHCR, 0x0);
48+
csr_write(THEAD_C9XX_CSR_MCOR, 0x22);
49+
csr_write(THEAD_C9XX_CSR_MHCR, 0x0);
5950
}
6051

6152
static void sun20i_d1_csr_restore(void)
6253
{
6354
/* Invalidate caches and the branch predictor. */
64-
csr_write(CSR_MCOR, 0x70013);
55+
csr_write(THEAD_C9XX_CSR_MCOR, 0x70013);
6556

6657
/* Restore custom CSRs, including the cache state. */
67-
csr_write(CSR_MXSTATUS, csr_mxstatus);
68-
csr_write(CSR_MHCR, csr_mhcr);
69-
csr_write(CSR_MHINT, csr_mhint);
58+
csr_write(THEAD_C9XX_CSR_MXSTATUS, csr_mxstatus);
59+
csr_write(THEAD_C9XX_CSR_MHCR, csr_mhcr);
60+
csr_write(THEAD_C9XX_CSR_MHINT, csr_mhint);
7061
}
7162

7263
/*

0 commit comments

Comments
 (0)