Skip to contentSkip to conversation

AE350 SMP support RISC-V

PATCH Superseded Andes 5 participants 38 messages Mar 19, 2019 – Apr 10, 2019 RISC-V

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Andes

author
#0 lore raw

cover AE350 SMP support RISC-V

From: Rick Chen <[email protected]>

This patch series was based on Lukas's patchsets of SMP support for RISC-V. Add Andestech's PLIC for IPI handling and PLMT to replace Soc timer. It has been verified on AE350 SMP platform in M-mode and boot SMP kernel ok.

Verification in S-mode is still on-going.

Rick Chen (9):
riscv: ax25: Create a simple-bus driver for the soc node
riscv: Add a SYSCON driver for Andestech's PLIC
riscv: Add a SYSCON driver for Andestech's PLMT
riscv: ae350: initialize PLIC
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/cpu/ax25/cpu.c               | 16 +++++++
 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/nds_plic.c               | 84 +++++++++++++++++++++++++++++++++
 arch/riscv/lib/nds_plmt.c               | 53 +++++++++++++++++++++
 board/AndesTech/ax25-ae350/Kconfig      |  1 +
 board/AndesTech/ax25-ae350/ax25-ae350.c | 30 ++++++++++++
 configs/ae350_rv32_defconfig            |  1 -
 configs/ae350_rv64_defconfig            |  1 -
 14 files changed, 320 insertions(+), 30 deletions(-)
 create mode 100644 arch/riscv/lib/nds_plic.c
 create mode 100644 arch/riscv/lib/nds_plmt.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Cc Greentime Hu <[email protected]>
---
 arch/riscv/cpu/ax25/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/riscv/cpu/ax25/cpu.c +16 -0
index 76689b2..e6e7404 100644
@@ -7,6 +7,7 @@
 /* CPU specific code */
 #include <common.h>
 #include <asm/cache.h>
+#include <dm.h>
 
 /*
  * cleanup_before_linux() is called just before we call linux
@@ -25,3 +26,18 @@ int cleanup_before_linux(void)
 
 	return 0;
 }
+
+/* To enumerate devices on the /soc/ node, create a "simple-bus" driver */
+static const struct udevice_id riscv_ae350_soc_ids[] = {
+	{
+		.compatible = "andestech,riscv-ae350-soc",
+	},
+	{ }
+};
+
+U_BOOT_DRIVER(riscv_ae350_soc_ids) = {
+	.name = "andestech,riscv-ae350-soc",
+	.id = UCLASS_SIMPLE_BUS,
+	.of_match = riscv_ae350_soc_ids,
+	.flags = DM_FLAG_PRE_RELOC,
+};
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Rick,

Quoted 6 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 6 lines
Cc Greentime Hu <[email protected]>
---
 arch/riscv/cpu/ax25/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Regards,
Bin

#3 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Bin

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

Quoted 7 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

Quoted 8 lines
Quoted 3 lines

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

I don't understand it.
Can you explain more clearly

Thanks
Rick

Quoted 9 lines
Quoted 6 lines
Cc Greentime Hu <[email protected]>
---
 arch/riscv/cpu/ax25/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Regards,
Bin

#4 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Rick,

Quoted 15 lines · Rick Chen

Hi Bin

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

Quoted 11 lines

Hi Rick,

Quoted 6 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Quoted 8 lines
Quoted 4 lines

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

Quoted 4 lines

I don't understand it.
Can you explain more clearly

Regards,
Bin

#5 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Bin

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:01寫道:

Quoted 24 lines

Hi Rick,

Quoted 20 lines · Rick Chen

Hi Bin

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

Quoted 15 lines

Hi Rick,

Quoted 6 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 7 lines
Quoted 3 lines

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

So you mean we shall have only riscv simple bus driver. We shall remove
U_BOOT_DRIVER(riscv_virtio_soc) in /arch/riscv/cpu/generic/cpu.c U_BOOT_DRIVER(riscv_ae350_soc_ids) in /arch/riscv/cpu/ax25/cpu.c and add
static const struct udevice_id riscv_simple_bus_ids[] = { {
.compatible = "simple-bus",
},
{ }
};

U_BOOT_DRIVER(riscv_simple_bus_ids) = {
.name = "simple-bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = riscv_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,
};

Does it right ?

Rick

Quoted 7 lines
Quoted 4 lines

I don't understand it.
Can you explain more clearly

Regards,
Bin

#6 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Rick,

Quoted 48 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:01寫道:

Quoted 24 lines

Hi Rick,

Quoted 20 lines · Rick Chen

Hi Bin

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

Quoted 15 lines

Hi Rick,

Quoted 6 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 7 lines
Quoted 3 lines

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

So you mean we shall have only riscv simple bus driver. We shall remove
U_BOOT_DRIVER(riscv_virtio_soc) in /arch/riscv/cpu/generic/cpu.c U_BOOT_DRIVER(riscv_ae350_soc_ids) in /arch/riscv/cpu/ax25/cpu.c and add
static const struct udevice_id riscv_simple_bus_ids[] = { {
.compatible = "simple-bus",
},
{ }
};

Quoted 8 lines

U_BOOT_DRIVER(riscv_simple_bus_ids) = {
.name = "simple-bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = riscv_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,
};

Does it right ?

No, you don't need add anything to the RISC-V codes. U-Boot provides a simple-bus driver and all you need do is to use "simple-bus" in your DTS files.

Regards,
Bin

#7 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午4:49寫道:

Quoted 59 lines

Hi Rick,

Quoted 55 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:01寫道:

Quoted 24 lines

Hi Rick,

Quoted 20 lines · Rick Chen

Hi Bin

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

Quoted 15 lines

Hi Rick,

Quoted 6 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 7 lines
Quoted 3 lines

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

So you mean we shall have only riscv simple bus driver. We shall remove
U_BOOT_DRIVER(riscv_virtio_soc) in /arch/riscv/cpu/generic/cpu.c U_BOOT_DRIVER(riscv_ae350_soc_ids) in /arch/riscv/cpu/ax25/cpu.c and add
static const struct udevice_id riscv_simple_bus_ids[] = { {
.compatible = "simple-bus",
},
{ }
};

U_BOOT_DRIVER(riscv_simple_bus_ids) = {
.name = "simple-bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = riscv_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,
};

Quoted 6 lines
Quoted 1 line

Does it right ?

No, you don't need add anything to the RISC-V codes. U-Boot provides a simple-bus driver and all you need do is to use "simple-bus" in your DTS files.

But if I only use "simple-bus" in DTS file.
It will fail in syscon_get_first_range that can not get correct information from reg.

Quoted 2 lines

Regards,
Bin

#8 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Rick,

Quoted 63 lines · Rick Chen

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午4:49寫道:

