Skip to contentSkip to conversation

AE350 SMP support RISC-V

PATCH Superseded Andes 3 participants 15 messages Mar 25, 2019 – Apr 1, 2019 RISC-V

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Andes

author
#0 lore raw

v2 cover AE350 SMP support RISC-V

From: Rick Chen <[email protected]>

Changes in v2:
- Drop patch1 and replace by simple-bus driver
- Rename nds_plic as andes_plic
- Move initialize plic to PLIC_BASE_GET() and called automatically
- Rename nds_plmt as andes_plmt
- Recovery dts isa string

Rick Chen (7):
riscv: Add a SYSCON driver for Andestech's PLIC
riscv: Add a SYSCON driver for Andestech's PLMT
riscv: ae350: disable ATCPIT100 timer
riscv: ax25: Add platform-specific Kconfig options
riscv: ax25: Andes specific cache shall only support in M-mode
riscv: dts: ae350 support SMP
riscv: ae350: enable SMP

 arch/riscv/Kconfig                   |  18 ++++++
 arch/riscv/cpu/ax25/Kconfig          |   7 +++
 arch/riscv/dts/ae350_32.dts          |  81 ++++++++++++++++++-------
 arch/riscv/dts/ae350_64.dts          |  47 +++++++++++++--
 arch/riscv/include/asm/global_data.h |   6 ++
 arch/riscv/include/asm/syscon.h      |   3 +-
 arch/riscv/lib/Makefile              |   2 +
 arch/riscv/lib/andes_plic.c          | 111 +++++++++++++++++++++++++++++++++++
 arch/riscv/lib/andes_plmt.c          |  53 +++++++++++++++++
 board/AndesTech/ax25-ae350/Kconfig   |   1 +
 configs/ae350_rv32_defconfig         |   1 -
 configs/ae350_rv64_defconfig         |   1 -
 12 files changed, 301 insertions(+), 30 deletions(-)
 create mode 100644 arch/riscv/lib/andes_plic.c
 create mode 100644 arch/riscv/lib/andes_plmt.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/7 riscv: Add a SYSCON driver for Andestech's PLIC

From: Rick Chen <[email protected]>

The Platform-Level Interrupt Controller(PLIC) block holds memory-mapped claim and pending registers associated with software interrupt. It is required for handling IPI.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/Kconfig                   |   9 +++
 arch/riscv/include/asm/global_data.h |   3 +
 arch/riscv/include/asm/syscon.h      |   2 +-
 arch/riscv/lib/Makefile              |   1 +
 arch/riscv/lib/andes_plic.c          | 111 +++++++++++++++++++++++++++++++++++
 5 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/andes_plic.c
arch/riscv/Kconfig +9 -0
index 3a4470d..511768b 100644
@@ -109,6 +109,15 @@ config SIFIVE_CLINT
 	  The SiFive CLINT block holds memory-mapped control and status registers
 	  associated with software and timer interrupts.
 
+config ANDES_PLIC
+	bool
+	depends on RISCV_MMODE
+	select REGMAP
+	select SYSCON
+	help
+	  The Andes PLIC block holds memory-mapped claim and pending registers
+	  associated with software interrupt.
+
 config RISCV_RDTIME
 	bool
 	default y if RISCV_SMODE
arch/riscv/include/asm/global_data.h +3 -0
index 80e3165..b867910 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
 	void __iomem *clint;	/* clint base address */
 #endif
+#ifdef CONFIG_ANDES_PLIC
+	void __iomem *plic;	/* plic base address */
+#endif
 #ifdef CONFIG_SMP
 	struct ipi_data ipi[CONFIG_NR_CPUS];
 #endif
