From 45970c07dc1f2fe6804235f9955da6c23b26eb08 Mon Sep 17 00:00:00 2001 From: Siyuan Cheng Date: Tue, 21 Jun 2022 17:28:56 +0800 Subject: [PATCH] arc: add XY mem support Add arc XY mem configuration Signed-off-by: Siyuan Cheng --- boards/arc/em_starterkit/arc_mpu_regions.c | 15 +++++++++++ boards/arc/em_starterkit/em_starterkit.dts | 10 +++++++ .../arc/em_starterkit/em_starterkit_em11d.dts | 10 +++++++ boards/arc/emsdp/arc_mpu_regions.c | 14 ++++++++++ boards/arc/emsdp/emsdp.dts | 1 + boards/arc/emsdp/emsdp_em9d.dts | 11 ++++++++ boards/arc/iotdk/arc_mpu_regions.c | 14 ++++++++++ boards/arc/iotdk/iotdk.dts | 11 ++++++++ boards/arc/nsim/arc_mpu_regions.c | 15 ++++++++++- boards/arc/nsim/nsim.dtsi | 16 ++++++++++++ boards/arc/nsim/nsim_em.dts | 26 +++++++++++++++++++ boards/arc/nsim/support/mdb_em.args | 5 ++-- boards/arc/nsim/support/nsim_em.props | 5 ++-- dts/bindings/arc/arc,xccm.yaml | 12 +++++++++ dts/bindings/arc/arc,yccm.yaml | 12 +++++++++ include/zephyr/arch/arc/v2/linker.ld | 6 +++++ include/zephyr/arch/arc/v2/xy_mem.ld | 17 ++++++++++++ soc/arc/snps_arc_iot/linker.ld | 1 + soc/arc/snps_emsdp/linker.ld | 1 + soc/arc/snps_emsk/linker.ld | 1 + soc/arc/snps_nsim/linker.ld | 1 + 21 files changed, 199 insertions(+), 5 deletions(-) create mode 100644 dts/bindings/arc/arc,xccm.yaml create mode 100644 dts/bindings/arc/arc,yccm.yaml create mode 100644 include/zephyr/arch/arc/v2/xy_mem.ld diff --git a/boards/arc/em_starterkit/arc_mpu_regions.c b/boards/arc/em_starterkit/arc_mpu_regions.c index 2bef27ec52e4..cde7df204bd1 100644 --- a/boards/arc/em_starterkit/arc_mpu_regions.c +++ b/boards/arc/em_starterkit/arc_mpu_regions.c @@ -29,6 +29,21 @@ static struct arc_mpu_region mpu_regions[] = { REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), #endif +#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0 + /* Region XCCM */ + MPU_REGION_ENTRY("XCCM", + DT_REG_ADDR(DT_INST(0, arc_xccm)), + DT_REG_SIZE(DT_INST(0, arc_xccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif +#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0 + /* Region YCCM */ + MPU_REGION_ENTRY("YCCM", + DT_REG_ADDR(DT_INST(0, arc_yccm)), + DT_REG_SIZE(DT_INST(0, arc_yccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif + #if DT_REG_SIZE(DT_INST(0, mmio_sram)) > 0 /* Region DDR RAM */ MPU_REGION_ENTRY("DDR RAM", diff --git a/boards/arc/em_starterkit/em_starterkit.dts b/boards/arc/em_starterkit/em_starterkit.dts index dd4854ffb915..63f97a132795 100644 --- a/boards/arc/em_starterkit/em_starterkit.dts +++ b/boards/arc/em_starterkit/em_starterkit.dts @@ -36,6 +36,16 @@ compatible = "arc,dccm"; reg = <0x80000000 DT_SIZE_K(128)>; }; + + xccm@c0000000 { + compatible = "arc,xccm"; + reg = <0xc0000000 DT_SIZE_K(8)>; + }; + + yccm@e0000000 { + compatible = "arc,yccm"; + reg = <0xe0000000 DT_SIZE_K(8)>; + }; }; &uart1 { diff --git a/boards/arc/em_starterkit/em_starterkit_em11d.dts b/boards/arc/em_starterkit/em_starterkit_em11d.dts index 825782113c9d..75a23beda8a3 100644 --- a/boards/arc/em_starterkit/em_starterkit_em11d.dts +++ b/boards/arc/em_starterkit/em_starterkit_em11d.dts @@ -36,6 +36,16 @@ compatible = "arc,dccm"; reg = <0x80000000 DT_SIZE_K(64)>; }; + + xccm@c0000000 { + compatible = "arc,xccm"; + reg = <0xc0000000 DT_SIZE_K(8)>; + }; + + yccm@e0000000 { + compatible = "arc,yccm"; + reg = <0xe0000000 DT_SIZE_K(8)>; + }; }; &uart1 { diff --git a/boards/arc/emsdp/arc_mpu_regions.c b/boards/arc/emsdp/arc_mpu_regions.c index 72cae4ce9774..45d15011b74a 100644 --- a/boards/arc/emsdp/arc_mpu_regions.c +++ b/boards/arc/emsdp/arc_mpu_regions.c @@ -20,6 +20,20 @@ static struct arc_mpu_region mpu_regions[] = { DT_REG_ADDR(DT_INST(0, arc_dccm)), DT_REG_SIZE(DT_INST(0, arc_dccm)), REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), + /* Region XCCM */ +#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0 + MPU_REGION_ENTRY("XCCM", + DT_REG_ADDR(DT_INST(0, arc_xccm)), + DT_REG_SIZE(DT_INST(0, arc_xccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif + /* Region YCCM */ +#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0 + MPU_REGION_ENTRY("YCCM", + DT_REG_ADDR(DT_INST(0, arc_yccm)), + DT_REG_SIZE(DT_INST(0, arc_yccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif /* Region DDR RAM */ MPU_REGION_ENTRY("SRAM", DT_REG_ADDR(DT_INST(0, mmio_sram)), diff --git a/boards/arc/emsdp/emsdp.dts b/boards/arc/emsdp/emsdp.dts index d7268eba8e91..f09c918e2bbe 100644 --- a/boards/arc/emsdp/emsdp.dts +++ b/boards/arc/emsdp/emsdp.dts @@ -7,6 +7,7 @@ /dts-v1/; #include +#include #include "board.dtsi" / { diff --git a/boards/arc/emsdp/emsdp_em9d.dts b/boards/arc/emsdp/emsdp_em9d.dts index d7268eba8e91..5e90bda4bcfd 100644 --- a/boards/arc/emsdp/emsdp_em9d.dts +++ b/boards/arc/emsdp/emsdp_em9d.dts @@ -7,6 +7,7 @@ /dts-v1/; #include +#include #include "board.dtsi" / { @@ -22,6 +23,16 @@ zephyr,console = &uart0; zephyr,shell-uart = &uart0; }; + + xccm@c0000000 { + compatible = "arc,xccm"; + reg = <0xc0000000 DT_SIZE_K(16)>; + }; + + yccm@e0000000 { + compatible = "arc,yccm"; + reg = <0xe0000000 DT_SIZE_K(16)>; + }; }; &uart0 { diff --git a/boards/arc/iotdk/arc_mpu_regions.c b/boards/arc/iotdk/arc_mpu_regions.c index 061c613b1b73..2d0ccbb0e2eb 100644 --- a/boards/arc/iotdk/arc_mpu_regions.c +++ b/boards/arc/iotdk/arc_mpu_regions.c @@ -20,6 +20,20 @@ static struct arc_mpu_region mpu_regions[] = { DT_REG_ADDR(DT_INST(0, arc_dccm)), DT_REG_SIZE(DT_INST(0, arc_dccm)), REGION_KERNEL_RAM_ATTR), + /* Region XCCM */ +#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0 + MPU_REGION_ENTRY("XCCM", + DT_REG_ADDR(DT_INST(0, arc_xccm)), + DT_REG_SIZE(DT_INST(0, arc_xccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif + /* Region YCCM */ +#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0 + MPU_REGION_ENTRY("YCCM", + DT_REG_ADDR(DT_INST(0, arc_yccm)), + DT_REG_SIZE(DT_INST(0, arc_yccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif /* Region DDR RAM */ MPU_REGION_ENTRY("SRAM", CONFIG_SRAM_BASE_ADDRESS, diff --git a/boards/arc/iotdk/iotdk.dts b/boards/arc/iotdk/iotdk.dts index adba2b512ae5..e1bd41db5b63 100644 --- a/boards/arc/iotdk/iotdk.dts +++ b/boards/arc/iotdk/iotdk.dts @@ -7,6 +7,7 @@ /dts-v1/; #include +#include #include "board.dtsi" / { @@ -23,6 +24,16 @@ zephyr,console = &uart0; zephyr,shell-uart = &uart0; }; + + xccm@c0000000 { + compatible = "arc,xccm"; + reg = <0xc0000000 DT_SIZE_K(32)>; + }; + + yccm@e0000000 { + compatible = "arc,yccm"; + reg = <0xe0000000 DT_SIZE_K(32)>; + }; }; &cpu0 { diff --git a/boards/arc/nsim/arc_mpu_regions.c b/boards/arc/nsim/arc_mpu_regions.c index 5cb2e8b46fb5..c4bedde9948a 100644 --- a/boards/arc/nsim/arc_mpu_regions.c +++ b/boards/arc/nsim/arc_mpu_regions.c @@ -37,7 +37,20 @@ static struct arc_mpu_region mpu_regions[] = { DT_REG_SIZE(DT_INST(0, arc_dccm)), REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), #endif - +#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0 + /* Region XCCM */ + MPU_REGION_ENTRY("XCCM", + DT_REG_ADDR(DT_INST(0, arc_xccm)), + DT_REG_SIZE(DT_INST(0, arc_xccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif +#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0 + /* Region YCCM */ + MPU_REGION_ENTRY("YCCM", + DT_REG_ADDR(DT_INST(0, arc_yccm)), + DT_REG_SIZE(DT_INST(0, arc_yccm)), + REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), +#endif /* * Region peripheral is shared by secure world and normal world by default, * no need a static mpu entry. If some peripherals belong to secure world, diff --git a/boards/arc/nsim/nsim.dtsi b/boards/arc/nsim/nsim.dtsi index 7e6bbc17569c..758abaaf8f91 100644 --- a/boards/arc/nsim/nsim.dtsi +++ b/boards/arc/nsim/nsim.dtsi @@ -9,6 +9,22 @@ #include "skeleton.dtsi" #include +#ifndef ICCM_ADDR +#define ICCM_ADDR 0 +#endif + +#ifndef ICCM_SIZE +#define ICCM_SIZE DT_SIZE_K(1024) +#endif + +#ifndef DCCM_ADDR +#define DCCM_ADDR 80000000 +#endif + +#ifndef DCCM_SIZE +#define DCCM_SIZE DT_SIZE_K(1024) +#endif + / { cpus { #address-cells = <1>; diff --git a/boards/arc/nsim/nsim_em.dts b/boards/arc/nsim/nsim_em.dts index f4bcdfc999e6..3668d669eacd 100644 --- a/boards/arc/nsim/nsim_em.dts +++ b/boards/arc/nsim/nsim_em.dts @@ -8,9 +8,35 @@ #include "nsim_em.dtsi" +#ifndef XCCM_ADDR +#define XCCM_ADDR c0000000 +#endif + +#ifndef XCCM_SIZE +#define XCCM_SIZE DT_SIZE_K(64) +#endif + +#ifndef YCCM_ADDR +#define YCCM_ADDR e0000000 +#endif + +#ifndef YCCM_SIZE +#define YCCM_SIZE DT_SIZE_K(64) +#endif + / { model = "snps,nsim_em"; compatible = "snps,nsim_em"; + + xccm0: xccm@XCCM_ADDR { + compatible = "arc,xccm"; + reg = ; + }; + + yccm0: yccm@YCCM_ADDR { + compatible = "arc,yccm"; + reg = ; + }; }; &cpu0 { diff --git a/boards/arc/nsim/support/mdb_em.args b/boards/arc/nsim/support/mdb_em.args index 3ac13c742939..f88fe75f3c22 100644 --- a/boards/arc/nsim/support/mdb_em.args +++ b/boards/arc/nsim/support/mdb_em.args @@ -22,9 +22,10 @@ -Xagu_wb_depth=4 -Xagu_accord -Xxy - -Xxy_config=dccm_y - -Xxy_size=8K + -Xxy_config=dccm_x_y + -Xxy_size=64K -Xxy_interleave + -Xxy_x_base=0xc0000000 -Xxy_y_base=0xe0000000 -Xfpus_div -Xfpu_mac diff --git a/boards/arc/nsim/support/nsim_em.props b/boards/arc/nsim/support/nsim_em.props index 4e8a20eeeada..f8678ccd0ea0 100644 --- a/boards/arc/nsim/support/nsim_em.props +++ b/boards/arc/nsim/support/nsim_em.props @@ -28,9 +28,10 @@ nsim_isa_agu_wb_depth=4 nsim_isa_agu_accord=1 nsim_isa_xy=1 - nsim_isa_xy_config=dccm_y - nsim_isa_xy_size=8K + nsim_isa_xy_config=dccm_x_y + nsim_isa_xy_size=64K nsim_isa_xy_interleave=1 + nsim_isa_xy_x_base=0xc0000000 nsim_isa_xy_y_base=0xe0000000 nsim_isa_fpus_div_option=1 nsim_isa_fpu_mac_option=1 diff --git a/dts/bindings/arc/arc,xccm.yaml b/dts/bindings/arc/arc,xccm.yaml new file mode 100644 index 000000000000..d56d4d2a31f5 --- /dev/null +++ b/dts/bindings/arc/arc,xccm.yaml @@ -0,0 +1,12 @@ +# Copyright (c) 2017, synopsy +# SPDX-License-Identifier: Apache-2.0 + +description: ARC XCCM + +compatible: "arc,xccm" + +include: base.yaml + +properties: + reg: + required: true diff --git a/dts/bindings/arc/arc,yccm.yaml b/dts/bindings/arc/arc,yccm.yaml new file mode 100644 index 000000000000..3754fe2c8c7a --- /dev/null +++ b/dts/bindings/arc/arc,yccm.yaml @@ -0,0 +1,12 @@ +# Copyright (c) 2017, synopsy +# SPDX-License-Identifier: Apache-2.0 + +description: ARC YCCM + +compatible: "arc,yccm" + +include: base.yaml + +properties: + reg: + required: true diff --git a/include/zephyr/arch/arc/v2/linker.ld b/include/zephyr/arch/arc/v2/linker.ld index bfbc08cc9c4c..b658cb2144e9 100644 --- a/include/zephyr/arch/arc/v2/linker.ld +++ b/include/zephyr/arch/arc/v2/linker.ld @@ -62,6 +62,12 @@ MEMORY { #endif #ifdef DCCM_START DCCM (rw) : ORIGIN = DCCM_START, LENGTH = DCCM_SIZE +#endif +#ifdef XCCM_START + XCCM (rw) : ORIGIN = XCCM_START, LENGTH = XCCM_SIZE +#endif +#ifdef YCCM_START + YCCM (rw) : ORIGIN = YCCM_START, LENGTH = YCCM_SIZE #endif /* Used by and documented in include/linker/intlist.ld */ IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K diff --git a/include/zephyr/arch/arc/v2/xy_mem.ld b/include/zephyr/arch/arc/v2/xy_mem.ld new file mode 100644 index 000000000000..199b18763f34 --- /dev/null +++ b/include/zephyr/arch/arc/v2/xy_mem.ld @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022 Synopsys + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#if DT_NODE_HAS_PROP(DT_INST(0, arc_xccm), reg) && \ + (DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0) +#define XCCM_START DT_REG_ADDR(DT_INST(0, arc_xccm)) +#define XCCM_SIZE DT_REG_SIZE(DT_INST(0, arc_xccm)) +#endif + +#if DT_NODE_HAS_PROP(DT_INST(0, arc_yccm), reg) && \ + (DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0) +#define YCCM_START DT_REG_ADDR(DT_INST(0, arc_yccm)) +#define YCCM_SIZE DT_REG_SIZE(DT_INST(0, arc_yccm)) +#endif diff --git a/soc/arc/snps_arc_iot/linker.ld b/soc/arc/snps_arc_iot/linker.ld index 5a6e747c8e27..aec2931c8dd4 100644 --- a/soc/arc/snps_arc_iot/linker.ld +++ b/soc/arc/snps_arc_iot/linker.ld @@ -42,4 +42,5 @@ #define DCCM_SIZE DT_REG_SIZE(DT_INST(0, arc_dccm)) #endif +#include #include diff --git a/soc/arc/snps_emsdp/linker.ld b/soc/arc/snps_emsdp/linker.ld index c0c69e336dd3..3713f11da3eb 100644 --- a/soc/arc/snps_emsdp/linker.ld +++ b/soc/arc/snps_emsdp/linker.ld @@ -38,4 +38,5 @@ #define DCCM_SIZE DT_REG_SIZE(DT_INST(0, arc_dccm)) #endif +#include #include diff --git a/soc/arc/snps_emsk/linker.ld b/soc/arc/snps_emsk/linker.ld index 26b9559ad6d3..3521d6ca4ed3 100644 --- a/soc/arc/snps_emsk/linker.ld +++ b/soc/arc/snps_emsk/linker.ld @@ -39,4 +39,5 @@ #define DCCM_SIZE DT_REG_SIZE(DT_INST(0, arc_dccm)) #endif +#include #include diff --git a/soc/arc/snps_nsim/linker.ld b/soc/arc/snps_nsim/linker.ld index b1cadb620d52..fa206e5d0820 100644 --- a/soc/arc/snps_nsim/linker.ld +++ b/soc/arc/snps_nsim/linker.ld @@ -33,4 +33,5 @@ #define SRAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) #endif +#include #include