Quoted 61 lines

Hi Rick,

Quoted 56 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:01寫道:

Quoted 24 lines

Hi Rick,

Quoted 20 lines · Rick Chen

Hi Bin

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

Quoted 15 lines

Hi Rick,

Quoted 6 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 7 lines
Quoted 3 lines

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

So you mean we shall have only riscv simple bus driver. We shall remove
U_BOOT_DRIVER(riscv_virtio_soc) in /arch/riscv/cpu/generic/cpu.c U_BOOT_DRIVER(riscv_ae350_soc_ids) in /arch/riscv/cpu/ax25/cpu.c and add
static const struct udevice_id riscv_simple_bus_ids[] = { {
.compatible = "simple-bus",
},
{ }
};

U_BOOT_DRIVER(riscv_simple_bus_ids) = {
.name = "simple-bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = riscv_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,
};

Does it right ?

Quoted 8 lines
Quoted 4 lines

No, you don't need add anything to the RISC-V codes. U-Boot provides a simple-bus driver and all you need do is to use "simple-bus" in your DTS files.

But if I only use "simple-bus" in DTS file.
It will fail in syscon_get_first_range that can not get correct information from reg.

Yes, we should fix "simple-bus" driver. See discussion in
https://patchwork.ozlabs.org/patch/1039493/

Regards,
Bin

#9 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Bin and Lukas

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午5:17寫道:

Quoted 72 lines

Hi Rick,

Quoted 68 lines · Rick Chen

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午4:49寫道:

Quoted 65 lines

Hi Rick,

Quoted 48 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:01寫道:

Quoted 24 lines

Hi Rick,

Quoted 20 lines · Rick Chen

Hi Bin

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

Quoted 15 lines

Hi Rick,

Quoted 6 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 7 lines
Quoted 3 lines

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

So you mean we shall have only riscv simple bus driver. We shall remove
U_BOOT_DRIVER(riscv_virtio_soc) in /arch/riscv/cpu/generic/cpu.c U_BOOT_DRIVER(riscv_ae350_soc_ids) in /arch/riscv/cpu/ax25/cpu.c and add
static const struct udevice_id riscv_simple_bus_ids[] = { {
.compatible = "simple-bus",
},
{ }
};

Quoted 8 lines

U_BOOT_DRIVER(riscv_simple_bus_ids) = {
.name = "simple-bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = riscv_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,
};

Does it right ?

No, you don't need add anything to the RISC-V codes. U-Boot provides a simple-bus driver and all you need do is to use "simple-bus" in your DTS files.

Quoted 6 lines
Quoted 3 lines

But if I only use "simple-bus" in DTS file.
It will fail in syscon_get_first_range that can not get correct information from reg.

Yes, we should fix "simple-bus" driver. See discussion in
https://patchwork.ozlabs.org/patch/1039493/

The series has been pull into master by Tom.

Can you fix the "simple-bus" driver ASAP.
AE350 will encounter the problem as below with the latest u-boot-riscv

U-Boot 2019.04-rc4-07392-g48b90d9 (Apr 10 2019 - 16:27:39 +0800)

DRAM: 1 GiB
Cannot send IPI to hart 1
Relocation of secondary harts has failed, error -19 ### ERROR ### Please RESET the board ###

Thanks
Rick

Quoted 3 lines

Regards,
Bin

#10 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Rick,

Quoted 79 lines · Rick Chen

Hi Bin and Lukas

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午5:17寫道:

Quoted 64 lines

Hi Rick,

Quoted 61 lines · Rick Chen

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午4:49寫道:

Quoted 59 lines

Hi Rick,

Quoted 43 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:01寫道:

Quoted 20 lines

Hi Rick,

Quoted 17 lines · Rick Chen

Hi Bin

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

Quoted 13 lines

Hi Rick,

Quoted 5 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 7 lines
Quoted 3 lines

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

So you mean we shall have only riscv simple bus driver. We shall remove
U_BOOT_DRIVER(riscv_virtio_soc) in /arch/riscv/cpu/generic/cpu.c U_BOOT_DRIVER(riscv_ae350_soc_ids) in /arch/riscv/cpu/ax25/cpu.c and add
static const struct udevice_id riscv_simple_bus_ids[] = { {
.compatible = "simple-bus",
},
{ }
};

Quoted 8 lines

U_BOOT_DRIVER(riscv_simple_bus_ids) = {
.name = "simple-bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = riscv_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,
};

Does it right ?

No, you don't need add anything to the RISC-V codes. U-Boot provides a simple-bus driver and all you need do is to use "simple-bus" in your DTS files.

Quoted 6 lines
Quoted 3 lines

But if I only use "simple-bus" in DTS file.
It will fail in syscon_get_first_range that can not get correct information from reg.

Yes, we should fix "simple-bus" driver. See discussion in
https://patchwork.ozlabs.org/patch/1039493/

The series has been pull into master by Tom.

Can you fix the "simple-bus" driver ASAP.
AE350 will encounter the problem as below with the latest u-boot-riscv

Quoted 7 lines

U-Boot 2019.04-rc4-07392-g48b90d9 (Apr 10 2019 - 16:27:39 +0800)

DRAM: 1 GiB
Cannot send IPI to hart 1
Relocation of secondary harts has failed, error -19 ### ERROR ### Please RESET the board ###

Yes, I will send the patch later today.

Thanks,
Lukas

#11 lore raw

PATCH 1/9 riscv: ax25: Create a simple-bus driver for the soc node

Hi Lukas

Auer, Lukas <[email protected]> 於 2019年4月10日 週三 下午5:21寫道:

Quoted 85 lines

Hi Rick,

Quoted 81 lines · Rick Chen

Hi Bin and Lukas

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午5:17寫道:

Quoted 64 lines

Hi Rick,

Quoted 61 lines · Rick Chen

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午4:49寫道:

Quoted 59 lines

Hi Rick,

Quoted 43 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:01寫道:

Quoted 20 lines

Hi Rick,

Quoted 17 lines · Rick Chen

Hi Bin

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

Quoted 13 lines

Hi Rick,

Quoted 5 lines · Andes

From: Rick Chen <[email protected]>

To enumerate devices on the /soc/ node, create a "simple-bus" driver to match "andestech,riscv-ae350-soc".

Could we change the /soc/ node compatible string to "simple-bus" instead? The QEMU 'virt' created a bad example and we should stop the contamination.

Quoted 7 lines
Quoted 3 lines

Do you mean change the
.compatible = "andestech,riscv-ae350-soc",
as "simple-bus" ???

Yes, I mean changing the /soc/ node compatible string in arch/riscv/dts/ae350_{32,64}.dts to "simpble-bus".

