platform: andes: Change all occurrences of andes45 to andes
authorBen Zong-You Xie <ben717@andestech.com>
Fri, 19 Apr 2024 03:58:24 +0000 (11:58 +0800)
committerAnup Patel <anup@brainfault.org>
Thu, 9 May 2024 12:27:51 +0000 (17:57 +0530)
To make the framework suit all Andes CPUs, change all occurrences of
andes45 to andes.

In addition, we fix some coding style problems and remove an unused
macro in andes.h.

Signed-off-by: Ben Zong-You Xie <ben717@andestech.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
platform/generic/Kconfig
platform/generic/andes/Kconfig
platform/generic/andes/ae350.c
platform/generic/andes/andes_pma.c
platform/generic/andes/andes_pmu.c
platform/generic/andes/andes_sbi.c
platform/generic/andes/objects.mk
platform/generic/andes/sleep.S
platform/generic/include/andes/andes.h
platform/generic/include/andes/andes_pma.h
platform/generic/renesas/rzfive/rzfive.c

index c9b601171a46cebf084d385656a6348f5cb379a4..6642a6eeaa1cb3bd28199de39970a2c0baf87d12 100644 (file)
@@ -37,7 +37,7 @@ config PLATFORM_ANDES_AE350
 
 config PLATFORM_RENESAS_RZFIVE
        bool "Renesas RZ/Five support"
-       select ANDES45_PMA
+       select ANDES_PMA
        select ANDES_SBI
        select ANDES_PMU
        default n
index 3665b337343f4d3bbf8780a16a84729936f86568..138710be598f23a5ab8a7f4ec00b869a3038cfd6 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: BSD-2-Clause
 
-config ANDES45_PMA
+config ANDES_PMA
        bool "Andes PMA support"
        default n
 
index 088ec077b58ed023a4ff109e4ca5958defbe2f7b..63c10bc465c77ab6cd5547268f6d3d7737e54169 100644 (file)
@@ -18,7 +18,7 @@
 #include <sbi/sbi_hsm.h>
 #include <sbi/sbi_ipi.h>
 #include <sbi/sbi_init.h>
-#include <andes/andes45.h>
+#include <andes/andes.h>
 
 static struct smu_data smu = { 0 };
 extern void __ae350_enable_coherency_warmboot(void);
@@ -65,8 +65,9 @@ static int ae350_hart_stop(void)
        smu_set_wakeup_events(&smu, 0x0, hartid);
        smu_set_command(&smu, DEEP_SLEEP_CMD, hartid);
 
-       rc = smu_set_reset_vector(&smu, (ulong)__ae350_enable_coherency_warmboot,
-                              hartid);
+       rc = smu_set_reset_vector(&smu,
+                                 (ulong)__ae350_enable_coherency_warmboot,
+                                 hartid);
        if (rc)
                goto fail;
 
index 2745bc3a9980d6943c2d22e43806bb3094a1333e..d5ea594a6e2844f6d01943628878a15762fd6602 100644 (file)
@@ -10,7 +10,8 @@
  *      Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
  */
 
-#include <andes/andes45_pma.h>
+#include <andes/andes.h>
+#include <andes/andes_pma.h>
 #include <libfdt.h>
 #include <sbi/riscv_asm.h>
 #include <sbi/riscv_io.h>
 #include <sbi/sbi_error.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 