arch/riscv/include/asm/syscon.h +1 -1
index d311ee6..c1b4b86 100644
@@ -9,11 +9,11 @@
 /*
  * System controllers in a RISC-V system
  *
- * So far only SiFive's Core Local Interruptor (CLINT) is defined.
  */
 enum {
 	RISCV_NONE,
 	RISCV_SYSCON_CLINT,	/* Core Local Interruptor (CLINT) */
+	RISCV_SYSCON_PLIC,	/* Platform Level Interrupt Controller (PLIC) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 35dbf64..1bf554b 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_CMD_GO) += boot.o
 obj-y	+= cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
 obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
+obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
 obj-y	+= interrupts.o
 obj-y	+= reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/andes_plic.c new file +111 -0

111 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/7 riscv: Add a SYSCON driver for Andestech's PLIC

Hi Rick,

Quoted 4 lines · Andes

From: Rick Chen <[email protected]>

The Platform-Level Interrupt Controller(PLIC)

nits: it should have a space before (PLIC)

Quoted 6 lines

block holds memory-mapped claim and pending registers associated with software interrupt. It is required for handling IPI.

Cc Greentime Hu <[email protected]>
Quoted 9 lines
---
 arch/riscv/Kconfig                   |   9 +++
 arch/riscv/include/asm/global_data.h |   3 +
 arch/riscv/include/asm/syscon.h      |   2 +-
 arch/riscv/lib/Makefile              |   1 +
 arch/riscv/lib/andes_plic.c          | 111 +++++++++++++++++++++++++++++++++++
 5 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/andes_plic.c

Could you please include a changelog in the future?

Quoted 106 lines
arch/riscv/Kconfig +9 -0
index 3a4470d..511768b 100644
@@ -109,6 +109,15 @@ config SIFIVE_CLINT
          The SiFive CLINT block holds memory-mapped control and status registers
          associated with software and timer interrupts.
 
+config ANDES_PLIC
+       bool
+       depends on RISCV_MMODE
+       select REGMAP
+       select SYSCON
+       help
+         The Andes PLIC block holds memory-mapped claim and pending registers
+         associated with software interrupt.
+
 config RISCV_RDTIME
        bool
        default y if RISCV_SMODE
arch/riscv/include/asm/global_data.h +3 -0
index 80e3165..b867910 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
        void __iomem *clint;    /* clint base address */
 #endif
+#ifdef CONFIG_ANDES_PLIC
+       void __iomem *plic;     /* plic base address */
+#endif
 #ifdef CONFIG_SMP
        struct ipi_data ipi[CONFIG_NR_CPUS];
 #endif
arch/riscv/include/asm/syscon.h +1 -1
index d311ee6..c1b4b86 100644
@@ -9,11 +9,11 @@
 /*
  * System controllers in a RISC-V system
  *
- * So far only SiFive's Core Local Interruptor (CLINT) is defined.
  */
 enum {
        RISCV_NONE,
        RISCV_SYSCON_CLINT,     /* Core Local Interruptor (CLINT) */
+       RISCV_SYSCON_PLIC,      /* Platform Level Interrupt Controller (PLIC) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 35dbf64..1bf554b 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_CMD_GO) += boot.o
 obj-y  += cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
 obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
+obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/andes_plic.c new file +37 -0
new file mode 100644
index 0000000..abf8a73
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019, Rick Chen <[email protected]>
+ *
+ * U-Boot syscon driver for Andes's Platform Level Interrupt Controller (PLIC).
+ * The PLIC block holds memory-mapped claim and pending registers
+ * associated with software interrupt.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.h>
+#include <cpu.h>
+
+/* pending register */
+#define PENDING_REG(base, hart)        ((ulong)(base) + 0x1000 + (hart) * 8)
+/* enable register */
+#define ENABLE_REG(base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)
+/* claim register */
+#define CLAIM_REG(base, hart)  ((ulong)(base) + 0x200004 + (hart) * 0x1000)
+
+#define ENABLE_HART_IPI         (0x80808080)
+#define SEND_IPI_TO_HART(hart)  (0x80>>hart)
+
+DECLARE_GLOBAL_DATA_PTR;
+int init_plic(void);
+
+#define PLIC_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \
+                                                                       \

arch/riscv/lib/andes_plic.c line 47

Quoted 10 lines
arch/riscv/lib/andes_plic.c new file +10 -0
+               if (!gd->arch.plic) {                                   \
+                       ret = syscon_get_first_range(RISCV_SYSCON_PLIC); \
+                       if (IS_ERR(ret))                                \
+                               return PTR_ERR(ret);                    \
+                       gd->arch.plic = ret;                            \
+                       init_plic();                                    \
+               }                                                       \
+       } while (0)
+
+int plic_init(int harts)

nits: suggest change the name to enable_ipi(), to better refelct what is done in the function, and it should be "static"

arch/riscv/lib/andes_plic.c line 52

Quoted 5 lines
arch/riscv/lib/andes_plic.c new file +5 -0
+{
+       int i;
+       int en = ENABLE_HART_IPI;
+
+       PLIC_BASE_GET();

There is no need to call PLIC_BASE_GET() here.

arch/riscv/lib/andes_plic.c line 62

Quoted 10 lines
arch/riscv/lib/andes_plic.c new file +10 -0
+       for (i = 0; i < harts ;i++)
+       {
+               en = en >> i;
+               writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, i));
+       }
+
+       return 0;
+}
+
+int init_plic(void)

nits: it should be "static"

Quoted 40 lines
arch/riscv/lib/andes_plic.c new file +40 -0
+{
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_find_first_device(UCLASS_CPU, &dev);
+       if (ret)
+               return ret;
+
+       if (ret == 0 && dev != NULL) {
+               ret = cpu_get_count(dev);
+               plic_init(ret);
+               return 0;
+       }
+
+       return -ENODEV;
+}
+
+int riscv_send_ipi(int hart)
+{
+       PLIC_BASE_GET();
+
+       writel(SEND_IPI_TO_HART(hart), (void __iomem *)PENDING_REG(gd->arch.plic, gd->arch.boot_hart));
+
+       return 0;
+}
+
+int riscv_clear_ipi(int hart)
+{
+       u32 source_id;
+
+       PLIC_BASE_GET();
+
+       source_id = readl((void __iomem *)CLAIM_REG(gd->arch.plic, hart));
+       writel(source_id, (void __iomem *)CLAIM_REG(gd->arch.plic, hart));
+
+       return 0;
+}
+
+static const struct udevice_id andes_plic_ids[] = {
+       { .compatible = "riscv,plic1", .data = RISCV_SYSCON_PLIC },

arch/riscv/lib/andes_plic.c

Quoted 10 lines
arch/riscv/lib/andes_plic.c new file +9 -1
+       { }
+};
+
+U_BOOT_DRIVER(nds_plic) = {
+       .name           = "andes_plic",
+       .id             = UCLASS_SYSCON,
+       .of_match       = andes_plic_ids,
+       .flags          = DM_FLAG_PRE_RELOC,
+};
--