So you mean we shall have only riscv simple bus driver. We shall remove
U_BOOT_DRIVER(riscv_virtio_soc) in /arch/riscv/cpu/generic/cpu.c U_BOOT_DRIVER(riscv_ae350_soc_ids) in /arch/riscv/cpu/ax25/cpu.c and add
static const struct udevice_id riscv_simple_bus_ids[] = { {
.compatible = "simple-bus",
},
{ }
};

Quoted 8 lines

U_BOOT_DRIVER(riscv_simple_bus_ids) = {
.name = "simple-bus",
.id = UCLASS_SIMPLE_BUS,
.of_match = riscv_simple_bus_ids,
.flags = DM_FLAG_PRE_RELOC,
};

Does it right ?

No, you don't need add anything to the RISC-V codes. U-Boot provides a simple-bus driver and all you need do is to use "simple-bus" in your DTS files.

Quoted 6 lines
Quoted 3 lines

But if I only use "simple-bus" in DTS file.
It will fail in syscon_get_first_range that can not get correct information from reg.

Yes, we should fix "simple-bus" driver. See discussion in
https://patchwork.ozlabs.org/patch/1039493/

The series has been pull into master by Tom.

Can you fix the "simple-bus" driver ASAP.
AE350 will encounter the problem as below with the latest u-boot-riscv

U-Boot 2019.04-rc4-07392-g48b90d9 (Apr 10 2019 - 16:27:39 +0800)

Quoted 7 lines
Quoted 5 lines

DRAM: 1 GiB
Cannot send IPI to hart 1
Relocation of secondary harts has failed, error -19 ### ERROR ### Please RESET the board ###

Yes, I will send the patch later today.

Thanks a lot.

Sincerely,
Rick

Quoted 3 lines

Thanks,
Lukas

author
#12 lore raw

PATCH 2/9 riscv: Add a SYSCON driver for Andestech's PLIC

In reply to Andes

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/nds_plic.c            | 84 ++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/nds_plic.c
arch/riscv/Kconfig +9 -0
index 3a4470d..fef11dd 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 NDS_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..15867f5 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
 	void __iomem *clint;	/* clint base address */
 #endif
+#ifdef CONFIG_NDS_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..0229989 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 Interrup Controller (PLIC) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 35dbf64..8187c2b 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_NDS_PLIC) += nds_plic.o
 obj-y	+= interrupts.o
 obj-y	+= reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plic.c new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
2.7.4
#13 lore raw

PATCH 2/9 riscv: Add a SYSCON driver for Andestech's PLIC

Hi Rick,

Quoted 6 lines · Andes

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

nits: need one space after interrupt.

arch/riscv/Kconfig

Quoted 17 lines

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/nds_plic.c            | 84 ++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/nds_plic.c
arch/riscv/Kconfig +0 -0
index 3a4470d..fef11dd 100644

Probably it makes more sense to put this to arch/riscv/cpu/ax25/Kconfig?

arch/riscv/Kconfig config SIFIVE_CLINT · line 112

Quoted 5 lines
arch/riscv/Kconfig +1 -0
@@ -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 NDS_PLIC

I am not sure if it is appropriate to call this "NDS_PLIC". Shouldn't it be "ANDES_PLIC", because ANDES_ and SIFIVE_ are vendor prefixes.

Quoted 30 lines
arch/riscv/Kconfig +8 -0
+       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..15867f5 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
        void __iomem *clint;    /* clint base address */
 #endif
+#ifdef CONFIG_NDS_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 +0 -0
index d311ee6..0229989 100644

arch/riscv/include/asm/syscon.h line 16

Quoted 9 lines
arch/riscv/include/asm/syscon.h +1 -1
@@ -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 Interrup Controller (PLIC) */

typo: Interrupt

arch/riscv/lib/nds_plic.c

Quoted 16 lines
arch/riscv/include/asm/syscon.h +0 -0
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 35dbf64..8187c2b 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_NDS_PLIC) += nds_plic.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plic.c +0 -0

And move this driver to arch/riscv/cpu/ax25 since it's only available in AX25 CPUs?

Quoted 33 lines

new file mode 100644
index 0000000..563da7d

arch/riscv/lib/nds_plic.c new file +28 -0
@@ -0,0 +1,84 @@
+// 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 <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.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)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PLIC_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \

arch/riscv/lib/nds_plic.c line 38

Quoted 10 lines
arch/riscv/lib/nds_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;                            \
+               }                                                       \
+       } while (0)
+
+int plic_init(int harts)

Can we make this function be automatically called in PLIC_BASE_GET()?

arch/riscv/lib/nds_plic.c line 41