-/* Configuration Registers */
-#define ANDES45_CSR_MMSC_CFG           0xFC2
-#define ANDES45_CSR_MMSC_PPMA_OFFSET   (1 << 30)
-
-#define ANDES45_PMAADDR_0              0xBD0
-
-#define ANDES45_PMACFG_0               0xBC0
-
-static inline unsigned long andes45_pma_read_cfg(unsigned int pma_cfg_off)
+static inline unsigned long andes_pma_read_cfg(unsigned int pma_cfg_off)
 {
 #define switchcase_pma_cfg_read(__pma_cfg_off, __val)          \
        case __pma_cfg_off:                                     \
@@ -39,7 +32,7 @@ static inline unsigned long andes45_pma_read_cfg(unsigned int pma_cfg_off)
        unsigned long ret = 0;
 
        switch (pma_cfg_off) {
-       switchcase_pma_cfg_read_2(ANDES45_PMACFG_0, ret)
+       switchcase_pma_cfg_read_2(CSR_PMACFG0, ret)
 
        default:
                sbi_panic("%s: Unknown PMA CFG offset %#x", __func__, pma_cfg_off);
@@ -52,7 +45,7 @@ static inline unsigned long andes45_pma_read_cfg(unsigned int pma_cfg_off)
 #undef switchcase_pma_cfg_read
 }
 
-static inline void andes45_pma_write_cfg(unsigned int pma_cfg_off, unsigned long val)
+static inline void andes_pma_write_cfg(unsigned int pma_cfg_off, unsigned long val)
 {
 #define switchcase_pma_cfg_write(__pma_cfg_off, __val)         \
        case __pma_cfg_off:                                     \
@@ -63,7 +56,7 @@ static inline void andes45_pma_write_cfg(unsigned int pma_cfg_off, unsigned long
        switchcase_pma_cfg_write(__pma_cfg_off + 2, __val)
 
        switch (pma_cfg_off) {
-       switchcase_pma_cfg_write_2(ANDES45_PMACFG_0, val)
+       switchcase_pma_cfg_write_2(CSR_PMACFG0, val)
 
        default:
                sbi_panic("%s: Unknown PMA CFG offset %#x", __func__, pma_cfg_off);
@@ -74,7 +67,7 @@ static inline void andes45_pma_write_cfg(unsigned int pma_cfg_off, unsigned long
 #undef switchcase_pma_cfg_write
 }
 
-static inline void andes45_pma_write_addr(unsigned int pma_addr_off, unsigned long val)
+static inline void andes_pma_write_addr(unsigned int pma_addr_off, unsigned long val)
 {
 #define switchcase_pma_write(__pma_addr_off, __val)            \
        case __pma_addr_off:                                    \
@@ -94,7 +87,7 @@ static inline void andes45_pma_write_addr(unsigned int pma_addr_off, unsigned lo
        switchcase_pma_write_8(__pma_addr_off + 8, __val)
 
        switch (pma_addr_off) {
-       switchcase_pma_write_16(ANDES45_PMAADDR_0, val)
+       switchcase_pma_write_16(CSR_PMAADDR0, val)
 
        default:
                sbi_panic("%s: Unknown PMA ADDR offset %#x", __func__, pma_addr_off);
@@ -108,7 +101,7 @@ static inline void andes45_pma_write_addr(unsigned int pma_addr_off, unsigned lo
 #undef switchcase_pma_write
 }
 
-static inline unsigned long andes45_pma_read_addr(unsigned int pma_addr_off)
+static inline unsigned long andes_pma_read_addr(unsigned int pma_addr_off)
 {
 #define switchcase_pma_read(__pma_addr_off, __val)             \
        case __pma_addr_off:                                    \
@@ -130,7 +123,7 @@ static inline unsigned long andes45_pma_read_addr(unsigned int pma_addr_off)
        unsigned long ret = 0;
 
        switch (pma_addr_off) {
-       switchcase_pma_read_16(ANDES45_PMAADDR_0, ret)
+       switchcase_pma_read_16(CSR_PMAADDR0, ret)
 
        default:
                sbi_panic("%s: Unknown PMA ADDR offset %#x", __func__, pma_addr_off);
@@ -146,9 +139,8 @@ static inline unsigned long andes45_pma_read_addr(unsigned int pma_addr_off)
 #undef switchcase_pma_read
 }
 
-static unsigned long
-andes45_pma_setup(const struct andes45_pma_region *pma_region,
-                 unsigned int entry_id)
+static unsigned long andes_pma_setup(const struct andes_pma_region *pma_region,
+                                    unsigned int entry_id)
 {
        unsigned long size = pma_region->size;
        unsigned long addr = pma_region->pa;
@@ -168,30 +160,30 @@ andes45_pma_setup(const struct andes45_pma_region *pma_region,
        if (entry_id > 15)
                return SBI_EINVAL;
 
-       if (!(pma_region->flags & ANDES45_PMACFG_ETYP_NAPOT))
+       if (!(pma_region->flags & ANDES_PMACFG_ETYP_NAPOT))
                return SBI_EINVAL;
 
        if ((addr & (size - 1)) != 0)
                return SBI_EINVAL;
 
-       pma_cfg_addr = entry_id / 8 ? ANDES45_PMACFG_0 + 2 : ANDES45_PMACFG_0;
-       pmacfg_val = andes45_pma_read_cfg(pma_cfg_addr);
+       pma_cfg_addr = entry_id / 8 ? CSR_PMACFG0 + 2 : CSR_PMACFG0;
+       pmacfg_val = andes_pma_read_cfg(pma_cfg_addr);
        pmaxcfg = (char *)&pmacfg_val + (entry_id % 8);
        *pmaxcfg = 0;
        *pmaxcfg = pma_region->flags;
 
-       andes45_pma_write_cfg(pma_cfg_addr, pmacfg_val);
+       andes_pma_write_cfg(pma_cfg_addr, pmacfg_val);
 
        pmaaddr = (addr >> 2) + (size >> 3) - 1;
 
-       andes45_pma_write_addr(ANDES45_PMAADDR_0 + entry_id, pmaaddr);
+       andes_pma_write_addr(CSR_PMAADDR0 + entry_id, pmaaddr);
 
-       return andes45_pma_read_addr(ANDES45_PMAADDR_0 + entry_id) == pmaaddr ?
-                       pmaaddr : SBI_EINVAL;
+       return andes_pma_read_addr(CSR_PMAADDR0 + entry_id) == pmaaddr ?
+              pmaaddr : SBI_EINVAL;
 }
 
-static int andes45_fdt_pma_resv(void *fdt, const struct andes45_pma_region *pma,
-                               unsigned int index, int parent)
+static int andes_fdt_pma_resv(void *fdt, const struct andes_pma_region *pma,
+                             unsigned int index, int parent)
 {
        int na = fdt_address_cells(fdt, 0);
        int ns = fdt_size_cells(fdt, 0);
@@ -208,15 +200,15 @@ static int andes45_fdt_pma_resv(void *fdt, const struct andes45_pma_region *pma,
        size_high = (u64)pma->size >> 32;
        size_low = pma->size;
 
-       if (na > 1 && addr_high)
+       if (na > 1 && addr_high) {
                sbi_snprintf(name, sizeof(name),
                             "pma_resv%d@%x,%x", index,
                             addr_high, addr_low);
-       else
+       } else {
                sbi_snprintf(name, sizeof(name),
                             "pma_resv%d@%x", index,
                             addr_low);
-
+       }
        subnode = fdt_add_subnode(fdt, parent, name);
        if (subnode < 0)
                return subnode;
@@ -244,7 +236,7 @@ static int andes45_fdt_pma_resv(void *fdt, const struct andes45_pma_region *pma,
                dma_default = true;
        }
 
-       /* encode the <reg> property value */
+       /* Encode the <reg> property value */
        val = reg;
        if (na > 1)
                *val++ = cpu_to_fdt32(addr_high);
@@ -261,9 +253,9 @@ static int andes45_fdt_pma_resv(void *fdt, const struct andes45_pma_region *pma,
        return 0;
 }
 
-static int andes45_fdt_reserved_memory_fixup(void *fdt,
-                                            const struct andes45_pma_region *pma,
-                                            unsigned int entry)
+static int andes_fdt_reserved_memory_fixup(void *fdt,
+                                          const struct andes_pma_region *pma,
+                                          unsigned int entry)
 {
        int parent;
 
@@ -292,13 +284,13 @@ static int andes45_fdt_reserved_memory_fixup(void *fdt,
                        return err;
        }
 
-       return andes45_fdt_pma_resv(fdt, pma, entry, parent);
+       return andes_fdt_pma_resv(fdt, pma, entry, parent);
 }
 
-int andes45_pma_setup_regions(const struct andes45_pma_region *pma_regions,
-                             unsigned int pma_regions_count)
+int andes_pma_setup_regions(const struct andes_pma_region *pma_regions,
+                           unsigned int pma_regions_count)
 {
-       unsigned long mmsc = csr_read(ANDES45_CSR_MMSC_CFG);
+       unsigned long mmsc = csr_read(CSR_MMSC_CFG);
        unsigned int dt_populate_cnt;
        unsigned int i, j;
        unsigned long pa;
@@ -308,15 +300,15 @@ int andes45_pma_setup_regions(const struct andes45_pma_region *pma_regions,
        if (!pma_regions || !pma_regions_count)
                return 0;
 
-       if (pma_regions_count > ANDES45_MAX_PMA_REGIONS)
+       if (pma_regions_count > ANDES_MAX_PMA_REGIONS)
                return SBI_EINVAL;
 
-       if ((mmsc & ANDES45_CSR_MMSC_PPMA_OFFSET) == 0)
+       if ((mmsc & MMSC_CFG_PPMA_MASK) == 0)
                return SBI_ENOTSUPP;
 
        /* Configure the PMA regions */
        for (i = 0; i < pma_regions_count; i++) {
-               pa = andes45_pma_setup(&pma_regions[i], i);
+               pa = andes_pma_setup(&pma_regions[i], i);
                if (pa == SBI_EINVAL)
                        return SBI_EINVAL;
        }
@@ -341,7 +333,7 @@ int andes45_pma_setup_regions(const struct andes45_pma_region *pma_regions,
                if (!pma_regions[i].dt_populate)
                        continue;
 
-               ret = andes45_fdt_reserved_memory_fixup(fdt, &pma_regions[i], j++);
+               ret = andes_fdt_reserved_memory_fixup(fdt, &pma_regions[i], j++);
                if (ret)
                        return ret;
        }
index 479fb9a6cd2becbdbaa988097b7c8988ecfb7a77..a075e0e5b5d02b33beb2ee011733dea4bcd25fc4 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright (C) 2023 Andes Technology Corporation
  */
 
-#include <andes/andes45.h>
+#include <andes/andes.h>
 #include <andes/andes_pmu.h>
 #include <sbi/sbi_bitops.h>
 #include <sbi/sbi_error.h>
index 267c663899ddc306f6dc51b33860b97469dab81f..43bafdc76acf205330453f5e57b8e0178f4f0af1 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2023 Renesas Electronics Corp.
  *
  */
-#include <andes/andes45.h>
+#include <andes/andes.h>
 #include <andes/andes_sbi.h>
 #include <sbi/riscv_asm.h>
 #include <sbi/sbi_error.h>
@@ -13,7 +13,7 @@ enum sbi_ext_andes_fid {
        SBI_EXT_ANDES_IOCP_SW_WORKAROUND,
 };
 
-static bool andes45_cache_controllable(void)
+static bool andes_cache_controllable(void)
 {
        return (((csr_read(CSR_MICM_CFG) & MICM_CFG_ISZ_MASK) ||
                 (csr_read(CSR_MDCM_CFG) & MDCM_CFG_DSZ_MASK)) &&
@@ -22,14 +22,14 @@ static bool andes45_cache_controllable(void)
                misa_extension('U'));
 }
 
-static bool andes45_iocp_disabled(void)
+static bool andes_iocp_disabled(void)
 {
        return (csr_read(CSR_MMSC_CFG) & MMSC_IOCP_MASK) ? false : true;
 }
 
-static bool andes45_apply_iocp_sw_workaround(void)
+static bool andes_apply_iocp_sw_workaround(void)
 {
-       return andes45_cache_controllable() & andes45_iocp_disabled();
+       return andes_cache_controllable() & andes_iocp_disabled();
 }
 
 int andes_sbi_vendor_ext_provider(long funcid,
@@ -39,7 +39,7 @@ int andes_sbi_vendor_ext_provider(long funcid,
 {
        switch (funcid) {
        case SBI_EXT_ANDES_IOCP_SW_WORKAROUND:
-               out->value = andes45_apply_iocp_sw_workaround();
+               out->value = andes_apply_iocp_sw_workaround();
                break;
 
        default:
index 6a8c66c2422cb0bf7fb7ea3f2750f0d7fbb0c729..15e618529c44e15696257122ce230d736867dedc 100644 (file)
@@ -5,6 +5,6 @@
 carray-platform_override_modules-$(CONFIG_PLATFORM_ANDES_AE350) += andes_ae350
 platform-objs-$(CONFIG_PLATFORM_ANDES_AE350) += andes/ae350.o andes/sleep.o
 
-platform-objs-$(CONFIG_ANDES45_PMA) += andes/andes45-pma.o
+platform-objs-$(CONFIG_ANDES_PMA) += andes/andes_pma.o
 platform-objs-$(CONFIG_ANDES_SBI) += andes/andes_sbi.o
 platform-objs-$(CONFIG_ANDES_PMU) += andes/andes_pmu.o
index 59a5597d6d8ca9bc10eee8799c8f8fbf8dc64a76..361aff3a6024425db47a9dcc59e456ab2b8f4c2a 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <sbi/riscv_encoding.h>
 #include <sbi/riscv_asm.h>
-#include <andes/andes45.h>
+#include <andes/andes.h>
 
        .section .text, "ax", %progbits
        .align 3
index 01f63d444ea3ba9e48dfbd1be8146472a139d94c..3403a58b8fc1901f44a777dbf6268d4b0e97b183 100644 (file)
@@ -1,7 +1,10 @@
-#ifndef _RISCV_ANDES45_H
-#define _RISCV_ANDES45_H
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Andes Technology Corporation
+ */
 
-#define CSR_MARCHID_MICROID 0xfff
+#ifndef _RISCV_ANDES_H
+#define _RISCV_ANDES_H
 
 /* Memory and Miscellaneous Registers */
 #define CSR_MCACHE_CTL         0x7ca
 #define CSR_MCOUNTERMASK_U     0x7d3
 #define CSR_MCOUNTEROVF                0x7d4
 
+/* PMA Related Registers */
+#define CSR_PMACFG0            0xbc0
+#define CSR_PMAADDR0           0xbd0
+
 #define MICM_CFG_ISZ_OFFSET            6
-#define MICM_CFG_ISZ_MASK              (0x7  << MICM_CFG_ISZ_OFFSET)
+#define MICM_CFG_ISZ_MASK              (7 << MICM_CFG_ISZ_OFFSET)
 
 #define MDCM_CFG_DSZ_OFFSET            6
-#define MDCM_CFG_DSZ_MASK              (0x7  << MDCM_CFG_DSZ_OFFSET)
+#define MDCM_CFG_DSZ_MASK              (7 << MDCM_CFG_DSZ_OFFSET)
 
 #define MMSC_CFG_CCTLCSR_OFFSET                16
-#define MMSC_CFG_CCTLCSR_MASK          (0x1 << MMSC_CFG_CCTLCSR_OFFSET)
-#define MMSC_IOCP_OFFSET                       47
-#define MMSC_IOCP_MASK                 (0x1ULL << MMSC_IOCP_OFFSET)
+#define MMSC_CFG_CCTLCSR_MASK          (1 << MMSC_CFG_CCTLCSR_OFFSET)
+#define MMSC_CFG_PPMA_OFFSET           30
+#define MMSC_CFG_PPMA_MASK             (1 << MMSC_CFG_PPMA_OFFSET)
+#define MMSC_IOCP_OFFSET               47
+#define MMSC_IOCP_MASK                 (1ULL << MMSC_IOCP_OFFSET)
 
 #define MCACHE_CTL_CCTL_SUEN_OFFSET    8
-#define MCACHE_CTL_CCTL_SUEN_MASK      (0x1 << MCACHE_CTL_CCTL_SUEN_OFFSET)
+#define MCACHE_CTL_CCTL_SUEN_MASK      (1 << MCACHE_CTL_CCTL_SUEN_OFFSET)
 
 /* Performance monitor */
 #define MMSC_CFG_PMNDS_MASK            (1 << 15)
@@ -58,4 +67,4 @@
 
 #endif /* __ASSEMBLER__ */
 
-#endif /* _RISCV_ANDES45_H */
+#endif /* _RISCV_ANDES_H */
index 37ec77cf670509b57f283fbd0f99a6aa23359eb7..bbc09cdd7741751a9c89acbf0c0ca48add497517 100644 (file)
@@ -3,21 +3,21 @@
  * Copyright (C) 2023 Renesas Electronics Corp.
  */
 
-#ifndef _ANDES45_PMA_H_
-#define _ANDES45_PMA_H_
+#ifndef _ANDES_PMA_H_
+#define _ANDES_PMA_H_
 
 #include <sbi/sbi_types.h>
 
-#define ANDES45_MAX_PMA_REGIONS                        16
+#define ANDES_MAX_PMA_REGIONS                  16
 
 /* Naturally aligned power of 2 region */
-#define ANDES45_PMACFG_ETYP_NAPOT              3
+#define ANDES_PMACFG_ETYP_NAPOT                        3
 
 /* Memory, Non-cacheable, Bufferable */
-#define ANDES45_PMACFG_MTYP_MEM_NON_CACHE_BUF  (3 << 2)
+#define ANDES_PMACFG_MTYP_MEM_NON_CACHE_BUF    (3 << 2)
 
 /**
- * struct andes45_pma_region - Describes PMA regions
+ * struct andes_pma_region - Describes PMA regions
  *
  * @pa: Address to be configured in the PMA
  * @size: Size of the region
@@ -32,7 +32,7 @@
  *              be set in the DT node. Note Linux expects single node
  *              with this property set.
  */
-struct andes45_pma_region {
+struct andes_pma_region {
        unsigned long pa;
        unsigned long size;
        u8 flags:7;
@@ -42,7 +42,7 @@ struct andes45_pma_region {
        bool dma_default;
 };
 
-int andes45_pma_setup_regions(const struct andes45_pma_region *pma_regions,
-                             unsigned int pma_regions_count);
+int andes_pma_setup_regions(const struct andes_pma_region *pma_regions,
+                           unsigned int pma_regions_count);
 
-#endif /* _ANDES45_PMA_H_ */
+#endif /* _ANDES_PMA_H_ */
index b5b5e6516a94b7ead548fe1da6675a3016709c11..515bcd7647361250bbb28f419e02a37f6ac1b729 100644 (file)
@@ -4,19 +4,19 @@
  *
  */
 
-#include <andes/andes45_pma.h>
+#include <andes/andes_pma.h>
 #include <andes/andes_pmu.h>
 #include <andes/andes_sbi.h>
 #include <platform_override.h>
 #include <sbi/sbi_domain.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 
-static const struct andes45_pma_region renesas_rzfive_pma_regions[] = {
+static const struct andes_pma_region renesas_rzfive_pma_regions[] = {
        {
                .pa = 0x58000000,
                .size = 0x8000000,
-               .flags = ANDES45_PMACFG_ETYP_NAPOT |
-                        ANDES45_PMACFG_MTYP_MEM_NON_CACHE_BUF,
+               .flags = ANDES_PMACFG_ETYP_NAPOT |
+                        ANDES_PMACFG_MTYP_MEM_NON_CACHE_BUF,
                .dt_populate = true,
                .shared_dma = true,
                .no_map = true,
@@ -26,8 +26,8 @@ static const struct andes45_pma_region renesas_rzfive_pma_regions[] = {
 
 static int renesas_rzfive_final_init(bool cold_boot, const struct fdt_match *match)
 {
-       return andes45_pma_setup_regions(renesas_rzfive_pma_regions,
-                                        array_size(renesas_rzfive_pma_regions));
+       return andes_pma_setup_regions(renesas_rzfive_pma_regions,
+                                      array_size(renesas_rzfive_pma_regions));
 }
 
 static int renesas_rzfive_early_init(bool cold_boot, const struct fdt_match *match)