Regards,
Bin

#3 lore raw

PATCH v2 1/7 riscv: Add a SYSCON driver for Andestech's PLIC

Hi Bin

Bin Meng <[email protected]> 於 2019年3月29日 週五 下午5:20寫道:

Quoted 10 lines

Hi Rick,

Quoted 4 lines · Andes

From: Rick Chen <[email protected]>

The Platform-Level Interrupt Controller(PLIC)

nits: it should have a space before (PLIC)

OK

Quoted 17 lines
Quoted 7 lines

block holds memory-mapped claim and pending registers associated with software interrupt. It is required for handling IPI.

Cc Greentime Hu <[email protected]>
Quoted 9 lines
---
 arch/riscv/Kconfig                   |   9 +++
 arch/riscv/include/asm/global_data.h |   3 +
 arch/riscv/include/asm/syscon.h      |   2 +-
 arch/riscv/lib/Makefile              |   1 +
 arch/riscv/lib/andes_plic.c          | 111 +++++++++++++++++++++++++++++++++++
 5 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/andes_plic.c
Quoted 1 line

Could you please include a changelog in the future?

OK

Quoted 112 lines
Quoted 112 lines
arch/riscv/Kconfig +9 -0
index 3a4470d..511768b 100644
@@ -109,6 +109,15 @@ config SIFIVE_CLINT
          The SiFive CLINT block holds memory-mapped control and status registers
          associated with software and timer interrupts.
 
+config ANDES_PLIC
+       bool
+       depends on RISCV_MMODE
+       select REGMAP
+       select SYSCON
+       help
+         The Andes PLIC block holds memory-mapped claim and pending registers
+         associated with software interrupt.
+
 config RISCV_RDTIME
        bool
        default y if RISCV_SMODE
arch/riscv/include/asm/global_data.h +3 -0
index 80e3165..b867910 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
        void __iomem *clint;    /* clint base address */
 #endif
+#ifdef CONFIG_ANDES_PLIC
+       void __iomem *plic;     /* plic base address */
+#endif
 #ifdef CONFIG_SMP
        struct ipi_data ipi[CONFIG_NR_CPUS];
 #endif
arch/riscv/include/asm/syscon.h +1 -1
index d311ee6..c1b4b86 100644
@@ -9,11 +9,11 @@
 /*
  * System controllers in a RISC-V system
  *
- * So far only SiFive's Core Local Interruptor (CLINT) is defined.
  */
 enum {
        RISCV_NONE,
        RISCV_SYSCON_CLINT,     /* Core Local Interruptor (CLINT) */
+       RISCV_SYSCON_PLIC,      /* Platform Level Interrupt Controller (PLIC) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 35dbf64..1bf554b 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_CMD_GO) += boot.o
 obj-y  += cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
 obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
+obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/andes_plic.c new file +42 -0
new file mode 100644
index 0000000..abf8a73
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019, Rick Chen <[email protected]>
+ *
+ * U-Boot syscon driver for Andes's Platform Level Interrupt Controller (PLIC).
+ * The PLIC block holds memory-mapped claim and pending registers
+ * associated with software interrupt.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.h>
+#include <cpu.h>
+
+/* pending register */
+#define PENDING_REG(base, hart)        ((ulong)(base) + 0x1000 + (hart) * 8)
+/* enable register */
+#define ENABLE_REG(base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)
+/* claim register */
+#define CLAIM_REG(base, hart)  ((ulong)(base) + 0x200004 + (hart) * 0x1000)
+
+#define ENABLE_HART_IPI         (0x80808080)
+#define SEND_IPI_TO_HART(hart)  (0x80>>hart)
+
+DECLARE_GLOBAL_DATA_PTR;
+int init_plic(void);
+
+#define PLIC_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \
+                                                                       \
+               if (!gd->arch.plic) {                                   \
+                       ret = syscon_get_first_range(RISCV_SYSCON_PLIC); \
+                       if (IS_ERR(ret))                                \
+                               return PTR_ERR(ret);                    \
+                       gd->arch.plic = ret;                            \
Quoted 8 lines

arch/riscv/lib/andes_plic.c line 47

Quoted 5 lines
arch/riscv/lib/andes_plic.c new file +5 -0
+                       init_plic();                                    \
+               }                                                       \
+       } while (0)
+
+int plic_init(int harts)

nits: suggest change the name to enable_ipi(), to better refelct what is done in the function, and it should be "static"

OK

Quoted 8 lines

arch/riscv/lib/andes_plic.c line 52

Quoted 6 lines
arch/riscv/lib/andes_plic.c new file +5 -0
+{
+       int i;
+       int en = ENABLE_HART_IPI;
+
+       PLIC_BASE_GET();

There is no need to call PLIC_BASE_GET() here.

OK

Quoted 13 lines

arch/riscv/lib/andes_plic.c line 62

Quoted 11 lines
arch/riscv/lib/andes_plic.c new file +10 -0
+       for (i = 0; i < harts ;i++)
+       {
+               en = en >> i;
+               writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, i));
+       }
+
+       return 0;
+}
+
+int init_plic(void)