Quoted 3 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+{
+       int i;
+       int en = 0x80808080;

Can we use some macros for this?

arch/riscv/lib/nds_plic.c line 44

Quoted 3 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+
+       PLIC_BASE_GET();
+       for(i=0;i<harts;i++)

nits: should have various spaces like i = 0;

arch/riscv/lib/nds_plic.c line 57

Quoted 13 lines
arch/riscv/lib/nds_plic.c new file +13 -0
+       {
+               en = en >> i;
+               writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, i));
+       }
+
+       return 0;
+}
+
+int riscv_send_ipi(int hart)
+{
+       PLIC_BASE_GET();
+
+       writel((0x80>>hart), (void __iomem *)PENDING_REG(gd->arch.plic, gd->arch.boot_hart));

macro for 0x80?

Quoted 18 lines
arch/riscv/lib/nds_plic.c new file +18 -0
+
+       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 nds_plic_ids[] = {
+       { .compatible = "riscv,plic1", .data = RISCV_SYSCON_PLIC },

arch/riscv/lib/nds_plic.c

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

Regards,
Bin

#14 lore raw

PATCH 2/9 riscv: Add a SYSCON driver for Andestech's PLIC

Hi Bin

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

Quoted 5 lines

Hi Rick,

Quoted 1 line · Andes
Quoted 7 lines
Quoted 5 lines

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

nits: need one space after interrupt.

OK
I will add space.

Quoted 14 lines
Quoted 14 lines

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/nds_plic.c            | 84 ++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/nds_plic.c
Quoted 6 lines

arch/riscv/Kconfig

Quoted 4 lines
arch/riscv/Kconfig +0 -0
index 3a4470d..fef11dd 100644

Probably it makes more sense to put this to arch/riscv/cpu/ax25/Kconfig?

I just refer to SIFIVE_CLINT. It also not make sense to place here, right ?

Quoted 9 lines

arch/riscv/Kconfig config SIFIVE_CLINT · line 112

Quoted 6 lines
arch/riscv/Kconfig +1 -0
@@ -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 NDS_PLIC

I am not sure if it is appropriate to call this "NDS_PLIC". Shouldn't it be "ANDES_PLIC", because ANDES_ and SIFIVE_ are vendor prefixes.

OK
I will use ANDES_PLIC to replace NDS_PLIC.

Quoted 34 lines
Quoted 34 lines
arch/riscv/Kconfig +8 -0
+       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..15867f5 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
        void __iomem *clint;    /* clint base address */
 #endif
+#ifdef CONFIG_NDS_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 +0 -0
index d311ee6..0229989 100644
@@ -9,11 +9,11 @@
 /*
  * System controllers in a RISC-V system
  *
Quoted 8 lines

arch/riscv/include/asm/syscon.h line 16

Quoted 6 lines
arch/riscv/include/asm/syscon.h +1 -1
- * 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 Interrup Controller (PLIC) */

typo: Interrupt

OK
I will correct it.

Quoted 12 lines
Quoted 12 lines
arch/riscv/include/asm/syscon.h +0 -0
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +0 -0
index 35dbf64..8187c2b 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
Quoted 8 lines

arch/riscv/lib/nds_plic.c

Quoted 5 lines
arch/riscv/lib/Makefile +1 -0
+obj-$(CONFIG_NDS_PLIC) += nds_plic.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plic.c +0 -0

And move this driver to arch/riscv/cpu/ax25 since it's only available in AX25 CPUs?

Same as sifive_clint.c . Shall it also move away from /lib ?

Quoted 38 lines
Quoted 38 lines

new file mode 100644
index 0000000..563da7d

arch/riscv/lib/nds_plic.c new file +32 -0
@@ -0,0 +1,84 @@
+// 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 <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.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)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PLIC_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \
+                                                                       \
+               if (!gd->arch.plic) {                                   \
+                       ret = syscon_get_first_range(RISCV_SYSCON_PLIC); \
+                       if (IS_ERR(ret))                                \
Quoted 8 lines

arch/riscv/lib/nds_plic.c line 38

Quoted 6 lines
arch/riscv/lib/nds_plic.c new file +6 -0
+                               return PTR_ERR(ret);                    \
+                       gd->arch.plic = ret;                            \
+               }                                                       \
+       } while (0)
+
+int plic_init(int harts)

Can we make this function be automatically called in PLIC_BASE_GET()?

OK
I will move it in PLIC_BASE_GET()

Quoted 6 lines

arch/riscv/lib/nds_plic.c line 41

Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+{
+       int i;
+       int en = 0x80808080;

Can we use some macros for this?

OK
I will use macro to represent it.

Quoted 6 lines

arch/riscv/lib/nds_plic.c line 44

Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+
+       PLIC_BASE_GET();
+       for(i=0;i<harts;i++)

nits: should have various spaces like i = 0;

OK

Quoted 16 lines
Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+       {
+               en = en >> i;
+               writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, i));

arch/riscv/lib/nds_plic.c line 57

Quoted 10 lines
arch/riscv/lib/nds_plic.c new file +10 -0
+       }
+
+       return 0;
+}
+
+int riscv_send_ipi(int hart)
+{
+       PLIC_BASE_GET();
+
+       writel((0x80>>hart), (void __iomem *)PENDING_REG(gd->arch.plic, gd->arch.boot_hart));

macro for 0x80?

OK
I will use macro to represent it.

Thanks for review.

Rick

Quoted 32 lines
Quoted 19 lines
arch/riscv/lib/nds_plic.c new file +18 -0
+
+       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 nds_plic_ids[] = {
+       { .compatible = "riscv,plic1", .data = RISCV_SYSCON_PLIC },

arch/riscv/lib/nds_plic.c

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

Regards,
Bin

#15 lore raw

PATCH 2/9 riscv: Add a SYSCON driver for Andestech's PLIC

Hi Rick,

Quoted 34 lines · Rick Chen

Hi Bin

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

Quoted 5 lines

Hi Rick,

Quoted 1 line · Andes
Quoted 7 lines
Quoted 5 lines

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

nits: need one space after interrupt.

OK
I will add space.

Quoted 14 lines
Quoted 14 lines

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/nds_plic.c            | 84 ++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/nds_plic.c
Quoted 8 lines
Quoted 6 lines

arch/riscv/Kconfig

Quoted 4 lines
arch/riscv/Kconfig +0 -0
index 3a4470d..fef11dd 100644

Probably it makes more sense to put this to arch/riscv/cpu/ax25/Kconfig?

I just refer to SIFIVE_CLINT. It also not make sense to place here, right ?

Maybe, but since the cpu directory is renamed to 'generic', I am not sure moving to that directory is a good idea.

Quoted 81 lines
Quoted 10 lines

arch/riscv/Kconfig config SIFIVE_CLINT · line 112

Quoted 7 lines
arch/riscv/Kconfig +1 -0
@@ -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 NDS_PLIC

I am not sure if it is appropriate to call this "NDS_PLIC". Shouldn't it be "ANDES_PLIC", because ANDES_ and SIFIVE_ are vendor prefixes.

OK
I will use ANDES_PLIC to replace NDS_PLIC.

Quoted 34 lines
Quoted 34 lines
arch/riscv/Kconfig +8 -0
+       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..15867f5 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
        void __iomem *clint;    /* clint base address */
 #endif
+#ifdef CONFIG_NDS_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 +0 -0
index d311ee6..0229989 100644
@@ -9,11 +9,11 @@
 /*
  * System controllers in a RISC-V system
  *
Quoted 8 lines

arch/riscv/include/asm/syscon.h line 16

Quoted 6 lines
arch/riscv/include/asm/syscon.h +1 -1
- * 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 Interrup Controller (PLIC) */

typo: Interrupt

OK
I will correct it.

Quoted 12 lines
Quoted 12 lines
arch/riscv/include/asm/syscon.h +0 -0
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +0 -0
index 35dbf64..8187c2b 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
Quoted 8 lines

arch/riscv/lib/nds_plic.c

Quoted 5 lines
arch/riscv/lib/Makefile +1 -0
+obj-$(CONFIG_NDS_PLIC) += nds_plic.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plic.c +0 -0

And move this driver to arch/riscv/cpu/ax25 since it's only available in AX25 CPUs?

Quoted 2 lines

Same as sifive_clint.c . Shall it also move away from /lib ?

I agree, but see comments above :)

Quoted 86 lines
Quoted 38 lines
Quoted 38 lines

new file mode 100644
index 0000000..563da7d

arch/riscv/lib/nds_plic.c new file +32 -0
@@ -0,0 +1,84 @@
+// 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 <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.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)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PLIC_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \
+                                                                       \
+               if (!gd->arch.plic) {                                   \
+                       ret = syscon_get_first_range(RISCV_SYSCON_PLIC); \
+                       if (IS_ERR(ret))                                \
Quoted 8 lines

arch/riscv/lib/nds_plic.c line 38

Quoted 6 lines
arch/riscv/lib/nds_plic.c new file +6 -0
+                               return PTR_ERR(ret);                    \
+                       gd->arch.plic = ret;                            \
+               }                                                       \
+       } while (0)
+
+int plic_init(int harts)

Can we make this function be automatically called in PLIC_BASE_GET()?

OK
I will move it in PLIC_BASE_GET()

Quoted 6 lines

arch/riscv/lib/nds_plic.c line 41

Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+{
+       int i;
+       int en = 0x80808080;

Can we use some macros for this?

OK
I will use macro to represent it.

Quoted 6 lines

arch/riscv/lib/nds_plic.c line 44

Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+
+       PLIC_BASE_GET();
+       for(i=0;i<harts;i++)

nits: should have various spaces like i = 0;

OK

Quoted 16 lines
Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+       {
+               en = en >> i;
+               writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, i));

arch/riscv/lib/nds_plic.c line 57

Quoted 10 lines
arch/riscv/lib/nds_plic.c new file +10 -0
+       }
+
+       return 0;
+}
+
+int riscv_send_ipi(int hart)
+{
+       PLIC_BASE_GET();
+
+       writel((0x80>>hart), (void __iomem *)PENDING_REG(gd->arch.plic, gd->arch.boot_hart));

macro for 0x80?

Quoted 5 lines

OK
I will use macro to represent it.

Thanks for review.

Regards,
Bin

#16 lore raw

PATCH 2/9 riscv: Add a SYSCON driver for Andestech's PLIC

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午3:32寫道:

Quoted 45 lines

Hi Rick,

Quoted 41 lines · Rick Chen

Hi Bin

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

Quoted 5 lines

Hi Rick,

Quoted 1 line · Andes
Quoted 7 lines
Quoted 5 lines

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

nits: need one space after interrupt.

OK
I will add space.

Quoted 20 lines

arch/riscv/Kconfig

Quoted 18 lines

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/nds_plic.c            | 84 ++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/nds_plic.c
arch/riscv/Kconfig +0 -0
index 3a4470d..fef11dd 100644

Probably it makes more sense to put this to arch/riscv/cpu/ax25/Kconfig?

Quoted 4 lines
Quoted 1 line

I just refer to SIFIVE_CLINT. It also not make sense to place here, right ?

Maybe, but since the cpu directory is renamed to 'generic', I am not sure moving to that directory is a good idea.

Maybe I will still put it in /arch/riscv/Kconfig.
And we can move them to the place they belong individually together if there have better place to accommodate to SIFIVE_CLINT.
How do you think ?

Rick

Quoted 181 lines
Quoted 82 lines
Quoted 11 lines

arch/riscv/Kconfig config SIFIVE_CLINT · line 112

Quoted 8 lines
arch/riscv/Kconfig +1 -0
@@ -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 NDS_PLIC

I am not sure if it is appropriate to call this "NDS_PLIC". Shouldn't it be "ANDES_PLIC", because ANDES_ and SIFIVE_ are vendor prefixes.

OK
I will use ANDES_PLIC to replace NDS_PLIC.

Quoted 34 lines
Quoted 34 lines
arch/riscv/Kconfig +8 -0
+       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..15867f5 100644
@@ -18,6 +18,9 @@ struct arch_global_data {
 #ifdef CONFIG_SIFIVE_CLINT
        void __iomem *clint;    /* clint base address */
 #endif
+#ifdef CONFIG_NDS_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 +0 -0
index d311ee6..0229989 100644
@@ -9,11 +9,11 @@
 /*
  * System controllers in a RISC-V system
  *
Quoted 8 lines

arch/riscv/include/asm/syscon.h line 16

Quoted 6 lines
arch/riscv/include/asm/syscon.h +1 -1
- * 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 Interrup Controller (PLIC) */

typo: Interrupt

OK
I will correct it.

Quoted 12 lines
Quoted 12 lines
arch/riscv/include/asm/syscon.h +0 -0
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +0 -0
index 35dbf64..8187c2b 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
Quoted 8 lines

arch/riscv/lib/nds_plic.c

Quoted 5 lines
arch/riscv/lib/Makefile +1 -0
+obj-$(CONFIG_NDS_PLIC) += nds_plic.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plic.c +0 -0

And move this driver to arch/riscv/cpu/ax25 since it's only available in AX25 CPUs?

Quoted 2 lines

Same as sifive_clint.c . Shall it also move away from /lib ?

I agree, but see comments above :)

Quoted 86 lines
Quoted 38 lines
Quoted 38 lines

new file mode 100644
index 0000000..563da7d

arch/riscv/lib/nds_plic.c new file +32 -0
@@ -0,0 +1,84 @@
+// 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 <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.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)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PLIC_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \
+                                                                       \
+               if (!gd->arch.plic) {                                   \
+                       ret = syscon_get_first_range(RISCV_SYSCON_PLIC); \
+                       if (IS_ERR(ret))                                \
Quoted 8 lines

arch/riscv/lib/nds_plic.c line 38

Quoted 6 lines
arch/riscv/lib/nds_plic.c new file +6 -0
+                               return PTR_ERR(ret);                    \
+                       gd->arch.plic = ret;                            \
+               }                                                       \
+       } while (0)
+
+int plic_init(int harts)

Can we make this function be automatically called in PLIC_BASE_GET()?

OK
I will move it in PLIC_BASE_GET()

Quoted 6 lines

arch/riscv/lib/nds_plic.c line 41

Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+{
+       int i;
+       int en = 0x80808080;

Can we use some macros for this?

OK
I will use macro to represent it.

Quoted 6 lines

arch/riscv/lib/nds_plic.c line 44

Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+
+       PLIC_BASE_GET();
+       for(i=0;i<harts;i++)

nits: should have various spaces like i = 0;

OK

Quoted 16 lines
Quoted 4 lines
arch/riscv/lib/nds_plic.c new file +3 -0
+       {
+               en = en >> i;
+               writel(en, (void __iomem *)ENABLE_REG(gd->arch.plic, i));

arch/riscv/lib/nds_plic.c line 57

Quoted 10 lines
arch/riscv/lib/nds_plic.c new file +10 -0
+       }
+
+       return 0;
+}
+
+int riscv_send_ipi(int hart)
+{
+       PLIC_BASE_GET();
+
+       writel((0x80>>hart), (void __iomem *)PENDING_REG(gd->arch.plic, gd->arch.boot_hart));

macro for 0x80?

Quoted 5 lines

OK
I will use macro to represent it.

Thanks for review.

Regards,
Bin

#17 lore raw

PATCH 2/9 riscv: Add a SYSCON driver for Andestech's PLIC

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Probably it makes more sense to put this to arch/riscv/cpu/ax25/Kconfig?

I just refer to SIFIVE_CLINT. It also not make sense to place here, right ?

Quoted 29 lines
Quoted 2 lines

Maybe, but since the cpu directory is renamed to 'generic', I am not sure moving to that directory is a good idea.

Maybe I will still put it in /arch/riscv/Kconfig.
And we can move them to the place they belong individually together if there have better place to accommodate to SIFIVE_CLINT.
How do you think ?

Quoted 18 lines
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines

+++ b/arch/riscv/lib/Makefile

arch/riscv/lib/Makefile +0 -0
@@ -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
Quoted 8 lines

arch/riscv/lib/nds_plic.c

Quoted 5 lines
arch/riscv/lib/Makefile +1 -0
+obj-$(CONFIG_NDS_PLIC) += nds_plic.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plic.c +0 -0

And move this driver to arch/riscv/cpu/ax25 since it's only available in AX25 CPUs?

Quoted 2 lines

Same as sifive_clint.c . Shall it also move away from /lib ?

I agree, but see comments above :)