nits: it should be "static"

OK

Quoted 46 lines
Quoted 46 lines
arch/riscv/lib/andes_plic.c new file +45 -0
+{
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_find_first_device(UCLASS_CPU, &dev);
+       if (ret)
+               return ret;
+
+       if (ret == 0 && dev != NULL) {
+               ret = cpu_get_count(dev);
+               plic_init(ret);
+               return 0;
+       }
+
+       return -ENODEV;
+}
+
+int riscv_send_ipi(int hart)
+{
+       PLIC_BASE_GET();
+
+       writel(SEND_IPI_TO_HART(hart), (void __iomem *)PENDING_REG(gd->arch.plic, gd->arch.boot_hart));
+
+       return 0;
+}
+
+int riscv_clear_ipi(int hart)
+{
+       u32 source_id;
+
+       PLIC_BASE_GET();
+
+       source_id = readl((void __iomem *)CLAIM_REG(gd->arch.plic, hart));
+       writel(source_id, (void __iomem *)CLAIM_REG(gd->arch.plic, hart));
+
+       return 0;
+}
+
+static const struct udevice_id andes_plic_ids[] = {
+       { .compatible = "riscv,plic1", .data = RISCV_SYSCON_PLIC },
+       { }
+};
+
+U_BOOT_DRIVER(nds_plic) = {
+       .name           = "andes_plic",
Quoted 8 lines

arch/riscv/lib/andes_plic.c

Quoted 5 lines
arch/riscv/lib/andes_plic.c new file +4 -1
+       .id             = UCLASS_SYSCON,
+       .of_match       = andes_plic_ids,
+       .flags          = DM_FLAG_PRE_RELOC,
+};
--

Regards,
Bin

Thanks for review.
Rick

author
#4 lore raw

PATCH v2 2/7 riscv: Add a SYSCON driver for Andestech's PLMT

In reply to Andes

From: Rick Chen <[email protected]>

The platform-Level Machine Timer(PLMT) block
holds memory-mapped mtime register associated
with timer tick.

This driver implements the riscv_get_time() which
is required by the generic RISC-V timer driver.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/Kconfig                   |  9 ++++++
 arch/riscv/include/asm/global_data.h |  3 ++
 arch/riscv/include/asm/syscon.h      |  1 +
 arch/riscv/lib/Makefile              |  1 +
 arch/riscv/lib/andes_plmt.c          | 53 ++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+)
 create mode 100644 arch/riscv/lib/andes_plmt.c
arch/riscv/Kconfig +9 -0
index 511768b..ae8ff7b 100644
@@ -118,6 +118,15 @@ config ANDES_PLIC
 	  The Andes PLIC block holds memory-mapped claim and pending registers
 	  associated with software interrupt.
 
+config ANDES_PLMT
+	bool
+	depends on RISCV_MMODE
+	select REGMAP
+	select SYSCON
+	help
+	  The Andes PLMT block holds memory-mapped mtime register
+	  associated with timer tick.
+
 config RISCV_RDTIME
 	bool
 	default y if RISCV_SMODE