It seems to me there might be a usefull distinction between potentially generic things like the Sifive/Berkely/Rocket-chip clint [1] and other vendor implementations which do not have necessarily have publicly reviewable hardware implementations.

[1] https://github.com/sifive/rocket-chip/blob/master/src/main/scala/devices/tilelink/CLINT.scala

author
#18 lore raw

PATCH 3/9 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
are 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/nds_plmt.c            | 53 ++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+)
 create mode 100644 arch/riscv/lib/nds_plmt.c
arch/riscv/Kconfig +9 -0
index fef11dd..697892e 100644
@@ -118,6 +118,15 @@ config NDS_PLIC
 	  The Andes PLIC block holds memory-mapped claim and pending registers
 	  associated with software interrupt.
 
+config NDS_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 15867f5..0695ae3 100644
@@ -21,6 +21,9 @@ struct arch_global_data {
 #ifdef CONFIG_NDS_PLIC
 	void __iomem *plic;	/* plic base address */
 #endif
+#ifdef CONFIG_NDS_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 0229989..9fdee09 100644
@@ -14,6 +14,7 @@ enum {
 	RISCV_NONE,
 	RISCV_SYSCON_CLINT,	/* Core Local Interruptor (CLINT) */
 	RISCV_SYSCON_PLIC,	/* Platform Level Interrup Controller (PLIC) */
+	RISCV_SYSCON_PLMT,	/* Platform Level Machine Timer (PLMT) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 8187c2b..383eed3 100644
@@ -12,6 +12,7 @@ obj-y	+= cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
 obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
 obj-$(CONFIG_NDS_PLIC) += nds_plic.o
+obj-$(CONFIG_NDS_PLMT) += nds_plmt.o
 obj-y	+= interrupts.o
 obj-y	+= reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plmt.c new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.7.4
#19 lore raw

PATCH 3/9 riscv: Add a SYSCON driver for Andestech's PLMT

Hi Rick,

Quoted 8 lines · 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

nits: need one space before "which"

Quoted 1 line

are required by the generic RISC-V timer driver.

are -> is

Quoted 17 lines
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/nds_plmt.c            | 53 ++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+)
 create mode 100644 arch/riscv/lib/nds_plmt.c
arch/riscv/Kconfig +0 -0
index fef11dd..697892e 100644

arch/riscv/Kconfig config NDS_PLIC · line 121

Quoted 4 lines
arch/riscv/Kconfig +1 -0
@@ -118,6 +118,15 @@ config NDS_PLIC
          The Andes PLIC block holds memory-mapped claim and pending registers
          associated with software interrupt.
 
+config NDS_PLMT

ANDES_PLMT?

Quoted 99 lines
arch/riscv/Kconfig +8 -0
+       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 15867f5..0695ae3 100644
@@ -21,6 +21,9 @@ struct arch_global_data {
 #ifdef CONFIG_NDS_PLIC
        void __iomem *plic;     /* plic base address */
 #endif
+#ifdef CONFIG_NDS_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 0229989..9fdee09 100644
@@ -14,6 +14,7 @@ enum {
        RISCV_NONE,
        RISCV_SYSCON_CLINT,     /* Core Local Interruptor (CLINT) */
        RISCV_SYSCON_PLIC,      /* Platform Level Interrup Controller (PLIC) */
+       RISCV_SYSCON_PLMT,      /* Platform Level Machine Timer (PLMT) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 8187c2b..383eed3 100644
@@ -12,6 +12,7 @@ obj-y += cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
 obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
 obj-$(CONFIG_NDS_PLIC) += nds_plic.o
+obj-$(CONFIG_NDS_PLMT) += nds_plmt.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plmt.c new file +44 -0
new file mode 100644
index 0000000..12d7e0e
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019, Rick Chen <[email protected]>
+ *
+ * U-Boot syscon driver for Andes's Platform Level Machine Timer (PLMT).
+ * The PLMT block holds memory-mapped mtime register
+ * associated with timer tick.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.h>
+
+/* mtime register */
+#define MTIME_REG(base)                        ((ulong)(base))
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PLMT_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \
+                                                                       \
+               if (!gd->arch.plmt) {                                   \
+                       ret = syscon_get_first_range(RISCV_SYSCON_PLMT); \
+                       if (IS_ERR(ret))                                \
+                               return PTR_ERR(ret);                    \
+                       gd->arch.plmt = ret;                            \
+               }                                                       \
+       } while (0)
+
+int riscv_get_time(u64 *time)
+{
+       PLMT_BASE_GET();
+
+       *time = readq((void __iomem *)MTIME_REG(gd->arch.plmt));
+
+       return 0;
+}
+
+static const struct udevice_id nds_plmt_ids[] = {
+       { .compatible = "riscv,plmt0", .data = RISCV_SYSCON_PLMT },

arch/riscv/lib/nds_plmt.c

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

Regards,
Bin

#20 lore raw

PATCH 3/9 riscv: Add a SYSCON driver for Andestech's PLMT

Hi Bin

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

Quoted 7 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

Quoted 7 lines
Quoted 5 lines

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

This driver implements the riscv_get_time()which

nits: need one space before "which"

OK

Quoted 4 lines
Quoted 2 lines

are required by the generic RISC-V timer driver.

are -> is

OK

Quoted 21 lines
Quoted 21 lines
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/nds_plmt.c            | 53 ++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+)
 create mode 100644 arch/riscv/lib/nds_plmt.c
arch/riscv/Kconfig +0 -0
index fef11dd..697892e 100644
@@ -118,6 +118,15 @@ config NDS_PLIC
          The Andes PLIC block holds memory-mapped claim and pending registers
          associated with software interrupt.
 
Quoted 3 lines

arch/riscv/Kconfig config NDS_PLIC · line 121

Quoted 1 line
arch/riscv/Kconfig +1 -0
+config NDS_PLMT

ANDES_PLMT?

OK

Quoted 113 lines
Quoted 100 lines
arch/riscv/Kconfig +8 -0
+       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 15867f5..0695ae3 100644
@@ -21,6 +21,9 @@ struct arch_global_data {
 #ifdef CONFIG_NDS_PLIC
        void __iomem *plic;     /* plic base address */
 #endif
+#ifdef CONFIG_NDS_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 0229989..9fdee09 100644
@@ -14,6 +14,7 @@ enum {
        RISCV_NONE,
        RISCV_SYSCON_CLINT,     /* Core Local Interruptor (CLINT) */
        RISCV_SYSCON_PLIC,      /* Platform Level Interrup Controller (PLIC) */
+       RISCV_SYSCON_PLMT,      /* Platform Level Machine Timer (PLMT) */
 };
 
 #endif /* _ASM_SYSCON_H */
arch/riscv/lib/Makefile +1 -0
index 8187c2b..383eed3 100644
@@ -12,6 +12,7 @@ obj-y += cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
 obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
 obj-$(CONFIG_NDS_PLIC) += nds_plic.o
+obj-$(CONFIG_NDS_PLMT) += nds_plmt.o
 obj-y  += interrupts.o
 obj-y  += reset.o
 obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
arch/riscv/lib/nds_plmt.c new file +44 -0
new file mode 100644
index 0000000..12d7e0e
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019, Rick Chen <[email protected]>
+ *
+ * U-Boot syscon driver for Andes's Platform Level Machine Timer (PLMT).
+ * The PLMT block holds memory-mapped mtime register
+ * associated with timer tick.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <asm/io.h>
+#include <asm/syscon.h>
+
+/* mtime register */
+#define MTIME_REG(base)                        ((ulong)(base))
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PLMT_BASE_GET(void)                                            \
+       do {                                                            \
+               long *ret;                                              \
+                                                                       \
+               if (!gd->arch.plmt) {                                   \
+                       ret = syscon_get_first_range(RISCV_SYSCON_PLMT); \
+                       if (IS_ERR(ret))                                \
+                               return PTR_ERR(ret);                    \
+                       gd->arch.plmt = ret;                            \
+               }                                                       \
+       } while (0)
+
+int riscv_get_time(u64 *time)
+{
+       PLMT_BASE_GET();
+
+       *time = readq((void __iomem *)MTIME_REG(gd->arch.plmt));
+
+       return 0;
+}
+
+static const struct udevice_id nds_plmt_ids[] = {
+       { .compatible = "riscv,plmt0", .data = RISCV_SYSCON_PLMT },

arch/riscv/lib/nds_plmt.c

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

Regards,
Bin

author
#21 lore raw

PATCH 4/9 riscv: ae350: initialize PLIC

In reply to Andes

From: Rick Chen <[email protected]>

Initialize PLIC when ae350 board startup.

Cc Greentime Hu <[email protected]>
---
 board/AndesTech/ax25-ae350/ax25-ae350.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/AndesTech/ax25-ae350/ax25-ae350.c +30 -0
index d343453..ebeb4b8 100644
@@ -11,10 +11,17 @@
 #include <linux/io.h>
 #include <faraday/ftsmc020.h>
 #include <fdtdec.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+#include <cpu.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 extern phys_addr_t prior_stage_fdt_address;
+extern int plic_init(int harts);
+
 /*
  * Miscellaneous platform dependent initializations
  */
@@ -97,9 +104,32 @@ int smc_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_NDS_PLIC
+int init_plic(void)
+{
+	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;
+}
+#endif
+
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
+#ifdef CONFIG_NDS_PLIC
+	init_plic();
+#endif
 	smc_init();
 
 	return 0;
Signature · 1 line
2.7.4
author
#22 lore raw

PATCH 5/9 riscv: ae350: disable ATCPIT100 timer

In reply to Andes

From: Rick Chen <[email protected]>

Disable ATCPIT100 SoC timer and replace by PLMT.

Cc Greentime Hu <[email protected]>
---
 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
#24 lore raw

PATCH 6/9 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.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/cpu/ax25/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/cpu/ax25/Kconfig +6 -0
index e9dbca2..0901709 100644
@@ -1,5 +1,11 @@
 config RISCV_NDS
 	bool
+	select ARCH_EARLY_INIT_R
+	imply CPU
+	imply CPU_RISCV
+	imply RISCV_TIMER
+	imply NDS_PLIC if RISCV_MMODE
+	imply NDS_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
#26 lore raw

PATCH 7/9 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.

Cc Greentime Hu <[email protected]>
---
 arch/riscv/cpu/ax25/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/riscv/cpu/ax25/Kconfig +1 -0
index 0901709..e030df4 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
#27 lore raw

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

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title

Quoted 9 lines

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

Cc Greentime Hu <[email protected]>
---
 arch/riscv/cpu/ax25/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Regards,
Bin

#28 lore raw

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

Hi Bin

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

Quoted 9 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title

OK
I will remove it.

Thanks for review.
Rick

Quoted 15 lines
Quoted 10 lines

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

Cc Greentime Hu <[email protected]>
---
 arch/riscv/cpu/ax25/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Regards,
Bin

author
#29 lore raw

PATCH 8/9 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..0b4d966 100644
@@ -25,17 +25,50 @@
 			reg = <0>;
 			status = "okay";
 			compatible = "riscv";
-			riscv,isa = "rv32imafdc";
+			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>;
 			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 {
@@ -49,29 +82,29 @@
 		compatible = "andestech,riscv-ae350-soc";
 		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

85 lines not on this page · raw message

Signature · 1 line
2.7.4
#30 lore raw

PATCH 8/9 riscv: dts: ae350 support SMP.

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title.

Quoted 12 lines
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 +0 -0
index 0679827..0b4d966 100644

arch/riscv/dts/ae350_32.dts line 28

Quoted 5 lines
arch/riscv/dts/ae350_32.dts +1 -1
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv32imafdc";
+                       riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

I am not sure what is this. Is this something approved?

Quoted 192 lines
arch/riscv/dts/ae350_32.dts +58 -21
+                       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 {
@@ -49,29 +82,29 @@
                compatible = "andestech,riscv-ae350-soc";
                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 +38 -5
index e48c298..3c7e152 100644
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv64imafdc";
+                       riscv,isa = "rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";
+                       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";
                        };
                };
+               CPU1: cpu at 1 {
+                       device_type = "cpu";
+                       reg = <1>;
+                       status = "okay";
+                       compatible = "riscv";
+                       riscv,isa = "rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";
+                       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 {
@@ -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>;
        };
 
        plmt0 at e6000000 {
                compatible = "riscv,plmt0";
-                       interrupts-extended = <&CPU0_intc 7>;
+      interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>;
                        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

#31 lore raw

PATCH 8/9 riscv: dts: ae350 support SMP.

Hi Bin

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

Quoted 9 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title.

OK.
I will remove it.

Quoted 8 lines
Quoted 8 lines
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(-)
Quoted 12 lines

arch/riscv/dts/ae350_32.dts line 28

Quoted 10 lines
arch/riscv/dts/ae350_32.dts +1 -1
index 0679827..0b4d966 100644
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv32imafdc";
+                       riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

I am not sure what is this. Is this something approved?

It is about elf checking (attribute) and seem has been upstream to GCC.
https://patchwork.ozlabs.org/cover/1040998/

Thanks
Rick

Quoted 206 lines
Quoted 193 lines
arch/riscv/dts/ae350_32.dts +58 -21
+                       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 {
@@ -49,29 +82,29 @@
                compatible = "andestech,riscv-ae350-soc";
                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 +38 -5
index e48c298..3c7e152 100644
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv64imafdc";
+                       riscv,isa = "rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";
+                       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";
                        };
                };
+               CPU1: cpu at 1 {
+                       device_type = "cpu";
+                       reg = <1>;
+                       status = "okay";
+                       compatible = "riscv";
+                       riscv,isa = "rv64i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";
+                       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 {
@@ -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>;
        };
 
        plmt0 at e6000000 {
                compatible = "riscv,plmt0";
-                       interrupts-extended = <&CPU0_intc 7>;
+      interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>;
                        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

#32 lore raw

PATCH 8/9 riscv: dts: ae350 support SMP.

Hi Rick,

Quoted 38 lines · Rick Chen

Hi Bin

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

Quoted 9 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title.

OK.
I will remove it.

Quoted 8 lines
Quoted 8 lines
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(-)
Quoted 12 lines

arch/riscv/dts/ae350_32.dts line 28

Quoted 10 lines
arch/riscv/dts/ae350_32.dts +1 -1
index 0679827..0b4d966 100644
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv32imafdc";
+                       riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

I am not sure what is this. Is this something approved?

Quoted 3 lines

It is about elf checking (attribute) and seem has been upstream to GCC.
https://patchwork.ozlabs.org/cover/1040998/

So that patch affects GCC's "-march" string? But why do we need adjust the "riscv,isa" string in DT?

Regards,
Bin

#33 lore raw

PATCH 8/9 riscv: dts: ae350 support SMP.

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午5:15寫道:

Quoted 42 lines

Hi Rick,

Quoted 38 lines · Rick Chen

Hi Bin

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

Quoted 9 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title.

OK.
I will remove it.

Quoted 20 lines
Quoted 13 lines
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 +0 -0
index 0679827..0b4d966 100644

arch/riscv/dts/ae350_32.dts line 28

Quoted 5 lines
arch/riscv/dts/ae350_32.dts +1 -1
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv32imafdc";
+                       riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

I am not sure what is this. Is this something approved?

Quoted 7 lines
Quoted 3 lines

It is about elf checking (attribute) and seem has been upstream to GCC.
https://patchwork.ozlabs.org/cover/1040998/

So that patch affects GCC's "-march" string? But why do we need adjust the "riscv,isa" string in DT?

We will use this to check user program (binutils will assign this string) when it run in kernel at run time.

Quoted 2 lines

Regards,
Bin

#34 lore raw

PATCH 8/9 riscv: dts: ae350 support SMP.

Hi Rick,

Quoted 48 lines · Rick Chen

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午5:15寫道:

Quoted 46 lines

Hi Rick,

Quoted 41 lines · Rick Chen

Hi Bin

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

Quoted 9 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title.

OK.
I will remove it.

Quoted 8 lines
Quoted 8 lines
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(-)
Quoted 12 lines

arch/riscv/dts/ae350_32.dts line 28

Quoted 10 lines
arch/riscv/dts/ae350_32.dts +1 -1
index 0679827..0b4d966 100644
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv32imafdc";
+                       riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

I am not sure what is this. Is this something approved?

It is about elf checking (attribute) and seem has been upstream to GCC.
https://patchwork.ozlabs.org/cover/1040998/

Quoted 6 lines
Quoted 3 lines

So that patch affects GCC's "-march" string? But why do we need adjust the "riscv,isa" string in DT?

We will use this to check user program (binutils will assign this string) when it run in kernel at run time.

Do you have details about this binutils checks? Is this new string approved by the DT upstream? At least I see latest QEMU still generates the old string.

Regards,
Bin

#35 lore raw

PATCH 8/9 riscv: dts: ae350 support SMP.

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午6:12寫道:

Quoted 56 lines

Hi Rick,

Quoted 52 lines · Rick Chen

Bin Meng <[email protected]> 於 2019年3月21日 週四 下午5:15寫道:

Quoted 49 lines

Hi Rick,

Quoted 38 lines · Rick Chen

Hi Bin

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

Quoted 9 lines

Hi Rick,

Quoted 3 lines · Andes

From: Rick Chen <[email protected]>

nits: remove the ending period in the commit title.

OK.
I will remove it.

Quoted 8 lines
Quoted 8 lines
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(-)
Quoted 12 lines

arch/riscv/dts/ae350_32.dts line 28

Quoted 10 lines
arch/riscv/dts/ae350_32.dts +1 -1
index 0679827..0b4d966 100644
@@ -25,17 +25,50 @@
                        reg = <0>;
                        status = "okay";
                        compatible = "riscv";
-                       riscv,isa = "rv32imafdc";
+                       riscv,isa = "rv32i2p0m2p0a2p0f2p0d2p0c2p0xv5-0p0";

I am not sure what is this. Is this something approved?

Quoted 3 lines

It is about elf checking (attribute) and seem has been upstream to GCC.
https://patchwork.ozlabs.org/cover/1040998/

So that patch affects GCC's "-march" string? But why do we need adjust the "riscv,isa" string in DT?

Quoted 6 lines
Quoted 2 lines

We will use this to check user program (binutils will assign this string) when it run in kernel at run time.

Do you have details about this binutils checks? Is this new string approved by the DT upstream? At least I see latest QEMU still generates the old string.

The string is NOT approved by the DT upstream.
We use it internally .

Quoted 3 lines

Regards,
Bin

author
#36 lore raw

PATCH 9/9 riscv: ae350: enable SMP

In reply to Andes

From: Rick Chen <[email protected]>

Cc Greentime Hu <[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