arch/riscv/include/asm/global_data.h +3 -0
index b867910..dffcd45 100644
@@ -21,6 +21,9 @@ struct arch_global_data {
 #ifdef CONFIG_ANDES_PLIC
 	void __iomem *plic;	/* plic base address */
 #endif
+#ifdef CONFIG_ANDES_PLMT
+	void __iomem *plmt;	/* plmt base address */
+#endif
 #ifdef CONFIG_SMP
 	struct ipi_data ipi[CONFIG_NR_CPUS];
 #endif
arch/riscv/include/asm/syscon.h +1 -0
index c1b4b86..6e12574 100644
@@ -14,6 +14,7 @@ enum {
 	RISCV_NONE,
 	RISCV_SYSCON_CLINT,	/* Core Local Interruptor (CLINT) */
 	RISCV_SYSCON_PLIC,	/* Platform Level Interrupt Controller (PLIC) */
+	RISCV_SYSCON_PLMT,	/* Platform Level Machine Timer (PLMT) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 1bf554b..1c332db 100644
@@ -12,6 +12,7 @@ obj-y	+= cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
 obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
 obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
+obj-$(CONFIG_ANDES_PLMT) += andes_plmt.o
 obj-y	+= interrupts.o
 obj-y	+= reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/andes_plmt.c new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 2/7 riscv: Add a SYSCON driver for Andestech's PLMT

Quoted 4 lines · Andes

From: Rick Chen <[email protected]>

The platform-Level Machine Timer(PLMT) block

nits: should have a space before (PLMT)

Quoted 8 lines

holds memory-mapped mtime register associated
with timer tick.

This driver implements the riscv_get_time() which
is required by the generic RISC-V timer driver.

Cc Greentime Hu <[email protected]>
Quoted 9 lines
---
 arch/riscv/Kconfig                   |  9 ++++++
 arch/riscv/include/asm/global_data.h |  3 ++
 arch/riscv/include/asm/syscon.h      |  1 +
 arch/riscv/lib/Makefile              |  1 +
 arch/riscv/lib/andes_plmt.c          | 53 ++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+)
 create mode 100644 arch/riscv/lib/andes_plmt.c

Other than that,

#6 lore raw

PATCH v2 2/7 riscv: Add a SYSCON driver for Andestech's PLMT

Hi Bin

Bin Meng <[email protected]> 於 2019年3月29日 週五 下午5:22寫道:

Quoted 8 lines · Andes
Quoted 4 lines

From: Rick Chen <[email protected]>

The platform-Level Machine Timer(PLMT) block

nits: should have a space before (PLMT)

OK

Quoted 19 lines
Quoted 9 lines

holds memory-mapped mtime register associated
with timer tick.

This driver implements the riscv_get_time() which
is required by the generic RISC-V timer driver.

Cc Greentime Hu <[email protected]>
Quoted 9 lines
---
 arch/riscv/Kconfig                   |  9 ++++++
 arch/riscv/include/asm/global_data.h |  3 ++
 arch/riscv/include/asm/syscon.h      |  1 +
 arch/riscv/lib/Makefile              |  1 +
 arch/riscv/lib/andes_plmt.c          | 53 ++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+)
 create mode 100644 arch/riscv/lib/andes_plmt.c
Quoted 2 lines

Other than that,

Thanks for review.
Rick

author
#7 lore raw

PATCH v2 3/7 riscv: ae350: disable ATCPIT100 timer

In reply to Andes

From: Rick Chen <[email protected]>

Disable ATCPIT100 SoC timer and replace by PLMT.

---
 configs/ae350_rv32_defconfig | 1 -
 configs/ae350_rv64_defconfig | 1 -
 2 files changed, 2 deletions(-)
configs/ae350_rv32_defconfig +0 -1
index 5837b48..e13c7de 100644
@@ -33,4 +33,3 @@ CONFIG_BAUDRATE=38400
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_ATCSPI200_SPI=y
-CONFIG_ATCPIT100_TIMER=y
configs/ae350_rv64_defconfig +0 -1
index b250d3f..a41f918 100644
@@ -34,4 +34,3 @@ CONFIG_BAUDRATE=38400
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_ATCSPI200_SPI=y
-CONFIG_ATCPIT100_TIMER=y
Signature · 1 line
2.7.4
author
#8 lore raw

PATCH v2 4/7 riscv: ax25: Add platform-specific Kconfig options

In reply to Andes

From: Rick Chen <[email protected]>

Add ax25 RISC-V platform-specific Kconfig options, to include CPU and timer drivers.

---
 arch/riscv/cpu/ax25/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/cpu/ax25/Kconfig +6 -0
index e9dbca2..68bd4e9 100644
@@ -1,5 +1,11 @@
 config RISCV_NDS
 	bool
+	select ARCH_EARLY_INIT_R
+	imply CPU
+	imply CPU_RISCV
+	imply RISCV_TIMER
+	imply ANDES_PLIC if RISCV_MMODE
+	imply ANDES_PLMT if RISCV_MMODE
 	help
 	  Run U-Boot on AndeStar V5 platforms and use some specific features
 	  which are provided by Andes Technology AndeStar V5 families.
Signature · 1 line
2.7.4
author
#9 lore raw

PATCH v2 5/7 riscv: ax25: Andes specific cache shall only support in M-mode

In reply to Andes

From: Rick Chen <[email protected]>

Limit the cache configuration only can be supported in M mode. It can not be manipulated in S mode.

---
 arch/riscv/cpu/ax25/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/riscv/cpu/ax25/Kconfig +1 -0
index 68bd4e9..6b4b92e 100644
@@ -14,6 +14,7 @@ if RISCV_NDS
 
 config RISCV_NDS_CACHE
 	bool "AndeStar V5 families specific cache support"
+	depends on RISCV_MMODE
 	help
 	  Provide Andes Technology AndeStar V5 families specific cache support.
 
Signature · 1 line
2.7.4
author
#10 lore raw

PATCH v2 6/7 riscv: dts: ae350 support SMP

In reply to Andes

From: Rick Chen <[email protected]>

Cc Greentime Hu <[email protected]>
---
 arch/riscv/dts/ae350_32.dts | 81 +++++++++++++++++++++++++++++++++------------
 arch/riscv/dts/ae350_64.dts | 47 +++++++++++++++++++++++---
 2 files changed, 101 insertions(+), 27 deletions(-)
arch/riscv/dts/ae350_32.dts +59 -22
index 0679827..7cff312 100644
@@ -26,16 +26,49 @@
 			status = "okay";
 			compatible = "riscv";
 			riscv,isa = "rv32imafdc";
+			riscv,priv-major = <1>;
+			riscv,priv-minor = <10>;
 			mmu-type = "riscv,sv32";
 			clock-frequency = <60000000>;
+			i-cache-size = <0x8000>;
+			i-cache-line-size = <32>;
 			d-cache-size = <0x8000>;
 			d-cache-line-size = <32>;
+			next-level-cache = <&L2>;
 			CPU0_intc: interrupt-controller {
 				#interrupt-cells = <1>;
 				interrupt-controller;
 				compatible = "riscv,cpu-intc";
 			};
 		};
+		CPU1: cpu at 1 {
+		device_type = "cpu";
+			reg = <1>;
+			status = "okay";
+			compatible = "riscv";
+			riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";
+			riscv,priv-major = <1>;
+			riscv,priv-minor = <10>;
+			mmu-type = "riscv,sv32";
+			clock-frequency = <60000000>;
+			i-cache-size = <0x8000>;
+			i-cache-line-size = <32>;
+			d-cache-size = <0x8000>;
+			d-cache-line-size = <32>;
+			next-level-cache = <&L2>;
+			CPU1_intc: interrupt-controller {
+				#interrupt-cells = <1>;
+				interrupt-controller;
+				compatible = "riscv,cpu-intc";
+			};
+		};
+
+		L2: l2-cache at e0500000 {
+			compatible = "cache";
+			cache-level = <2>;
+			cache-size = <0x40000>;
+			reg = <0x0 0xe0500000 0x0 0x40000>;
+		};
 	};
 
 	memory at 0 {
@@ -46,32 +79,32 @@
 	soc {
 		#address-cells = <1>;
 		#size-cells = <1>;
-		compatible = "andestech,riscv-ae350-soc";
+		compatible = "simple-bus";
 		ranges;
 
-	plic0: interrupt-controller at e4000000 {
-		compatible = "riscv,plic0";
-		#address-cells = <1>;
-		#interrupt-cells = <1>;
-		interrupt-controller;
-		reg = <0xe4000000 0x2000000>;
-		riscv,ndev=<71>;
-		interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9>;
-	};
+		plic0: interrupt-controller at e4000000 {
+			compatible = "riscv,plic0";
+			#address-cells = <1>;
+			#interrupt-cells = <1>;
+			interrupt-controller;
+			reg = <0xe4000000 0x2000000>;
+			riscv,ndev=<71>;
+			interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9>;
+		};
 
-	plic1: interrupt-controller at e6400000 {
-		compatible = "riscv,plic1";
-		#address-cells = <1>;
-		#interrupt-cells = <1>;
-		interrupt-controller;
-		reg = <0xe6400000 0x400000>;
-		riscv,ndev=<1>;
-		interrupts-extended = <&CPU0_intc 3>;
-	};
+		plic1: interrupt-controller at e6400000 {
+			compatible = "riscv,plic1";
+			#address-cells = <1>;
+			#interrupt-cells = <1>;
+			interrupt-controller;
+			reg = <0xe6400000 0x400000>;
+			riscv,ndev=<2>;
+			interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3>;
+		};
 
-	plmt0 at e6000000 {
-		compatible = "riscv,plmt0";
-			interrupts-extended = <&CPU0_intc 7>;
+		plmt0 at e6000000 {
+			compatible = "riscv,plmt0";
+			interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>;
 			reg = <0xe6000000 0x100000>;
 		};
 	};
@@ -146,6 +179,10 @@
 		interrupt-parent = <&plic0>;
 	};
 
+	pmu {
+		compatible = "riscv,base-pmu";
+	};
+
 	virtio_mmio at fe007000 {
 		interrupts = <0x17 0x4>;
 		interrupt-parent = <0x2>;
arch/riscv/dts/ae350_64.dts +42 -5

91 lines not on this page · raw message

Signature · 1 line
2.7.4
#11 lore raw

PATCH v2 6/7 riscv: dts: ae350 support SMP

Hi Rick,

Quoted 25 lines · Andes

From: Rick Chen <[email protected]>

Cc Greentime Hu <[email protected]>
---
 arch/riscv/dts/ae350_32.dts | 81 +++++++++++++++++++++++++++++++++------------
 arch/riscv/dts/ae350_64.dts | 47 +++++++++++++++++++++++---
 2 files changed, 101 insertions(+), 27 deletions(-)
arch/riscv/dts/ae350_32.dts +4 -0
index 0679827..7cff312 100644
@@ -26,16 +26,49 @@
                        status = "okay";
                        compatible = "riscv";
                        riscv,isa = "rv32imafdc";
+                       riscv,priv-major = <1>;
+                       riscv,priv-minor = <10>;
                        mmu-type = "riscv,sv32";
                        clock-frequency = <60000000>;
+                       i-cache-size = <0x8000>;
+                       i-cache-line-size = <32>;
                        d-cache-size = <0x8000>;

arch/riscv/dts/ae350_32.dts line 45

Quoted 10 lines
arch/riscv/dts/ae350_32.dts +3 -0
                        d-cache-line-size = <32>;
+                       next-level-cache = <&L2>;
                        CPU0_intc: interrupt-controller {
                                #interrupt-cells = <1>;
                                interrupt-controller;
                                compatible = "riscv,cpu-intc";
                        };
                };
+               CPU1: cpu at 1 {
+               device_type = "cpu";

the indention looks wrong

arch/riscv/dts/ae350_32.dts line 49

Quoted 4 lines
arch/riscv/dts/ae350_32.dts +4 -0
+                       reg = <1>;
+                       status = "okay";
+                       compatible = "riscv";
+                       riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

the isa string is not recovered, like cpu0

Quoted 5 lines
arch/riscv/dts/ae350_32.dts +5 -0
+                       riscv,priv-major = <1>;
+                       riscv,priv-minor = <10>;
+                       mmu-type = "riscv,sv32";
+                       clock-frequency = <60000000>;
+                       i-cache-size = <0x8000>;

arch/riscv/dts/ae350_32.dts line 64

Quoted 10 lines
arch/riscv/dts/ae350_32.dts +10 -0
+                       i-cache-line-size = <32>;
+                       d-cache-size = <0x8000>;
+                       d-cache-line-size = <32>;
+                       next-level-cache = <&L2>;
+                       CPU1_intc: interrupt-controller {
+                               #interrupt-cells = <1>;
+                               interrupt-controller;
+                               compatible = "riscv,cpu-intc";
+                       };
+               };

[snip]

Regards,
Bin

#12 lore raw

PATCH v2 6/7 riscv: dts: ae350 support SMP

In reply to Andes

Two more comments regarding ae350_64.dts

Quoted 10 lines · Andes

From: Rick Chen <[email protected]>

Cc Greentime Hu <[email protected]>
---
 arch/riscv/dts/ae350_32.dts | 81 +++++++++++++++++++++++++++++++++------------
 arch/riscv/dts/ae350_64.dts | 47 +++++++++++++++++++++++---
 2 files changed, 101 insertions(+), 27 deletions(-)

[snip]

Quoted 19 lines
arch/riscv/dts/ae350_64.dts +5 -0
index e48c298..9e1d63a 100644
@@ -26,16 +26,49 @@
                        status = "okay";
                        compatible = "riscv";
                        riscv,isa = "rv64imafdc";
+                       riscv,priv-major = <1>;
+                       riscv,priv-minor = <10>;
                        mmu-type = "riscv,sv39";
                        clock-frequency = <60000000>;
+                       i-cache-size = <0x8000>;
+                       i-cache-line-size = <32>;
                        d-cache-size = <0x8000>;
                        d-cache-line-size = <32>;
+                       next-level-cache = <&L2>;
                        CPU0_intc: interrupt-controller {
                                #interrupt-cells = <1>;

arch/riscv/dts/ae350_64.dts line 49

Quoted 10 lines
arch/riscv/dts/ae350_64.dts +6 -0
                                interrupt-controller;
                                compatible = "riscv,cpu-intc";
                        };
                };
+               CPU1: cpu at 1 {
+                       device_type = "cpu";
+                       reg = <1>;
+                       status = "okay";
+                       compatible = "riscv";
+                       riscv,isa = "rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

isa string not recovered

Quoted 47 lines
arch/riscv/dts/ae350_64.dts +24 -2
+                       riscv,priv-major = <1>;
+                       riscv,priv-minor = <10>;
+                       mmu-type = "riscv,sv39";
+                       clock-frequency = <60000000>;
+                       i-cache-size = <0x8000>;
+                       i-cache-line-size = <32>;
+                       d-cache-size = <0x8000>;
+                       d-cache-line-size = <32>;
+                       next-level-cache = <&L2>;
+                       CPU1_intc: interrupt-controller {
+                               #interrupt-cells = <1>;
+                               interrupt-controller;
+                               compatible = "riscv,cpu-intc";
+                       };
+               };
+
+               L2: l2-cache at e0500000 {
+                       compatible = "cache";
+                       cache-level = <2>;
+                       cache-size = <0x40000>;
+                       reg = <0x0 0xe0500000 0x0 0x40000>;
+               };
        };
 
        memory at 0 {
@@ -46,7 +79,7 @@
        soc {
                #address-cells = <2>;
                #size-cells = <2>;
-               compatible = "andestech,riscv-ae350-soc";
+               compatible = "simple-bus";
                ranges;
 
        plic0: interrupt-controller at e4000000 {
@@ -56,7 +89,7 @@
                interrupt-controller;
                reg = <0x0 0xe4000000 0x0 0x2000000>;
                riscv,ndev=<71>;
-               interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9>;
+               interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9>;
        };
 
        plic1: interrupt-controller at e6400000 {
@@ -65,13 +98,13 @@
                #interrupt-cells = <2>;
                interrupt-controller;
                reg = <0x0 0xe6400000 0x0 0x400000>;

arch/riscv/dts/ae350_64.dts line 107

Quoted 10 lines
arch/riscv/dts/ae350_64.dts +3 -3
-               riscv,ndev=<1>;
-               interrupts-extended = <&CPU0_intc 3>;
+                       riscv,ndev=<2>;
+                       interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3>;
        };
 
        plmt0 at e6000000 {
                compatible = "riscv,plmt0";
-                       interrupts-extended = <&CPU0_intc 7>;
+      interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>;

nits: the alignment looks wrong

Quoted 5 lines
arch/riscv/dts/ae350_64.dts +0 -0
                        reg = <0x0 0xe6000000 0x0 0x100000>;
                };
        };
@@ -146,6 +179,10 @@
                interrupt-parent = <&plic0>;

arch/riscv/dts/ae350_64.dts

Quoted 10 lines
arch/riscv/dts/ae350_64.dts +4 -1
        };
 
+       pmu {
+               compatible = "riscv,base-pmu";
+       };
+
        virtio_mmio at fe007000 {
                interrupts = <0x17 0x4>;
                interrupt-parent = <0x2>;
--

Regards,
Bin

#13 lore raw

PATCH v2 6/7 riscv: dts: ae350 support SMP

Hi Bin

Bin Meng <[email protected]> 於 2019年3月29日 週五 下午5:34寫道:

Quoted 40 lines

Two more comments regarding ae350_64.dts

Quoted 10 lines · Andes

From: Rick Chen <[email protected]>

Cc Greentime Hu <[email protected]>
---
 arch/riscv/dts/ae350_32.dts | 81 +++++++++++++++++++++++++++++++++------------
 arch/riscv/dts/ae350_64.dts | 47 +++++++++++++++++++++++---
 2 files changed, 101 insertions(+), 27 deletions(-)

[snip]

Quoted 23 lines
arch/riscv/dts/ae350_64.dts +5 -0
index e48c298..9e1d63a 100644
@@ -26,16 +26,49 @@
                        status = "okay";
                        compatible = "riscv";
                        riscv,isa = "rv64imafdc";
+                       riscv,priv-major = <1>;
+                       riscv,priv-minor = <10>;
                        mmu-type = "riscv,sv39";
                        clock-frequency = <60000000>;
+                       i-cache-size = <0x8000>;
+                       i-cache-line-size = <32>;
                        d-cache-size = <0x8000>;
                        d-cache-line-size = <32>;
+                       next-level-cache = <&L2>;
                        CPU0_intc: interrupt-controller {
                                #interrupt-cells = <1>;
                                interrupt-controller;
                                compatible = "riscv,cpu-intc";
                        };
                };
Quoted 8 lines

arch/riscv/dts/ae350_64.dts line 49

Quoted 6 lines
arch/riscv/dts/ae350_64.dts +6 -0
+               CPU1: cpu at 1 {
+                       device_type = "cpu";
+                       reg = <1>;
+                       status = "okay";
+                       compatible = "riscv";
+                       riscv,isa = "rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

isa string not recovered

OK
I will remove it.

Quoted 54 lines
Quoted 54 lines
arch/riscv/dts/ae350_64.dts +26 -4
+                       riscv,priv-major = <1>;
+                       riscv,priv-minor = <10>;
+                       mmu-type = "riscv,sv39";
+                       clock-frequency = <60000000>;
+                       i-cache-size = <0x8000>;
+                       i-cache-line-size = <32>;
+                       d-cache-size = <0x8000>;
+                       d-cache-line-size = <32>;
+                       next-level-cache = <&L2>;
+                       CPU1_intc: interrupt-controller {
+                               #interrupt-cells = <1>;
+                               interrupt-controller;
+                               compatible = "riscv,cpu-intc";
+                       };
+               };
+
+               L2: l2-cache at e0500000 {
+                       compatible = "cache";
+                       cache-level = <2>;
+                       cache-size = <0x40000>;
+                       reg = <0x0 0xe0500000 0x0 0x40000>;
+               };
        };
 
        memory at 0 {
@@ -46,7 +79,7 @@
        soc {
                #address-cells = <2>;
                #size-cells = <2>;
-               compatible = "andestech,riscv-ae350-soc";
+               compatible = "simple-bus";
                ranges;
 
        plic0: interrupt-controller at e4000000 {
@@ -56,7 +89,7 @@
                interrupt-controller;
                reg = <0x0 0xe4000000 0x0 0x2000000>;
                riscv,ndev=<71>;
-               interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9>;
+               interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9>;
        };
 
        plic1: interrupt-controller at e6400000 {
@@ -65,13 +98,13 @@
                #interrupt-cells = <2>;
                interrupt-controller;
                reg = <0x0 0xe6400000 0x0 0x400000>;
-               riscv,ndev=<1>;
-               interrupts-extended = <&CPU0_intc 3>;
+                       riscv,ndev=<2>;
+                       interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3>;
        };
 
Quoted 6 lines

arch/riscv/dts/ae350_64.dts line 107

Quoted 4 lines
arch/riscv/dts/ae350_64.dts +1 -1
        plmt0 at e6000000 {
                compatible = "riscv,plmt0";
-                       interrupts-extended = <&CPU0_intc 7>;
+      interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>;

nits: the alignment looks wrong

OK

Thanks
Rick

Quoted 19 lines
Quoted 6 lines
arch/riscv/dts/ae350_64.dts +0 -0
                        reg = <0x0 0xe6000000 0x0 0x100000>;
                };
        };
@@ -146,6 +179,10 @@
                interrupt-parent = <&plic0>;

arch/riscv/dts/ae350_64.dts

Quoted 10 lines
arch/riscv/dts/ae350_64.dts +4 -1
        };
 
+       pmu {
+               compatible = "riscv,base-pmu";
+       };
+
        virtio_mmio at fe007000 {
                interrupts = <0x17 0x4>;
                interrupt-parent = <0x2>;
--

Regards,
Bin

author
#14 lore raw

PATCH v2 7/7 riscv: ae350: enable SMP

In reply to Andes

From: Rick Chen <[email protected]>

---
 board/AndesTech/ax25-ae350/Kconfig | 1 +
 1 file changed, 1 insertion(+)
board/AndesTech/ax25-ae350/Kconfig +1 -0
index 44cb302..5e682b6 100644
@@ -24,5 +24,6 @@ config ENV_OFFSET
 config BOARD_SPECIFIC_OPTIONS # dummy
 	def_bool y
 	select RISCV_NDS
+	imply SMP
 
 endif
Signature · 1 line
2.7.4