From 863f841de2c4695b1ad54df79693a2aef23c0d95 Mon Sep 17 00:00:00 2001 From: Saravanan Sekar Date: Tue, 10 Nov 2026 12:23:06 +0530 Subject: [PATCH 01/16] arch/tricore: Select the AURIX family with a Kconfig choice. ARCH_CHIP_TC3XX and ARCH_CHIP_TC4XX are two independent options with a prompt, so a configuration can enable both families, or none, and then ARCH_CHIP has no value. Make them a choice, named after the family as ARCH_CHIP_TC3X and ARCH_CHIP_TC4X like the arm chip choice (ARCH_CHIP_STM32F4, ARCH_CHIP_SAMV7), and update their users and the two board configurations. Signed-off-by: Saravanan Sekar --- arch/tricore/Kconfig | 26 ++++++++++++------- arch/tricore/include/irq.h | 2 +- arch/tricore/src/cmake/chip.cmake | 4 +-- arch/tricore/src/cmake/tasking.cmake | 8 +++--- .../tricore/src/common/aurix/tricore_asclin.h | 4 +-- .../tricore/src/common/aurix/tricore_serial.c | 12 ++++----- arch/tricore/src/common/gnu/tricore_head.S | 16 ++++++------ .../src/common/tasking/tricore_head.asm | 18 ++++++------- arch/tricore/src/common/tricore_irq.c | 2 +- arch/tricore/src/common/tricore_stm.h | 4 +-- arch/tricore/src/tc4xx/Toolchain.defs | 2 +- .../a2g-tc397-5v-tft/configs/nsh/defconfig | 2 +- .../triboard_tc4x9_com/configs/nsh/defconfig | 2 +- 13 files changed, 54 insertions(+), 48 deletions(-) diff --git a/arch/tricore/Kconfig b/arch/tricore/Kconfig index 175a06f121f7b..6937fe665ad77 100644 --- a/arch/tricore/Kconfig +++ b/arch/tricore/Kconfig @@ -81,8 +81,12 @@ config ARCH_FAMILY default "tc1v6" if ARCH_TC1V6 default "tc1v8" if ARCH_TC1V8 -config ARCH_CHIP_TC3XX - bool "infineon aurix tc3xx" +choice + prompt "AURIX family" + default ARCH_CHIP_TC3X + +config ARCH_CHIP_TC3X + bool "Infineon AURIX TC3x" select ARCH_TC1V6 select ARCH_HAVE_ADDRENV select ARCH_HAVE_MULTICPU @@ -93,10 +97,10 @@ config ARCH_CHIP_TC3XX select ONESHOT select ONESHOT_COUNT ---help--- - Infineon aurix tc3xx (six cores) + Infineon AURIX TC3x (six cores) -config ARCH_CHIP_TC4XX - bool "infineon aurix tc4xx" +config ARCH_CHIP_TC4X + bool "Infineon AURIX TC4x" select ARCH_TC1V8 select ARCH_HAVE_ADDRENV select ARCH_HAVE_FPU if !TRICORE_CSRM @@ -109,12 +113,14 @@ config ARCH_CHIP_TC4XX select ONESHOT_COUNT select HAVE_SECURITY_CORE ---help--- - Infineon aurix tc4xx (six cores and one security core) + Infineon AURIX TC4x (six cores and one security core) + +endchoice # AURIX family config ARCH_CHIP string - default "tc3xx" if ARCH_CHIP_TC3XX - default "tc4xx" if ARCH_CHIP_TC4XX + default "tc3xx" if ARCH_CHIP_TC3X + default "tc4xx" if ARCH_CHIP_TC4X config ARCH_IRQ_DISABLE_PRIORITY int "IRQ disable priority threshold" @@ -174,11 +180,11 @@ config TRICORE_TRAP_ALERT Print the trap name and reason before the trap panics. The panic message has the trap class and TIN in any case. -if ARCH_CHIP_TC3XX +if ARCH_CHIP_TC3X source "arch/tricore/src/tc3xx/Kconfig" endif -if ARCH_CHIP_TC4XX +if ARCH_CHIP_TC4X source "arch/tricore/src/tc4xx/Kconfig" endif diff --git a/arch/tricore/include/irq.h b/arch/tricore/include/irq.h index f2586278b397e..4c00e8fad1921 100644 --- a/arch/tricore/include/irq.h +++ b/arch/tricore/include/irq.h @@ -266,7 +266,7 @@ static inline_function int up_cpu_index(void) uint8_t id = tricore_mfcr(TRICORE_CPU_CORE_ID) & 0x7; -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X id = id > 5 ? 5 : id; #endif diff --git a/arch/tricore/src/cmake/chip.cmake b/arch/tricore/src/cmake/chip.cmake index c509b8f9f52a9..7b82534efe3b0 100644 --- a/arch/tricore/src/cmake/chip.cmake +++ b/arch/tricore/src/cmake/chip.cmake @@ -22,7 +22,7 @@ set(PLATFORM_FLAGS) -if(CONFIG_ARCH_CHIP_TC3XX) +if(CONFIG_ARCH_CHIP_TC3X) if(CONFIG_TRICORE_TOOLCHAIN_TASKING) add_compile_options(--default-near-size=0) add_compile_options(--cpu=tc39xb) @@ -31,7 +31,7 @@ if(CONFIG_ARCH_CHIP_TC3XX) else() list(APPEND PLATFORM_FLAGS -mcpu=tc39xx -mtc162) endif() -elseif(CONFIG_ARCH_CHIP_TC4XX) +elseif(CONFIG_ARCH_CHIP_TC4X) if(CONFIG_TRICORE_TOOLCHAIN_TASKING) add_compile_options(--misrac-version=2004 --user-mode=hypervisor) add_compile_options(--default-near-size=0) diff --git a/arch/tricore/src/cmake/tasking.cmake b/arch/tricore/src/cmake/tasking.cmake index 055b6641833a6..1cfab8c32d283 100644 --- a/arch/tricore/src/cmake/tasking.cmake +++ b/arch/tricore/src/cmake/tasking.cmake @@ -128,9 +128,9 @@ set(CMAKE_CXX_LINK_EXECUTABLE # Architecture flags add_link_options(-v) -if(CONFIG_ARCH_CHIP_TC3XX) +if(CONFIG_ARCH_CHIP_TC3X) add_compile_options($<$:--iso=11>) -elseif(CONFIG_ARCH_CHIP_TC4XX) +elseif(CONFIG_ARCH_CHIP_TC4X) add_compile_options($<$:--iso=17>) endif() add_compile_options( @@ -278,9 +278,9 @@ endif() set(NUTTX_FIND_TOOLCHAIN_LIB_DEFINED true) function(nuttx_find_toolchain_lib) if(TASKING_ROOT_PATH AND ARGN) - if(CONFIG_ARCH_CHIP_TC3XX) + if(CONFIG_ARCH_CHIP_TC3X) nuttx_add_extra_library(${TASKING_ROOT_PATH}/lib/tc162/${ARGN}) - elseif(CONFIG_ARCH_CHIP_TC4XX) + elseif(CONFIG_ARCH_CHIP_TC4X) nuttx_add_extra_library(${TASKING_ROOT_PATH}/lib/tc18/${ARGN}) endif() endif() diff --git a/arch/tricore/src/common/aurix/tricore_asclin.h b/arch/tricore/src/common/aurix/tricore_asclin.h index c6fa39d8787c8..7a598c3ffb8d9 100644 --- a/arch/tricore/src/common/aurix/tricore_asclin.h +++ b/arch/tricore/src/common/aurix/tricore_asclin.h @@ -29,9 +29,9 @@ #include -#if defined(CONFIG_ARCH_CHIP_TC3XX) +#if defined(CONFIG_ARCH_CHIP_TC3X) # include "hardware/tc3xx_asclin.h" -#elif defined(CONFIG_ARCH_CHIP_TC4XX) +#elif defined(CONFIG_ARCH_CHIP_TC4X) # include "hardware/tc4xx_asclin.h" #endif diff --git a/arch/tricore/src/common/aurix/tricore_serial.c b/arch/tricore/src/common/aurix/tricore_serial.c index 675f4dafdf83e..99db36be1d26d 100644 --- a/arch/tricore/src/common/aurix/tricore_serial.c +++ b/arch/tricore/src/common/aurix/tricore_serial.c @@ -46,10 +46,10 @@ #include "tricore_internal.h" #include "tricore_asclin.h" -#if defined(CONFIG_ARCH_CHIP_TC3XX) +#if defined(CONFIG_ARCH_CHIP_TC3X) # include "hardware/tc3xx_port.h" # include "tc3xx_wdt.h" -#elif defined(CONFIG_ARCH_CHIP_TC4XX) +#elif defined(CONFIG_ARCH_CHIP_TC4X) # include "hardware/tc4xx_port.h" #endif @@ -240,7 +240,7 @@ static void asclin_modify(uintptr_t reg, uint32_t clear, uint32_t set) static void asclin_pin_config(uintptr_t port, int pin, bool tx) { -#if defined(CONFIG_ARCH_CHIP_TC3XX) +#if defined(CONFIG_ARCH_CHIP_TC3X) int shift = TC3XX_PORT_IOCR_SHIFT(pin); asclin_modify(TC3XX_PORT_IOCR(port, pin), TC3XX_PORT_IOCR_MASK << shift, @@ -251,7 +251,7 @@ static void asclin_pin_config(uintptr_t port, int pin, bool tx) asclin_modify(TC3XX_PORT_PDR(port, pin), TC3XX_PORT_PDR_MASK << shift, TC3XX_PORT_PAD_SPEED1 << shift); tc3xx_wdt_cpu_endinit(true); -#elif defined(CONFIG_ARCH_CHIP_TC4XX) +#elif defined(CONFIG_ARCH_CHIP_TC4X) uintptr_t drvcfg = TC4XX_PORT_DRVCFG(port, pin); asclin_modify(drvcfg, TC4XX_PORT_DRVCFG_MODE_MASK, @@ -359,11 +359,11 @@ static void asclin_init(struct up_dev_s *priv) { /* Enable the module, under the CPU ENDINIT on TC3xx */ -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X tc3xx_wdt_cpu_endinit(false); #endif asclin_modify(ASCLIN_REG(priv, CLC), ASCLIN_CLC_DISR, 0); -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X tc3xx_wdt_cpu_endinit(true); #endif diff --git a/arch/tricore/src/common/gnu/tricore_head.S b/arch/tricore/src/common/gnu/tricore_head.S index be92cb482833b..797766adfe90c 100644 --- a/arch/tricore/src/common/gnu/tricore_head.S +++ b/arch/tricore/src/common/gnu/tricore_head.S @@ -34,10 +34,10 @@ #define TRICORE_PSW_RESET 0x980 /* Supervisor, call depth counting on */ #define TRICORE_BIV_VECTOR 0x1fe0 /* Single interrupt vector at INTTAB + 0x1fe0 */ -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X # define TC3XX_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ #endif -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X # define TC4XX_PSW_VIRT 0xb00 /* PSW for disabling the virtualization */ #endif @@ -91,7 +91,7 @@ tricore_head: movh.a %a9, hi:__a9_mem lea %a9, [%a9]lo:__a9_mem -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X jl tc3xx_endinit_clear #endif @@ -101,7 +101,7 @@ tricore_head: mtcr TRICORE_CPU_BTV, %d15 isync -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X movh.a %a15, hi:__psram_boot_csa lea %a15, [%a15]lo:__psram_boot_csa mov.d %d15, %a15 @@ -189,7 +189,7 @@ tricore_head: mtcr TRICORE_CPU_LCX, %d15 isync -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X jl tc3xx_endinit_set #endif @@ -201,7 +201,7 @@ tricore_head: mtcr TRICORE_CPU_PSW, %d0 isync -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X call tricore_wdt_disable #endif @@ -243,7 +243,7 @@ tricore_head: lea %a15, [%a15]lo:tricore_start ji %a15 -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X /**************************************************************************** * Name: tc3xx_endinit_clear, tc3xx_endinit_set * @@ -293,7 +293,7 @@ tc3xx_endinit_set: ji %a11 #endif -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X /**************************************************************************** * Name: tricore_virt_off * diff --git a/arch/tricore/src/common/tasking/tricore_head.asm b/arch/tricore/src/common/tasking/tricore_head.asm index 2e6cbf9d270e3..bcb69ebeb1295 100644 --- a/arch/tricore/src/common/tasking/tricore_head.asm +++ b/arch/tricore/src/common/tasking/tricore_head.asm @@ -34,10 +34,10 @@ #define TRICORE_PSW_RESET 0x980 /* Supervisor, call depth counting on */ #define TRICORE_BIV_VECTOR 0x1fe0 /* Single interrupt vector at INTTAB + 0x1fe0 */ -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X # define TC3XX_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ #endif -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X # define TC4XX_PSW_VIRT 0xb00 /* PSW for disabling the virtualization */ #endif @@ -70,7 +70,7 @@ tricore_csa_link .macro addr, tmp1, tmp2 .extern __TRAPTAB_CPU0 .extern __INTTAB_CPU0 .extern __psram_ustack -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X .extern __psram_boot_csa .extern __psram_boot_csa_end .extern tricore_ram_init @@ -116,7 +116,7 @@ tricore_head: movh.a a9, #@HIS(__a9_mem) lea a9, [a9]@LOS(__a9_mem) -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X jl tc3xx_endinit_clear #endif @@ -126,7 +126,7 @@ tricore_head: mtcr #TRICORE_CPU_BTV, d15 isync -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X movh.a a15, #@HIS(__psram_boot_csa) lea a15, [a15]@LOS(__psram_boot_csa) mov.d d15, a15 @@ -213,7 +213,7 @@ tricore_head: mtcr #TRICORE_CPU_LCX, d15 isync -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X jl tc3xx_endinit_set #endif @@ -225,7 +225,7 @@ tricore_head: mtcr #TRICORE_CPU_PSW, d0 isync -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X call tricore_wdt_disable #endif @@ -266,7 +266,7 @@ tricore_head: lea a15, [a15]@LOS(tricore_start) ji a15 -#ifdef CONFIG_ARCH_CHIP_TC3XX +#ifdef CONFIG_ARCH_CHIP_TC3X /**************************************************************************** * Name: tc3xx_endinit_clear, tc3xx_endinit_set * @@ -313,7 +313,7 @@ tc3xx_endinit_set: ji a11 #endif -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X /**************************************************************************** * Name: tricore_virt_off * diff --git a/arch/tricore/src/common/tricore_irq.c b/arch/tricore/src/common/tricore_irq.c index 4176c35906aed..e4d3a3555ef35 100644 --- a/arch/tricore/src/common/tricore_irq.c +++ b/arch/tricore/src/common/tricore_irq.c @@ -127,7 +127,7 @@ static void tricore_gpsrinitialize(void) /* Cpucs gpsr init */ -#ifndef CONFIG_ARCH_CHIP_TC3XX +#ifndef CONFIG_ARCH_CHIP_TC3X tricore_src_init(TRICORE_IRQ2SRC(TRICORE_GPSR_IRQNUM(6, cpu)), tos, IRQ_TO_NDX(TRICORE_GPSR_IRQNUM(6, cpu))); #endif diff --git a/arch/tricore/src/common/tricore_stm.h b/arch/tricore/src/common/tricore_stm.h index 66bfda87ca95d..813cd0c0777d8 100644 --- a/arch/tricore/src/common/tricore_stm.h +++ b/arch/tricore/src/common/tricore_stm.h @@ -35,7 +35,7 @@ /* System timer hardware registers. */ -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X # define TRICORE_STM_BASE(n) (0xf8800000 + ((n) << 18)) /* STMn */ # define TRICORE_STM_SRC(n) (0xf4432028 + (n) * 0x40) /* SR2 */ @@ -69,7 +69,7 @@ /* OCS can only be written with OCDS enabled */ -#ifdef CONFIG_ARCH_CHIP_TC4XX +#ifdef CONFIG_ARCH_CHIP_TC4X # define TRICORE_CBS_OSTATE 0xfa18006c #else # define TRICORE_CBS_OSTATE 0xf0000480 diff --git a/arch/tricore/src/tc4xx/Toolchain.defs b/arch/tricore/src/tc4xx/Toolchain.defs index c7c5a5e5ac82e..0f030aea2881a 100644 --- a/arch/tricore/src/tc4xx/Toolchain.defs +++ b/arch/tricore/src/tc4xx/Toolchain.defs @@ -20,7 +20,7 @@ # ############################################################################ -ifeq ($(CONFIG_ARCH_CHIP_TC4XX),y) +ifeq ($(CONFIG_ARCH_CHIP_TC4X),y) ifeq ($(CONFIG_TRICORE_TOOLCHAIN_TASKING),y) ARCHCPUFLAGS += --misrac-version=2004 --user-mode=hypervisor ARCHCPUFLAGS += --default-near-size=0 diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig b/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig index 3d60fa5ef5f5f..9f7dd1e41378a 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig +++ b/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig @@ -11,7 +11,7 @@ CONFIG_ARCH_BOARD="a2g-tc397-5v-tft" CONFIG_ARCH_BOARD_A2G_TC397_5V_TFT=y CONFIG_ARCH_CHIP="tc3xx" CONFIG_ARCH_CHIP_TC39X=y -CONFIG_ARCH_CHIP_TC3XX=y +CONFIG_ARCH_CHIP_TC3X=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_NUSER_INTERRUPTS=48 CONFIG_ARCH_STACKDUMP=y diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/configs/nsh/defconfig b/boards/tricore/tc4xx/triboard_tc4x9_com/configs/nsh/defconfig index 4d82ca70f48cb..5dda49ae9c06d 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/configs/nsh/defconfig +++ b/boards/tricore/tc4xx/triboard_tc4x9_com/configs/nsh/defconfig @@ -11,7 +11,7 @@ CONFIG_ARCH_BOARD="triboard_tc4x9_com" CONFIG_ARCH_BOARD_TRIBOARD_TC4X9_COM=y CONFIG_ARCH_CHIP="tc4xx" CONFIG_ARCH_CHIP_TC4DX=y -CONFIG_ARCH_CHIP_TC4XX=y +CONFIG_ARCH_CHIP_TC4X=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_NUSER_INTERRUPTS=48 CONFIG_ARCH_STACKDUMP=y From 14c0eb20edfb0d4c451da30f47095e084ab54f47 Mon Sep 17 00:00:00 2001 From: Saravanan Sekar Date: Tue, 10 Nov 2026 12:23:06 +0530 Subject: [PATCH 02/16] arch/tricore: Name the TC3xx chip option after the part. The TC3xx chip option ARCH_CHIP_TC39X names the TC39x series. Name it after the part of the a2g-tc397-5v-tft board, ARCH_CHIP_TC397, as the arm chips do (ARCH_CHIP_STM32F407VG), so that further TC3xx parts can be added to its choice, and update the board dependency and configuration. The TC4xx option ARCH_CHIP_TC4DX keeps its name. Both chip choices get a plain prompt. Signed-off-by: Saravanan Sekar --- arch/tricore/src/tc3xx/Kconfig | 8 ++++---- arch/tricore/src/tc3xx/Toolchain.defs | 2 +- arch/tricore/src/tc4xx/Kconfig | 4 ++-- boards/Kconfig | 2 +- .../tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/tricore/src/tc3xx/Kconfig b/arch/tricore/src/tc3xx/Kconfig index b69c664062531..66ca027eecab6 100644 --- a/arch/tricore/src/tc3xx/Kconfig +++ b/arch/tricore/src/tc3xx/Kconfig @@ -25,11 +25,11 @@ # choice - prompt "TC3XX Chip Selection" - default ARCH_CHIP_TC39X + prompt "Infineon AURIX TC3x chip selection" + default ARCH_CHIP_TC397 -config ARCH_CHIP_TC39X - bool "TC3XX TC39X" +config ARCH_CHIP_TC397 + bool "TC397 SoC" endchoice diff --git a/arch/tricore/src/tc3xx/Toolchain.defs b/arch/tricore/src/tc3xx/Toolchain.defs index 7d9aa7a757918..175c921863121 100644 --- a/arch/tricore/src/tc3xx/Toolchain.defs +++ b/arch/tricore/src/tc3xx/Toolchain.defs @@ -20,7 +20,7 @@ # ############################################################################ -ifeq ($(CONFIG_ARCH_CHIP_TC39X),y) +ifeq ($(CONFIG_ARCH_CHIP_TC397),y) ifeq ($(CONFIG_TRICORE_TOOLCHAIN_TASKING),y) ARCHCPUFLAGS += --cpu=tc39xb ARCHCPUFLAGS += --default-near-size=0 diff --git a/arch/tricore/src/tc4xx/Kconfig b/arch/tricore/src/tc4xx/Kconfig index 53da2474ffed0..5d9aa9949e061 100644 --- a/arch/tricore/src/tc4xx/Kconfig +++ b/arch/tricore/src/tc4xx/Kconfig @@ -25,11 +25,11 @@ # choice - prompt "TC4XX Chip Selection" + prompt "Infineon AURIX TC4x chip selection" default ARCH_CHIP_TC4DX config ARCH_CHIP_TC4DX - bool "TC4XX TC4DX" + bool "TC4Dx SoC" endchoice diff --git a/boards/Kconfig b/boards/Kconfig index 0360b2e58d87b..433abc1177703 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -2872,7 +2872,7 @@ config ARCH_BOARD_QEMU_RH850_U2C config ARCH_BOARD_A2G_TC397_5V_TFT bool "Infineon's AURIX TC397 board: KIT_A2G_TC397_5V_TFT" - depends on ARCH_CHIP_TC39X + depends on ARCH_CHIP_TC397 ---help--- This options selects support for NuttX on the Infineon's AURIX board board featuring the TC397 6Quad CPU. diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig b/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig index 9f7dd1e41378a..f58f8b2f500ee 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig +++ b/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig @@ -10,7 +10,7 @@ CONFIG_ARCH="tricore" CONFIG_ARCH_BOARD="a2g-tc397-5v-tft" CONFIG_ARCH_BOARD_A2G_TC397_5V_TFT=y CONFIG_ARCH_CHIP="tc3xx" -CONFIG_ARCH_CHIP_TC39X=y +CONFIG_ARCH_CHIP_TC397=y CONFIG_ARCH_CHIP_TC3X=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_NUSER_INTERRUPTS=48 From e8960884431ea63328a1ad35af2bac0ac35cc145 Mon Sep 17 00:00:00 2001 From: Saravanan Sekar Date: Tue, 10 Nov 2026 12:23:06 +0530 Subject: [PATCH 03/16] arch/tricore: Move the UART option to the AURIX Kconfig. The ASCLIN UART driver is common to TC3xx and TC4xx, but each family has its own option for it, TC3XX_UART0 and TC4XX_UART0, which the driver has to combine. Replace both with TRICORE_UART0 in a new src/common/aurix/Kconfig, for the options of the common AURIX drivers. It keeps the default of y, so the board configurations do not change. Signed-off-by: Saravanan Sekar --- arch/tricore/Kconfig | 2 ++ arch/tricore/src/common/aurix/Kconfig | 16 ++++++++++++++++ arch/tricore/src/common/aurix/tricore_serial.c | 14 +++++--------- arch/tricore/src/tc3xx/Kconfig | 12 ------------ arch/tricore/src/tc4xx/Kconfig | 12 ------------ 5 files changed, 23 insertions(+), 33 deletions(-) create mode 100644 arch/tricore/src/common/aurix/Kconfig diff --git a/arch/tricore/Kconfig b/arch/tricore/Kconfig index 6937fe665ad77..fc2ea7c29e8d1 100644 --- a/arch/tricore/Kconfig +++ b/arch/tricore/Kconfig @@ -180,6 +180,8 @@ config TRICORE_TRAP_ALERT Print the trap name and reason before the trap panics. The panic message has the trap class and TIN in any case. +source "arch/tricore/src/common/aurix/Kconfig" + if ARCH_CHIP_TC3X source "arch/tricore/src/tc3xx/Kconfig" endif diff --git a/arch/tricore/src/common/aurix/Kconfig b/arch/tricore/src/common/aurix/Kconfig new file mode 100644 index 0000000000000..7c56d5f50ce67 --- /dev/null +++ b/arch/tricore/src/common/aurix/Kconfig @@ -0,0 +1,16 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menu "AURIX Peripheral Support" + +config TRICORE_UART0 + bool "ASCLIN0 UART" + default y + select UART0_SERIALDRIVER + select ARCH_HAVE_SERIAL_TERMIOS + ---help--- + Use ASCLIN0 as UART0, on the P14.1 RX and P14.0 TX pins. + +endmenu diff --git a/arch/tricore/src/common/aurix/tricore_serial.c b/arch/tricore/src/common/aurix/tricore_serial.c index 99db36be1d26d..e7f4d6660c40e 100644 --- a/arch/tricore/src/common/aurix/tricore_serial.c +++ b/arch/tricore/src/common/aurix/tricore_serial.c @@ -59,10 +59,6 @@ * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_TC3XX_UART0) || defined(CONFIG_TC4XX_UART0) -# define HAVE_UART0 1 -#endif - /* Bit timing: fPD is fASCLINF, 16 times oversampling, sample point 8 */ #define ASCLIN_PRESCALER 1 @@ -87,7 +83,7 @@ * be ttyS0. If there is no console then will use the lowest numbered UART. */ -#if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(HAVE_UART0) +#if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_TRICORE_UART0) # define HAVE_SERIAL_CONSOLE 1 #else # undef CONFIG_UART0_SERIAL_CONSOLE @@ -105,7 +101,7 @@ #else # undef CONSOLE_DEV /* No console */ # undef CONFIG_UART0_SERIAL_CONSOLE -# if defined(HAVE_UART0) +# if defined(CONFIG_TRICORE_UART0) # define TTYS0_DEV g_uart0port /* UART0 is ttyS0 */ # define SERIAL_CONSOLE 1 # else @@ -114,7 +110,7 @@ #endif #undef HAVE_UART_DEVICE -#if defined(HAVE_UART0) +#if defined(CONFIG_TRICORE_UART0) # define HAVE_UART_DEVICE 1 #endif @@ -180,12 +176,12 @@ static const struct uart_ops_s g_uart_ops = /* I/O buffers */ -#ifdef HAVE_UART0 +#ifdef CONFIG_TRICORE_UART0 static char g_uart0rxbuffer[CONFIG_UART0_RXBUFSIZE]; static char g_uart0txbuffer[CONFIG_UART0_TXBUFSIZE]; #endif -#ifdef HAVE_UART0 +#ifdef CONFIG_TRICORE_UART0 static struct up_dev_s g_uart0priv = { diff --git a/arch/tricore/src/tc3xx/Kconfig b/arch/tricore/src/tc3xx/Kconfig index 66ca027eecab6..c8e339c613500 100644 --- a/arch/tricore/src/tc3xx/Kconfig +++ b/arch/tricore/src/tc3xx/Kconfig @@ -38,15 +38,3 @@ comment "TC3XX Configuration Options" config CPU_CLOCK_FREQUENCY int "CPU clock frequency (Hz)" default 300000000 - -menu "TC3XX Peripheral Support" - -# These are the peripheral selections proper - -config TC3XX_UART0 - bool "TC3XX UART0" - default y - select UART0_SERIALDRIVER - select ARCH_HAVE_SERIAL_TERMIOS - -endmenu diff --git a/arch/tricore/src/tc4xx/Kconfig b/arch/tricore/src/tc4xx/Kconfig index 5d9aa9949e061..0371e84a87de9 100644 --- a/arch/tricore/src/tc4xx/Kconfig +++ b/arch/tricore/src/tc4xx/Kconfig @@ -38,15 +38,3 @@ comment "TC4XX Configuration Options" config CPU_CLOCK_FREQUENCY int "CPU clock frequency (Hz)" default 500000000 - -menu "TC4XX Peripheral Support" - -# These are the peripheral selections proper - -config TC4XX_UART0 - bool "TC4XX UART0" - default y - select UART0_SERIALDRIVER - select ARCH_HAVE_SERIAL_TERMIOS - -endmenu From db8f7fb35fe5f011031bafccf2f64a282ed65e83 Mon Sep 17 00:00:00 2001 From: Saravanan Sekar Date: Tue, 10 Nov 2026 12:23:36 +0530 Subject: [PATCH 04/16] arch/tricore: Drop the empty arch/chip/chip.h headers. The public chip.h of TC3xx and TC4xx has been empty since the system timer, ASCLIN and startup definitions moved to the internal headers, and only the UART driver still includes it. Drop both headers and that include. Signed-off-by: Saravanan Sekar --- arch/tricore/include/tc3xx/chip.h | 48 ------------------- arch/tricore/include/tc4xx/chip.h | 48 ------------------- .../tricore/src/common/aurix/tricore_serial.c | 2 - 3 files changed, 98 deletions(-) delete mode 100644 arch/tricore/include/tc3xx/chip.h delete mode 100644 arch/tricore/include/tc4xx/chip.h diff --git a/arch/tricore/include/tc3xx/chip.h b/arch/tricore/include/tc3xx/chip.h deleted file mode 100644 index 1fa1dbfdd718d..0000000000000 --- a/arch/tricore/include/tc3xx/chip.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** - * arch/tricore/include/tc3xx/chip.h - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_TRICORE_INCLUDE_TC3XX_CHIP_H -#define __ARCH_TRICORE_INCLUDE_TC3XX_CHIP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Functions Prototypes - ****************************************************************************/ - -#endif /* __ARCH_TRICORE_INCLUDE_TC3XX_CHIP_H */ diff --git a/arch/tricore/include/tc4xx/chip.h b/arch/tricore/include/tc4xx/chip.h deleted file mode 100644 index 07cec2547151c..0000000000000 --- a/arch/tricore/include/tc4xx/chip.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** - * arch/tricore/include/tc4xx/chip.h - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_TRICORE_INCLUDE_TC4XX_CHIP_H -#define __ARCH_TRICORE_INCLUDE_TC4XX_CHIP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Functions Prototypes - ****************************************************************************/ - -#endif /* __ARCH_TRICORE_INCLUDE_TC4XX_CHIP_H */ diff --git a/arch/tricore/src/common/aurix/tricore_serial.c b/arch/tricore/src/common/aurix/tricore_serial.c index e7f4d6660c40e..eacdac7d44ed8 100644 --- a/arch/tricore/src/common/aurix/tricore_serial.c +++ b/arch/tricore/src/common/aurix/tricore_serial.c @@ -41,8 +41,6 @@ #include -#include - #include "tricore_internal.h" #include "tricore_asclin.h" From 2fee2f907c63e0f358901b50007f1f3074ad5145 Mon Sep 17 00:00:00 2001 From: Saravanan Sekar Date: Tue, 10 Nov 2026 12:23:37 +0530 Subject: [PATCH 05/16] arch/tricore: Rename tc3xx and tc4xx to tc3x and tc4x. The chip family options are ARCH_CHIP_TC3X and ARCH_CHIP_TC4X, but the chip and board directories, file names and identifiers still use tc3xx and tc4xx. Rename arch/tricore/src, arch/tricore/include, boards/tricore and Documentation/platforms/tricore tc3xx and tc4xx to tc3x and tc4x, ARCH_CHIP with them, the chip file names and the tc3xx_, tc4xx_, TC3XX_ and TC4XX_ prefixes, keeping the aligned columns. The board names stay. The chip and board directories both follow ARCH_CHIP, so they move in one step. No functional change. The Make.defs files move together with their CMakeLists.txt, and the board Make.defs only change the Toolchain.defs path, which CMake takes from ARCH_CHIP [skip-cmake-parity]. Signed-off-by: Saravanan Sekar --- .../boards/a2g-tc397-5v-tft/index.rst | 0 .../tricore/{tc3xx => tc3x}/index.rst | 0 .../boards/triboard_tc4x9_com/index.rst | 0 .../tricore/{tc4xx => tc4x}/index.rst | 0 arch/tricore/Kconfig | 10 +- arch/tricore/include/{tc3xx => tc3x}/irq.h | 8 +- arch/tricore/include/{tc4xx => tc4x}/irq.h | 8 +- .../tricore/src/common/aurix/tricore_asclin.h | 4 +- .../tricore/src/common/aurix/tricore_serial.c | 34 +- arch/tricore/src/common/gnu/tricore_head.S | 26 +- .../src/common/tasking/tricore_head.asm | 22 +- arch/tricore/src/common/tricore_hwdebug.c | 6 +- arch/tricore/src/{tc3xx => tc3x}/.gitignore | 0 .../src/{tc3xx => tc3x}/CMakeLists.txt | 4 +- arch/tricore/src/{tc3xx => tc3x}/Kconfig | 4 +- arch/tricore/src/{tc3xx => tc3x}/Make.defs | 10 +- .../src/{tc3xx => tc3x}/Toolchain.defs | 2 +- arch/tricore/src/{tc3xx => tc3x}/chip.h | 16 +- .../hardware/tc3x_asclin.h} | 8 +- arch/tricore/src/tc3x/hardware/tc3x_clock.h | 78 +++ .../tc3xx_cpu.h => tc3x/hardware/tc3x_cpu.h} | 16 +- .../hardware/tc3x_port.h} | 30 +- .../tc3xx_smu.h => tc3x/hardware/tc3x_smu.h} | 20 +- .../tc3xx_wdt.h => tc3x/hardware/tc3x_wdt.h} | 30 +- arch/tricore/src/tc3x/tc3x_clockconfig.c | 484 +++++++++++++++ .../tc4xx_timerisr.c => tc3x/tc3x_timerisr.c} | 2 +- .../{tc3xx/tc3xx_wdt.c => tc3x/tc3x_wdt.c} | 64 +- .../{tc3xx/tc3xx_wdt.h => tc3x/tc3x_wdt.h} | 12 +- arch/tricore/src/tc3xx/hardware/tc3xx_clock.h | 78 --- arch/tricore/src/tc3xx/tc3xx_clockconfig.c | 484 --------------- .../src/{tc4xx => tc4x}/CMakeLists.txt | 4 +- arch/tricore/src/{tc4xx => tc4x}/Kconfig | 4 +- arch/tricore/src/{tc4xx => tc4x}/Make.defs | 12 +- .../src/{tc4xx => tc4x}/Toolchain.defs | 2 +- arch/tricore/src/{tc4xx => tc4x}/chip.h | 16 +- .../hardware/tc4x_asclin.h} | 8 +- arch/tricore/src/tc4x/hardware/tc4x_clock.h | 100 +++ .../tc4xx_cpu.h => tc4x/hardware/tc4x_cpu.h} | 14 +- .../tc4xx_dmu.h => tc4x/hardware/tc4x_dmu.h} | 14 +- .../hardware/tc4x_port.h} | 20 +- .../tc4xx_smu.h => tc4x/hardware/tc4x_smu.h} | 20 +- .../tc4xx_vmt.h => tc4x/hardware/tc4x_vmt.h} | 36 +- .../tc4xx_wdt.h => tc4x/hardware/tc4x_wdt.h} | 34 +- arch/tricore/src/tc4x/tc4x_clockconfig.c | 587 ++++++++++++++++++ .../{tc4xx/tc4xx_ram.c => tc4x/tc4x_ram.c} | 90 +-- .../tc3xx_timerisr.c => tc4x/tc4x_timerisr.c} | 2 +- .../{tc4xx/tc4xx_wdt.c => tc4x/tc4x_wdt.c} | 76 +-- .../{tc4xx/tc4xx_wdt.h => tc4x/tc4x_wdt.h} | 10 +- arch/tricore/src/tc4xx/hardware/tc4xx_clock.h | 100 --- arch/tricore/src/tc4xx/tc4xx_clockconfig.c | 587 ------------------ boards/Kconfig | 2 +- .../a2g-tc397-5v-tft/CMakeLists.txt | 2 +- .../{tc3xx => tc3x}/a2g-tc397-5v-tft/Kconfig | 2 +- .../a2g-tc397-5v-tft/configs/nsh/defconfig | 2 +- .../a2g-tc397-5v-tft/include/board.h | 8 +- .../include/board_memorymap.h | 8 +- .../a2g-tc397-5v-tft/kernel/CMakeLists.txt | 2 +- .../a2g-tc397-5v-tft/kernel/tc397_userspace.c | 2 +- .../scripts/Lcf_Gnuc_Tricore_Tc.lsl.user | 2 +- .../scripts/Lcf_Tasking_Tricore_Tc.lsl.user | 2 +- .../a2g-tc397-5v-tft/scripts/Make.defs | 4 +- .../a2g-tc397-5v-tft/scripts/tricore.ld | 2 +- .../a2g-tc397-5v-tft/scripts/tricore.lsl | 6 +- .../a2g-tc397-5v-tft/src/CMakeLists.txt | 2 +- .../a2g-tc397-5v-tft/src/Makefile | 2 +- .../a2g-tc397-5v-tft/src/tc397.h | 8 +- .../a2g-tc397-5v-tft/src/tc397_boardinit.c | 2 +- .../a2g-tc397-5v-tft/src/tc397_bringup.c | 2 +- .../a2g-tc397-5v-tft/src/tc397_userspace.c | 2 +- .../triboard_tc4x9_com/CMakeLists.txt | 2 +- .../triboard_tc4x9_com/Kconfig | 2 +- .../triboard_tc4x9_com/configs/nsh/defconfig | 2 +- .../triboard_tc4x9_com/include/board.h | 8 +- .../include/board_memorymap.h | 8 +- .../triboard_tc4x9_com/kernel/CMakeLists.txt | 2 +- .../kernel/tc4d9_userspace.c | 2 +- .../scripts/Lcf_Gnuc_Tricore_Tc.lsl.user | 2 +- .../scripts/Lcf_Tasking_Tricore_Tc.lsl.user | 2 +- .../triboard_tc4x9_com/scripts/Make.defs | 4 +- .../triboard_tc4x9_com/scripts/tricore.ld | 2 +- .../triboard_tc4x9_com/scripts/tricore.lsl | 6 +- .../triboard_tc4x9_com/src/CMakeLists.txt | 2 +- .../triboard_tc4x9_com/src/Makefile | 2 +- .../triboard_tc4x9_com/src/tc4d9_userspace.c | 2 +- .../triboard_tc4x9_com/src/tc4da.h | 8 +- .../triboard_tc4x9_com/src/tc4da_boardinit.c | 2 +- .../triboard_tc4x9_com/src/tc4da_bringup.c | 2 +- 87 files changed, 1659 insertions(+), 1659 deletions(-) rename Documentation/platforms/tricore/{tc3xx => tc3x}/boards/a2g-tc397-5v-tft/index.rst (100%) rename Documentation/platforms/tricore/{tc3xx => tc3x}/index.rst (100%) rename Documentation/platforms/tricore/{tc4xx => tc4x}/boards/triboard_tc4x9_com/index.rst (100%) rename Documentation/platforms/tricore/{tc4xx => tc4x}/index.rst (100%) rename arch/tricore/include/{tc3xx => tc3x}/irq.h (94%) rename arch/tricore/include/{tc4xx => tc4x}/irq.h (95%) rename arch/tricore/src/{tc3xx => tc3x}/.gitignore (100%) rename arch/tricore/src/{tc3xx => tc3x}/CMakeLists.txt (91%) rename arch/tricore/src/{tc3xx => tc3x}/Kconfig (94%) rename arch/tricore/src/{tc3xx => tc3x}/Make.defs (89%) rename arch/tricore/src/{tc3xx => tc3x}/Toolchain.defs (97%) rename arch/tricore/src/{tc3xx => tc3x}/chip.h (86%) rename arch/tricore/src/{tc3xx/hardware/tc3xx_asclin.h => tc3x/hardware/tc3x_asclin.h} (88%) create mode 100644 arch/tricore/src/tc3x/hardware/tc3x_clock.h rename arch/tricore/src/{tc3xx/hardware/tc3xx_cpu.h => tc3x/hardware/tc3x_cpu.h} (75%) rename arch/tricore/src/{tc3xx/hardware/tc3xx_port.h => tc3x/hardware/tc3x_port.h} (64%) rename arch/tricore/src/{tc3xx/hardware/tc3xx_smu.h => tc3x/hardware/tc3x_smu.h} (71%) rename arch/tricore/src/{tc3xx/hardware/tc3xx_wdt.h => tc3x/hardware/tc3x_wdt.h} (60%) create mode 100644 arch/tricore/src/tc3x/tc3x_clockconfig.c rename arch/tricore/src/{tc4xx/tc4xx_timerisr.c => tc3x/tc3x_timerisr.c} (98%) rename arch/tricore/src/{tc3xx/tc3xx_wdt.c => tc3x/tc3x_wdt.c} (69%) rename arch/tricore/src/{tc3xx/tc3xx_wdt.h => tc3x/tc3x_wdt.h} (84%) delete mode 100644 arch/tricore/src/tc3xx/hardware/tc3xx_clock.h delete mode 100644 arch/tricore/src/tc3xx/tc3xx_clockconfig.c rename arch/tricore/src/{tc4xx => tc4x}/CMakeLists.txt (90%) rename arch/tricore/src/{tc4xx => tc4x}/Kconfig (94%) rename arch/tricore/src/{tc4xx => tc4x}/Make.defs (87%) rename arch/tricore/src/{tc4xx => tc4x}/Toolchain.defs (97%) rename arch/tricore/src/{tc4xx => tc4x}/chip.h (85%) rename arch/tricore/src/{tc4xx/hardware/tc4xx_asclin.h => tc4x/hardware/tc4x_asclin.h} (88%) create mode 100644 arch/tricore/src/tc4x/hardware/tc4x_clock.h rename arch/tricore/src/{tc4xx/hardware/tc4xx_cpu.h => tc4x/hardware/tc4x_cpu.h} (76%) rename arch/tricore/src/{tc4xx/hardware/tc4xx_dmu.h => tc4x/hardware/tc4x_dmu.h} (78%) rename arch/tricore/src/{tc4xx/hardware/tc4xx_port.h => tc4x/hardware/tc4x_port.h} (68%) rename arch/tricore/src/{tc4xx/hardware/tc4xx_smu.h => tc4x/hardware/tc4x_smu.h} (71%) rename arch/tricore/src/{tc4xx/hardware/tc4xx_vmt.h => tc4x/hardware/tc4x_vmt.h} (60%) rename arch/tricore/src/{tc4xx/hardware/tc4xx_wdt.h => tc4x/hardware/tc4x_wdt.h} (57%) create mode 100644 arch/tricore/src/tc4x/tc4x_clockconfig.c rename arch/tricore/src/{tc4xx/tc4xx_ram.c => tc4x/tc4x_ram.c} (62%) rename arch/tricore/src/{tc3xx/tc3xx_timerisr.c => tc4x/tc4x_timerisr.c} (98%) rename arch/tricore/src/{tc4xx/tc4xx_wdt.c => tc4x/tc4x_wdt.c} (65%) rename arch/tricore/src/{tc4xx/tc4xx_wdt.h => tc4x/tc4x_wdt.h} (85%) delete mode 100644 arch/tricore/src/tc4xx/hardware/tc4xx_clock.h delete mode 100644 arch/tricore/src/tc4xx/tc4xx_clockconfig.c rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/CMakeLists.txt (95%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/Kconfig (95%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/configs/nsh/defconfig (98%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/include/board.h (86%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/include/board_memorymap.h (98%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/kernel/CMakeLists.txt (94%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/kernel/tc397_userspace.c (97%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user (99%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user (98%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/scripts/Make.defs (94%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/scripts/tricore.ld (98%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/scripts/tricore.lsl (97%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/src/CMakeLists.txt (96%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/src/Makefile (95%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/src/tc397.h (90%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/src/tc397_boardinit.c (98%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/src/tc397_bringup.c (97%) rename boards/tricore/{tc3xx => tc3x}/a2g-tc397-5v-tft/src/tc397_userspace.c (97%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/CMakeLists.txt (94%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/Kconfig (95%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/configs/nsh/defconfig (98%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/include/board.h (85%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/include/board_memorymap.h (98%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/kernel/CMakeLists.txt (94%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/kernel/tc4d9_userspace.c (97%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user (99%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user (98%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/scripts/Make.defs (94%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/scripts/tricore.ld (98%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/scripts/tricore.lsl (98%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/src/CMakeLists.txt (96%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/src/Makefile (95%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/src/tc4d9_userspace.c (97%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/src/tc4da.h (90%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/src/tc4da_boardinit.c (98%) rename boards/tricore/{tc4xx => tc4x}/triboard_tc4x9_com/src/tc4da_bringup.c (97%) diff --git a/Documentation/platforms/tricore/tc3xx/boards/a2g-tc397-5v-tft/index.rst b/Documentation/platforms/tricore/tc3x/boards/a2g-tc397-5v-tft/index.rst similarity index 100% rename from Documentation/platforms/tricore/tc3xx/boards/a2g-tc397-5v-tft/index.rst rename to Documentation/platforms/tricore/tc3x/boards/a2g-tc397-5v-tft/index.rst diff --git a/Documentation/platforms/tricore/tc3xx/index.rst b/Documentation/platforms/tricore/tc3x/index.rst similarity index 100% rename from Documentation/platforms/tricore/tc3xx/index.rst rename to Documentation/platforms/tricore/tc3x/index.rst diff --git a/Documentation/platforms/tricore/tc4xx/boards/triboard_tc4x9_com/index.rst b/Documentation/platforms/tricore/tc4x/boards/triboard_tc4x9_com/index.rst similarity index 100% rename from Documentation/platforms/tricore/tc4xx/boards/triboard_tc4x9_com/index.rst rename to Documentation/platforms/tricore/tc4x/boards/triboard_tc4x9_com/index.rst diff --git a/Documentation/platforms/tricore/tc4xx/index.rst b/Documentation/platforms/tricore/tc4x/index.rst similarity index 100% rename from Documentation/platforms/tricore/tc4xx/index.rst rename to Documentation/platforms/tricore/tc4x/index.rst diff --git a/arch/tricore/Kconfig b/arch/tricore/Kconfig index fc2ea7c29e8d1..b382b90bf36be 100644 --- a/arch/tricore/Kconfig +++ b/arch/tricore/Kconfig @@ -119,8 +119,8 @@ endchoice # AURIX family config ARCH_CHIP string - default "tc3xx" if ARCH_CHIP_TC3X - default "tc4xx" if ARCH_CHIP_TC4X + default "tc3x" if ARCH_CHIP_TC3X + default "tc4x" if ARCH_CHIP_TC4X config ARCH_IRQ_DISABLE_PRIORITY int "IRQ disable priority threshold" @@ -165,7 +165,7 @@ config ARCH_HAVE_PPRS config HAVE_SECURITY_CORE bool ---help--- - In addition to the 6 cores, tc4xx also has one more security core. + In addition to the 6 cores, tc4x also has one more security core. config CPU_COREID int "TRICORE CPU CORE ID" @@ -183,11 +183,11 @@ config TRICORE_TRAP_ALERT source "arch/tricore/src/common/aurix/Kconfig" if ARCH_CHIP_TC3X -source "arch/tricore/src/tc3xx/Kconfig" +source "arch/tricore/src/tc3x/Kconfig" endif if ARCH_CHIP_TC4X -source "arch/tricore/src/tc4xx/Kconfig" +source "arch/tricore/src/tc4x/Kconfig" endif endif # ARCH_TRICORE diff --git a/arch/tricore/include/tc3xx/irq.h b/arch/tricore/include/tc3x/irq.h similarity index 94% rename from arch/tricore/include/tc3xx/irq.h rename to arch/tricore/include/tc3x/irq.h index 387b332f9b315..c9980e131de73 100644 --- a/arch/tricore/include/tc3xx/irq.h +++ b/arch/tricore/include/tc3x/irq.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/include/tc3xx/irq.h + * arch/tricore/include/tc3x/irq.h * * SPDX-License-Identifier: Apache-2.0 * @@ -24,8 +24,8 @@ * only indirectly through nuttx/irq.h */ -#ifndef __ARCH_TRICORE_INCLUDE_TC3XX_IRQ_H -#define __ARCH_TRICORE_INCLUDE_TC3XX_IRQ_H +#ifndef __ARCH_TRICORE_INCLUDE_TC3X_IRQ_H +#define __ARCH_TRICORE_INCLUDE_TC3X_IRQ_H /**************************************************************************** * Included Files @@ -83,4 +83,4 @@ extern "C" #endif #endif -#endif /* __ARCH_TRICORE_INCLUDE_TC3XX_IRQ_H */ +#endif /* __ARCH_TRICORE_INCLUDE_TC3X_IRQ_H */ diff --git a/arch/tricore/include/tc4xx/irq.h b/arch/tricore/include/tc4x/irq.h similarity index 95% rename from arch/tricore/include/tc4xx/irq.h rename to arch/tricore/include/tc4x/irq.h index 7a5e51e4ef2df..c1d93de20f74b 100644 --- a/arch/tricore/include/tc4xx/irq.h +++ b/arch/tricore/include/tc4x/irq.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/include/tc4xx/irq.h + * arch/tricore/include/tc4x/irq.h * * SPDX-License-Identifier: Apache-2.0 * @@ -24,8 +24,8 @@ * only indirectly through nuttx/irq.h */ -#ifndef __ARCH_TRICORE_INCLUDE_TC4XX_IRQ_H -#define __ARCH_TRICORE_INCLUDE_TC4XX_IRQ_H +#ifndef __ARCH_TRICORE_INCLUDE_TC4X_IRQ_H +#define __ARCH_TRICORE_INCLUDE_TC4X_IRQ_H /**************************************************************************** * Included Files @@ -85,4 +85,4 @@ extern "C" #endif #endif -#endif /* __ARCH_TRICORE_INCLUDE_TC4XX_IRQ_H */ +#endif /* __ARCH_TRICORE_INCLUDE_TC4X_IRQ_H */ diff --git a/arch/tricore/src/common/aurix/tricore_asclin.h b/arch/tricore/src/common/aurix/tricore_asclin.h index 7a598c3ffb8d9..3bce6c309e778 100644 --- a/arch/tricore/src/common/aurix/tricore_asclin.h +++ b/arch/tricore/src/common/aurix/tricore_asclin.h @@ -30,9 +30,9 @@ #include #if defined(CONFIG_ARCH_CHIP_TC3X) -# include "hardware/tc3xx_asclin.h" +# include "hardware/tc3x_asclin.h" #elif defined(CONFIG_ARCH_CHIP_TC4X) -# include "hardware/tc4xx_asclin.h" +# include "hardware/tc4x_asclin.h" #endif /**************************************************************************** diff --git a/arch/tricore/src/common/aurix/tricore_serial.c b/arch/tricore/src/common/aurix/tricore_serial.c index eacdac7d44ed8..e446c55098282 100644 --- a/arch/tricore/src/common/aurix/tricore_serial.c +++ b/arch/tricore/src/common/aurix/tricore_serial.c @@ -45,10 +45,10 @@ #include "tricore_asclin.h" #if defined(CONFIG_ARCH_CHIP_TC3X) -# include "hardware/tc3xx_port.h" -# include "tc3xx_wdt.h" +# include "hardware/tc3x_port.h" +# include "tc3x_wdt.h" #elif defined(CONFIG_ARCH_CHIP_TC4X) -# include "hardware/tc4xx_port.h" +# include "hardware/tc4x_port.h" #endif #include @@ -235,22 +235,22 @@ static void asclin_modify(uintptr_t reg, uint32_t clear, uint32_t set) static void asclin_pin_config(uintptr_t port, int pin, bool tx) { #if defined(CONFIG_ARCH_CHIP_TC3X) - int shift = TC3XX_PORT_IOCR_SHIFT(pin); + int shift = TC3X_PORT_IOCR_SHIFT(pin); - asclin_modify(TC3XX_PORT_IOCR(port, pin), TC3XX_PORT_IOCR_MASK << shift, - (tx ? TC3XX_PORT_OUT_ALT2 : TC3XX_PORT_IN_PULLUP) << shift); + asclin_modify(TC3X_PORT_IOCR(port, pin), TC3X_PORT_IOCR_MASK << shift, + (tx ? TC3X_PORT_OUT_ALT2 : TC3X_PORT_IN_PULLUP) << shift); - shift = TC3XX_PORT_PDR_SHIFT(pin); - tc3xx_wdt_cpu_endinit(false); - asclin_modify(TC3XX_PORT_PDR(port, pin), TC3XX_PORT_PDR_MASK << shift, - TC3XX_PORT_PAD_SPEED1 << shift); - tc3xx_wdt_cpu_endinit(true); + shift = TC3X_PORT_PDR_SHIFT(pin); + tc3x_wdt_cpu_endinit(false); + asclin_modify(TC3X_PORT_PDR(port, pin), TC3X_PORT_PDR_MASK << shift, + TC3X_PORT_PAD_SPEED1 << shift); + tc3x_wdt_cpu_endinit(true); #elif defined(CONFIG_ARCH_CHIP_TC4X) - uintptr_t drvcfg = TC4XX_PORT_DRVCFG(port, pin); + uintptr_t drvcfg = TC4X_PORT_DRVCFG(port, pin); - asclin_modify(drvcfg, TC4XX_PORT_DRVCFG_MODE_MASK, - tx ? TC4XX_PORT_OUT_ALT2 : TC4XX_PORT_IN_PULLUP); - asclin_modify(drvcfg, TC4XX_PORT_DRVCFG_PAD_MASK, TC4XX_PORT_PAD_SPEED1); + asclin_modify(drvcfg, TC4X_PORT_DRVCFG_MODE_MASK, + tx ? TC4X_PORT_OUT_ALT2 : TC4X_PORT_IN_PULLUP); + asclin_modify(drvcfg, TC4X_PORT_DRVCFG_PAD_MASK, TC4X_PORT_PAD_SPEED1); #endif } @@ -354,11 +354,11 @@ static void asclin_init(struct up_dev_s *priv) /* Enable the module, under the CPU ENDINIT on TC3xx */ #ifdef CONFIG_ARCH_CHIP_TC3X - tc3xx_wdt_cpu_endinit(false); + tc3x_wdt_cpu_endinit(false); #endif asclin_modify(ASCLIN_REG(priv, CLC), ASCLIN_CLC_DISR, 0); #ifdef CONFIG_ARCH_CHIP_TC3X - tc3xx_wdt_cpu_endinit(true); + tc3x_wdt_cpu_endinit(true); #endif /* Clock off, initialise mode, bit timing and baud rate */ diff --git a/arch/tricore/src/common/gnu/tricore_head.S b/arch/tricore/src/common/gnu/tricore_head.S index 797766adfe90c..13c39adf79d47 100644 --- a/arch/tricore/src/common/gnu/tricore_head.S +++ b/arch/tricore/src/common/gnu/tricore_head.S @@ -35,10 +35,10 @@ #define TRICORE_BIV_VECTOR 0x1fe0 /* Single interrupt vector at INTTAB + 0x1fe0 */ #ifdef CONFIG_ARCH_CHIP_TC3X -# define TC3XX_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ +# define TC3X_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ #endif #ifdef CONFIG_ARCH_CHIP_TC4X -# define TC4XX_PSW_VIRT 0xb00 /* PSW for disabling the virtualization */ +# define TC4X_PSW_VIRT 0xb00 /* PSW for disabling the virtualization */ #endif /* Make the CSA link word of the CSA address in addr: the segment in bits @@ -92,7 +92,7 @@ tricore_head: lea %a9, [%a9]lo:__a9_mem #ifdef CONFIG_ARCH_CHIP_TC3X - jl tc3xx_endinit_clear + jl tc3x_endinit_clear #endif movh.a %a15, hi:__TRAPTAB_CPU0 @@ -190,7 +190,7 @@ tricore_head: isync #ifdef CONFIG_ARCH_CHIP_TC3X - jl tc3xx_endinit_set + jl tc3x_endinit_set #endif movh.a %sp, hi:__ustack @@ -245,23 +245,23 @@ tricore_head: #ifdef CONFIG_ARCH_CHIP_TC3X /**************************************************************************** - * Name: tc3xx_endinit_clear, tc3xx_endinit_set + * Name: tc3x_endinit_clear, tc3x_endinit_set * * Description: - * Clear (tc3xx_endinit_clear) or set (tc3xx_endinit_set) the ENDINIT + * Clear (tc3x_endinit_clear) or set (tc3x_endinit_set) the ENDINIT * of the watchdog of the calling CPU with the password and the lock * sequence, and wait until it has changed. Called with jl, before * any CSA exists. CPU5 has the core ID 6 on TC39x. * ****************************************************************************/ - .type tc3xx_endinit_clear, %function -tc3xx_endinit_clear: + .type tc3x_endinit_clear, %function +tc3x_endinit_clear: mov %d5, 0 j 2f - .type tc3xx_endinit_set, %function -tc3xx_endinit_set: + .type tc3x_endinit_set, %function +tc3x_endinit_set: mov %d5, 1 2: mfcr %d4, TRICORE_CPU_CORE_ID @@ -271,8 +271,8 @@ tc3xx_endinit_set: 3: sh %d15, %d4, 1 add %d4, %d15, %d4 - movh.a %a15, hi:TC3XX_WDTCPU0_CON0 - lea %a15, [%a15]lo:TC3XX_WDTCPU0_CON0 + movh.a %a15, hi:TC3X_WDTCPU0_CON0 + lea %a15, [%a15]lo:TC3X_WDTCPU0_CON0 addsc.a %a15, %a15, %d4, 2 /* Password access with the inverted password bits 7:2, then the @@ -307,7 +307,7 @@ tricore_virt_off: mov %d0, 0 mtcr TRICORE_CPU_VCON0, %d0 isync - mov %d0, TC4XX_PSW_VIRT + mov %d0, TC4X_PSW_VIRT mtcr TRICORE_CPU_PSW, %d0 isync rfh diff --git a/arch/tricore/src/common/tasking/tricore_head.asm b/arch/tricore/src/common/tasking/tricore_head.asm index bcb69ebeb1295..58d0493dfc2cb 100644 --- a/arch/tricore/src/common/tasking/tricore_head.asm +++ b/arch/tricore/src/common/tasking/tricore_head.asm @@ -35,10 +35,10 @@ #define TRICORE_BIV_VECTOR 0x1fe0 /* Single interrupt vector at INTTAB + 0x1fe0 */ #ifdef CONFIG_ARCH_CHIP_TC3X -# define TC3XX_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ +# define TC3X_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ #endif #ifdef CONFIG_ARCH_CHIP_TC4X -# define TC4XX_PSW_VIRT 0xb00 /* PSW for disabling the virtualization */ +# define TC4X_PSW_VIRT 0xb00 /* PSW for disabling the virtualization */ #endif /* Make the CSA link word of the CSA address in addr: the segment in bits @@ -117,7 +117,7 @@ tricore_head: lea a9, [a9]@LOS(__a9_mem) #ifdef CONFIG_ARCH_CHIP_TC3X - jl tc3xx_endinit_clear + jl tc3x_endinit_clear #endif movh.a a15, #@HIS(__TRAPTAB_CPU0) @@ -214,7 +214,7 @@ tricore_head: isync #ifdef CONFIG_ARCH_CHIP_TC3X - jl tc3xx_endinit_set + jl tc3x_endinit_set #endif movh.a a10, #@HIS(__ustack) @@ -268,21 +268,21 @@ tricore_head: #ifdef CONFIG_ARCH_CHIP_TC3X /**************************************************************************** - * Name: tc3xx_endinit_clear, tc3xx_endinit_set + * Name: tc3x_endinit_clear, tc3x_endinit_set * * Description: - * Clear (tc3xx_endinit_clear) or set (tc3xx_endinit_set) the ENDINIT + * Clear (tc3x_endinit_clear) or set (tc3x_endinit_set) the ENDINIT * of the watchdog of the calling CPU with the password and the lock * sequence, and wait until it has changed. Called with jl, before * any CSA exists. CPU5 has the core ID 6 on TC39x. * ****************************************************************************/ -tc3xx_endinit_clear: +tc3x_endinit_clear: mov d5, #0 j 2n -tc3xx_endinit_set: +tc3x_endinit_set: mov d5, #1 2: mfcr d4, #TRICORE_CPU_CORE_ID @@ -292,8 +292,8 @@ tc3xx_endinit_set: 3: sh d15, d4, #1 add d4, d15, d4 - movh.a a15, #@HIS(TC3XX_WDTCPU0_CON0) - lea a15, [a15]@LOS(TC3XX_WDTCPU0_CON0) + movh.a a15, #@HIS(TC3X_WDTCPU0_CON0) + lea a15, [a15]@LOS(TC3X_WDTCPU0_CON0) addsc.a a15, a15, d4, #2 ; Password access with the inverted password bits 7:2, then the @@ -326,7 +326,7 @@ tricore_virt_off: mov d0, #0 mtcr #TRICORE_CPU_VCON0, d0 isync - mov d0, #TC4XX_PSW_VIRT + mov d0, #TC4X_PSW_VIRT mtcr #TRICORE_CPU_PSW, d0 isync rfh diff --git a/arch/tricore/src/common/tricore_hwdebug.c b/arch/tricore/src/common/tricore_hwdebug.c index b11534bca33af..483fc85b9995d 100644 --- a/arch/tricore/src/common/tricore_hwdebug.c +++ b/arch/tricore/src/common/tricore_hwdebug.c @@ -68,8 +68,8 @@ #define TC_TREVT_TYP_OFF 12 /* 0: watchpoint 1: breakpoint */ #define TC_TREVT_AST_OFF 27 /* Address store trigger */ #define TC_TREVT_ALD_OFF 28 /* Address load trigger */ -#define TC_TREVT_EVTA_MSK 0x7 /* EVTA field mask (tc3xx) */ -#define TC_TREVT_EN_MSK 0x1 /* EN bit mask (tc4xx) */ +#define TC_TREVT_EVTA_MSK 0x7 /* EVTA field mask (tc3x) */ +#define TC_TREVT_EN_MSK 0x1 /* EN bit mask (tc4x) */ #define TC_DBGSR_EVTSRC_OFF 8 #define TC_DBGSR_EVTSRC_MSK 0x1f @@ -94,7 +94,7 @@ #define TREVT_DEBUG_WP_ALD (1 << TC_TREVT_ALD_OFF) #define TREVT_DEBUG_WP_ASTLD (TREVT_DEBUG_WP_AST | TREVT_DEBUG_WP_ALD) -/* Register TREVT[2:0] have difference between tc3xx and tc4xx */ +/* Register TREVT[2:0] have difference between tc3x and tc4x */ #ifdef CONFIG_ARCH_TC1V6 #define TREVT_CFG_REG_EN_MASK TC_TREVT_EVTA_MSK diff --git a/arch/tricore/src/tc3xx/.gitignore b/arch/tricore/src/tc3x/.gitignore similarity index 100% rename from arch/tricore/src/tc3xx/.gitignore rename to arch/tricore/src/tc3x/.gitignore diff --git a/arch/tricore/src/tc3xx/CMakeLists.txt b/arch/tricore/src/tc3x/CMakeLists.txt similarity index 91% rename from arch/tricore/src/tc3xx/CMakeLists.txt rename to arch/tricore/src/tc3x/CMakeLists.txt index 42bee43a4a685..105dcf348d015 100644 --- a/arch/tricore/src/tc3xx/CMakeLists.txt +++ b/arch/tricore/src/tc3x/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# arch/tricore/src/tc3xx/CMakeLists.txt +# arch/tricore/src/tc3x/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # @@ -20,7 +20,7 @@ # # ############################################################################## -set(SRCS tc3xx_timerisr.c tc3xx_wdt.c tc3xx_clockconfig.c) +set(SRCS tc3x_timerisr.c tc3x_wdt.c tc3x_clockconfig.c) target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/tricore/src/tc3xx/Kconfig b/arch/tricore/src/tc3x/Kconfig similarity index 94% rename from arch/tricore/src/tc3xx/Kconfig rename to arch/tricore/src/tc3x/Kconfig index c8e339c613500..6212c8e7bcf02 100644 --- a/arch/tricore/src/tc3xx/Kconfig +++ b/arch/tricore/src/tc3x/Kconfig @@ -1,5 +1,5 @@ ############################################################################ -# arch/tricore/src/tc3xx/Kconfig +# arch/tricore/src/tc3x/Kconfig # # SPDX-License-Identifier: Apache-2.0 # @@ -33,7 +33,7 @@ config ARCH_CHIP_TC397 endchoice -comment "TC3XX Configuration Options" +comment "TC3X Configuration Options" config CPU_CLOCK_FREQUENCY int "CPU clock frequency (Hz)" diff --git a/arch/tricore/src/tc3xx/Make.defs b/arch/tricore/src/tc3x/Make.defs similarity index 89% rename from arch/tricore/src/tc3xx/Make.defs rename to arch/tricore/src/tc3x/Make.defs index dc3c77d2f7912..a9820890995d4 100644 --- a/arch/tricore/src/tc3xx/Make.defs +++ b/arch/tricore/src/tc3x/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# arch/tricore/src/tc3xx/Make.defs +# arch/tricore/src/tc3x/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -20,9 +20,9 @@ # ############################################################################ -CHIP_CSRCS += tc3xx_timerisr.c -CHIP_CSRCS += tc3xx_wdt.c -CHIP_CSRCS += tc3xx_clockconfig.c +CHIP_CSRCS += tc3x_timerisr.c +CHIP_CSRCS += tc3x_wdt.c +CHIP_CSRCS += tc3x_clockconfig.c include common/aurix/Make.defs @@ -31,7 +31,7 @@ ifeq ($(CONFIG_BUILD_PROTECTED),y) VPATH += $(BOARD_DIR)/kernel endif -VPATH += tc3xx +VPATH += tc3x # The TASKING link takes libc_fpu.a from here diff --git a/arch/tricore/src/tc3xx/Toolchain.defs b/arch/tricore/src/tc3x/Toolchain.defs similarity index 97% rename from arch/tricore/src/tc3xx/Toolchain.defs rename to arch/tricore/src/tc3x/Toolchain.defs index 175c921863121..6138ff84a6ef6 100644 --- a/arch/tricore/src/tc3xx/Toolchain.defs +++ b/arch/tricore/src/tc3x/Toolchain.defs @@ -1,5 +1,5 @@ ############################################################################ -# arch/tricore/src/tc3xx/Toolchain.defs +# arch/tricore/src/tc3x/Toolchain.defs # # SPDX-License-Identifier: Apache-2.0 # diff --git a/arch/tricore/src/tc3xx/chip.h b/arch/tricore/src/tc3x/chip.h similarity index 86% rename from arch/tricore/src/tc3xx/chip.h rename to arch/tricore/src/tc3x/chip.h index d56c9c13c8588..7d7af365efdad 100644 --- a/arch/tricore/src/tc3xx/chip.h +++ b/arch/tricore/src/tc3x/chip.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/chip.h + * arch/tricore/src/tc3x/chip.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,14 +20,14 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC3XX_CHIP_H -#define __ARCH_TRICORE_SRC_TC3XX_CHIP_H +#ifndef __ARCH_TRICORE_SRC_TC3X_CHIP_H +#define __ARCH_TRICORE_SRC_TC3X_CHIP_H /**************************************************************************** * Included Files ****************************************************************************/ -#include "hardware/tc3xx_cpu.h" +#include "hardware/tc3x_cpu.h" /* UART0 pins: ASCLIN0 RXA on P14.1, TX on P14.0 (alternate output 2) */ @@ -51,9 +51,9 @@ */ #define TRICORE_START_CORES 1 -#define TRICORE_START_PC(n) TC3XX_CPU_PC(n) -#define TRICORE_START_HALT(n) TC3XX_CPU_SYSCON(n) -#define TRICORE_START_BHALT TC3XX_SYSCON_BHALT +#define TRICORE_START_PC(n) TC3X_CPU_PC(n) +#define TRICORE_START_HALT(n) TC3X_CPU_SYSCON(n) +#define TRICORE_START_BHALT TC3X_SYSCON_BHALT /* Core index from CORE_ID; CPU5 has the core ID 6 on TC39x */ @@ -61,4 +61,4 @@ #define tricore_core_index() (tricore_core_id() > 5 ? 5 : \ tricore_core_id()) -#endif /* __ARCH_TRICORE_SRC_TC3XX_CHIP_H */ +#endif /* __ARCH_TRICORE_SRC_TC3X_CHIP_H */ diff --git a/arch/tricore/src/tc3xx/hardware/tc3xx_asclin.h b/arch/tricore/src/tc3x/hardware/tc3x_asclin.h similarity index 88% rename from arch/tricore/src/tc3xx/hardware/tc3xx_asclin.h rename to arch/tricore/src/tc3x/hardware/tc3x_asclin.h index 4a47432179c93..e406567a42257 100644 --- a/arch/tricore/src/tc3xx/hardware/tc3xx_asclin.h +++ b/arch/tricore/src/tc3x/hardware/tc3x_asclin.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/hardware/tc3xx_asclin.h + * arch/tricore/src/tc3x/hardware/tc3x_asclin.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_ASCLIN_H -#define __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_ASCLIN_H +#ifndef __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_ASCLIN_H +#define __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_ASCLIN_H /**************************************************************************** * Pre-processor Definitions @@ -45,4 +45,4 @@ #define ASCLIN_RXDATA_OFFSET 0x048 #define ASCLIN_CSR_OFFSET 0x04c -#endif /* __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_ASCLIN_H */ +#endif /* __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_ASCLIN_H */ diff --git a/arch/tricore/src/tc3x/hardware/tc3x_clock.h b/arch/tricore/src/tc3x/hardware/tc3x_clock.h new file mode 100644 index 0000000000000..3fdfa4ce947ce --- /dev/null +++ b/arch/tricore/src/tc3x/hardware/tc3x_clock.h @@ -0,0 +1,78 @@ +/**************************************************************************** + * arch/tricore/src/tc3x/hardware/tc3x_clock.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_CLOCK_H +#define __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_CLOCK_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* SCU clock control unit (CCU) registers */ + +#define TC3X_SCU_OSCCON 0xf0036010 +#define TC3X_SCU_SYSPLLSTAT 0xf0036014 +#define TC3X_SCU_SYSPLLCON0 0xf0036018 +#define TC3X_SCU_SYSPLLCON1 0xf003601c +#define TC3X_SCU_PERPLLSTAT 0xf0036024 +#define TC3X_SCU_PERPLLCON0 0xf0036028 +#define TC3X_SCU_PERPLLCON1 0xf003602c +#define TC3X_SCU_CCUCON0 0xf0036030 +#define TC3X_SCU_CCUCON1 0xf0036034 +#define TC3X_SCU_CCUCON2 0xf0036040 +#define TC3X_SCU_CCUCON5 0xf003604c +#define TC3X_SCU_CCUCON6 0xf0036080 /* CCUCON6 to CCUCON11 */ + +#define TC3X_OSCCON_PLLLV (1 << 1) +#define TC3X_OSCCON_MODE_MASK (0x3 << 5) +#define TC3X_OSCCON_PLLHV (1 << 8) +#define TC3X_OSCCON_OSCVAL_SHIFT 16 +#define TC3X_OSCCON_OSCVAL_MASK (0x1f << TC3X_OSCCON_OSCVAL_SHIFT) + +#define TC3X_PLLCON0_DIVBY (1 << 0) /* PERPLLCON0 only */ +#define TC3X_PLLCON0_NDIV_SHIFT 9 +#define TC3X_PLLCON0_NDIV_MASK (0x7f << TC3X_PLLCON0_NDIV_SHIFT) +#define TC3X_PLLCON0_PLLPWD (1 << 16) +#define TC3X_PLLCON0_RESLD (1 << 18) +#define TC3X_PLLCON0_PDIV_SHIFT 24 +#define TC3X_PLLCON0_PDIV_MASK (0x7 << TC3X_PLLCON0_PDIV_SHIFT) +#define TC3X_PLLCON0_INSEL_SHIFT 30 /* SYSPLLCON0 only */ +#define TC3X_PLLCON0_INSEL_MASK (0x3 << TC3X_PLLCON0_INSEL_SHIFT) + +#define TC3X_PLLCON1_K2DIV_MASK (0x7 << 0) +#define TC3X_PLLCON1_K3DIV_SHIFT 8 /* PERPLLCON1 only */ +#define TC3X_PLLCON1_K3DIV_MASK (0x7 << TC3X_PLLCON1_K3DIV_SHIFT) + +#define TC3X_PLLSTAT_PWDSTAT (1 << 1) +#define TC3X_PLLSTAT_LOCK (1 << 2) +#define TC3X_PLLSTAT_K3RDY (1 << 4) /* PERPLLSTAT only */ +#define TC3X_PLLSTAT_K2RDY (1 << 5) + +#define TC3X_CCUCON_UP (1 << 30) +#define TC3X_CCUCON_LCK (1 << 31) +#define TC3X_CCUCON0_CLKSEL_MASK (0x3 << 28) +#define TC3X_CCUCON0_CLKSEL_PLL (0x1 << 28) +#define TC3X_CCUCON1_CLKSEL_MASK ((0x3 << 4) | (0x3 << 20) | (0x3 << 28)) +#define TC3X_CCUCON2_ASCLINFDIV (0xf << 0) +#define TC3X_CCUCON2_CLKSEL_MASK (0x3 << 12) + +#endif /* __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_CLOCK_H */ diff --git a/arch/tricore/src/tc3xx/hardware/tc3xx_cpu.h b/arch/tricore/src/tc3x/hardware/tc3x_cpu.h similarity index 75% rename from arch/tricore/src/tc3xx/hardware/tc3xx_cpu.h rename to arch/tricore/src/tc3x/hardware/tc3x_cpu.h index 7b5b2e4107de2..71f7f89742773 100644 --- a/arch/tricore/src/tc3xx/hardware/tc3xx_cpu.h +++ b/arch/tricore/src/tc3x/hardware/tc3x_cpu.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/hardware/tc3xx_cpu.h + * arch/tricore/src/tc3x/hardware/tc3x_cpu.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_CPU_H -#define __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_CPU_H +#ifndef __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_CPU_H +#define __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_CPU_H /**************************************************************************** * Pre-processor Definitions @@ -31,10 +31,10 @@ * of the CPUs are 0x20000 apart, but those of CPU5 are at 0xf88c0000. */ -#define TC3XX_CPU_CSFR(n) ((n) < 5 ? 0xf8800000 + (n) * 0x20000 : \ +#define TC3X_CPU_CSFR(n) ((n) < 5 ? 0xf8800000 + (n) * 0x20000 : \ 0xf88c0000) -#define TC3XX_CPU_PC(n) (TC3XX_CPU_CSFR(n) + 0x1fe08) -#define TC3XX_CPU_SYSCON(n) (TC3XX_CPU_CSFR(n) + 0x1fe14) -#define TC3XX_SYSCON_BHALT (1 << 24) +#define TC3X_CPU_PC(n) (TC3X_CPU_CSFR(n) + 0x1fe08) +#define TC3X_CPU_SYSCON(n) (TC3X_CPU_CSFR(n) + 0x1fe14) +#define TC3X_SYSCON_BHALT (1 << 24) -#endif /* __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_CPU_H */ +#endif /* __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_CPU_H */ diff --git a/arch/tricore/src/tc3xx/hardware/tc3xx_port.h b/arch/tricore/src/tc3x/hardware/tc3x_port.h similarity index 64% rename from arch/tricore/src/tc3xx/hardware/tc3xx_port.h rename to arch/tricore/src/tc3x/hardware/tc3x_port.h index 767e269620f74..28988a92cdfd2 100644 --- a/arch/tricore/src/tc3xx/hardware/tc3xx_port.h +++ b/arch/tricore/src/tc3x/hardware/tc3x_port.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/hardware/tc3xx_port.h + * arch/tricore/src/tc3x/hardware/tc3x_port.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_PORT_H -#define __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_PORT_H +#ifndef __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_PORT_H +#define __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_PORT_H /**************************************************************************** * Pre-processor Definitions @@ -31,20 +31,20 @@ * protected by the CPU ENDINIT. */ -#define TC3XX_PORT_IOCR0_OFFSET 0x10 -#define TC3XX_PORT_PDR0_OFFSET 0x40 +#define TC3X_PORT_IOCR0_OFFSET 0x10 +#define TC3X_PORT_PDR0_OFFSET 0x40 -#define TC3XX_PORT_IOCR(p, n) ((p) + TC3XX_PORT_IOCR0_OFFSET + \ +#define TC3X_PORT_IOCR(p, n) ((p) + TC3X_PORT_IOCR0_OFFSET + \ ((n) / 4) * 4) -#define TC3XX_PORT_IOCR_SHIFT(n) (((n) & 3) * 8) -#define TC3XX_PORT_IOCR_MASK 0xff -#define TC3XX_PORT_PDR(p, n) ((p) + TC3XX_PORT_PDR0_OFFSET + \ +#define TC3X_PORT_IOCR_SHIFT(n) (((n) & 3) * 8) +#define TC3X_PORT_IOCR_MASK 0xff +#define TC3X_PORT_PDR(p, n) ((p) + TC3X_PORT_PDR0_OFFSET + \ ((n) / 8) * 4) -#define TC3XX_PORT_PDR_SHIFT(n) (((n) & 7) * 4) -#define TC3XX_PORT_PDR_MASK 0xf +#define TC3X_PORT_PDR_SHIFT(n) (((n) & 7) * 4) +#define TC3X_PORT_PDR_MASK 0xf -#define TC3XX_PORT_IN_PULLUP 0x10 /* Input with pull-up */ -#define TC3XX_PORT_OUT_ALT2 0x90 /* Push-pull, alternate 2 */ -#define TC3XX_PORT_PAD_SPEED1 0 /* CMOS automotive speed 1 */ +#define TC3X_PORT_IN_PULLUP 0x10 /* Input with pull-up */ +#define TC3X_PORT_OUT_ALT2 0x90 /* Push-pull, alternate 2 */ +#define TC3X_PORT_PAD_SPEED1 0 /* CMOS automotive speed 1 */ -#endif /* __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_PORT_H */ +#endif /* __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_PORT_H */ diff --git a/arch/tricore/src/tc3xx/hardware/tc3xx_smu.h b/arch/tricore/src/tc3x/hardware/tc3x_smu.h similarity index 71% rename from arch/tricore/src/tc3xx/hardware/tc3xx_smu.h rename to arch/tricore/src/tc3x/hardware/tc3x_smu.h index 7c21b0f300f92..5a4e908062852 100644 --- a/arch/tricore/src/tc3xx/hardware/tc3xx_smu.h +++ b/arch/tricore/src/tc3x/hardware/tc3x_smu.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/hardware/tc3xx_smu.h + * arch/tricore/src/tc3x/hardware/tc3x_smu.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_SMU_H -#define __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_SMU_H +#ifndef __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_SMU_H +#define __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_SMU_H /**************************************************************************** * Pre-processor Definitions @@ -29,12 +29,12 @@ /* Safety management unit (SMU) registers */ -#define TC3XX_SMU_CMD 0xf0036820 -#define TC3XX_SMU_KEYS 0xf0036834 -#define TC3XX_SMU_AGCF8(n) (0xf0036960 + (n) * 4) -#define TC3XX_SMU_AG8 0xf00369e0 +#define TC3X_SMU_CMD 0xf0036820 +#define TC3X_SMU_KEYS 0xf0036834 +#define TC3X_SMU_AGCF8(n) (0xf0036960 + (n) * 4) +#define TC3X_SMU_AG8 0xf00369e0 -#define TC3XX_SMU_KEYS_CFG 0xbc -#define TC3XX_SMU_CMD_ALARM_CLR 0x5 +#define TC3X_SMU_KEYS_CFG 0xbc +#define TC3X_SMU_CMD_ALARM_CLR 0x5 -#endif /* __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_SMU_H */ +#endif /* __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_SMU_H */ diff --git a/arch/tricore/src/tc3xx/hardware/tc3xx_wdt.h b/arch/tricore/src/tc3x/hardware/tc3x_wdt.h similarity index 60% rename from arch/tricore/src/tc3xx/hardware/tc3xx_wdt.h rename to arch/tricore/src/tc3x/hardware/tc3x_wdt.h index 6d3764a1063a6..8175050320803 100644 --- a/arch/tricore/src/tc3xx/hardware/tc3xx_wdt.h +++ b/arch/tricore/src/tc3x/hardware/tc3x_wdt.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/hardware/tc3xx_wdt.h + * arch/tricore/src/tc3x/hardware/tc3x_wdt.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_WDT_H -#define __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_WDT_H +#ifndef __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_WDT_H +#define __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_WDT_H /**************************************************************************** * Pre-processor Definitions @@ -29,20 +29,20 @@ /* SCU watchdog timers: one per CPU and the safety watchdog */ -#define TC3XX_SCU_WDTCPU_CON0(n) (0xf003624c + (n) * 0xc) -#define TC3XX_SCU_WDTCPU_CON1(n) (0xf0036250 + (n) * 0xc) -#define TC3XX_SCU_WDTS_CON0 0xf00362a8 -#define TC3XX_SCU_WDTS_CON1 0xf00362ac +#define TC3X_SCU_WDTCPU_CON0(n) (0xf003624c + (n) * 0xc) +#define TC3X_SCU_WDTCPU_CON1(n) (0xf0036250 + (n) * 0xc) +#define TC3X_SCU_WDTS_CON0 0xf00362a8 +#define TC3X_SCU_WDTS_CON1 0xf00362ac -#define TC3XX_WDT_CON0_ENDINIT (1 << 0) /* End of init */ -#define TC3XX_WDT_CON0_LCK (1 << 1) /* Lock */ -#define TC3XX_WDT_CON0_PW_SHIFT 2 /* Password */ -#define TC3XX_WDT_CON0_PW_MASK (0x3fff << TC3XX_WDT_CON0_PW_SHIFT) -#define TC3XX_WDT_CON0_REL_MASK (0xffff << 16) /* Reload value */ -#define TC3XX_WDT_CON1_DR (1 << 3) /* Disable request */ +#define TC3X_WDT_CON0_ENDINIT (1 << 0) /* End of init */ +#define TC3X_WDT_CON0_LCK (1 << 1) /* Lock */ +#define TC3X_WDT_CON0_PW_SHIFT 2 /* Password */ +#define TC3X_WDT_CON0_PW_MASK (0x3fff << TC3X_WDT_CON0_PW_SHIFT) +#define TC3X_WDT_CON0_REL_MASK (0xffff << 16) /* Reload value */ +#define TC3X_WDT_CON1_DR (1 << 3) /* Disable request */ /* The low six password bits read inverted */ -#define TC3XX_WDT_PW_INVERTED 0x3f +#define TC3X_WDT_PW_INVERTED 0x3f -#endif /* __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_WDT_H */ +#endif /* __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_WDT_H */ diff --git a/arch/tricore/src/tc3x/tc3x_clockconfig.c b/arch/tricore/src/tc3x/tc3x_clockconfig.c new file mode 100644 index 0000000000000..bdd5e2894ac81 --- /dev/null +++ b/arch/tricore/src/tc3x/tc3x_clockconfig.c @@ -0,0 +1,484 @@ +/**************************************************************************** + * arch/tricore/src/tc3x/tc3x_clockconfig.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "tricore_internal.h" +#include "hardware/tc3x_clock.h" +#include "hardware/tc3x_smu.h" +#include "tc3x_wdt.h" +#include "tricore_stm.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define TC3X_SMU_CCU_ALARMS 0x1d + +/* STM0 timer bits [31:0], for the waits of the PLL ramp up */ + +#define TC3X_STM0_TIM0 (TRICORE_STM_BASE(0) + TRICORE_STM_TIM0_OFFSET) + +/* Loop counts before a wait gives up */ + +#define TC3X_CCUCON_LCK_TIMEOUT 0x1000 +#define TC3X_PLL_LOCK_TIMEOUT 0x3000 +#define TC3X_PLL_PWDSTAT_TIMEOUT 0x3000 +#define TC3X_PLL_KRDY_TIMEOUT 0x6000 +#define TC3X_OSC_TIMEOUT 0x493e0 + +/* Clock setup: 20 MHz crystal, system PLL 300 MHz, peripheral PLL 320 and + * 200 MHz, as the iLLD IfxScuCcu default configuration for TC39xB. + */ + +#define TC3X_XTAL_MHZ 20 +#define TC3X_PLL_INSEL_OSC0 1 + +#define TC3X_SYSPLL_PDIV (1 - 1) +#define TC3X_SYSPLL_NDIV (30 - 1) +#define TC3X_SYSPLL_K2_INITIAL (6 - 1) + +#define TC3X_PERPLL_PDIV (1 - 1) +#define TC3X_PERPLL_NDIV (32 - 1) +#define TC3X_PERPLL_K2 (2 - 1) +#define TC3X_PERPLL_K3 (2 - 1) + +/* Wait of each PLL ramp up step, 100 us at the 100 MHz STM clock */ + +#define TC3X_PLL_STEP_WAIT 10000 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct tc3x_ccucon_s +{ + uint32_t value; + uint32_t mask; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* System PLL K2 divider steps from 100 MHz up to 300 MHz */ + +static const uint8_t g_tc3x_k2_steps[] = +{ + 4 - 1, 3 - 1, 2 - 1 +}; + +/* Clock distribution: CCUCON0, 1, 2, 5, then 6 to 11 */ + +static const struct tc3x_ccucon_s g_tc3x_ccucon[] = +{ + { 0x07230113, 0x0fff0fff }, + { 0x21110212, 0x3f3f0fbf }, + { 0x00001201, 0x00003f0f }, + { 0x00000132, 0x00000fff }, + { 0x00000000, 0x0000003f }, + { 0x00000000, 0x0000003f }, + { 0x00000000, 0x0000003f }, + { 0x00000000, 0x0000003f }, + { 0x00000000, 0x0000003f }, + { 0x00000000, 0x0000003f }, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tc3x_wait + * + * Description: + * Wait until all bits of mask in the register equal the bits in value. + * Return 1 if the wait gave up after count loops, otherwise 0. + * + ****************************************************************************/ + +static int tc3x_wait(uintptr_t reg, uint32_t mask, uint32_t value, + uint32_t count) +{ + while ((getreg32(reg) & mask) != value) + { + if (--count == 0) + { + return 1; + } + } + + return 0; +} + +static void tc3x_modify(uintptr_t reg, uint32_t clear, uint32_t set) +{ + putreg32((getreg32(reg) & ~clear) | set, reg); +} + +/**************************************************************************** + * Name: tc3x_ccucon_write + * + * Description: + * Write a CCUCON register that has a LCK bit, waiting until it is + * unlocked before and after the write. + * + ****************************************************************************/ + +static int tc3x_ccucon_write(uintptr_t reg, uint32_t value) +{ + int ret; + + ret = tc3x_wait(reg, TC3X_CCUCON_LCK, 0, TC3X_CCUCON_LCK_TIMEOUT); + putreg32(value, reg); + ret |= tc3x_wait(reg, TC3X_CCUCON_LCK, 0, TC3X_CCUCON_LCK_TIMEOUT); + + return ret; +} + +static uint32_t tc3x_ccucon_value(uintptr_t reg, + const struct tc3x_ccucon_s *cfg) +{ + return (getreg32(reg) & ~cfg->mask) | (cfg->value & cfg->mask); +} + +static void tc3x_smu_ccu_alarms(bool enable) +{ + int i; + + putreg32(TC3X_SMU_KEYS_CFG, TC3X_SMU_KEYS); + if (enable) + { + putreg32(TC3X_SMU_CMD_ALARM_CLR, TC3X_SMU_CMD); + putreg32(TC3X_SMU_CCU_ALARMS, TC3X_SMU_AG8); + } + else + { + for (i = 0; i < 3; i++) + { + tc3x_modify(TC3X_SMU_AGCF8(i), TC3X_SMU_CCU_ALARMS, 0); + } + } + + putreg32(0, TC3X_SMU_KEYS); +} + +/**************************************************************************** + * Name: tc3x_pll_init + * + * Description: + * Run the clocks from the backup clock, set up the oscillator and both + * PLLs, wait for the lock and switch back to the PLLs. + * + ****************************************************************************/ + +static int tc3x_pll_init(void) +{ + uint32_t kready = TC3X_PLLSTAT_K2RDY | TC3X_PLLSTAT_K3RDY; + uint32_t count; + int ret; + + tc3x_wdt_safety_endinit(false); + + ret = tc3x_wait(TC3X_SCU_CCUCON0, TC3X_CCUCON_LCK, 0, + TC3X_CCUCON_LCK_TIMEOUT); + tc3x_modify(TC3X_SCU_CCUCON0, TC3X_CCUCON0_CLKSEL_MASK, + TC3X_CCUCON_UP); + ret |= tc3x_wait(TC3X_SCU_CCUCON0, TC3X_CCUCON_LCK, 0, + TC3X_CCUCON_LCK_TIMEOUT); + + tc3x_smu_ccu_alarms(false); + + /* Power down both PLLs, so that the new settings cause no glitches */ + + tc3x_modify(TC3X_SCU_SYSPLLCON0, TC3X_PLLCON0_PLLPWD, 0); + tc3x_modify(TC3X_SCU_PERPLLCON0, TC3X_PLLCON0_PLLPWD, 0); + ret |= tc3x_wait(TC3X_SCU_SYSPLLSTAT, TC3X_PLLSTAT_PWDSTAT, + TC3X_PLLSTAT_PWDSTAT, TC3X_PLL_PWDSTAT_TIMEOUT); + ret |= tc3x_wait(TC3X_SCU_PERPLLSTAT, TC3X_PLLSTAT_PWDSTAT, + TC3X_PLLSTAT_PWDSTAT, TC3X_PLL_PWDSTAT_TIMEOUT); + + /* External crystal */ + + tc3x_modify(TC3X_SCU_OSCCON, + TC3X_OSCCON_MODE_MASK | TC3X_OSCCON_OSCVAL_MASK, + (TC3X_XTAL_MHZ - 15) << TC3X_OSCCON_OSCVAL_SHIFT); + + tc3x_modify(TC3X_SCU_SYSPLLCON0, + TC3X_PLLCON0_PDIV_MASK | TC3X_PLLCON0_NDIV_MASK | + TC3X_PLLCON0_INSEL_MASK, + (TC3X_SYSPLL_PDIV << TC3X_PLLCON0_PDIV_SHIFT) | + (TC3X_SYSPLL_NDIV << TC3X_PLLCON0_NDIV_SHIFT) | + (TC3X_PLL_INSEL_OSC0 << TC3X_PLLCON0_INSEL_SHIFT)); + + /* K3DIV must be 0 or 1 before PERPLLCON0.DIVBY changes */ + + tc3x_modify(TC3X_SCU_PERPLLCON1, TC3X_PLLCON1_K3DIV_MASK, + 1 << TC3X_PLLCON1_K3DIV_SHIFT); + tc3x_modify(TC3X_SCU_PERPLLCON0, + TC3X_PLLCON0_DIVBY | TC3X_PLLCON0_PDIV_MASK | + TC3X_PLLCON0_NDIV_MASK, + (TC3X_PERPLL_PDIV << TC3X_PLLCON0_PDIV_SHIFT) | + (TC3X_PERPLL_NDIV << TC3X_PLLCON0_NDIV_SHIFT)); + + /* Power up both PLLs and set the initial K dividers */ + + tc3x_modify(TC3X_SCU_SYSPLLCON0, 0, TC3X_PLLCON0_PLLPWD); + tc3x_modify(TC3X_SCU_PERPLLCON0, 0, TC3X_PLLCON0_PLLPWD); + ret |= tc3x_wait(TC3X_SCU_SYSPLLSTAT, TC3X_PLLSTAT_PWDSTAT, 0, + TC3X_PLL_PWDSTAT_TIMEOUT); + ret |= tc3x_wait(TC3X_SCU_PERPLLSTAT, TC3X_PLLSTAT_PWDSTAT, 0, + TC3X_PLL_PWDSTAT_TIMEOUT); + + ret |= tc3x_wait(TC3X_SCU_SYSPLLSTAT, TC3X_PLLSTAT_K2RDY, + TC3X_PLLSTAT_K2RDY, TC3X_PLL_KRDY_TIMEOUT); + ret |= tc3x_wait(TC3X_SCU_PERPLLSTAT, kready, kready, + TC3X_PLL_KRDY_TIMEOUT); + + tc3x_modify(TC3X_SCU_SYSPLLCON1, TC3X_PLLCON1_K2DIV_MASK, + TC3X_SYSPLL_K2_INITIAL); + tc3x_modify(TC3X_SCU_PERPLLCON1, + TC3X_PLLCON1_K2DIV_MASK | TC3X_PLLCON1_K3DIV_MASK, + TC3X_PERPLL_K2 | (1 << TC3X_PLLCON1_K3DIV_SHIFT)); + + ret |= tc3x_wait(TC3X_SCU_SYSPLLSTAT, TC3X_PLLSTAT_K2RDY, + TC3X_PLLSTAT_K2RDY, TC3X_PLL_KRDY_TIMEOUT); + ret |= tc3x_wait(TC3X_SCU_PERPLLSTAT, kready, kready, + TC3X_PLL_KRDY_TIMEOUT); + + /* Wait for the oscillator, then for the lock of both PLLs */ + + count = TC3X_OSC_TIMEOUT; + while ((getreg32(TC3X_SCU_OSCCON) & + (TC3X_OSCCON_PLLLV | TC3X_OSCCON_PLLHV)) == 0) + { + if (--count == 0) + { + ret = 1; + break; + } + } + + tc3x_modify(TC3X_SCU_SYSPLLCON0, 0, TC3X_PLLCON0_RESLD); + tc3x_modify(TC3X_SCU_PERPLLCON0, 0, TC3X_PLLCON0_RESLD); + ret |= tc3x_wait(TC3X_SCU_SYSPLLSTAT, TC3X_PLLSTAT_LOCK, + TC3X_PLLSTAT_LOCK, TC3X_PLL_LOCK_TIMEOUT); + ret |= tc3x_wait(TC3X_SCU_PERPLLSTAT, TC3X_PLLSTAT_LOCK, + TC3X_PLLSTAT_LOCK, TC3X_PLL_LOCK_TIMEOUT); + + ret |= tc3x_wait(TC3X_SCU_PERPLLSTAT, TC3X_PLLSTAT_K3RDY, + TC3X_PLLSTAT_K3RDY, TC3X_PLL_KRDY_TIMEOUT); + tc3x_modify(TC3X_SCU_PERPLLCON1, TC3X_PLLCON1_K3DIV_MASK, + TC3X_PERPLL_K3 << TC3X_PLLCON1_K3DIV_SHIFT); + ret |= tc3x_wait(TC3X_SCU_PERPLLSTAT, TC3X_PLLSTAT_K3RDY, + TC3X_PLLSTAT_K3RDY, TC3X_PLL_KRDY_TIMEOUT); + + tc3x_smu_ccu_alarms(true); + + ret |= tc3x_ccucon_write(TC3X_SCU_CCUCON0, + (getreg32(TC3X_SCU_CCUCON0) & + ~TC3X_CCUCON0_CLKSEL_MASK) | + TC3X_CCUCON0_CLKSEL_PLL | TC3X_CCUCON_UP); + + tc3x_wdt_safety_endinit(true); + return ret; +} + +/**************************************************************************** + * Name: tc3x_clock_distribute + * + * Description: + * Set the clock dividers. A clock select of CCUCON1 or CCUCON2 that is + * not 0 is first cleared together with the new dividers. + * + ****************************************************************************/ + +static int tc3x_clock_distribute(void) +{ + const struct tc3x_ccucon_s *cfg = g_tc3x_ccucon; + int ret; + int i; + + tc3x_wdt_safety_endinit(false); + + ret = tc3x_ccucon_write(TC3X_SCU_CCUCON0, + tc3x_ccucon_value(TC3X_SCU_CCUCON0, &cfg[0])); + + if ((getreg32(TC3X_SCU_CCUCON1) & TC3X_CCUCON1_CLKSEL_MASK) != 0) + { + ret |= tc3x_ccucon_write(TC3X_SCU_CCUCON1, + tc3x_ccucon_value(TC3X_SCU_CCUCON1, + &cfg[1]) & + ~TC3X_CCUCON1_CLKSEL_MASK); + } + + ret |= tc3x_ccucon_write(TC3X_SCU_CCUCON1, + tc3x_ccucon_value(TC3X_SCU_CCUCON1, &cfg[1])); + + if ((getreg32(TC3X_SCU_CCUCON2) & TC3X_CCUCON2_CLKSEL_MASK) != 0) + { + ret |= tc3x_ccucon_write(TC3X_SCU_CCUCON2, + tc3x_ccucon_value(TC3X_SCU_CCUCON2, + &cfg[2]) & + ~TC3X_CCUCON2_CLKSEL_MASK); + } + + ret |= tc3x_ccucon_write(TC3X_SCU_CCUCON2, + tc3x_ccucon_value(TC3X_SCU_CCUCON2, &cfg[2])); + + ret |= tc3x_ccucon_write(TC3X_SCU_CCUCON5, + tc3x_ccucon_value(TC3X_SCU_CCUCON5, &cfg[3]) | + TC3X_CCUCON_UP); + + for (i = 0; i < 6; i++) + { + uintptr_t reg = TC3X_SCU_CCUCON6 + i * 4; + + putreg32(tc3x_ccucon_value(reg, &cfg[4 + i]), reg); + } + + tc3x_wdt_safety_endinit(true); + return ret; +} + +/**************************************************************************** + * Name: tc3x_pll_ramp_up + * + * Description: + * Raise the system PLL to its final frequency in steps of the K2 + * divider, waiting after each step. + * + ****************************************************************************/ + +static int tc3x_pll_ramp_up(void) +{ + uint32_t start; + int ret = 0; + int i; + + for (i = 0; i < sizeof(g_tc3x_k2_steps); i++) + { + tc3x_wdt_safety_endinit(false); + ret |= tc3x_wait(TC3X_SCU_SYSPLLSTAT, TC3X_PLLSTAT_K2RDY, + TC3X_PLLSTAT_K2RDY, TC3X_PLL_KRDY_TIMEOUT); + tc3x_modify(TC3X_SCU_SYSPLLCON1, TC3X_PLLCON1_K2DIV_MASK, + g_tc3x_k2_steps[i]); + tc3x_wdt_safety_endinit(true); + + start = getreg32(TC3X_STM0_TIM0); + while (getreg32(TC3X_STM0_TIM0) - start < TC3X_PLL_STEP_WAIT); + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tricore_clock_asclinf + * + * Description: + * Return the fast ASCLIN clock (fASCLINF) in Hz, from the peripheral PLL + * output 2 and the ASCLINF divider, computed as the iLLD IfxScuCcu does. + * + ****************************************************************************/ + +uint32_t tricore_clock_asclinf(void) +{ + static const uint8_t divs[16] = + { + 1, 1, 2, 3, 4, 5, 6, 6, 8, 8, 10, 10, 12, 12, 12, 15 + }; + + uint32_t div = getreg32(TC3X_SCU_CCUCON2) & TC3X_CCUCON2_ASCLINFDIV; + uint32_t con0 = getreg32(TC3X_SCU_PERPLLCON0); + uint32_t con1 = getreg32(TC3X_SCU_PERPLLCON1); + uint64_t pll2; + + if (div == 0) + { + return 0; + } + + /* Backup clock, 100 MHz */ + + if ((getreg32(TC3X_SCU_CCUCON0) & TC3X_CCUCON0_CLKSEL_MASK) != + TC3X_CCUCON0_CLKSEL_PLL) + { + return 100000000 / divs[div]; + } + + /* The PLL output 2 divider is K3DIV + 1 times 2, or times 1.6 without + * DIVBY, counted here in tenths + */ + + pll2 = ((uint64_t)TC3X_XTAL_MHZ * 1000000 * + (((con0 & TC3X_PLLCON0_NDIV_MASK) >> TC3X_PLLCON0_NDIV_SHIFT) + + 1) * 10) / + ((((con0 & TC3X_PLLCON0_PDIV_MASK) >> TC3X_PLLCON0_PDIV_SHIFT) + + 1) * + (((con1 & TC3X_PLLCON1_K3DIV_MASK) >> TC3X_PLLCON1_K3DIV_SHIFT) + + 1) * + ((con0 & TC3X_PLLCON0_DIVBY) != 0 ? 20 : 16)); + + return pll2 / divs[div]; +} + +/**************************************************************************** + * Name: tricore_clockconfig + * + * Description: + * Set up the oscillator, the PLLs and the clock distribution. Called by + * the startup code before the C runtime is initialized, so it may only + * use constant data. + * + * Returned Value: + * 0 on success, 1 if a wait for the hardware gave up. + * + ****************************************************************************/ + +int tricore_clockconfig(void) +{ + int ret; + + ret = tc3x_pll_init(); + if (ret == 0) + { + ret = tc3x_clock_distribute(); + } + + if (ret == 0) + { + ret = tc3x_pll_ramp_up(); + } + + return ret; +} diff --git a/arch/tricore/src/tc4xx/tc4xx_timerisr.c b/arch/tricore/src/tc3x/tc3x_timerisr.c similarity index 98% rename from arch/tricore/src/tc4xx/tc4xx_timerisr.c rename to arch/tricore/src/tc3x/tc3x_timerisr.c index c3eac284c92a0..b8ae99a4ca12e 100644 --- a/arch/tricore/src/tc4xx/tc4xx_timerisr.c +++ b/arch/tricore/src/tc3x/tc3x_timerisr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/tc4xx_timerisr.c + * arch/tricore/src/tc3x/tc3x_timerisr.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/tricore/src/tc3xx/tc3xx_wdt.c b/arch/tricore/src/tc3x/tc3x_wdt.c similarity index 69% rename from arch/tricore/src/tc3xx/tc3xx_wdt.c rename to arch/tricore/src/tc3x/tc3x_wdt.c index 068ae48987fb5..4c94b37eb5f8c 100644 --- a/arch/tricore/src/tc3xx/tc3xx_wdt.c +++ b/arch/tricore/src/tc3x/tc3x_wdt.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/tc3xx_wdt.c + * arch/tricore/src/tc3x/tc3x_wdt.c * * SPDX-License-Identifier: Apache-2.0 * @@ -32,15 +32,15 @@ #include #include "tricore_internal.h" -#include "hardware/tc3xx_wdt.h" -#include "tc3xx_wdt.h" +#include "hardware/tc3x_wdt.h" +#include "tc3x_wdt.h" /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** - * Name: tc3xx_wdt_endinit + * Name: tc3x_wdt_endinit * * Description: * Set or clear ENDINIT of a watchdog with its password, unlocking CON0 @@ -48,39 +48,39 @@ * ****************************************************************************/ -static void tc3xx_wdt_endinit(uintptr_t con0, uint32_t pw, bool set) +static void tc3x_wdt_endinit(uintptr_t con0, uint32_t pw, bool set) { uint32_t regval = getreg32(con0); - uint32_t rel = regval & TC3XX_WDT_CON0_REL_MASK; + uint32_t rel = regval & TC3X_WDT_CON0_REL_MASK; - pw <<= TC3XX_WDT_CON0_PW_SHIFT; - if ((regval & TC3XX_WDT_CON0_LCK) != 0) + pw <<= TC3X_WDT_CON0_PW_SHIFT; + if ((regval & TC3X_WDT_CON0_LCK) != 0) { - putreg32(rel | pw | TC3XX_WDT_CON0_ENDINIT, con0); + putreg32(rel | pw | TC3X_WDT_CON0_ENDINIT, con0); } - putreg32(rel | pw | TC3XX_WDT_CON0_LCK | - (set ? TC3XX_WDT_CON0_ENDINIT : 0), con0); + putreg32(rel | pw | TC3X_WDT_CON0_LCK | + (set ? TC3X_WDT_CON0_ENDINIT : 0), con0); - while (((getreg32(con0) & TC3XX_WDT_CON0_ENDINIT) != 0) != set); + while (((getreg32(con0) & TC3X_WDT_CON0_ENDINIT) != 0) != set); } /**************************************************************************** - * Name: tc3xx_wdt_disable + * Name: tc3x_wdt_disable * * Description: * Request a watchdog to be disabled. * ****************************************************************************/ -static void tc3xx_wdt_disable(uintptr_t con0, uintptr_t con1) +static void tc3x_wdt_disable(uintptr_t con0, uintptr_t con1) { - uint32_t pw = ((getreg32(con0) & TC3XX_WDT_CON0_PW_MASK) >> - TC3XX_WDT_CON0_PW_SHIFT) ^ TC3XX_WDT_PW_INVERTED; + uint32_t pw = ((getreg32(con0) & TC3X_WDT_CON0_PW_MASK) >> + TC3X_WDT_CON0_PW_SHIFT) ^ TC3X_WDT_PW_INVERTED; - tc3xx_wdt_endinit(con0, pw, false); - putreg32(getreg32(con1) | TC3XX_WDT_CON1_DR, con1); - tc3xx_wdt_endinit(con0, pw, true); + tc3x_wdt_endinit(con0, pw, false); + putreg32(getreg32(con1) | TC3X_WDT_CON1_DR, con1); + tc3x_wdt_endinit(con0, pw, true); } /**************************************************************************** @@ -88,23 +88,23 @@ static void tc3xx_wdt_disable(uintptr_t con0, uintptr_t con1) ****************************************************************************/ /**************************************************************************** - * Name: tc3xx_wdt_safety_endinit + * Name: tc3x_wdt_safety_endinit * * Description: * Set or clear the safety ENDINIT, which protects the clock registers. * ****************************************************************************/ -void tc3xx_wdt_safety_endinit(bool set) +void tc3x_wdt_safety_endinit(bool set) { - uint32_t pw = ((getreg32(TC3XX_SCU_WDTS_CON0) & TC3XX_WDT_CON0_PW_MASK) >> - TC3XX_WDT_CON0_PW_SHIFT) ^ TC3XX_WDT_PW_INVERTED; + uint32_t pw = ((getreg32(TC3X_SCU_WDTS_CON0) & TC3X_WDT_CON0_PW_MASK) >> + TC3X_WDT_CON0_PW_SHIFT) ^ TC3X_WDT_PW_INVERTED; - tc3xx_wdt_endinit(TC3XX_SCU_WDTS_CON0, pw, set); + tc3x_wdt_endinit(TC3X_SCU_WDTS_CON0, pw, set); } /**************************************************************************** - * Name: tc3xx_wdt_cpu_endinit + * Name: tc3x_wdt_cpu_endinit * * Description: * Set or clear the ENDINIT of the calling CPU, which protects for example @@ -113,18 +113,18 @@ void tc3xx_wdt_safety_endinit(bool set) * ****************************************************************************/ -void tc3xx_wdt_cpu_endinit(bool set) +void tc3x_wdt_cpu_endinit(bool set) { uint32_t cpu = tricore_mfcr(TRICORE_CPU_CORE_ID); uintptr_t con0; uint32_t pw; cpu = cpu > 5 ? 5 : cpu; - con0 = TC3XX_SCU_WDTCPU_CON0(cpu); - pw = ((getreg32(con0) & TC3XX_WDT_CON0_PW_MASK) >> - TC3XX_WDT_CON0_PW_SHIFT) ^ TC3XX_WDT_PW_INVERTED; + con0 = TC3X_SCU_WDTCPU_CON0(cpu); + pw = ((getreg32(con0) & TC3X_WDT_CON0_PW_MASK) >> + TC3X_WDT_CON0_PW_SHIFT) ^ TC3X_WDT_PW_INVERTED; - tc3xx_wdt_endinit(con0, pw, set); + tc3x_wdt_endinit(con0, pw, set); } /**************************************************************************** @@ -141,6 +141,6 @@ void tricore_wdt_disable(void) uint32_t cpu = tricore_mfcr(TRICORE_CPU_CORE_ID); cpu = cpu > 5 ? 5 : cpu; - tc3xx_wdt_disable(TC3XX_SCU_WDTCPU_CON0(cpu), TC3XX_SCU_WDTCPU_CON1(cpu)); - tc3xx_wdt_disable(TC3XX_SCU_WDTS_CON0, TC3XX_SCU_WDTS_CON1); + tc3x_wdt_disable(TC3X_SCU_WDTCPU_CON0(cpu), TC3X_SCU_WDTCPU_CON1(cpu)); + tc3x_wdt_disable(TC3X_SCU_WDTS_CON0, TC3X_SCU_WDTS_CON1); } diff --git a/arch/tricore/src/tc3xx/tc3xx_wdt.h b/arch/tricore/src/tc3x/tc3x_wdt.h similarity index 84% rename from arch/tricore/src/tc3xx/tc3xx_wdt.h rename to arch/tricore/src/tc3x/tc3x_wdt.h index 7af46c609d357..95480dddc7d1f 100644 --- a/arch/tricore/src/tc3xx/tc3xx_wdt.h +++ b/arch/tricore/src/tc3x/tc3x_wdt.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/tc3xx_wdt.h + * arch/tricore/src/tc3x/tc3x_wdt.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC3XX_TC3XX_WDT_H -#define __ARCH_TRICORE_SRC_TC3XX_TC3XX_WDT_H +#ifndef __ARCH_TRICORE_SRC_TC3X_TC3X_WDT_H +#define __ARCH_TRICORE_SRC_TC3X_TC3X_WDT_H /**************************************************************************** * Included Files @@ -33,7 +33,7 @@ * Public Function Prototypes ****************************************************************************/ -void tc3xx_wdt_safety_endinit(bool set); -void tc3xx_wdt_cpu_endinit(bool set); +void tc3x_wdt_safety_endinit(bool set); +void tc3x_wdt_cpu_endinit(bool set); -#endif /* __ARCH_TRICORE_SRC_TC3XX_TC3XX_WDT_H */ +#endif /* __ARCH_TRICORE_SRC_TC3X_TC3X_WDT_H */ diff --git a/arch/tricore/src/tc3xx/hardware/tc3xx_clock.h b/arch/tricore/src/tc3xx/hardware/tc3xx_clock.h deleted file mode 100644 index 0ada5a1e704bb..0000000000000 --- a/arch/tricore/src/tc3xx/hardware/tc3xx_clock.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - * arch/tricore/src/tc3xx/hardware/tc3xx_clock.h - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_CLOCK_H -#define __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_CLOCK_H - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* SCU clock control unit (CCU) registers */ - -#define TC3XX_SCU_OSCCON 0xf0036010 -#define TC3XX_SCU_SYSPLLSTAT 0xf0036014 -#define TC3XX_SCU_SYSPLLCON0 0xf0036018 -#define TC3XX_SCU_SYSPLLCON1 0xf003601c -#define TC3XX_SCU_PERPLLSTAT 0xf0036024 -#define TC3XX_SCU_PERPLLCON0 0xf0036028 -#define TC3XX_SCU_PERPLLCON1 0xf003602c -#define TC3XX_SCU_CCUCON0 0xf0036030 -#define TC3XX_SCU_CCUCON1 0xf0036034 -#define TC3XX_SCU_CCUCON2 0xf0036040 -#define TC3XX_SCU_CCUCON5 0xf003604c -#define TC3XX_SCU_CCUCON6 0xf0036080 /* CCUCON6 to CCUCON11 */ - -#define TC3XX_OSCCON_PLLLV (1 << 1) -#define TC3XX_OSCCON_MODE_MASK (0x3 << 5) -#define TC3XX_OSCCON_PLLHV (1 << 8) -#define TC3XX_OSCCON_OSCVAL_SHIFT 16 -#define TC3XX_OSCCON_OSCVAL_MASK (0x1f << TC3XX_OSCCON_OSCVAL_SHIFT) - -#define TC3XX_PLLCON0_DIVBY (1 << 0) /* PERPLLCON0 only */ -#define TC3XX_PLLCON0_NDIV_SHIFT 9 -#define TC3XX_PLLCON0_NDIV_MASK (0x7f << TC3XX_PLLCON0_NDIV_SHIFT) -#define TC3XX_PLLCON0_PLLPWD (1 << 16) -#define TC3XX_PLLCON0_RESLD (1 << 18) -#define TC3XX_PLLCON0_PDIV_SHIFT 24 -#define TC3XX_PLLCON0_PDIV_MASK (0x7 << TC3XX_PLLCON0_PDIV_SHIFT) -#define TC3XX_PLLCON0_INSEL_SHIFT 30 /* SYSPLLCON0 only */ -#define TC3XX_PLLCON0_INSEL_MASK (0x3 << TC3XX_PLLCON0_INSEL_SHIFT) - -#define TC3XX_PLLCON1_K2DIV_MASK (0x7 << 0) -#define TC3XX_PLLCON1_K3DIV_SHIFT 8 /* PERPLLCON1 only */ -#define TC3XX_PLLCON1_K3DIV_MASK (0x7 << TC3XX_PLLCON1_K3DIV_SHIFT) - -#define TC3XX_PLLSTAT_PWDSTAT (1 << 1) -#define TC3XX_PLLSTAT_LOCK (1 << 2) -#define TC3XX_PLLSTAT_K3RDY (1 << 4) /* PERPLLSTAT only */ -#define TC3XX_PLLSTAT_K2RDY (1 << 5) - -#define TC3XX_CCUCON_UP (1 << 30) -#define TC3XX_CCUCON_LCK (1 << 31) -#define TC3XX_CCUCON0_CLKSEL_MASK (0x3 << 28) -#define TC3XX_CCUCON0_CLKSEL_PLL (0x1 << 28) -#define TC3XX_CCUCON1_CLKSEL_MASK ((0x3 << 4) | (0x3 << 20) | (0x3 << 28)) -#define TC3XX_CCUCON2_ASCLINFDIV (0xf << 0) -#define TC3XX_CCUCON2_CLKSEL_MASK (0x3 << 12) - -#endif /* __ARCH_TRICORE_SRC_TC3XX_HARDWARE_TC3XX_CLOCK_H */ diff --git a/arch/tricore/src/tc3xx/tc3xx_clockconfig.c b/arch/tricore/src/tc3xx/tc3xx_clockconfig.c deleted file mode 100644 index 3c88b7047e84b..0000000000000 --- a/arch/tricore/src/tc3xx/tc3xx_clockconfig.c +++ /dev/null @@ -1,484 +0,0 @@ -/**************************************************************************** - * arch/tricore/src/tc3xx/tc3xx_clockconfig.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include "tricore_internal.h" -#include "hardware/tc3xx_clock.h" -#include "hardware/tc3xx_smu.h" -#include "tc3xx_wdt.h" -#include "tricore_stm.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define TC3XX_SMU_CCU_ALARMS 0x1d - -/* STM0 timer bits [31:0], for the waits of the PLL ramp up */ - -#define TC3XX_STM0_TIM0 (TRICORE_STM_BASE(0) + TRICORE_STM_TIM0_OFFSET) - -/* Loop counts before a wait gives up */ - -#define TC3XX_CCUCON_LCK_TIMEOUT 0x1000 -#define TC3XX_PLL_LOCK_TIMEOUT 0x3000 -#define TC3XX_PLL_PWDSTAT_TIMEOUT 0x3000 -#define TC3XX_PLL_KRDY_TIMEOUT 0x6000 -#define TC3XX_OSC_TIMEOUT 0x493e0 - -/* Clock setup: 20 MHz crystal, system PLL 300 MHz, peripheral PLL 320 and - * 200 MHz, as the iLLD IfxScuCcu default configuration for TC39xB. - */ - -#define TC3XX_XTAL_MHZ 20 -#define TC3XX_PLL_INSEL_OSC0 1 - -#define TC3XX_SYSPLL_PDIV (1 - 1) -#define TC3XX_SYSPLL_NDIV (30 - 1) -#define TC3XX_SYSPLL_K2_INITIAL (6 - 1) - -#define TC3XX_PERPLL_PDIV (1 - 1) -#define TC3XX_PERPLL_NDIV (32 - 1) -#define TC3XX_PERPLL_K2 (2 - 1) -#define TC3XX_PERPLL_K3 (2 - 1) - -/* Wait of each PLL ramp up step, 100 us at the 100 MHz STM clock */ - -#define TC3XX_PLL_STEP_WAIT 10000 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct tc3xx_ccucon_s -{ - uint32_t value; - uint32_t mask; -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* System PLL K2 divider steps from 100 MHz up to 300 MHz */ - -static const uint8_t g_tc3xx_k2_steps[] = -{ - 4 - 1, 3 - 1, 2 - 1 -}; - -/* Clock distribution: CCUCON0, 1, 2, 5, then 6 to 11 */ - -static const struct tc3xx_ccucon_s g_tc3xx_ccucon[] = -{ - { 0x07230113, 0x0fff0fff }, - { 0x21110212, 0x3f3f0fbf }, - { 0x00001201, 0x00003f0f }, - { 0x00000132, 0x00000fff }, - { 0x00000000, 0x0000003f }, - { 0x00000000, 0x0000003f }, - { 0x00000000, 0x0000003f }, - { 0x00000000, 0x0000003f }, - { 0x00000000, 0x0000003f }, - { 0x00000000, 0x0000003f }, -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: tc3xx_wait - * - * Description: - * Wait until all bits of mask in the register equal the bits in value. - * Return 1 if the wait gave up after count loops, otherwise 0. - * - ****************************************************************************/ - -static int tc3xx_wait(uintptr_t reg, uint32_t mask, uint32_t value, - uint32_t count) -{ - while ((getreg32(reg) & mask) != value) - { - if (--count == 0) - { - return 1; - } - } - - return 0; -} - -static void tc3xx_modify(uintptr_t reg, uint32_t clear, uint32_t set) -{ - putreg32((getreg32(reg) & ~clear) | set, reg); -} - -/**************************************************************************** - * Name: tc3xx_ccucon_write - * - * Description: - * Write a CCUCON register that has a LCK bit, waiting until it is - * unlocked before and after the write. - * - ****************************************************************************/ - -static int tc3xx_ccucon_write(uintptr_t reg, uint32_t value) -{ - int ret; - - ret = tc3xx_wait(reg, TC3XX_CCUCON_LCK, 0, TC3XX_CCUCON_LCK_TIMEOUT); - putreg32(value, reg); - ret |= tc3xx_wait(reg, TC3XX_CCUCON_LCK, 0, TC3XX_CCUCON_LCK_TIMEOUT); - - return ret; -} - -static uint32_t tc3xx_ccucon_value(uintptr_t reg, - const struct tc3xx_ccucon_s *cfg) -{ - return (getreg32(reg) & ~cfg->mask) | (cfg->value & cfg->mask); -} - -static void tc3xx_smu_ccu_alarms(bool enable) -{ - int i; - - putreg32(TC3XX_SMU_KEYS_CFG, TC3XX_SMU_KEYS); - if (enable) - { - putreg32(TC3XX_SMU_CMD_ALARM_CLR, TC3XX_SMU_CMD); - putreg32(TC3XX_SMU_CCU_ALARMS, TC3XX_SMU_AG8); - } - else - { - for (i = 0; i < 3; i++) - { - tc3xx_modify(TC3XX_SMU_AGCF8(i), TC3XX_SMU_CCU_ALARMS, 0); - } - } - - putreg32(0, TC3XX_SMU_KEYS); -} - -/**************************************************************************** - * Name: tc3xx_pll_init - * - * Description: - * Run the clocks from the backup clock, set up the oscillator and both - * PLLs, wait for the lock and switch back to the PLLs. - * - ****************************************************************************/ - -static int tc3xx_pll_init(void) -{ - uint32_t kready = TC3XX_PLLSTAT_K2RDY | TC3XX_PLLSTAT_K3RDY; - uint32_t count; - int ret; - - tc3xx_wdt_safety_endinit(false); - - ret = tc3xx_wait(TC3XX_SCU_CCUCON0, TC3XX_CCUCON_LCK, 0, - TC3XX_CCUCON_LCK_TIMEOUT); - tc3xx_modify(TC3XX_SCU_CCUCON0, TC3XX_CCUCON0_CLKSEL_MASK, - TC3XX_CCUCON_UP); - ret |= tc3xx_wait(TC3XX_SCU_CCUCON0, TC3XX_CCUCON_LCK, 0, - TC3XX_CCUCON_LCK_TIMEOUT); - - tc3xx_smu_ccu_alarms(false); - - /* Power down both PLLs, so that the new settings cause no glitches */ - - tc3xx_modify(TC3XX_SCU_SYSPLLCON0, TC3XX_PLLCON0_PLLPWD, 0); - tc3xx_modify(TC3XX_SCU_PERPLLCON0, TC3XX_PLLCON0_PLLPWD, 0); - ret |= tc3xx_wait(TC3XX_SCU_SYSPLLSTAT, TC3XX_PLLSTAT_PWDSTAT, - TC3XX_PLLSTAT_PWDSTAT, TC3XX_PLL_PWDSTAT_TIMEOUT); - ret |= tc3xx_wait(TC3XX_SCU_PERPLLSTAT, TC3XX_PLLSTAT_PWDSTAT, - TC3XX_PLLSTAT_PWDSTAT, TC3XX_PLL_PWDSTAT_TIMEOUT); - - /* External crystal */ - - tc3xx_modify(TC3XX_SCU_OSCCON, - TC3XX_OSCCON_MODE_MASK | TC3XX_OSCCON_OSCVAL_MASK, - (TC3XX_XTAL_MHZ - 15) << TC3XX_OSCCON_OSCVAL_SHIFT); - - tc3xx_modify(TC3XX_SCU_SYSPLLCON0, - TC3XX_PLLCON0_PDIV_MASK | TC3XX_PLLCON0_NDIV_MASK | - TC3XX_PLLCON0_INSEL_MASK, - (TC3XX_SYSPLL_PDIV << TC3XX_PLLCON0_PDIV_SHIFT) | - (TC3XX_SYSPLL_NDIV << TC3XX_PLLCON0_NDIV_SHIFT) | - (TC3XX_PLL_INSEL_OSC0 << TC3XX_PLLCON0_INSEL_SHIFT)); - - /* K3DIV must be 0 or 1 before PERPLLCON0.DIVBY changes */ - - tc3xx_modify(TC3XX_SCU_PERPLLCON1, TC3XX_PLLCON1_K3DIV_MASK, - 1 << TC3XX_PLLCON1_K3DIV_SHIFT); - tc3xx_modify(TC3XX_SCU_PERPLLCON0, - TC3XX_PLLCON0_DIVBY | TC3XX_PLLCON0_PDIV_MASK | - TC3XX_PLLCON0_NDIV_MASK, - (TC3XX_PERPLL_PDIV << TC3XX_PLLCON0_PDIV_SHIFT) | - (TC3XX_PERPLL_NDIV << TC3XX_PLLCON0_NDIV_SHIFT)); - - /* Power up both PLLs and set the initial K dividers */ - - tc3xx_modify(TC3XX_SCU_SYSPLLCON0, 0, TC3XX_PLLCON0_PLLPWD); - tc3xx_modify(TC3XX_SCU_PERPLLCON0, 0, TC3XX_PLLCON0_PLLPWD); - ret |= tc3xx_wait(TC3XX_SCU_SYSPLLSTAT, TC3XX_PLLSTAT_PWDSTAT, 0, - TC3XX_PLL_PWDSTAT_TIMEOUT); - ret |= tc3xx_wait(TC3XX_SCU_PERPLLSTAT, TC3XX_PLLSTAT_PWDSTAT, 0, - TC3XX_PLL_PWDSTAT_TIMEOUT); - - ret |= tc3xx_wait(TC3XX_SCU_SYSPLLSTAT, TC3XX_PLLSTAT_K2RDY, - TC3XX_PLLSTAT_K2RDY, TC3XX_PLL_KRDY_TIMEOUT); - ret |= tc3xx_wait(TC3XX_SCU_PERPLLSTAT, kready, kready, - TC3XX_PLL_KRDY_TIMEOUT); - - tc3xx_modify(TC3XX_SCU_SYSPLLCON1, TC3XX_PLLCON1_K2DIV_MASK, - TC3XX_SYSPLL_K2_INITIAL); - tc3xx_modify(TC3XX_SCU_PERPLLCON1, - TC3XX_PLLCON1_K2DIV_MASK | TC3XX_PLLCON1_K3DIV_MASK, - TC3XX_PERPLL_K2 | (1 << TC3XX_PLLCON1_K3DIV_SHIFT)); - - ret |= tc3xx_wait(TC3XX_SCU_SYSPLLSTAT, TC3XX_PLLSTAT_K2RDY, - TC3XX_PLLSTAT_K2RDY, TC3XX_PLL_KRDY_TIMEOUT); - ret |= tc3xx_wait(TC3XX_SCU_PERPLLSTAT, kready, kready, - TC3XX_PLL_KRDY_TIMEOUT); - - /* Wait for the oscillator, then for the lock of both PLLs */ - - count = TC3XX_OSC_TIMEOUT; - while ((getreg32(TC3XX_SCU_OSCCON) & - (TC3XX_OSCCON_PLLLV | TC3XX_OSCCON_PLLHV)) == 0) - { - if (--count == 0) - { - ret = 1; - break; - } - } - - tc3xx_modify(TC3XX_SCU_SYSPLLCON0, 0, TC3XX_PLLCON0_RESLD); - tc3xx_modify(TC3XX_SCU_PERPLLCON0, 0, TC3XX_PLLCON0_RESLD); - ret |= tc3xx_wait(TC3XX_SCU_SYSPLLSTAT, TC3XX_PLLSTAT_LOCK, - TC3XX_PLLSTAT_LOCK, TC3XX_PLL_LOCK_TIMEOUT); - ret |= tc3xx_wait(TC3XX_SCU_PERPLLSTAT, TC3XX_PLLSTAT_LOCK, - TC3XX_PLLSTAT_LOCK, TC3XX_PLL_LOCK_TIMEOUT); - - ret |= tc3xx_wait(TC3XX_SCU_PERPLLSTAT, TC3XX_PLLSTAT_K3RDY, - TC3XX_PLLSTAT_K3RDY, TC3XX_PLL_KRDY_TIMEOUT); - tc3xx_modify(TC3XX_SCU_PERPLLCON1, TC3XX_PLLCON1_K3DIV_MASK, - TC3XX_PERPLL_K3 << TC3XX_PLLCON1_K3DIV_SHIFT); - ret |= tc3xx_wait(TC3XX_SCU_PERPLLSTAT, TC3XX_PLLSTAT_K3RDY, - TC3XX_PLLSTAT_K3RDY, TC3XX_PLL_KRDY_TIMEOUT); - - tc3xx_smu_ccu_alarms(true); - - ret |= tc3xx_ccucon_write(TC3XX_SCU_CCUCON0, - (getreg32(TC3XX_SCU_CCUCON0) & - ~TC3XX_CCUCON0_CLKSEL_MASK) | - TC3XX_CCUCON0_CLKSEL_PLL | TC3XX_CCUCON_UP); - - tc3xx_wdt_safety_endinit(true); - return ret; -} - -/**************************************************************************** - * Name: tc3xx_clock_distribute - * - * Description: - * Set the clock dividers. A clock select of CCUCON1 or CCUCON2 that is - * not 0 is first cleared together with the new dividers. - * - ****************************************************************************/ - -static int tc3xx_clock_distribute(void) -{ - const struct tc3xx_ccucon_s *cfg = g_tc3xx_ccucon; - int ret; - int i; - - tc3xx_wdt_safety_endinit(false); - - ret = tc3xx_ccucon_write(TC3XX_SCU_CCUCON0, - tc3xx_ccucon_value(TC3XX_SCU_CCUCON0, &cfg[0])); - - if ((getreg32(TC3XX_SCU_CCUCON1) & TC3XX_CCUCON1_CLKSEL_MASK) != 0) - { - ret |= tc3xx_ccucon_write(TC3XX_SCU_CCUCON1, - tc3xx_ccucon_value(TC3XX_SCU_CCUCON1, - &cfg[1]) & - ~TC3XX_CCUCON1_CLKSEL_MASK); - } - - ret |= tc3xx_ccucon_write(TC3XX_SCU_CCUCON1, - tc3xx_ccucon_value(TC3XX_SCU_CCUCON1, &cfg[1])); - - if ((getreg32(TC3XX_SCU_CCUCON2) & TC3XX_CCUCON2_CLKSEL_MASK) != 0) - { - ret |= tc3xx_ccucon_write(TC3XX_SCU_CCUCON2, - tc3xx_ccucon_value(TC3XX_SCU_CCUCON2, - &cfg[2]) & - ~TC3XX_CCUCON2_CLKSEL_MASK); - } - - ret |= tc3xx_ccucon_write(TC3XX_SCU_CCUCON2, - tc3xx_ccucon_value(TC3XX_SCU_CCUCON2, &cfg[2])); - - ret |= tc3xx_ccucon_write(TC3XX_SCU_CCUCON5, - tc3xx_ccucon_value(TC3XX_SCU_CCUCON5, &cfg[3]) | - TC3XX_CCUCON_UP); - - for (i = 0; i < 6; i++) - { - uintptr_t reg = TC3XX_SCU_CCUCON6 + i * 4; - - putreg32(tc3xx_ccucon_value(reg, &cfg[4 + i]), reg); - } - - tc3xx_wdt_safety_endinit(true); - return ret; -} - -/**************************************************************************** - * Name: tc3xx_pll_ramp_up - * - * Description: - * Raise the system PLL to its final frequency in steps of the K2 - * divider, waiting after each step. - * - ****************************************************************************/ - -static int tc3xx_pll_ramp_up(void) -{ - uint32_t start; - int ret = 0; - int i; - - for (i = 0; i < sizeof(g_tc3xx_k2_steps); i++) - { - tc3xx_wdt_safety_endinit(false); - ret |= tc3xx_wait(TC3XX_SCU_SYSPLLSTAT, TC3XX_PLLSTAT_K2RDY, - TC3XX_PLLSTAT_K2RDY, TC3XX_PLL_KRDY_TIMEOUT); - tc3xx_modify(TC3XX_SCU_SYSPLLCON1, TC3XX_PLLCON1_K2DIV_MASK, - g_tc3xx_k2_steps[i]); - tc3xx_wdt_safety_endinit(true); - - start = getreg32(TC3XX_STM0_TIM0); - while (getreg32(TC3XX_STM0_TIM0) - start < TC3XX_PLL_STEP_WAIT); - } - - return ret; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: tricore_clock_asclinf - * - * Description: - * Return the fast ASCLIN clock (fASCLINF) in Hz, from the peripheral PLL - * output 2 and the ASCLINF divider, computed as the iLLD IfxScuCcu does. - * - ****************************************************************************/ - -uint32_t tricore_clock_asclinf(void) -{ - static const uint8_t divs[16] = - { - 1, 1, 2, 3, 4, 5, 6, 6, 8, 8, 10, 10, 12, 12, 12, 15 - }; - - uint32_t div = getreg32(TC3XX_SCU_CCUCON2) & TC3XX_CCUCON2_ASCLINFDIV; - uint32_t con0 = getreg32(TC3XX_SCU_PERPLLCON0); - uint32_t con1 = getreg32(TC3XX_SCU_PERPLLCON1); - uint64_t pll2; - - if (div == 0) - { - return 0; - } - - /* Backup clock, 100 MHz */ - - if ((getreg32(TC3XX_SCU_CCUCON0) & TC3XX_CCUCON0_CLKSEL_MASK) != - TC3XX_CCUCON0_CLKSEL_PLL) - { - return 100000000 / divs[div]; - } - - /* The PLL output 2 divider is K3DIV + 1 times 2, or times 1.6 without - * DIVBY, counted here in tenths - */ - - pll2 = ((uint64_t)TC3XX_XTAL_MHZ * 1000000 * - (((con0 & TC3XX_PLLCON0_NDIV_MASK) >> TC3XX_PLLCON0_NDIV_SHIFT) + - 1) * 10) / - ((((con0 & TC3XX_PLLCON0_PDIV_MASK) >> TC3XX_PLLCON0_PDIV_SHIFT) + - 1) * - (((con1 & TC3XX_PLLCON1_K3DIV_MASK) >> TC3XX_PLLCON1_K3DIV_SHIFT) + - 1) * - ((con0 & TC3XX_PLLCON0_DIVBY) != 0 ? 20 : 16)); - - return pll2 / divs[div]; -} - -/**************************************************************************** - * Name: tricore_clockconfig - * - * Description: - * Set up the oscillator, the PLLs and the clock distribution. Called by - * the startup code before the C runtime is initialized, so it may only - * use constant data. - * - * Returned Value: - * 0 on success, 1 if a wait for the hardware gave up. - * - ****************************************************************************/ - -int tricore_clockconfig(void) -{ - int ret; - - ret = tc3xx_pll_init(); - if (ret == 0) - { - ret = tc3xx_clock_distribute(); - } - - if (ret == 0) - { - ret = tc3xx_pll_ramp_up(); - } - - return ret; -} diff --git a/arch/tricore/src/tc4xx/CMakeLists.txt b/arch/tricore/src/tc4x/CMakeLists.txt similarity index 90% rename from arch/tricore/src/tc4xx/CMakeLists.txt rename to arch/tricore/src/tc4x/CMakeLists.txt index 99de15ae0e628..e7473bd247d0b 100644 --- a/arch/tricore/src/tc4xx/CMakeLists.txt +++ b/arch/tricore/src/tc4x/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# arch/tricore/src/tc4xx/CMakeLists.txt +# arch/tricore/src/tc4x/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # @@ -20,7 +20,7 @@ # # ############################################################################## -set(SRCS tc4xx_timerisr.c tc4xx_wdt.c tc4xx_clockconfig.c tc4xx_ram.c) +set(SRCS tc4x_timerisr.c tc4x_wdt.c tc4x_clockconfig.c tc4x_ram.c) target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/tricore/src/tc4xx/Kconfig b/arch/tricore/src/tc4x/Kconfig similarity index 94% rename from arch/tricore/src/tc4xx/Kconfig rename to arch/tricore/src/tc4x/Kconfig index 0371e84a87de9..669f086818b12 100644 --- a/arch/tricore/src/tc4xx/Kconfig +++ b/arch/tricore/src/tc4x/Kconfig @@ -1,5 +1,5 @@ ############################################################################ -# arch/tricore/src/tc4xx/Kconfig +# arch/tricore/src/tc4x/Kconfig # # SPDX-License-Identifier: Apache-2.0 # @@ -33,7 +33,7 @@ config ARCH_CHIP_TC4DX endchoice -comment "TC4XX Configuration Options" +comment "TC4X Configuration Options" config CPU_CLOCK_FREQUENCY int "CPU clock frequency (Hz)" diff --git a/arch/tricore/src/tc4xx/Make.defs b/arch/tricore/src/tc4x/Make.defs similarity index 87% rename from arch/tricore/src/tc4xx/Make.defs rename to arch/tricore/src/tc4x/Make.defs index 88f61a843a59f..c7afa7a37d3d4 100644 --- a/arch/tricore/src/tc4xx/Make.defs +++ b/arch/tricore/src/tc4x/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# arch/tricore/src/tc4xx/Make.defs +# arch/tricore/src/tc4x/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -20,10 +20,10 @@ # ############################################################################ -CHIP_CSRCS += tc4xx_timerisr.c -CHIP_CSRCS += tc4xx_wdt.c -CHIP_CSRCS += tc4xx_clockconfig.c -CHIP_CSRCS += tc4xx_ram.c +CHIP_CSRCS += tc4x_timerisr.c +CHIP_CSRCS += tc4x_wdt.c +CHIP_CSRCS += tc4x_clockconfig.c +CHIP_CSRCS += tc4x_ram.c include common/aurix/Make.defs @@ -32,7 +32,7 @@ ifeq ($(CONFIG_BUILD_PROTECTED),y) VPATH += $(BOARD_DIR)/kernel endif -VPATH += tc4xx +VPATH += tc4x # The TASKING link takes libc_fpu.a from here diff --git a/arch/tricore/src/tc4xx/Toolchain.defs b/arch/tricore/src/tc4x/Toolchain.defs similarity index 97% rename from arch/tricore/src/tc4xx/Toolchain.defs rename to arch/tricore/src/tc4x/Toolchain.defs index 0f030aea2881a..e01c38d1c6a4b 100644 --- a/arch/tricore/src/tc4xx/Toolchain.defs +++ b/arch/tricore/src/tc4x/Toolchain.defs @@ -1,5 +1,5 @@ ############################################################################ -# arch/tricore/src/tc4xx/Toolchain.defs +# arch/tricore/src/tc4x/Toolchain.defs # # SPDX-License-Identifier: Apache-2.0 # diff --git a/arch/tricore/src/tc4xx/chip.h b/arch/tricore/src/tc4x/chip.h similarity index 85% rename from arch/tricore/src/tc4xx/chip.h rename to arch/tricore/src/tc4x/chip.h index 22e708e4e7c08..9335eac4d1b6d 100644 --- a/arch/tricore/src/tc4xx/chip.h +++ b/arch/tricore/src/tc4x/chip.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/chip.h + * arch/tricore/src/tc4x/chip.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,14 +20,14 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_CHIP_H -#define __ARCH_TRICORE_SRC_TC4XX_CHIP_H +#ifndef __ARCH_TRICORE_SRC_TC4X_CHIP_H +#define __ARCH_TRICORE_SRC_TC4X_CHIP_H /**************************************************************************** * Included Files ****************************************************************************/ -#include "hardware/tc4xx_cpu.h" +#include "hardware/tc4x_cpu.h" /* UART0 pins: ASCLIN0 RXA on P14.1, TX on P14.0 (alternate output 2) */ @@ -51,13 +51,13 @@ */ #define TRICORE_START_CORES 5 -#define TRICORE_START_PC(n) TC4XX_CPU_HRA_PC(n) -#define TRICORE_START_HALT(n) TC4XX_CPU_HRA_BOOTCON(n) -#define TRICORE_START_BHALT TC4XX_BOOTCON_BHALT +#define TRICORE_START_PC(n) TC4X_CPU_HRA_PC(n) +#define TRICORE_START_HALT(n) TC4X_CPU_HRA_BOOTCON(n) +#define TRICORE_START_BHALT TC4X_BOOTCON_BHALT /* Core index from CORE_ID */ #define tricore_core_id() (tricore_mfcr(TRICORE_CPU_CORE_ID) & 0x7) #define tricore_core_index() tricore_core_id() -#endif /* __ARCH_TRICORE_SRC_TC4XX_CHIP_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_CHIP_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_asclin.h b/arch/tricore/src/tc4x/hardware/tc4x_asclin.h similarity index 88% rename from arch/tricore/src/tc4xx/hardware/tc4xx_asclin.h rename to arch/tricore/src/tc4x/hardware/tc4x_asclin.h index 9449fd91ac467..4af8e6c26be3f 100644 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_asclin.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_asclin.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_asclin.h + * arch/tricore/src/tc4x/hardware/tc4x_asclin.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_ASCLIN_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_ASCLIN_H +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_ASCLIN_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_ASCLIN_H /**************************************************************************** * Pre-processor Definitions @@ -45,4 +45,4 @@ #define ASCLIN_TXDATA_OFFSET 0x140 #define ASCLIN_RXDATA_OFFSET 0x160 -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_ASCLIN_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_ASCLIN_H */ diff --git a/arch/tricore/src/tc4x/hardware/tc4x_clock.h b/arch/tricore/src/tc4x/hardware/tc4x_clock.h new file mode 100644 index 0000000000000..d06dcd566440b --- /dev/null +++ b/arch/tricore/src/tc4x/hardware/tc4x_clock.h @@ -0,0 +1,100 @@ +/**************************************************************************** + * arch/tricore/src/tc4x/hardware/tc4x_clock.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_CLOCK_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_CLOCK_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clock module registers */ + +#define TC4X_CLOCK_OSCCON 0xf0064100 +#define TC4X_CLOCK_RAMPCON0 0xf0064200 +#define TC4X_CLOCK_RAMPSTAT 0xf006420c +#define TC4X_CLOCK_SYSPLLCON0 0xf0064300 +#define TC4X_CLOCK_SYSPLLCON1 0xf0064304 +#define TC4X_CLOCK_SYSPLLSTAT 0xf006430c +#define TC4X_CLOCK_PERPLLCON0 0xf0064380 +#define TC4X_CLOCK_PERPLLCON1 0xf0064384 +#define TC4X_CLOCK_PERPLLSTAT 0xf006438c +#define TC4X_CLOCK_CCUCON 0xf0064400 +#define TC4X_CLOCK_CCUSTAT 0xf0064404 +#define TC4X_CLOCK_SYSCCUCON0 0xf0064410 +#define TC4X_CLOCK_SYSCCUCON1 0xf0064414 +#define TC4X_CLOCK_PERCCUCON0 0xf0064420 +#define TC4X_CLOCK_PERCCUCON1 0xf0064424 +#define TC4X_CLOCK_OSCMON1 0xf0064508 +#define TC4X_CLOCK_OSCSTAT 0xf006450c +#define TC4X_CLOCK_RAMPMON 0xf0064510 + +#define TC4X_OSCCON_MODE_SHIFT 8 +#define TC4X_OSCCON_MODE_MASK (0x7 << TC4X_OSCCON_MODE_SHIFT) +#define TC4X_OSCCON_INSEL_SHIFT 24 +#define TC4X_OSCCON_INSEL_MASK (0x3 << TC4X_OSCCON_INSEL_SHIFT) + +#define TC4X_OSCMON1_OSCVAL_MASK (0x7f << 0) +#define TC4X_OSCMON1_SMONEN (1 << 8) +#define TC4X_OSCMON1_PMONEN (1 << 24) +#define TC4X_OSCSTAT_WDS_MASK ((0x3 << 0) | (0x3 << 16)) + +#define TC4X_RAMPCON0_UFL_MASK (0x3ff << 0) +#define TC4X_RAMPCON0_CMD_SHIFT 16 +#define TC4X_RAMPCON0_CMD_MASK (0x7 << TC4X_RAMPCON0_CMD_SHIFT) +#define TC4X_RAMPCON0_PWR (1 << 19) +#define TC4X_RAMPSTAT_FSTAT_SHIFT 16 +#define TC4X_RAMPSTAT_FSTAT_MASK (0x3 << TC4X_RAMPSTAT_FSTAT_SHIFT) +#define TC4X_RAMPSTAT_ACTIVE (1 << 23) +#define TC4X_RAMPSTAT_FLLLOCK (1 << 24) +#define TC4X_RAMPMON_FLLLDEN (1 << 28) + +#define TC4X_PLLCON0_PLLPWR (1 << 0) +#define TC4X_PLLCON0_NDIV_SHIFT 8 +#define TC4X_PLLCON0_NDIV_MASK (0x7f << TC4X_PLLCON0_NDIV_SHIFT) +#define TC4X_PLLCON0_PDIV_SHIFT 16 +#define TC4X_PLLCON0_PDIV_MASK (0x7 << TC4X_PLLCON0_PDIV_SHIFT) +#define TC4X_PLLSTAT_PWRSTAT (1 << 0) +#define TC4X_PLLSTAT_PLLLOCK (1 << 1) + +#define TC4X_PLLCON1_K2DIV_MASK (0xf << 0) +#define TC4X_PLLCON1_K2PRE_SHIFT 4 +#define TC4X_PLLCON1_K2PRE_MASK (0x3 << TC4X_PLLCON1_K2PRE_SHIFT) +#define TC4X_PLLCON1_K3DIV_SHIFT 8 +#define TC4X_PLLCON1_K3DIV_MASK (0x7 << TC4X_PLLCON1_K3DIV_SHIFT) +#define TC4X_PLLCON1_K3PRE_SHIFT 12 +#define TC4X_PLLCON1_K3PRE_MASK (0xf << TC4X_PLLCON1_K3PRE_SHIFT) +#define TC4X_PLLCON1_K4DIV_SHIFT 16 /* PERPLLCON1 only */ +#define TC4X_PLLCON1_K4DIV_MASK (0x7 << TC4X_PLLCON1_K4DIV_SHIFT) +#define TC4X_PLLCON1_K4PRE_SHIFT 20 /* PERPLLCON1 only */ +#define TC4X_PLLCON1_K4PRE_MASK (0x3 << TC4X_PLLCON1_K4PRE_SHIFT) + +#define TC4X_CCUSTAT_LCK (1 << 31) +#define TC4X_CCU_CLKSELS_MASK (0x3 << 0) /* CCUCON and CCUSTAT */ +#define TC4X_CCU_CLKSELS_PLL 0 +#define TC4X_CCU_CLKSELS_BACK 1 +#define TC4X_CCU_CLKSELS_RAMP 2 +#define TC4X_CCU_CLKSELP (1 << 16) /* Set: backup clock */ +#define TC4X_CCUCON_UP (1 << 30) /* SYSCCUCON0 and 1 */ +#define TC4X_PERCCUCON1_ASCLINFDIV (0xf << 0) + +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_CLOCK_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_cpu.h b/arch/tricore/src/tc4x/hardware/tc4x_cpu.h similarity index 76% rename from arch/tricore/src/tc4xx/hardware/tc4xx_cpu.h rename to arch/tricore/src/tc4x/hardware/tc4x_cpu.h index d928773c16222..e93bd0a3418de 100644 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_cpu.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_cpu.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_cpu.h + * arch/tricore/src/tc4x/hardware/tc4x_cpu.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CPU_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CPU_H +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_CPU_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_CPU_H /**************************************************************************** * Pre-processor Definitions @@ -29,8 +29,8 @@ /* Start of the other cores: HRA PC and BOOTCON.BHALT of each CPU */ -#define TC4XX_CPU_HRA_PC(n) (0xf881fe08 + (n) * 0x40000) -#define TC4XX_CPU_HRA_BOOTCON(n) (0xf881fe60 + (n) * 0x40000) -#define TC4XX_BOOTCON_BHALT (1 << 0) +#define TC4X_CPU_HRA_PC(n) (0xf881fe08 + (n) * 0x40000) +#define TC4X_CPU_HRA_BOOTCON(n) (0xf881fe60 + (n) * 0x40000) +#define TC4X_BOOTCON_BHALT (1 << 0) -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CPU_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_CPU_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_dmu.h b/arch/tricore/src/tc4x/hardware/tc4x_dmu.h similarity index 78% rename from arch/tricore/src/tc4xx/hardware/tc4xx_dmu.h rename to arch/tricore/src/tc4x/hardware/tc4x_dmu.h index 565ffcc3afc47..63f25bd5b8dbe 100644 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_dmu.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_dmu.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_dmu.h + * arch/tricore/src/tc4x/hardware/tc4x_dmu.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_DMU_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_DMU_H +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_DMU_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_DMU_H /**************************************************************************** * Pre-processor Definitions @@ -29,9 +29,9 @@ /* Data memory unit (DMU) flash wait state registers */ -#define TC4XX_DMU_HOST_DFWAIT 0xf8040100 -#define TC4XX_DMU_HOST_PFWAIT 0xf804011c +#define TC4X_DMU_HOST_DFWAIT 0xf8040100 +#define TC4X_DMU_HOST_PFWAIT 0xf804011c -#define TC4XX_DMU_RFLASH_MASK 0x1f +#define TC4X_DMU_RFLASH_MASK 0x1f -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_DMU_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_DMU_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_port.h b/arch/tricore/src/tc4x/hardware/tc4x_port.h similarity index 68% rename from arch/tricore/src/tc4xx/hardware/tc4xx_port.h rename to arch/tricore/src/tc4x/hardware/tc4x_port.h index 63e37ceb6635f..6268b3df8fc9d 100644 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_port.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_port.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_port.h + * arch/tricore/src/tc4x/hardware/tc4x_port.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_PORT_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_PORT_H +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_PORT_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_PORT_H /**************************************************************************** * Pre-processor Definitions @@ -29,12 +29,12 @@ /* Port pad configuration: one DRVCFG register per pin */ -#define TC4XX_PORT_DRVCFG(p, n) ((p) + 0x304 + (n) * 0x10) -#define TC4XX_PORT_DRVCFG_MODE_MASK 0xf3 /* MODE, OD and DIR */ -#define TC4XX_PORT_DRVCFG_PAD_MASK 0x7700 /* PD and PL */ +#define TC4X_PORT_DRVCFG(p, n) ((p) + 0x304 + (n) * 0x10) +#define TC4X_PORT_DRVCFG_MODE_MASK 0xf3 /* MODE, OD and DIR */ +#define TC4X_PORT_DRVCFG_PAD_MASK 0x7700 /* PD and PL */ -#define TC4XX_PORT_IN_PULLUP 0x20 /* Input with pull-up */ -#define TC4XX_PORT_OUT_ALT2 0x21 /* Push-pull, alternate 2 */ -#define TC4XX_PORT_PAD_SPEED1 0 /* CMOS automotive speed 1 */ +#define TC4X_PORT_IN_PULLUP 0x20 /* Input with pull-up */ +#define TC4X_PORT_OUT_ALT2 0x21 /* Push-pull, alternate 2 */ +#define TC4X_PORT_PAD_SPEED1 0 /* CMOS automotive speed 1 */ -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_PORT_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_PORT_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_smu.h b/arch/tricore/src/tc4x/hardware/tc4x_smu.h similarity index 71% rename from arch/tricore/src/tc4xx/hardware/tc4xx_smu.h rename to arch/tricore/src/tc4x/hardware/tc4x_smu.h index 5dbd50df3d994..c79dd4d346d49 100644 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_smu.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_smu.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_smu.h + * arch/tricore/src/tc4x/hardware/tc4x_smu.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_SMU_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_SMU_H +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_SMU_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_SMU_H /**************************************************************************** * Pre-processor Definitions @@ -29,12 +29,12 @@ /* Safety management unit (SMU_SAFE0) registers */ -#define TC4XX_SMU_SAFE0_CMD 0xf0029000 -#define TC4XX_SMU_SAFE0_KEYS 0xf002901c -#define TC4XX_SMU_SAFE0_AGSF8_CON(n) (0xf00291a0 + (n) * 4) -#define TC4XX_SMU_SAFE0_AGSF8_STS 0xf00291b8 +#define TC4X_SMU_SAFE0_CMD 0xf0029000 +#define TC4X_SMU_SAFE0_KEYS 0xf002901c +#define TC4X_SMU_SAFE0_AGSF8_CON(n) (0xf00291a0 + (n) * 4) +#define TC4X_SMU_SAFE0_AGSF8_STS 0xf00291b8 -#define TC4XX_SMU_KEYS_CFG 0xbc -#define TC4XX_SMU_CMD_ALARM_CLR 5 +#define TC4X_SMU_KEYS_CFG 0xbc +#define TC4X_SMU_CMD_ALARM_CLR 5 -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_SMU_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_SMU_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_vmt.h b/arch/tricore/src/tc4x/hardware/tc4x_vmt.h similarity index 60% rename from arch/tricore/src/tc4xx/hardware/tc4xx_vmt.h rename to arch/tricore/src/tc4x/hardware/tc4x_vmt.h index f0cb2faa0649f..10c8ca9c151f3 100644 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_vmt.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_vmt.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_vmt.h + * arch/tricore/src/tc4x/hardware/tc4x_vmt.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_VMT_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_VMT_H +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_VMT_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_VMT_H /**************************************************************************** * Pre-processor Definitions @@ -29,20 +29,20 @@ /* Volatile memory test (VMT) module and its MBIST controllers */ -#define TC4XX_VMT_BASE 0xf0400000 -#define TC4XX_VMT_SIZE 0x20000 -#define TC4XX_VMT_CLC 0x0 -#define TC4XX_VMT_CLC_DISS (1 << 1) -#define TC4XX_VMT_MEMTEST 0x80 -#define TC4XX_VMT_MEMSTAT 0x88 -#define TC4XX_VMT_MEMDONE 0x8c -#define TC4XX_VMT_MC(n) (0x1000 + (n) * 0x200) -#define TC4XX_VMT_MC_CONFIG0 0x00 -#define TC4XX_VMT_MC_CONFIG1 0x04 -#define TC4XX_VMT_MC_MCONTROL 0x0c -#define TC4XX_VMT_MC_RANGE 0x14 -#define TC4XX_VMT_MC_ALMSRCS 0x1d0 +#define TC4X_VMT_BASE 0xf0400000 +#define TC4X_VMT_SIZE 0x20000 +#define TC4X_VMT_CLC 0x0 +#define TC4X_VMT_CLC_DISS (1 << 1) +#define TC4X_VMT_MEMTEST 0x80 +#define TC4X_VMT_MEMSTAT 0x88 +#define TC4X_VMT_MEMDONE 0x8c +#define TC4X_VMT_MC(n) (0x1000 + (n) * 0x200) +#define TC4X_VMT_MC_CONFIG0 0x00 +#define TC4X_VMT_MC_CONFIG1 0x04 +#define TC4X_VMT_MC_MCONTROL 0x0c +#define TC4X_VMT_MC_RANGE 0x14 +#define TC4X_VMT_MC_ALMSRCS 0x1d0 -#define TC4XX_ALMSRCS_ALARMS ((1 << 5) | (1 << 4)) /* MISCE, OPENE */ +#define TC4X_ALMSRCS_ALARMS ((1 << 5) | (1 << 4)) /* MISCE, OPENE */ -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_VMT_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_VMT_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_wdt.h b/arch/tricore/src/tc4x/hardware/tc4x_wdt.h similarity index 57% rename from arch/tricore/src/tc4xx/hardware/tc4xx_wdt.h rename to arch/tricore/src/tc4x/hardware/tc4x_wdt.h index db0b94c16ff35..d975016f6c908 100644 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_wdt.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_wdt.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_wdt.h + * arch/tricore/src/tc4x/hardware/tc4x_wdt.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_WDT_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_WDT_H +#ifndef __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_WDT_H +#define __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_WDT_H /**************************************************************************** * Pre-processor Definitions @@ -29,22 +29,22 @@ /* WTU watchdog timers: one per CPU and the system watchdog */ -#define TC4XX_WTU_WDTCPU_CTRLA(n) (0xf000003c + (n) * 0x30) -#define TC4XX_WTU_WDTCPU_CTRLB(n) (0xf0000040 + (n) * 0x30) -#define TC4XX_WTU_WDTSYS_CTRLA 0xf00001a8 -#define TC4XX_WTU_WDTSYS_CTRLB 0xf00001ac -#define TC4XX_WTU_STAT_OFFSET 8 /* From CTRLA */ +#define TC4X_WTU_WDTCPU_CTRLA(n) (0xf000003c + (n) * 0x30) +#define TC4X_WTU_WDTCPU_CTRLB(n) (0xf0000040 + (n) * 0x30) +#define TC4X_WTU_WDTSYS_CTRLA 0xf00001a8 +#define TC4X_WTU_WDTSYS_CTRLB 0xf00001ac +#define TC4X_WTU_STAT_OFFSET 8 /* From CTRLA */ -#define TC4XX_WTU_CTRLA_LCK (1 << 0) /* Lock */ -#define TC4XX_WTU_CTRLA_PW_SHIFT 1 /* Password */ -#define TC4XX_WTU_CTRLA_PW_MASK (0x7fff << TC4XX_WTU_CTRLA_PW_SHIFT) -#define TC4XX_WTU_CTRLA_TCVI_SHIFT 16 /* Timer check value */ -#define TC4XX_WTU_CTRLB_DR (1 << 0) /* Disable request */ -#define TC4XX_WTU_STAT_TC (1 << 8) /* Timer check */ -#define TC4XX_WTU_STAT_TIM_SHIFT 16 /* Timer value */ +#define TC4X_WTU_CTRLA_LCK (1 << 0) /* Lock */ +#define TC4X_WTU_CTRLA_PW_SHIFT 1 /* Password */ +#define TC4X_WTU_CTRLA_PW_MASK (0x7fff << TC4X_WTU_CTRLA_PW_SHIFT) +#define TC4X_WTU_CTRLA_TCVI_SHIFT 16 /* Timer check value */ +#define TC4X_WTU_CTRLB_DR (1 << 0) /* Disable request */ +#define TC4X_WTU_STAT_TC (1 << 8) /* Timer check */ +#define TC4X_WTU_STAT_TIM_SHIFT 16 /* Timer value */ /* The low seven password bits read inverted */ -#define TC4XX_WTU_PW_INVERTED 0x7f +#define TC4X_WTU_PW_INVERTED 0x7f -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_WDT_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_WDT_H */ diff --git a/arch/tricore/src/tc4x/tc4x_clockconfig.c b/arch/tricore/src/tc4x/tc4x_clockconfig.c new file mode 100644 index 0000000000000..094989148857e --- /dev/null +++ b/arch/tricore/src/tc4x/tc4x_clockconfig.c @@ -0,0 +1,587 @@ +/**************************************************************************** + * arch/tricore/src/tc4x/tc4x_clockconfig.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "tricore_internal.h" +#include "hardware/tc4x_clock.h" +#include "hardware/tc4x_dmu.h" +#include "hardware/tc4x_smu.h" +#include "tc4x_wdt.h" +#include "tricore_stm.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* SMU alarms 272 and 273: system and peripheral PLL crystal clock out of + * range, in alarm group 8 of SMU_SAFE0 + */ + +#define TC4X_SMU_PLL_ALARMS ((1 << 16) | (1 << 17)) + +/* Flash wait states for the final clocks */ + +#define TC4X_DFLASH_WAIT 5 +#define TC4X_PFLASH_WAIT 8 + +/* CPU0 STM timer, 100 MHz while the clocks are set up */ + +#define TC4X_STM0_ABS (TRICORE_STM_BASE(0) + TRICORE_STM_ABS_OFFSET) +#define TC4X_STM_TICKS_PER_US 100 + +/* Loop counts before a wait gives up */ + +#define TC4X_CCU_LCK_TIMEOUT 0x1000 +#define TC4X_PLL_LCK_TIMEOUT 0x2710 +#define TC4X_PLL_LOCK_TIMEOUT 0xf000 +#define TC4X_RAMP_TIMEOUT 0x1fffff + +/* Clock setup: 25 MHz crystal, system PLL 500 MHz, peripheral PLL 160 and + * 200 MHz, as the iLLD IfxClock default configuration for TC4Dx. + */ + +#define TC4X_XTAL_MHZ 25 +#define TC4X_PLL_INSEL_OSC0 1 +#define TC4X_OSCCON_MASK (0xff020) /* Bits 5 and 12 to 19 */ +#define TC4X_OSCCON_VALUE (1 << 5) +#define TC4X_RAMP_UFL 400 + +#define TC4X_SYSPLL_PDIV (1 - 1) +#define TC4X_SYSPLL_NDIV (40 - 1) +#define TC4X_SYSPLL_K2 (2 - 1) +#define TC4X_SYSPLL_K2PRE (1 - 1) +#define TC4X_SYSPLL_K3 (2 - 1) +#define TC4X_SYSPLL_K3PRE (2 - 1) +#define TC4X_SYSPLLCON1_INITIAL 0x0000a111 + +#define TC4X_PERPLL_PDIV (1 - 1) +#define TC4X_PERPLL_NDIV (32 - 1) +#define TC4X_PERPLL_K2 (5 - 1) +#define TC4X_PERPLL_K2PRE 0 +#define TC4X_PERPLL_K3 (2 - 1) +#define TC4X_PERPLL_K3PRE 10 +#define TC4X_PERPLL_K4 (2 - 1) +#define TC4X_PERPLL_K4PRE 1 +#define TC4X_PERPLLCON1_PREDIV 0x0010a010 +#define TC4X_PERPLLCON1_DIV 0x00010101 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct tc4x_ccucon_s +{ + uintptr_t reg; + uint32_t value; + uint32_t mask; + uint32_t set; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Clock distribution, written before the PLLs are set up */ + +static const struct tc4x_ccucon_s g_tc4x_ccucon[] = +{ + { TC4X_CLOCK_SYSCCUCON0, 0x21051225, 0x2f0fffff, TC4X_CCUCON_UP }, + { TC4X_CLOCK_SYSCCUCON1, 0x02222002, 0x0ffff00f, TC4X_CCUCON_UP }, + { TC4X_CLOCK_PERCCUCON0, 0x12212111, 0xff3f3f3f, 0 }, + { TC4X_CLOCK_PERCCUCON1, 0x1f115111, 0x1ff1ffff, 0 }, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tc4x_wait + * + * Description: + * Wait until all bits of mask in the register equal the bits in value. + * Return 1 if the wait gave up after count loops, otherwise 0. + * + ****************************************************************************/ + +static int tc4x_wait(uintptr_t reg, uint32_t mask, uint32_t value, + uint32_t count) +{ + while ((getreg32(reg) & mask) != value) + { + if (--count == 0) + { + return 1; + } + } + + return 0; +} + +static int tc4x_wait_unlocked(uint32_t count) +{ + return tc4x_wait(TC4X_CLOCK_CCUSTAT, TC4X_CCUSTAT_LCK, 0, count); +} + +static void tc4x_modify(uintptr_t reg, uint32_t clear, uint32_t set) +{ + putreg32((getreg32(reg) & ~clear) | set, reg); +} + +/**************************************************************************** + * Name: tc4x_delay + * + * Description: + * Wait for us microseconds on the STM, servicing the watchdogs. + * + ****************************************************************************/ + +static void tc4x_delay(uint32_t us) +{ + uint32_t start = getreg32(TC4X_STM0_ABS); + + while (getreg32(TC4X_STM0_ABS) - start < us * TC4X_STM_TICKS_PER_US) + { + tc4x_wdt_service(); + } +} + +static void tc4x_smu_pll_alarms(bool enable) +{ + int i; + + if (enable) + { + putreg32(TC4X_SMU_CMD_ALARM_CLR, TC4X_SMU_SAFE0_CMD); + putreg32(1 << 16, TC4X_SMU_SAFE0_AGSF8_STS); + putreg32(TC4X_SMU_CMD_ALARM_CLR, TC4X_SMU_SAFE0_CMD); + putreg32(1 << 17, TC4X_SMU_SAFE0_AGSF8_STS); + return; + } + + /* Internal alarm action disabled */ + + putreg32(TC4X_SMU_KEYS_CFG, TC4X_SMU_SAFE0_KEYS); + for (i = 0; i < 4; i++) + { + tc4x_modify(TC4X_SMU_SAFE0_AGSF8_CON(i), TC4X_SMU_PLL_ALARMS, 0); + } + + putreg32(0, TC4X_SMU_SAFE0_KEYS); +} + +/**************************************************************************** + * Name: tc4x_clock_distribute + ****************************************************************************/ + +static int tc4x_clock_distribute(void) +{ + const struct tc4x_ccucon_s *cfg; + int ret = 0; + int i; + + tc4x_modify(TC4X_DMU_HOST_DFWAIT, TC4X_DMU_RFLASH_MASK, + TC4X_DFLASH_WAIT); + tc4x_modify(TC4X_DMU_HOST_PFWAIT, TC4X_DMU_RFLASH_MASK, + TC4X_PFLASH_WAIT); + + for (i = 0; i < sizeof(g_tc4x_ccucon) / sizeof(g_tc4x_ccucon[0]); i++) + { + uint32_t regval; + + cfg = &g_tc4x_ccucon[i]; + regval = (getreg32(cfg->reg) & ~cfg->mask) | + (cfg->value & cfg->mask) | cfg->set; + ret |= tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + putreg32(regval, cfg->reg); + } + + return ret; +} + +/**************************************************************************** + * Name: tc4x_osc_init + * + * Description: + * Power up the crystal and the ramp oscillator, select the crystal as + * PLL input and wait for it to be stable. + * + ****************************************************************************/ + +static int tc4x_osc_init(void) +{ + uint32_t mode; + uint32_t osccon; + uint32_t count; + int ret; + + ret = tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + + tc4x_smu_pll_alarms(false); + + mode = (getreg32(TC4X_CLOCK_OSCCON) & TC4X_OSCCON_MODE_MASK) >> + TC4X_OSCCON_MODE_SHIFT; + if (mode == 7) + { + tc4x_modify(TC4X_CLOCK_OSCCON, TC4X_OSCCON_MODE_MASK, + 3 << TC4X_OSCCON_MODE_SHIFT); + tc4x_modify(TC4X_CLOCK_OSCCON, TC4X_OSCCON_MODE_MASK, 0); + } + else if (mode != 2 && mode != 0) + { + osccon = getreg32(TC4X_CLOCK_OSCCON) & ~TC4X_OSCCON_MODE_MASK; + tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + putreg32(osccon, TC4X_CLOCK_OSCCON); + } + + if ((getreg32(TC4X_CLOCK_RAMPSTAT) & TC4X_RAMPSTAT_ACTIVE) == 0) + { + tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + tc4x_modify(TC4X_CLOCK_RAMPCON0, 0, TC4X_RAMPCON0_PWR); + + count = TC4X_CCU_LCK_TIMEOUT; + while ((getreg32(TC4X_CLOCK_RAMPSTAT) & TC4X_RAMPSTAT_ACTIVE) == 0 && + --count != 0); + } + + tc4x_modify(TC4X_CLOCK_RAMPMON, 0, TC4X_RAMPMON_FLLLDEN); + + osccon = getreg32(TC4X_CLOCK_OSCCON) & ~TC4X_OSCCON_MASK; + tc4x_modify(TC4X_CLOCK_OSCMON1, TC4X_OSCMON1_OSCVAL_MASK, + (TC4X_XTAL_MHZ - 15) | TC4X_OSCMON1_SMONEN | + TC4X_OSCMON1_PMONEN); + + ret |= tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + putreg32(osccon | TC4X_OSCCON_VALUE, TC4X_CLOCK_OSCCON); + ret |= tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + tc4x_modify(TC4X_CLOCK_OSCCON, TC4X_OSCCON_INSEL_MASK, + TC4X_PLL_INSEL_OSC0 << TC4X_OSCCON_INSEL_SHIFT); + + /* The crystal may need up to 3 ms to give a stable clock */ + + tc4x_delay(3000); + if ((getreg32(TC4X_CLOCK_OSCSTAT) & TC4X_OSCSTAT_WDS_MASK) != 0) + { + ret = 1; + } + + return ret; +} + +/**************************************************************************** + * Name: tc4x_pll_init + * + * Description: + * Set up one PLL: power it down, set the initial K dividers, power it up + * with P and N, wait for the lock and set the final K dividers. + * + * Returned Value: + * 0 on success, 1 if a wait gave up, -1 if the PLL cannot be powered + * down because the clock runs from it. + * + ****************************************************************************/ + +static int tc4x_pll_init(uintptr_t con0, uintptr_t con1, uintptr_t stat, + uint32_t pdiv, uint32_t ndiv, uint32_t prediv, + uint32_t premask, uint32_t div, uint32_t divmask, + bool sys) +{ + uint32_t regval; + int ret = 0; + + if ((getreg32(stat) & TC4X_PLLSTAT_PWRSTAT) != 0) + { + regval = getreg32(TC4X_CLOCK_CCUSTAT); + if (sys ? ((regval & TC4X_CCU_CLKSELS_MASK) == + TC4X_CCU_CLKSELS_PLL || + (regval & TC4X_CCU_CLKSELS_MASK) == 3) : + (regval & TC4X_CCU_CLKSELP) == 0) + { + return -1; + } + + tc4x_modify(con0, TC4X_PLLCON0_PLLPWR, 0); + } + + ret |= tc4x_wait_unlocked(TC4X_PLL_LCK_TIMEOUT); + if (sys) + { + putreg32(TC4X_SYSPLLCON1_INITIAL, con1); + } + else + { + putreg32(TC4X_PERPLLCON1_PREDIV, con1); + ret |= tc4x_wait_unlocked(TC4X_PLL_LCK_TIMEOUT); + tc4x_modify(con1, 0, TC4X_PERPLLCON1_DIV); + ret |= tc4x_wait_unlocked(TC4X_PLL_LCK_TIMEOUT); + } + + /* The peripheral PLL K pre-dividers are set from the value written + * above, as IfxClock does + */ + + regval = getreg32(con1); + + tc4x_modify(con0, TC4X_PLLCON0_PDIV_MASK | TC4X_PLLCON0_NDIV_MASK, + (pdiv << TC4X_PLLCON0_PDIV_SHIFT) | + (ndiv << TC4X_PLLCON0_NDIV_SHIFT) | TC4X_PLLCON0_PLLPWR); + ret |= tc4x_wait_unlocked(TC4X_PLL_LCK_TIMEOUT); + ret |= tc4x_wait(stat, TC4X_PLLSTAT_PWRSTAT, TC4X_PLLSTAT_PWRSTAT, + TC4X_PLL_LCK_TIMEOUT); + + /* Wait 1 ms to avoid jitter */ + + tc4x_delay(1000); + ret |= tc4x_wait(stat, TC4X_PLLSTAT_PLLLOCK, TC4X_PLLSTAT_PLLLOCK, + TC4X_PLL_LCK_TIMEOUT); + + if (sys) + { + regval = getreg32(con1); + } + + putreg32((regval & ~premask) | prediv, con1); + tc4x_delay(10); + ret |= tc4x_wait_unlocked(TC4X_PLL_LCK_TIMEOUT); + + tc4x_modify(con1, divmask, div); + ret |= tc4x_wait_unlocked(TC4X_PLL_LCK_TIMEOUT); + + return ret; +} + +/**************************************************************************** + * Name: tc4x_clock_switch + * + * Description: + * Run the system clock from the ramp oscillator, ramp it up to the PLL + * frequency and switch both clocks to the PLLs. + * + ****************************************************************************/ + +static int tc4x_clock_switch(void) +{ + uint32_t regval; + int ret; + + tc4x_smu_pll_alarms(true); + + regval = getreg32(TC4X_CLOCK_CCUCON); + regval &= ~TC4X_CCU_CLKSELS_MASK; + regval |= TC4X_CCU_CLKSELS_RAMP | TC4X_CCU_CLKSELP; + ret = tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + putreg32(regval, TC4X_CLOCK_CCUCON); + + ret |= tc4x_wait(TC4X_CLOCK_RAMPSTAT, TC4X_RAMPSTAT_FLLLOCK, + TC4X_RAMPSTAT_FLLLOCK, TC4X_CCU_LCK_TIMEOUT); + + regval = getreg32(TC4X_CLOCK_RAMPCON0); + regval &= ~(TC4X_RAMPCON0_UFL_MASK | TC4X_RAMPCON0_CMD_MASK); + regval |= TC4X_RAMP_UFL | (1 << TC4X_RAMPCON0_CMD_SHIFT); + ret |= tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + putreg32(regval, TC4X_CLOCK_RAMPCON0); + + /* Ramp frequency at the top */ + + ret |= tc4x_wait(TC4X_CLOCK_RAMPSTAT, TC4X_RAMPSTAT_FSTAT_MASK, + 2 << TC4X_RAMPSTAT_FSTAT_SHIFT, TC4X_RAMP_TIMEOUT); + ret |= tc4x_wait(TC4X_CLOCK_SYSPLLSTAT, TC4X_PLLSTAT_PLLLOCK, + TC4X_PLLSTAT_PLLLOCK, TC4X_PLL_LOCK_TIMEOUT); + ret |= tc4x_wait(TC4X_CLOCK_PERPLLSTAT, TC4X_PLLSTAT_PLLLOCK, + TC4X_PLLSTAT_PLLLOCK, TC4X_PLL_LOCK_TIMEOUT); + + regval = getreg32(TC4X_CLOCK_CCUCON); + regval &= ~(TC4X_CCU_CLKSELS_MASK | TC4X_CCU_CLKSELP); + regval |= TC4X_CCU_CLKSELS_PLL; + ret |= tc4x_wait_unlocked(TC4X_CCU_LCK_TIMEOUT); + putreg32(regval, TC4X_CLOCK_CCUCON); + + return ret; +} + +/**************************************************************************** + * Name: tc4x_osc_power_on + * + * Description: + * Power up the crystal oscillator in external crystal mode, as the + * iLLD startup code does before the clock setup. + * + ****************************************************************************/ + +static void tc4x_osc_power_on(void) +{ + uint32_t regval = getreg32(TC4X_CLOCK_OSCCON) & ~TC4X_OSCCON_MODE_MASK; + uint32_t count = TC4X_CCU_LCK_TIMEOUT; + + while ((getreg32(TC4X_CLOCK_CCUSTAT) & TC4X_CCUSTAT_LCK) != 0) + { + if (--count == 0) + { + putreg32(regval, TC4X_CLOCK_OSCCON); + __asm__ __volatile__ ("debug"); + return; + } + } + + putreg32(regval, TC4X_CLOCK_OSCCON); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tricore_clock_asclinf + * + * Description: + * Return the fast ASCLIN clock (fASCLINF) in Hz, from the peripheral PLL + * output 2 and the ASCLINF divider, computed as the iLLD IfxClock does. + * + ****************************************************************************/ + +uint32_t tricore_clock_asclinf(void) +{ + static const uint8_t divs[16] = + { + 1, 1, 2, 3, 4, 5, 6, 6, 8, 8, 10, 10, 12, 12, 12, 15 + }; + + /* K3 predivider in tenths */ + + static const uint8_t prediv[16] = + { + 10, 11, 12, 10, 14, 10, 16, 17, 10, 10, 20, 10, 10, 10, 10, 10 + }; + + uint32_t div = getreg32(TC4X_CLOCK_PERCCUCON1) & + TC4X_PERCCUCON1_ASCLINFDIV; + uint32_t con0 = getreg32(TC4X_CLOCK_PERPLLCON0); + uint32_t con1 = getreg32(TC4X_CLOCK_PERPLLCON1); + uint32_t stat = getreg32(TC4X_CLOCK_PERPLLSTAT); + uint64_t pll2; + + if (div == 0) + { + return 0; + } + + /* Backup clock, 100 MHz */ + + if ((getreg32(TC4X_CLOCK_CCUSTAT) & TC4X_CCU_CLKSELP) != 0) + { + return 100000000 / divs[div]; + } + + if ((stat & (TC4X_PLLSTAT_PLLLOCK | TC4X_PLLSTAT_PWRSTAT)) != + (TC4X_PLLSTAT_PLLLOCK | TC4X_PLLSTAT_PWRSTAT)) + { + return 0; + } + + pll2 = ((uint64_t)TC4X_XTAL_MHZ * 1000000 * + (((con0 & TC4X_PLLCON0_NDIV_MASK) >> TC4X_PLLCON0_NDIV_SHIFT) + + 1) * 10) / + ((((con0 & TC4X_PLLCON0_PDIV_MASK) >> TC4X_PLLCON0_PDIV_SHIFT) + + 1) * + (((con1 & TC4X_PLLCON1_K3DIV_MASK) >> TC4X_PLLCON1_K3DIV_SHIFT) + + 1) * + prediv[(con1 & TC4X_PLLCON1_K3PRE_MASK) >> + TC4X_PLLCON1_K3PRE_SHIFT]); + + return pll2 / divs[div]; +} + +/**************************************************************************** + * Name: tricore_clockconfig + * + * Description: + * Power up the crystal, then set up the flash wait states, the clock + * distribution, the oscillators and the PLLs. Called by the startup code + * once .data and .bss are initialized. + * + * Returned Value: + * 0 on success, 1 if a wait for the hardware gave up. + * + ****************************************************************************/ + +int tricore_clockconfig(void) +{ + int ret; + int pll; + + tc4x_osc_power_on(); + + ret = tc4x_clock_distribute(); + if (ret != 0) + { + return ret; + } + + ret |= tc4x_osc_init(); + + pll = tc4x_pll_init(TC4X_CLOCK_SYSPLLCON0, TC4X_CLOCK_SYSPLLCON1, + TC4X_CLOCK_SYSPLLSTAT, TC4X_SYSPLL_PDIV, + TC4X_SYSPLL_NDIV, + (TC4X_SYSPLL_K2PRE << TC4X_PLLCON1_K2PRE_SHIFT) | + (TC4X_SYSPLL_K3PRE << TC4X_PLLCON1_K3PRE_SHIFT), + TC4X_PLLCON1_K2PRE_MASK | TC4X_PLLCON1_K3PRE_MASK, + TC4X_SYSPLL_K2 | + (TC4X_SYSPLL_K3 << TC4X_PLLCON1_K3DIV_SHIFT), + TC4X_PLLCON1_K2DIV_MASK | TC4X_PLLCON1_K3DIV_MASK, + true); + if (pll < 0) + { + return 1; + } + + ret |= pll; + pll = tc4x_pll_init(TC4X_CLOCK_PERPLLCON0, TC4X_CLOCK_PERPLLCON1, + TC4X_CLOCK_PERPLLSTAT, TC4X_PERPLL_PDIV, + TC4X_PERPLL_NDIV, + (TC4X_PERPLL_K2PRE << TC4X_PLLCON1_K2PRE_SHIFT) | + (TC4X_PERPLL_K3PRE << TC4X_PLLCON1_K3PRE_SHIFT) | + (TC4X_PERPLL_K4PRE << TC4X_PLLCON1_K4PRE_SHIFT), + TC4X_PLLCON1_K2PRE_MASK | TC4X_PLLCON1_K3PRE_MASK | + TC4X_PLLCON1_K4PRE_MASK, + TC4X_PERPLL_K2 | + (TC4X_PERPLL_K3 << TC4X_PLLCON1_K3DIV_SHIFT) | + (TC4X_PERPLL_K4 << TC4X_PLLCON1_K4DIV_SHIFT), + TC4X_PLLCON1_K2DIV_MASK | TC4X_PLLCON1_K3DIV_MASK | + TC4X_PLLCON1_K4DIV_MASK, false); + if (pll < 0) + { + return 1; + } + + ret |= pll; + ret |= tc4x_clock_switch(); + + return ret; +} diff --git a/arch/tricore/src/tc4xx/tc4xx_ram.c b/arch/tricore/src/tc4x/tc4x_ram.c similarity index 62% rename from arch/tricore/src/tc4xx/tc4xx_ram.c rename to arch/tricore/src/tc4x/tc4x_ram.c index 48e31814a46db..aea30b2e77e2c 100644 --- a/arch/tricore/src/tc4xx/tc4xx_ram.c +++ b/arch/tricore/src/tc4x/tc4x_ram.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/tc4xx_ram.c + * arch/tricore/src/tc4x/tc4x_ram.c * * SPDX-License-Identifier: Apache-2.0 * @@ -31,7 +31,7 @@ #include #include "tricore_internal.h" -#include "hardware/tc4xx_vmt.h" +#include "hardware/tc4x_vmt.h" /**************************************************************************** * Pre-processor Definitions @@ -39,15 +39,15 @@ /* SRAMs that the boot firmware initializes after a power-on reset */ -#define TC4XX_UCB0_RAMINIT 0xae408814 -#define TC4XX_RAMIN_MASK (0x3 << 0) /* 0: warm and cold PORST */ -#define TC4XX_RAMINSEL_CPU0 (1 << 16) /* Set: not the CPU0 SRAMs */ -#define TC4XX_LMUINSEL_CPU0 (1 << 24) /* Set: not the CPU0 DLMU */ +#define TC4X_UCB0_RAMINIT 0xae408814 +#define TC4X_RAMIN_MASK (0x3 << 0) /* 0: warm and cold PORST */ +#define TC4X_RAMINSEL_CPU0 (1 << 16) /* Set: not the CPU0 SRAMs */ +#define TC4X_LMUINSEL_CPU0 (1 << 24) /* Set: not the CPU0 DLMU */ /* SSH (MBIST controller) selectors of the DSPR and the DLMU of CPU0 */ -#define TC4XX_SSH_CPU0_DSPR 0 -#define TC4XX_SSH_CPU0_DLMU 4 +#define TC4X_SSH_CPU0_DSPR 0 +#define TC4X_SSH_CPU0_DLMU 4 /**************************************************************************** * Private Data @@ -57,7 +57,7 @@ * never initializes */ -static const uint8_t g_tc4xx_sram[] = +static const uint8_t g_tc4x_sram[] = { 0x17, 0x18, 0x20, 0x21, 0x19, 0x1a, 0x1b, 0x22, 0x23, 0x24, /* LMU0-9 */ 0xa2, 0xa3, 0xa4, 0xa5, 0xa6 /* MCAN0-4 */ @@ -68,7 +68,7 @@ static const uint8_t g_tc4xx_sram[] = ****************************************************************************/ /**************************************************************************** - * Name: tc4xx_sram_clear + * Name: tc4x_sram_clear * * Description: * Fill a whole SRAM with ECC correct zeros through its SSH, with @@ -76,45 +76,45 @@ static const uint8_t g_tc4xx_sram[] = * ****************************************************************************/ -static void tc4xx_sram_clear(uint32_t sel) +static void tc4x_sram_clear(uint32_t sel) { - uintptr_t vmt = TC4XX_VMT_BASE + (sel >> 5) * TC4XX_VMT_SIZE; - uintptr_t mc = vmt + TC4XX_VMT_MC(sel % 32); + uintptr_t vmt = TC4X_VMT_BASE + (sel >> 5) * TC4X_VMT_SIZE; + uintptr_t mc = vmt + TC4X_VMT_MC(sel % 32); uint32_t mask = 1 << (sel % 32); - if ((getreg32(vmt + TC4XX_VMT_CLC) & TC4XX_VMT_CLC_DISS) != 0) + if ((getreg32(vmt + TC4X_VMT_CLC) & TC4X_VMT_CLC_DISS) != 0) { - putreg32(0, vmt + TC4XX_VMT_CLC); + putreg32(0, vmt + TC4X_VMT_CLC); } /* Enable the MBIST shell and start the clear */ - putreg32(getreg32(mc + TC4XX_VMT_MC_ALMSRCS) & ~TC4XX_ALMSRCS_ALARMS, - mc + TC4XX_VMT_MC_ALMSRCS); - putreg32(getreg32(vmt + TC4XX_VMT_MEMTEST) | mask, - vmt + TC4XX_VMT_MEMTEST); - while ((getreg32(vmt + TC4XX_VMT_MEMSTAT) & mask) != 0); + putreg32(getreg32(mc + TC4X_VMT_MC_ALMSRCS) & ~TC4X_ALMSRCS_ALARMS, + mc + TC4X_VMT_MC_ALMSRCS); + putreg32(getreg32(vmt + TC4X_VMT_MEMTEST) | mask, + vmt + TC4X_VMT_MEMTEST); + while ((getreg32(vmt + TC4X_VMT_MEMSTAT) & mask) != 0); - putreg32((1 << 15) | (1 << 0), mc + TC4XX_VMT_MC_MCONTROL); - putreg32(getreg32(mc + TC4XX_VMT_MC_MCONTROL) & ~(1 << 0), - mc + TC4XX_VMT_MC_MCONTROL); - while ((getreg32(vmt + TC4XX_VMT_MEMDONE) & mask) == 0); + putreg32((1 << 15) | (1 << 0), mc + TC4X_VMT_MC_MCONTROL); + putreg32(getreg32(mc + TC4X_VMT_MC_MCONTROL) & ~(1 << 0), + mc + TC4X_VMT_MC_MCONTROL); + while ((getreg32(vmt + TC4X_VMT_MEMDONE) & mask) == 0); /* Read address 0 once, then disable the MBIST shell again */ - putreg32(1 << 3, mc + TC4XX_VMT_MC_MCONTROL); - putreg32((1 << 12) | (1 << 0), mc + TC4XX_VMT_MC_CONFIG0); - putreg32(0, mc + TC4XX_VMT_MC_CONFIG1); - putreg32(0, mc + TC4XX_VMT_MC_RANGE); - putreg32((1 << 3) | (1 << 0), mc + TC4XX_VMT_MC_MCONTROL); - putreg32(1 << 3, mc + TC4XX_VMT_MC_MCONTROL); - while ((getreg32(vmt + TC4XX_VMT_MEMDONE) & mask) == 0); - - putreg32(getreg32(vmt + TC4XX_VMT_MEMTEST) & ~mask, - vmt + TC4XX_VMT_MEMTEST); - while ((getreg32(vmt + TC4XX_VMT_MEMSTAT) & mask) != 0); - putreg32(getreg32(mc + TC4XX_VMT_MC_ALMSRCS) | TC4XX_ALMSRCS_ALARMS, - mc + TC4XX_VMT_MC_ALMSRCS); + putreg32(1 << 3, mc + TC4X_VMT_MC_MCONTROL); + putreg32((1 << 12) | (1 << 0), mc + TC4X_VMT_MC_CONFIG0); + putreg32(0, mc + TC4X_VMT_MC_CONFIG1); + putreg32(0, mc + TC4X_VMT_MC_RANGE); + putreg32((1 << 3) | (1 << 0), mc + TC4X_VMT_MC_MCONTROL); + putreg32(1 << 3, mc + TC4X_VMT_MC_MCONTROL); + while ((getreg32(vmt + TC4X_VMT_MEMDONE) & mask) == 0); + + putreg32(getreg32(vmt + TC4X_VMT_MEMTEST) & ~mask, + vmt + TC4X_VMT_MEMTEST); + while ((getreg32(vmt + TC4X_VMT_MEMSTAT) & mask) != 0); + putreg32(getreg32(mc + TC4X_VMT_MC_ALMSRCS) | TC4X_ALMSRCS_ALARMS, + mc + TC4X_VMT_MC_ALMSRCS); } /**************************************************************************** @@ -136,22 +136,22 @@ static void tc4xx_sram_clear(uint32_t sel) void tricore_ram_init(void) { - uint32_t raminit = getreg32(TC4XX_UCB0_RAMINIT); - uint32_t partial = raminit & TC4XX_RAMIN_MASK; + uint32_t raminit = getreg32(TC4X_UCB0_RAMINIT); + uint32_t partial = raminit & TC4X_RAMIN_MASK; int i; - if (partial != 0 || (raminit & TC4XX_RAMINSEL_CPU0) != 0) + if (partial != 0 || (raminit & TC4X_RAMINSEL_CPU0) != 0) { - tc4xx_sram_clear(TC4XX_SSH_CPU0_DSPR); + tc4x_sram_clear(TC4X_SSH_CPU0_DSPR); } - if (partial != 0 || (raminit & TC4XX_LMUINSEL_CPU0) != 0) + if (partial != 0 || (raminit & TC4X_LMUINSEL_CPU0) != 0) { - tc4xx_sram_clear(TC4XX_SSH_CPU0_DLMU); + tc4x_sram_clear(TC4X_SSH_CPU0_DLMU); } - for (i = 0; i < nitems(g_tc4xx_sram); i++) + for (i = 0; i < nitems(g_tc4x_sram); i++) { - tc4xx_sram_clear(g_tc4xx_sram[i]); + tc4x_sram_clear(g_tc4x_sram[i]); } } diff --git a/arch/tricore/src/tc3xx/tc3xx_timerisr.c b/arch/tricore/src/tc4x/tc4x_timerisr.c similarity index 98% rename from arch/tricore/src/tc3xx/tc3xx_timerisr.c rename to arch/tricore/src/tc4x/tc4x_timerisr.c index df18c08586e15..de8d7154584ed 100644 --- a/arch/tricore/src/tc3xx/tc3xx_timerisr.c +++ b/arch/tricore/src/tc4x/tc4x_timerisr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc3xx/tc3xx_timerisr.c + * arch/tricore/src/tc4x/tc4x_timerisr.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/tricore/src/tc4xx/tc4xx_wdt.c b/arch/tricore/src/tc4x/tc4x_wdt.c similarity index 65% rename from arch/tricore/src/tc4xx/tc4xx_wdt.c rename to arch/tricore/src/tc4x/tc4x_wdt.c index 1127c6cef4de9..444e96f7fb89c 100644 --- a/arch/tricore/src/tc4xx/tc4xx_wdt.c +++ b/arch/tricore/src/tc4x/tc4x_wdt.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/tc4xx_wdt.c + * arch/tricore/src/tc4x/tc4x_wdt.c * * SPDX-License-Identifier: Apache-2.0 * @@ -31,8 +31,8 @@ #include #include "tricore_internal.h" -#include "hardware/tc4xx_wdt.h" -#include "tc4xx_wdt.h" +#include "hardware/tc4x_wdt.h" +#include "tc4x_wdt.h" /**************************************************************************** * Pre-processor Definitions @@ -40,14 +40,14 @@ /* Core index in CORE_ID */ -#define TC4XX_CORE_ID_MASK 0x7 +#define TC4X_CORE_ID_MASK 0x7 /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** - * Name: tc4xx_wdt_disable + * Name: tc4x_wdt_disable * * Description: * Request a watchdog to be disabled: unlock CTRLA with the password if it @@ -55,36 +55,36 @@ * ****************************************************************************/ -static void tc4xx_wdt_disable(uintptr_t ctrla, uintptr_t ctrlb) +static void tc4x_wdt_disable(uintptr_t ctrla, uintptr_t ctrlb) { uint32_t a = getreg32(ctrla); uint32_t b = getreg32(ctrlb); - uint32_t pw = ((a & TC4XX_WTU_CTRLA_PW_MASK) >> TC4XX_WTU_CTRLA_PW_SHIFT) ^ - TC4XX_WTU_PW_INVERTED; + uint32_t pw = ((a & TC4X_WTU_CTRLA_PW_MASK) >> TC4X_WTU_CTRLA_PW_SHIFT) ^ + TC4X_WTU_PW_INVERTED; - if ((a & TC4XX_WTU_CTRLA_LCK) != 0) + if ((a & TC4X_WTU_CTRLA_LCK) != 0) { - a &= ~(TC4XX_WTU_CTRLA_LCK | TC4XX_WTU_CTRLA_PW_MASK); - a |= pw << TC4XX_WTU_CTRLA_PW_SHIFT; + a &= ~(TC4X_WTU_CTRLA_LCK | TC4X_WTU_CTRLA_PW_MASK); + a |= pw << TC4X_WTU_CTRLA_PW_SHIFT; } putreg32(a, ctrla); - putreg32(b | TC4XX_WTU_CTRLB_DR, ctrlb); - putreg32(a | TC4XX_WTU_CTRLA_LCK, ctrla); + putreg32(b | TC4X_WTU_CTRLB_DR, ctrlb); + putreg32(a | TC4X_WTU_CTRLA_LCK, ctrla); } /**************************************************************************** - * Name: tc4xx_wdt_password + * Name: tc4x_wdt_password ****************************************************************************/ -static uint32_t tc4xx_wdt_password(uintptr_t ctrla) +static uint32_t tc4x_wdt_password(uintptr_t ctrla) { - return ((getreg32(ctrla) & TC4XX_WTU_CTRLA_PW_MASK) >> - TC4XX_WTU_CTRLA_PW_SHIFT) ^ TC4XX_WTU_PW_INVERTED; + return ((getreg32(ctrla) & TC4X_WTU_CTRLA_PW_MASK) >> + TC4X_WTU_CTRLA_PW_SHIFT) ^ TC4X_WTU_PW_INVERTED; } /**************************************************************************** - * Name: tc4xx_wdt_service_one + * Name: tc4x_wdt_service_one * * Description: * Service a watchdog: unlock CTRLA with the password, with the inverted @@ -92,27 +92,27 @@ static uint32_t tc4xx_wdt_password(uintptr_t ctrla) * ****************************************************************************/ -static void tc4xx_wdt_service_one(uintptr_t ctrla, uint32_t pw) +static void tc4x_wdt_service_one(uintptr_t ctrla, uint32_t pw) { uint32_t a = getreg32(ctrla); - if ((a & TC4XX_WTU_CTRLA_LCK) != 0) + if ((a & TC4X_WTU_CTRLA_LCK) != 0) { - uint32_t stat = getreg32(ctrla + TC4XX_WTU_STAT_OFFSET); + uint32_t stat = getreg32(ctrla + TC4X_WTU_STAT_OFFSET); - a &= ~(TC4XX_WTU_CTRLA_LCK | TC4XX_WTU_CTRLA_PW_MASK); - a |= pw << TC4XX_WTU_CTRLA_PW_SHIFT; - if ((stat & TC4XX_WTU_STAT_TC) != 0) + a &= ~(TC4X_WTU_CTRLA_LCK | TC4X_WTU_CTRLA_PW_MASK); + a |= pw << TC4X_WTU_CTRLA_PW_SHIFT; + if ((stat & TC4X_WTU_STAT_TC) != 0) { - a &= ~(0xffff << TC4XX_WTU_CTRLA_TCVI_SHIFT); - a |= (~stat >> TC4XX_WTU_STAT_TIM_SHIFT) << - TC4XX_WTU_CTRLA_TCVI_SHIFT; + a &= ~(0xffff << TC4X_WTU_CTRLA_TCVI_SHIFT); + a |= (~stat >> TC4X_WTU_STAT_TIM_SHIFT) << + TC4X_WTU_CTRLA_TCVI_SHIFT; } putreg32(a, ctrla); } - putreg32(a | TC4XX_WTU_CTRLA_LCK, ctrla); + putreg32(a | TC4X_WTU_CTRLA_LCK, ctrla); } /**************************************************************************** @@ -120,7 +120,7 @@ static void tc4xx_wdt_service_one(uintptr_t ctrla, uint32_t pw) ****************************************************************************/ /**************************************************************************** - * Name: tc4xx_wdt_service + * Name: tc4x_wdt_service * * Description: * Service the CPU0 and the system watchdog, for the long waits of the @@ -128,12 +128,12 @@ static void tc4xx_wdt_service_one(uintptr_t ctrla, uint32_t pw) * ****************************************************************************/ -void tc4xx_wdt_service(void) +void tc4x_wdt_service(void) { - tc4xx_wdt_service_one(TC4XX_WTU_WDTCPU_CTRLA(0), - tc4xx_wdt_password(TC4XX_WTU_WDTCPU_CTRLA(0))); - tc4xx_wdt_service_one(TC4XX_WTU_WDTSYS_CTRLA, - tc4xx_wdt_password(TC4XX_WTU_WDTSYS_CTRLA)); + tc4x_wdt_service_one(TC4X_WTU_WDTCPU_CTRLA(0), + tc4x_wdt_password(TC4X_WTU_WDTCPU_CTRLA(0))); + tc4x_wdt_service_one(TC4X_WTU_WDTSYS_CTRLA, + tc4x_wdt_password(TC4X_WTU_WDTSYS_CTRLA)); } /**************************************************************************** @@ -146,9 +146,9 @@ void tc4xx_wdt_service(void) void tricore_wdt_disable(void) { - uint32_t cpu = tricore_mfcr(TRICORE_CPU_CORE_ID) & TC4XX_CORE_ID_MASK; + uint32_t cpu = tricore_mfcr(TRICORE_CPU_CORE_ID) & TC4X_CORE_ID_MASK; - tc4xx_wdt_disable(TC4XX_WTU_WDTCPU_CTRLA(cpu), - TC4XX_WTU_WDTCPU_CTRLB(cpu)); - tc4xx_wdt_disable(TC4XX_WTU_WDTSYS_CTRLA, TC4XX_WTU_WDTSYS_CTRLB); + tc4x_wdt_disable(TC4X_WTU_WDTCPU_CTRLA(cpu), + TC4X_WTU_WDTCPU_CTRLB(cpu)); + tc4x_wdt_disable(TC4X_WTU_WDTSYS_CTRLA, TC4X_WTU_WDTSYS_CTRLB); } diff --git a/arch/tricore/src/tc4xx/tc4xx_wdt.h b/arch/tricore/src/tc4x/tc4x_wdt.h similarity index 85% rename from arch/tricore/src/tc4xx/tc4xx_wdt.h rename to arch/tricore/src/tc4x/tc4x_wdt.h index b258ee162e5a8..843ec0da3fb81 100644 --- a/arch/tricore/src/tc4xx/tc4xx_wdt.h +++ b/arch/tricore/src/tc4x/tc4x_wdt.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/tricore/src/tc4xx/tc4xx_wdt.h + * arch/tricore/src/tc4x/tc4x_wdt.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,13 +20,13 @@ * ****************************************************************************/ -#ifndef __ARCH_TRICORE_SRC_TC4XX_TC4XX_WDT_H -#define __ARCH_TRICORE_SRC_TC4XX_TC4XX_WDT_H +#ifndef __ARCH_TRICORE_SRC_TC4X_TC4X_WDT_H +#define __ARCH_TRICORE_SRC_TC4X_TC4X_WDT_H /**************************************************************************** * Public Function Prototypes ****************************************************************************/ -void tc4xx_wdt_service(void); +void tc4x_wdt_service(void); -#endif /* __ARCH_TRICORE_SRC_TC4XX_TC4XX_WDT_H */ +#endif /* __ARCH_TRICORE_SRC_TC4X_TC4X_WDT_H */ diff --git a/arch/tricore/src/tc4xx/hardware/tc4xx_clock.h b/arch/tricore/src/tc4xx/hardware/tc4xx_clock.h deleted file mode 100644 index 37aa47cb13a35..0000000000000 --- a/arch/tricore/src/tc4xx/hardware/tc4xx_clock.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** - * arch/tricore/src/tc4xx/hardware/tc4xx_clock.h - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CLOCK_H -#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CLOCK_H - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Clock module registers */ - -#define TC4XX_CLOCK_OSCCON 0xf0064100 -#define TC4XX_CLOCK_RAMPCON0 0xf0064200 -#define TC4XX_CLOCK_RAMPSTAT 0xf006420c -#define TC4XX_CLOCK_SYSPLLCON0 0xf0064300 -#define TC4XX_CLOCK_SYSPLLCON1 0xf0064304 -#define TC4XX_CLOCK_SYSPLLSTAT 0xf006430c -#define TC4XX_CLOCK_PERPLLCON0 0xf0064380 -#define TC4XX_CLOCK_PERPLLCON1 0xf0064384 -#define TC4XX_CLOCK_PERPLLSTAT 0xf006438c -#define TC4XX_CLOCK_CCUCON 0xf0064400 -#define TC4XX_CLOCK_CCUSTAT 0xf0064404 -#define TC4XX_CLOCK_SYSCCUCON0 0xf0064410 -#define TC4XX_CLOCK_SYSCCUCON1 0xf0064414 -#define TC4XX_CLOCK_PERCCUCON0 0xf0064420 -#define TC4XX_CLOCK_PERCCUCON1 0xf0064424 -#define TC4XX_CLOCK_OSCMON1 0xf0064508 -#define TC4XX_CLOCK_OSCSTAT 0xf006450c -#define TC4XX_CLOCK_RAMPMON 0xf0064510 - -#define TC4XX_OSCCON_MODE_SHIFT 8 -#define TC4XX_OSCCON_MODE_MASK (0x7 << TC4XX_OSCCON_MODE_SHIFT) -#define TC4XX_OSCCON_INSEL_SHIFT 24 -#define TC4XX_OSCCON_INSEL_MASK (0x3 << TC4XX_OSCCON_INSEL_SHIFT) - -#define TC4XX_OSCMON1_OSCVAL_MASK (0x7f << 0) -#define TC4XX_OSCMON1_SMONEN (1 << 8) -#define TC4XX_OSCMON1_PMONEN (1 << 24) -#define TC4XX_OSCSTAT_WDS_MASK ((0x3 << 0) | (0x3 << 16)) - -#define TC4XX_RAMPCON0_UFL_MASK (0x3ff << 0) -#define TC4XX_RAMPCON0_CMD_SHIFT 16 -#define TC4XX_RAMPCON0_CMD_MASK (0x7 << TC4XX_RAMPCON0_CMD_SHIFT) -#define TC4XX_RAMPCON0_PWR (1 << 19) -#define TC4XX_RAMPSTAT_FSTAT_SHIFT 16 -#define TC4XX_RAMPSTAT_FSTAT_MASK (0x3 << TC4XX_RAMPSTAT_FSTAT_SHIFT) -#define TC4XX_RAMPSTAT_ACTIVE (1 << 23) -#define TC4XX_RAMPSTAT_FLLLOCK (1 << 24) -#define TC4XX_RAMPMON_FLLLDEN (1 << 28) - -#define TC4XX_PLLCON0_PLLPWR (1 << 0) -#define TC4XX_PLLCON0_NDIV_SHIFT 8 -#define TC4XX_PLLCON0_NDIV_MASK (0x7f << TC4XX_PLLCON0_NDIV_SHIFT) -#define TC4XX_PLLCON0_PDIV_SHIFT 16 -#define TC4XX_PLLCON0_PDIV_MASK (0x7 << TC4XX_PLLCON0_PDIV_SHIFT) -#define TC4XX_PLLSTAT_PWRSTAT (1 << 0) -#define TC4XX_PLLSTAT_PLLLOCK (1 << 1) - -#define TC4XX_PLLCON1_K2DIV_MASK (0xf << 0) -#define TC4XX_PLLCON1_K2PRE_SHIFT 4 -#define TC4XX_PLLCON1_K2PRE_MASK (0x3 << TC4XX_PLLCON1_K2PRE_SHIFT) -#define TC4XX_PLLCON1_K3DIV_SHIFT 8 -#define TC4XX_PLLCON1_K3DIV_MASK (0x7 << TC4XX_PLLCON1_K3DIV_SHIFT) -#define TC4XX_PLLCON1_K3PRE_SHIFT 12 -#define TC4XX_PLLCON1_K3PRE_MASK (0xf << TC4XX_PLLCON1_K3PRE_SHIFT) -#define TC4XX_PLLCON1_K4DIV_SHIFT 16 /* PERPLLCON1 only */ -#define TC4XX_PLLCON1_K4DIV_MASK (0x7 << TC4XX_PLLCON1_K4DIV_SHIFT) -#define TC4XX_PLLCON1_K4PRE_SHIFT 20 /* PERPLLCON1 only */ -#define TC4XX_PLLCON1_K4PRE_MASK (0x3 << TC4XX_PLLCON1_K4PRE_SHIFT) - -#define TC4XX_CCUSTAT_LCK (1 << 31) -#define TC4XX_CCU_CLKSELS_MASK (0x3 << 0) /* CCUCON and CCUSTAT */ -#define TC4XX_CCU_CLKSELS_PLL 0 -#define TC4XX_CCU_CLKSELS_BACK 1 -#define TC4XX_CCU_CLKSELS_RAMP 2 -#define TC4XX_CCU_CLKSELP (1 << 16) /* Set: backup clock */ -#define TC4XX_CCUCON_UP (1 << 30) /* SYSCCUCON0 and 1 */ -#define TC4XX_PERCCUCON1_ASCLINFDIV (0xf << 0) - -#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CLOCK_H */ diff --git a/arch/tricore/src/tc4xx/tc4xx_clockconfig.c b/arch/tricore/src/tc4xx/tc4xx_clockconfig.c deleted file mode 100644 index c0c082f0ca4de..0000000000000 --- a/arch/tricore/src/tc4xx/tc4xx_clockconfig.c +++ /dev/null @@ -1,587 +0,0 @@ -/**************************************************************************** - * arch/tricore/src/tc4xx/tc4xx_clockconfig.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include "tricore_internal.h" -#include "hardware/tc4xx_clock.h" -#include "hardware/tc4xx_dmu.h" -#include "hardware/tc4xx_smu.h" -#include "tc4xx_wdt.h" -#include "tricore_stm.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* SMU alarms 272 and 273: system and peripheral PLL crystal clock out of - * range, in alarm group 8 of SMU_SAFE0 - */ - -#define TC4XX_SMU_PLL_ALARMS ((1 << 16) | (1 << 17)) - -/* Flash wait states for the final clocks */ - -#define TC4XX_DFLASH_WAIT 5 -#define TC4XX_PFLASH_WAIT 8 - -/* CPU0 STM timer, 100 MHz while the clocks are set up */ - -#define TC4XX_STM0_ABS (TRICORE_STM_BASE(0) + TRICORE_STM_ABS_OFFSET) -#define TC4XX_STM_TICKS_PER_US 100 - -/* Loop counts before a wait gives up */ - -#define TC4XX_CCU_LCK_TIMEOUT 0x1000 -#define TC4XX_PLL_LCK_TIMEOUT 0x2710 -#define TC4XX_PLL_LOCK_TIMEOUT 0xf000 -#define TC4XX_RAMP_TIMEOUT 0x1fffff - -/* Clock setup: 25 MHz crystal, system PLL 500 MHz, peripheral PLL 160 and - * 200 MHz, as the iLLD IfxClock default configuration for TC4Dx. - */ - -#define TC4XX_XTAL_MHZ 25 -#define TC4XX_PLL_INSEL_OSC0 1 -#define TC4XX_OSCCON_MASK (0xff020) /* Bits 5 and 12 to 19 */ -#define TC4XX_OSCCON_VALUE (1 << 5) -#define TC4XX_RAMP_UFL 400 - -#define TC4XX_SYSPLL_PDIV (1 - 1) -#define TC4XX_SYSPLL_NDIV (40 - 1) -#define TC4XX_SYSPLL_K2 (2 - 1) -#define TC4XX_SYSPLL_K2PRE (1 - 1) -#define TC4XX_SYSPLL_K3 (2 - 1) -#define TC4XX_SYSPLL_K3PRE (2 - 1) -#define TC4XX_SYSPLLCON1_INITIAL 0x0000a111 - -#define TC4XX_PERPLL_PDIV (1 - 1) -#define TC4XX_PERPLL_NDIV (32 - 1) -#define TC4XX_PERPLL_K2 (5 - 1) -#define TC4XX_PERPLL_K2PRE 0 -#define TC4XX_PERPLL_K3 (2 - 1) -#define TC4XX_PERPLL_K3PRE 10 -#define TC4XX_PERPLL_K4 (2 - 1) -#define TC4XX_PERPLL_K4PRE 1 -#define TC4XX_PERPLLCON1_PREDIV 0x0010a010 -#define TC4XX_PERPLLCON1_DIV 0x00010101 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct tc4xx_ccucon_s -{ - uintptr_t reg; - uint32_t value; - uint32_t mask; - uint32_t set; -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* Clock distribution, written before the PLLs are set up */ - -static const struct tc4xx_ccucon_s g_tc4xx_ccucon[] = -{ - { TC4XX_CLOCK_SYSCCUCON0, 0x21051225, 0x2f0fffff, TC4XX_CCUCON_UP }, - { TC4XX_CLOCK_SYSCCUCON1, 0x02222002, 0x0ffff00f, TC4XX_CCUCON_UP }, - { TC4XX_CLOCK_PERCCUCON0, 0x12212111, 0xff3f3f3f, 0 }, - { TC4XX_CLOCK_PERCCUCON1, 0x1f115111, 0x1ff1ffff, 0 }, -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: tc4xx_wait - * - * Description: - * Wait until all bits of mask in the register equal the bits in value. - * Return 1 if the wait gave up after count loops, otherwise 0. - * - ****************************************************************************/ - -static int tc4xx_wait(uintptr_t reg, uint32_t mask, uint32_t value, - uint32_t count) -{ - while ((getreg32(reg) & mask) != value) - { - if (--count == 0) - { - return 1; - } - } - - return 0; -} - -static int tc4xx_wait_unlocked(uint32_t count) -{ - return tc4xx_wait(TC4XX_CLOCK_CCUSTAT, TC4XX_CCUSTAT_LCK, 0, count); -} - -static void tc4xx_modify(uintptr_t reg, uint32_t clear, uint32_t set) -{ - putreg32((getreg32(reg) & ~clear) | set, reg); -} - -/**************************************************************************** - * Name: tc4xx_delay - * - * Description: - * Wait for us microseconds on the STM, servicing the watchdogs. - * - ****************************************************************************/ - -static void tc4xx_delay(uint32_t us) -{ - uint32_t start = getreg32(TC4XX_STM0_ABS); - - while (getreg32(TC4XX_STM0_ABS) - start < us * TC4XX_STM_TICKS_PER_US) - { - tc4xx_wdt_service(); - } -} - -static void tc4xx_smu_pll_alarms(bool enable) -{ - int i; - - if (enable) - { - putreg32(TC4XX_SMU_CMD_ALARM_CLR, TC4XX_SMU_SAFE0_CMD); - putreg32(1 << 16, TC4XX_SMU_SAFE0_AGSF8_STS); - putreg32(TC4XX_SMU_CMD_ALARM_CLR, TC4XX_SMU_SAFE0_CMD); - putreg32(1 << 17, TC4XX_SMU_SAFE0_AGSF8_STS); - return; - } - - /* Internal alarm action disabled */ - - putreg32(TC4XX_SMU_KEYS_CFG, TC4XX_SMU_SAFE0_KEYS); - for (i = 0; i < 4; i++) - { - tc4xx_modify(TC4XX_SMU_SAFE0_AGSF8_CON(i), TC4XX_SMU_PLL_ALARMS, 0); - } - - putreg32(0, TC4XX_SMU_SAFE0_KEYS); -} - -/**************************************************************************** - * Name: tc4xx_clock_distribute - ****************************************************************************/ - -static int tc4xx_clock_distribute(void) -{ - const struct tc4xx_ccucon_s *cfg; - int ret = 0; - int i; - - tc4xx_modify(TC4XX_DMU_HOST_DFWAIT, TC4XX_DMU_RFLASH_MASK, - TC4XX_DFLASH_WAIT); - tc4xx_modify(TC4XX_DMU_HOST_PFWAIT, TC4XX_DMU_RFLASH_MASK, - TC4XX_PFLASH_WAIT); - - for (i = 0; i < sizeof(g_tc4xx_ccucon) / sizeof(g_tc4xx_ccucon[0]); i++) - { - uint32_t regval; - - cfg = &g_tc4xx_ccucon[i]; - regval = (getreg32(cfg->reg) & ~cfg->mask) | - (cfg->value & cfg->mask) | cfg->set; - ret |= tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - putreg32(regval, cfg->reg); - } - - return ret; -} - -/**************************************************************************** - * Name: tc4xx_osc_init - * - * Description: - * Power up the crystal and the ramp oscillator, select the crystal as - * PLL input and wait for it to be stable. - * - ****************************************************************************/ - -static int tc4xx_osc_init(void) -{ - uint32_t mode; - uint32_t osccon; - uint32_t count; - int ret; - - ret = tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - - tc4xx_smu_pll_alarms(false); - - mode = (getreg32(TC4XX_CLOCK_OSCCON) & TC4XX_OSCCON_MODE_MASK) >> - TC4XX_OSCCON_MODE_SHIFT; - if (mode == 7) - { - tc4xx_modify(TC4XX_CLOCK_OSCCON, TC4XX_OSCCON_MODE_MASK, - 3 << TC4XX_OSCCON_MODE_SHIFT); - tc4xx_modify(TC4XX_CLOCK_OSCCON, TC4XX_OSCCON_MODE_MASK, 0); - } - else if (mode != 2 && mode != 0) - { - osccon = getreg32(TC4XX_CLOCK_OSCCON) & ~TC4XX_OSCCON_MODE_MASK; - tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - putreg32(osccon, TC4XX_CLOCK_OSCCON); - } - - if ((getreg32(TC4XX_CLOCK_RAMPSTAT) & TC4XX_RAMPSTAT_ACTIVE) == 0) - { - tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - tc4xx_modify(TC4XX_CLOCK_RAMPCON0, 0, TC4XX_RAMPCON0_PWR); - - count = TC4XX_CCU_LCK_TIMEOUT; - while ((getreg32(TC4XX_CLOCK_RAMPSTAT) & TC4XX_RAMPSTAT_ACTIVE) == 0 && - --count != 0); - } - - tc4xx_modify(TC4XX_CLOCK_RAMPMON, 0, TC4XX_RAMPMON_FLLLDEN); - - osccon = getreg32(TC4XX_CLOCK_OSCCON) & ~TC4XX_OSCCON_MASK; - tc4xx_modify(TC4XX_CLOCK_OSCMON1, TC4XX_OSCMON1_OSCVAL_MASK, - (TC4XX_XTAL_MHZ - 15) | TC4XX_OSCMON1_SMONEN | - TC4XX_OSCMON1_PMONEN); - - ret |= tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - putreg32(osccon | TC4XX_OSCCON_VALUE, TC4XX_CLOCK_OSCCON); - ret |= tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - tc4xx_modify(TC4XX_CLOCK_OSCCON, TC4XX_OSCCON_INSEL_MASK, - TC4XX_PLL_INSEL_OSC0 << TC4XX_OSCCON_INSEL_SHIFT); - - /* The crystal may need up to 3 ms to give a stable clock */ - - tc4xx_delay(3000); - if ((getreg32(TC4XX_CLOCK_OSCSTAT) & TC4XX_OSCSTAT_WDS_MASK) != 0) - { - ret = 1; - } - - return ret; -} - -/**************************************************************************** - * Name: tc4xx_pll_init - * - * Description: - * Set up one PLL: power it down, set the initial K dividers, power it up - * with P and N, wait for the lock and set the final K dividers. - * - * Returned Value: - * 0 on success, 1 if a wait gave up, -1 if the PLL cannot be powered - * down because the clock runs from it. - * - ****************************************************************************/ - -static int tc4xx_pll_init(uintptr_t con0, uintptr_t con1, uintptr_t stat, - uint32_t pdiv, uint32_t ndiv, uint32_t prediv, - uint32_t premask, uint32_t div, uint32_t divmask, - bool sys) -{ - uint32_t regval; - int ret = 0; - - if ((getreg32(stat) & TC4XX_PLLSTAT_PWRSTAT) != 0) - { - regval = getreg32(TC4XX_CLOCK_CCUSTAT); - if (sys ? ((regval & TC4XX_CCU_CLKSELS_MASK) == - TC4XX_CCU_CLKSELS_PLL || - (regval & TC4XX_CCU_CLKSELS_MASK) == 3) : - (regval & TC4XX_CCU_CLKSELP) == 0) - { - return -1; - } - - tc4xx_modify(con0, TC4XX_PLLCON0_PLLPWR, 0); - } - - ret |= tc4xx_wait_unlocked(TC4XX_PLL_LCK_TIMEOUT); - if (sys) - { - putreg32(TC4XX_SYSPLLCON1_INITIAL, con1); - } - else - { - putreg32(TC4XX_PERPLLCON1_PREDIV, con1); - ret |= tc4xx_wait_unlocked(TC4XX_PLL_LCK_TIMEOUT); - tc4xx_modify(con1, 0, TC4XX_PERPLLCON1_DIV); - ret |= tc4xx_wait_unlocked(TC4XX_PLL_LCK_TIMEOUT); - } - - /* The peripheral PLL K pre-dividers are set from the value written - * above, as IfxClock does - */ - - regval = getreg32(con1); - - tc4xx_modify(con0, TC4XX_PLLCON0_PDIV_MASK | TC4XX_PLLCON0_NDIV_MASK, - (pdiv << TC4XX_PLLCON0_PDIV_SHIFT) | - (ndiv << TC4XX_PLLCON0_NDIV_SHIFT) | TC4XX_PLLCON0_PLLPWR); - ret |= tc4xx_wait_unlocked(TC4XX_PLL_LCK_TIMEOUT); - ret |= tc4xx_wait(stat, TC4XX_PLLSTAT_PWRSTAT, TC4XX_PLLSTAT_PWRSTAT, - TC4XX_PLL_LCK_TIMEOUT); - - /* Wait 1 ms to avoid jitter */ - - tc4xx_delay(1000); - ret |= tc4xx_wait(stat, TC4XX_PLLSTAT_PLLLOCK, TC4XX_PLLSTAT_PLLLOCK, - TC4XX_PLL_LCK_TIMEOUT); - - if (sys) - { - regval = getreg32(con1); - } - - putreg32((regval & ~premask) | prediv, con1); - tc4xx_delay(10); - ret |= tc4xx_wait_unlocked(TC4XX_PLL_LCK_TIMEOUT); - - tc4xx_modify(con1, divmask, div); - ret |= tc4xx_wait_unlocked(TC4XX_PLL_LCK_TIMEOUT); - - return ret; -} - -/**************************************************************************** - * Name: tc4xx_clock_switch - * - * Description: - * Run the system clock from the ramp oscillator, ramp it up to the PLL - * frequency and switch both clocks to the PLLs. - * - ****************************************************************************/ - -static int tc4xx_clock_switch(void) -{ - uint32_t regval; - int ret; - - tc4xx_smu_pll_alarms(true); - - regval = getreg32(TC4XX_CLOCK_CCUCON); - regval &= ~TC4XX_CCU_CLKSELS_MASK; - regval |= TC4XX_CCU_CLKSELS_RAMP | TC4XX_CCU_CLKSELP; - ret = tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - putreg32(regval, TC4XX_CLOCK_CCUCON); - - ret |= tc4xx_wait(TC4XX_CLOCK_RAMPSTAT, TC4XX_RAMPSTAT_FLLLOCK, - TC4XX_RAMPSTAT_FLLLOCK, TC4XX_CCU_LCK_TIMEOUT); - - regval = getreg32(TC4XX_CLOCK_RAMPCON0); - regval &= ~(TC4XX_RAMPCON0_UFL_MASK | TC4XX_RAMPCON0_CMD_MASK); - regval |= TC4XX_RAMP_UFL | (1 << TC4XX_RAMPCON0_CMD_SHIFT); - ret |= tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - putreg32(regval, TC4XX_CLOCK_RAMPCON0); - - /* Ramp frequency at the top */ - - ret |= tc4xx_wait(TC4XX_CLOCK_RAMPSTAT, TC4XX_RAMPSTAT_FSTAT_MASK, - 2 << TC4XX_RAMPSTAT_FSTAT_SHIFT, TC4XX_RAMP_TIMEOUT); - ret |= tc4xx_wait(TC4XX_CLOCK_SYSPLLSTAT, TC4XX_PLLSTAT_PLLLOCK, - TC4XX_PLLSTAT_PLLLOCK, TC4XX_PLL_LOCK_TIMEOUT); - ret |= tc4xx_wait(TC4XX_CLOCK_PERPLLSTAT, TC4XX_PLLSTAT_PLLLOCK, - TC4XX_PLLSTAT_PLLLOCK, TC4XX_PLL_LOCK_TIMEOUT); - - regval = getreg32(TC4XX_CLOCK_CCUCON); - regval &= ~(TC4XX_CCU_CLKSELS_MASK | TC4XX_CCU_CLKSELP); - regval |= TC4XX_CCU_CLKSELS_PLL; - ret |= tc4xx_wait_unlocked(TC4XX_CCU_LCK_TIMEOUT); - putreg32(regval, TC4XX_CLOCK_CCUCON); - - return ret; -} - -/**************************************************************************** - * Name: tc4xx_osc_power_on - * - * Description: - * Power up the crystal oscillator in external crystal mode, as the - * iLLD startup code does before the clock setup. - * - ****************************************************************************/ - -static void tc4xx_osc_power_on(void) -{ - uint32_t regval = getreg32(TC4XX_CLOCK_OSCCON) & ~TC4XX_OSCCON_MODE_MASK; - uint32_t count = TC4XX_CCU_LCK_TIMEOUT; - - while ((getreg32(TC4XX_CLOCK_CCUSTAT) & TC4XX_CCUSTAT_LCK) != 0) - { - if (--count == 0) - { - putreg32(regval, TC4XX_CLOCK_OSCCON); - __asm__ __volatile__ ("debug"); - return; - } - } - - putreg32(regval, TC4XX_CLOCK_OSCCON); -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: tricore_clock_asclinf - * - * Description: - * Return the fast ASCLIN clock (fASCLINF) in Hz, from the peripheral PLL - * output 2 and the ASCLINF divider, computed as the iLLD IfxClock does. - * - ****************************************************************************/ - -uint32_t tricore_clock_asclinf(void) -{ - static const uint8_t divs[16] = - { - 1, 1, 2, 3, 4, 5, 6, 6, 8, 8, 10, 10, 12, 12, 12, 15 - }; - - /* K3 predivider in tenths */ - - static const uint8_t prediv[16] = - { - 10, 11, 12, 10, 14, 10, 16, 17, 10, 10, 20, 10, 10, 10, 10, 10 - }; - - uint32_t div = getreg32(TC4XX_CLOCK_PERCCUCON1) & - TC4XX_PERCCUCON1_ASCLINFDIV; - uint32_t con0 = getreg32(TC4XX_CLOCK_PERPLLCON0); - uint32_t con1 = getreg32(TC4XX_CLOCK_PERPLLCON1); - uint32_t stat = getreg32(TC4XX_CLOCK_PERPLLSTAT); - uint64_t pll2; - - if (div == 0) - { - return 0; - } - - /* Backup clock, 100 MHz */ - - if ((getreg32(TC4XX_CLOCK_CCUSTAT) & TC4XX_CCU_CLKSELP) != 0) - { - return 100000000 / divs[div]; - } - - if ((stat & (TC4XX_PLLSTAT_PLLLOCK | TC4XX_PLLSTAT_PWRSTAT)) != - (TC4XX_PLLSTAT_PLLLOCK | TC4XX_PLLSTAT_PWRSTAT)) - { - return 0; - } - - pll2 = ((uint64_t)TC4XX_XTAL_MHZ * 1000000 * - (((con0 & TC4XX_PLLCON0_NDIV_MASK) >> TC4XX_PLLCON0_NDIV_SHIFT) + - 1) * 10) / - ((((con0 & TC4XX_PLLCON0_PDIV_MASK) >> TC4XX_PLLCON0_PDIV_SHIFT) + - 1) * - (((con1 & TC4XX_PLLCON1_K3DIV_MASK) >> TC4XX_PLLCON1_K3DIV_SHIFT) + - 1) * - prediv[(con1 & TC4XX_PLLCON1_K3PRE_MASK) >> - TC4XX_PLLCON1_K3PRE_SHIFT]); - - return pll2 / divs[div]; -} - -/**************************************************************************** - * Name: tricore_clockconfig - * - * Description: - * Power up the crystal, then set up the flash wait states, the clock - * distribution, the oscillators and the PLLs. Called by the startup code - * once .data and .bss are initialized. - * - * Returned Value: - * 0 on success, 1 if a wait for the hardware gave up. - * - ****************************************************************************/ - -int tricore_clockconfig(void) -{ - int ret; - int pll; - - tc4xx_osc_power_on(); - - ret = tc4xx_clock_distribute(); - if (ret != 0) - { - return ret; - } - - ret |= tc4xx_osc_init(); - - pll = tc4xx_pll_init(TC4XX_CLOCK_SYSPLLCON0, TC4XX_CLOCK_SYSPLLCON1, - TC4XX_CLOCK_SYSPLLSTAT, TC4XX_SYSPLL_PDIV, - TC4XX_SYSPLL_NDIV, - (TC4XX_SYSPLL_K2PRE << TC4XX_PLLCON1_K2PRE_SHIFT) | - (TC4XX_SYSPLL_K3PRE << TC4XX_PLLCON1_K3PRE_SHIFT), - TC4XX_PLLCON1_K2PRE_MASK | TC4XX_PLLCON1_K3PRE_MASK, - TC4XX_SYSPLL_K2 | - (TC4XX_SYSPLL_K3 << TC4XX_PLLCON1_K3DIV_SHIFT), - TC4XX_PLLCON1_K2DIV_MASK | TC4XX_PLLCON1_K3DIV_MASK, - true); - if (pll < 0) - { - return 1; - } - - ret |= pll; - pll = tc4xx_pll_init(TC4XX_CLOCK_PERPLLCON0, TC4XX_CLOCK_PERPLLCON1, - TC4XX_CLOCK_PERPLLSTAT, TC4XX_PERPLL_PDIV, - TC4XX_PERPLL_NDIV, - (TC4XX_PERPLL_K2PRE << TC4XX_PLLCON1_K2PRE_SHIFT) | - (TC4XX_PERPLL_K3PRE << TC4XX_PLLCON1_K3PRE_SHIFT) | - (TC4XX_PERPLL_K4PRE << TC4XX_PLLCON1_K4PRE_SHIFT), - TC4XX_PLLCON1_K2PRE_MASK | TC4XX_PLLCON1_K3PRE_MASK | - TC4XX_PLLCON1_K4PRE_MASK, - TC4XX_PERPLL_K2 | - (TC4XX_PERPLL_K3 << TC4XX_PLLCON1_K3DIV_SHIFT) | - (TC4XX_PERPLL_K4 << TC4XX_PLLCON1_K4DIV_SHIFT), - TC4XX_PLLCON1_K2DIV_MASK | TC4XX_PLLCON1_K3DIV_MASK | - TC4XX_PLLCON1_K4DIV_MASK, false); - if (pll < 0) - { - return 1; - } - - ret |= pll; - ret |= tc4xx_clock_switch(); - - return ret; -} diff --git a/boards/Kconfig b/boards/Kconfig index 433abc1177703..1d08073076a1d 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -4742,7 +4742,7 @@ if ARCH_BOARD_QEMU_RH850_U2C source "boards/rh850/u2c/qemu-rh850-u2c/Kconfig" endif if ARCH_BOARD_A2G_TC397_5V_TFT -source "boards/tricore/tc3xx/a2g-tc397-5v-tft/Kconfig" +source "boards/tricore/tc3x/a2g-tc397-5v-tft/Kconfig" endif if ARCH_BOARD_MPS2_AN500 source "boards/arm/mps/mps2-an500/Kconfig" diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/CMakeLists.txt b/boards/tricore/tc3x/a2g-tc397-5v-tft/CMakeLists.txt similarity index 95% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/CMakeLists.txt rename to boards/tricore/tc3x/a2g-tc397-5v-tft/CMakeLists.txt index 5864dba4ba25d..92a3e3af1a99b 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/CMakeLists.txt +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/tricore/tc3xx/a2g-tc397-5v-tft/CMakeLists.txt +# boards/tricore/tc3x/a2g-tc397-5v-tft/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/Kconfig b/boards/tricore/tc3x/a2g-tc397-5v-tft/Kconfig similarity index 95% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/Kconfig rename to boards/tricore/tc3x/a2g-tc397-5v-tft/Kconfig index 7292ccfdd9c11..b48b8c4a1d31a 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/Kconfig +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/Kconfig @@ -1,5 +1,5 @@ ############################################################################ -# boards/tricore/tc3xx/a2g-tc397-5v-tft/Kconfig +# boards/tricore/tc3x/a2g-tc397-5v-tft/Kconfig # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig b/boards/tricore/tc3x/a2g-tc397-5v-tft/configs/nsh/defconfig similarity index 98% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig rename to boards/tricore/tc3x/a2g-tc397-5v-tft/configs/nsh/defconfig index f58f8b2f500ee..c95e415d2e5bf 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/configs/nsh/defconfig +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/configs/nsh/defconfig @@ -9,7 +9,7 @@ CONFIG_ARCH="tricore" CONFIG_ARCH_BOARD="a2g-tc397-5v-tft" CONFIG_ARCH_BOARD_A2G_TC397_5V_TFT=y -CONFIG_ARCH_CHIP="tc3xx" +CONFIG_ARCH_CHIP="tc3x" CONFIG_ARCH_CHIP_TC397=y CONFIG_ARCH_CHIP_TC3X=y CONFIG_ARCH_INTERRUPTSTACK=2048 diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board.h b/boards/tricore/tc3x/a2g-tc397-5v-tft/include/board.h similarity index 86% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board.h rename to boards/tricore/tc3x/a2g-tc397-5v-tft/include/board.h index b6464840fb657..b7919a4912b13 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board.h +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/include/board.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board.h + * boards/tricore/tc3x/a2g-tc397-5v-tft/include/board.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_INCLUDE_BOARD_H -#define __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_INCLUDE_BOARD_H +#ifndef __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_INCLUDE_BOARD_H +#define __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_INCLUDE_BOARD_H /**************************************************************************** * Included Files @@ -37,4 +37,4 @@ * Public Functions Definitions ****************************************************************************/ -#endif /* __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_INCLUDE_BOARD_H */ +#endif /* __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_INCLUDE_BOARD_H */ diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board_memorymap.h b/boards/tricore/tc3x/a2g-tc397-5v-tft/include/board_memorymap.h similarity index 98% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board_memorymap.h rename to boards/tricore/tc3x/a2g-tc397-5v-tft/include/board_memorymap.h index c13fb79cce35d..3759f43549117 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board_memorymap.h +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/include/board_memorymap.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/include/board_memorymap.h + * boards/tricore/tc3x/a2g-tc397-5v-tft/include/board_memorymap.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_INCLUDE_BOARD_MEMORYMAP_H -#define __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_INCLUDE_BOARD_MEMORYMAP_H +#ifndef __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_INCLUDE_BOARD_MEMORYMAP_H /**************************************************************************** * Included Files @@ -358,4 +358,4 @@ extern "C" #endif /* __ASSEMBLY__ */ -#endif /* __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_INCLUDE_BOARD_MEMORYMAP_H */ +#endif /* __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/CMakeLists.txt b/boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/CMakeLists.txt similarity index 94% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/CMakeLists.txt rename to boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/CMakeLists.txt index 3a8826cddd824..fde4bb3767204 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/CMakeLists.txt +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/CMakeLists.txt +# boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/tc397_userspace.c b/boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/tc397_userspace.c similarity index 97% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/tc397_userspace.c rename to boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/tc397_userspace.c index f34646b03d2b4..9acdd2877d2ac 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/tc397_userspace.c +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/tc397_userspace.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/kernel/tc397_userspace.c + * boards/tricore/tc3x/a2g-tc397-5v-tft/kernel/tc397_userspace.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user similarity index 99% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user rename to boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user index ac6cd239e2613..c027ab19aef81 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user + * boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user similarity index 98% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user rename to boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user index e42cf28ddafa0..4f325e1878e7c 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user + * boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Lcf_Tasking_Tricore_Tc.lsl.user * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Make.defs b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Make.defs similarity index 94% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Make.defs rename to boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Make.defs index a3362ca48f31a..92553c8b71073 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Make.defs +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/Make.defs +# boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -22,7 +22,7 @@ include $(TOPDIR)/.config include $(TOPDIR)/tools/Config.mk -include $(TOPDIR)/arch/tricore/src/tc3xx/Toolchain.defs +include $(TOPDIR)/arch/tricore/src/tc3x/Toolchain.defs ifeq ($(CONFIG_TRICORE_TOOLCHAIN_TASKING),y) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)tricore.lsl diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.ld b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.ld similarity index 98% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.ld rename to boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.ld index e68bb68c61188..a5172908e805e 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.ld +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.ld @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.ld + * boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.ld * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.lsl b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.lsl similarity index 97% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.lsl rename to boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.lsl index d9615ec1b0656..14b1ef959b123 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.lsl +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.lsl @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/scripts/tricore.lsl + * boards/tricore/tc3x/a2g-tc397-5v-tft/scripts/tricore.lsl * * SPDX-License-Identifier: Apache-2.0 * @@ -58,7 +58,7 @@ #define USTACK0 ISTACK0_END #define USTACK0_END (USTACK0 - USTACK_SIZE) -derivative nuttx_tc3xx +derivative nuttx_tc3x { core tc0 { @@ -84,7 +84,7 @@ derivative nuttx_tc3xx processor mpe { - derivative = nuttx_tc3xx; + derivative = nuttx_tc3x; } section_setup mpe:tc0:linear diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/CMakeLists.txt b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/CMakeLists.txt similarity index 96% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/src/CMakeLists.txt rename to boards/tricore/tc3x/a2g-tc397-5v-tft/src/CMakeLists.txt index 0f6fda75f4f0a..9cf001232519e 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/CMakeLists.txt +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/tricore/tc3xx/a2g-tc397-5v-tft/src/CMakeLists.txt +# boards/tricore/tc3x/a2g-tc397-5v-tft/src/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/Makefile b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/Makefile similarity index 95% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/src/Makefile rename to boards/tricore/tc3x/a2g-tc397-5v-tft/src/Makefile index e9d6f8cae864e..a5e2e557ffaba 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/Makefile +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# boards/tricore/tc3xx/a2g-tc397-5v-tft/src/Makefile +# boards/tricore/tc3x/a2g-tc397-5v-tft/src/Makefile # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397.h b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397.h similarity index 90% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397.h rename to boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397.h index 4b6fdc9481329..6d581d0f240ef 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397.h +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397.h + * boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_SRC_TC397_H -#define __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_SRC_TC397_H +#ifndef __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_SRC_TC397_H +#define __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_SRC_TC397_H /**************************************************************************** * Included Files @@ -62,4 +62,4 @@ int tc397_bringup(void); #endif #endif /* __ASSEMBLY__ */ -#endif /* __BOARDS_TRICORE_TC3XX_A2G_TC397_5V_TFT_SRC_TC397_H */ +#endif /* __BOARDS_TRICORE_TC3X_A2G_TC397_5V_TFT_SRC_TC397_H */ diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_boardinit.c b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_boardinit.c similarity index 98% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_boardinit.c rename to boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_boardinit.c index b49502e09d392..e68f4bdbf97e5 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_boardinit.c +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_boardinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_boardinit.c + * boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_boardinit.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_bringup.c similarity index 97% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c rename to boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_bringup.c index 0ee14dc79cff9..a9d5f0c3d1c15 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_bringup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c + * boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_bringup.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_userspace.c b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_userspace.c similarity index 97% rename from boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_userspace.c rename to boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_userspace.c index 2297fae48837b..c8e5aaa449e66 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_userspace.c +++ b/boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_userspace.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_userspace.c + * boards/tricore/tc3x/a2g-tc397-5v-tft/src/tc397_userspace.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/CMakeLists.txt b/boards/tricore/tc4x/triboard_tc4x9_com/CMakeLists.txt similarity index 94% rename from boards/tricore/tc4xx/triboard_tc4x9_com/CMakeLists.txt rename to boards/tricore/tc4x/triboard_tc4x9_com/CMakeLists.txt index 219520b382c82..e5b551de5ebec 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/CMakeLists.txt +++ b/boards/tricore/tc4x/triboard_tc4x9_com/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/tricore/tc4xx/triboard_tc4x9_com/CMakeLists.txt +# boards/tricore/tc4x/triboard_tc4x9_com/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/Kconfig b/boards/tricore/tc4x/triboard_tc4x9_com/Kconfig similarity index 95% rename from boards/tricore/tc4xx/triboard_tc4x9_com/Kconfig rename to boards/tricore/tc4x/triboard_tc4x9_com/Kconfig index 9ffd71c166cc2..170eca2ca2e64 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/Kconfig +++ b/boards/tricore/tc4x/triboard_tc4x9_com/Kconfig @@ -1,5 +1,5 @@ ############################################################################ -# boards/tricore/tc4xx/triboard_tc4x9_com/Kconfig +# boards/tricore/tc4x/triboard_tc4x9_com/Kconfig # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/configs/nsh/defconfig b/boards/tricore/tc4x/triboard_tc4x9_com/configs/nsh/defconfig similarity index 98% rename from boards/tricore/tc4xx/triboard_tc4x9_com/configs/nsh/defconfig rename to boards/tricore/tc4x/triboard_tc4x9_com/configs/nsh/defconfig index 5dda49ae9c06d..00a897e2c8231 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/configs/nsh/defconfig +++ b/boards/tricore/tc4x/triboard_tc4x9_com/configs/nsh/defconfig @@ -9,7 +9,7 @@ CONFIG_ARCH="tricore" CONFIG_ARCH_BOARD="triboard_tc4x9_com" CONFIG_ARCH_BOARD_TRIBOARD_TC4X9_COM=y -CONFIG_ARCH_CHIP="tc4xx" +CONFIG_ARCH_CHIP="tc4x" CONFIG_ARCH_CHIP_TC4DX=y CONFIG_ARCH_CHIP_TC4X=y CONFIG_ARCH_INTERRUPTSTACK=2048 diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/include/board.h b/boards/tricore/tc4x/triboard_tc4x9_com/include/board.h similarity index 85% rename from boards/tricore/tc4xx/triboard_tc4x9_com/include/board.h rename to boards/tricore/tc4x/triboard_tc4x9_com/include/board.h index d54335750c61a..95353ef65044f 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/include/board.h +++ b/boards/tricore/tc4x/triboard_tc4x9_com/include/board.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/include/board.h + * boards/tricore/tc4x/triboard_tc4x9_com/include/board.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_H -#define __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_H +#ifndef __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_H +#define __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_H /**************************************************************************** * Included Files @@ -37,4 +37,4 @@ * Public Functions Definitions ****************************************************************************/ -#endif /* __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_H */ +#endif /* __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_H */ diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/include/board_memorymap.h b/boards/tricore/tc4x/triboard_tc4x9_com/include/board_memorymap.h similarity index 98% rename from boards/tricore/tc4xx/triboard_tc4x9_com/include/board_memorymap.h rename to boards/tricore/tc4x/triboard_tc4x9_com/include/board_memorymap.h index 27fdf77f38107..723c46baca9ac 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/include/board_memorymap.h +++ b/boards/tricore/tc4x/triboard_tc4x9_com/include/board_memorymap.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/include/board_memorymap.h + * boards/tricore/tc4x/triboard_tc4x9_com/include/board_memorymap.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_MEMORYMAP_H -#define __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_MEMORYMAP_H +#ifndef __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_MEMORYMAP_H /**************************************************************************** * Included Files @@ -449,4 +449,4 @@ extern "C" #endif /* __ASSEMBLY__ */ -#endif /* __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_MEMORYMAP_H */ +#endif /* __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/kernel/CMakeLists.txt b/boards/tricore/tc4x/triboard_tc4x9_com/kernel/CMakeLists.txt similarity index 94% rename from boards/tricore/tc4xx/triboard_tc4x9_com/kernel/CMakeLists.txt rename to boards/tricore/tc4x/triboard_tc4x9_com/kernel/CMakeLists.txt index f23c48dfeab6c..1d9391e01fc62 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/kernel/CMakeLists.txt +++ b/boards/tricore/tc4x/triboard_tc4x9_com/kernel/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/tricore/tc4xx/triboard_tc4x9_com/kernel/CMakeLists.txt +# boards/tricore/tc4x/triboard_tc4x9_com/kernel/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/kernel/tc4d9_userspace.c b/boards/tricore/tc4x/triboard_tc4x9_com/kernel/tc4d9_userspace.c similarity index 97% rename from boards/tricore/tc4xx/triboard_tc4x9_com/kernel/tc4d9_userspace.c rename to boards/tricore/tc4x/triboard_tc4x9_com/kernel/tc4d9_userspace.c index 36b8bf450eb2b..0ddce75c070dc 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/kernel/tc4d9_userspace.c +++ b/boards/tricore/tc4x/triboard_tc4x9_com/kernel/tc4d9_userspace.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/kernel/tc4d9_userspace.c + * boards/tricore/tc4x/triboard_tc4x9_com/kernel/tc4d9_userspace.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user similarity index 99% rename from boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user rename to boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user index bd4bc461950cd..06a17da1d4efe 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user +++ b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user + * boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Gnuc_Tricore_Tc.lsl.user * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user similarity index 98% rename from boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user rename to boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user index 2be1d05f385b0..e30a1676a1a78 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user +++ b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user + * boards/tricore/tc4x/triboard_tc4x9_com/scripts/Lcf_Tasking_Tricore_Tc.lsl.user * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Make.defs b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/Make.defs similarity index 94% rename from boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Make.defs rename to boards/tricore/tc4x/triboard_tc4x9_com/scripts/Make.defs index 68788f26843ef..2ddba82aaed79 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Make.defs +++ b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/tricore/tc4xx/triboard_tc4x9_com/scripts/Make.defs +# boards/tricore/tc4x/triboard_tc4x9_com/scripts/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -22,7 +22,7 @@ include $(TOPDIR)/.config include $(TOPDIR)/tools/Config.mk -include $(TOPDIR)/arch/tricore/src/tc4xx/Toolchain.defs +include $(TOPDIR)/arch/tricore/src/tc4x/Toolchain.defs ifeq ($(CONFIG_TRICORE_TOOLCHAIN_TASKING),y) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)tricore.lsl diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.ld b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.ld similarity index 98% rename from boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.ld rename to boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.ld index fc63b06acd8f4..0dd60f7f9d549 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.ld +++ b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.ld @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.ld + * boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.ld * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.lsl b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.lsl similarity index 98% rename from boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.lsl rename to boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.lsl index e911e50fe0659..6a3145baac63c 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.lsl +++ b/boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.lsl @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/scripts/tricore.lsl + * boards/tricore/tc4x/triboard_tc4x9_com/scripts/tricore.lsl * * SPDX-License-Identifier: Apache-2.0 * @@ -62,7 +62,7 @@ #define USTACK0 ISTACK0_END #define USTACK0_END (USTACK0 - USTACK_SIZE) -derivative nuttx_tc4xx +derivative nuttx_tc4x { core tc0 { @@ -96,7 +96,7 @@ derivative nuttx_tc4xx processor mpe { - derivative = nuttx_tc4xx; + derivative = nuttx_tc4x; } section_setup mpe:tc0:linear diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/src/CMakeLists.txt b/boards/tricore/tc4x/triboard_tc4x9_com/src/CMakeLists.txt similarity index 96% rename from boards/tricore/tc4xx/triboard_tc4x9_com/src/CMakeLists.txt rename to boards/tricore/tc4x/triboard_tc4x9_com/src/CMakeLists.txt index b0ce858ec9538..6e335a0668d18 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/src/CMakeLists.txt +++ b/boards/tricore/tc4x/triboard_tc4x9_com/src/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# boards/tricore/tc4xx/triboard_tc4x9_com/src/CMakeLists.txt +# boards/tricore/tc4x/triboard_tc4x9_com/src/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/src/Makefile b/boards/tricore/tc4x/triboard_tc4x9_com/src/Makefile similarity index 95% rename from boards/tricore/tc4xx/triboard_tc4x9_com/src/Makefile rename to boards/tricore/tc4x/triboard_tc4x9_com/src/Makefile index 655bb3cb11171..2ed432db3db55 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/src/Makefile +++ b/boards/tricore/tc4x/triboard_tc4x9_com/src/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# boards/tricore/tc4xx/triboard_tc4x9_com/src/Makefile +# boards/tricore/tc4x/triboard_tc4x9_com/src/Makefile # # SPDX-License-Identifier: Apache-2.0 # diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4d9_userspace.c b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4d9_userspace.c similarity index 97% rename from boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4d9_userspace.c rename to boards/tricore/tc4x/triboard_tc4x9_com/src/tc4d9_userspace.c index 0ac90f19fd411..0897ae75efb87 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4d9_userspace.c +++ b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4d9_userspace.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4d9_userspace.c + * boards/tricore/tc4x/triboard_tc4x9_com/src/tc4d9_userspace.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da.h b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da.h similarity index 90% rename from boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da.h rename to boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da.h index 4d804ea5295d7..f6b9ec52878d8 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da.h +++ b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da.h + * boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_SRC_TC4DA_H -#define __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_SRC_TC4DA_H +#ifndef __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_SRC_TC4DA_H +#define __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_SRC_TC4DA_H /**************************************************************************** * Included Files @@ -62,4 +62,4 @@ int tc4da_bringup(void); #endif #endif /* __ASSEMBLY__ */ -#endif /* __BOARDS_TRICORE_TC4XX_TRIBOARD_TC4X9_COM_SRC_TC4DA_H */ +#endif /* __BOARDS_TRICORE_TC4X_TRIBOARD_TC4X9_COM_SRC_TC4DA_H */ diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_boardinit.c b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_boardinit.c similarity index 98% rename from boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_boardinit.c rename to boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_boardinit.c index b940b91156f67..1eb9e51d9088c 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_boardinit.c +++ b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_boardinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_boardinit.c + * boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_boardinit.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_bringup.c similarity index 97% rename from boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c rename to boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_bringup.c index ef901bb53d2cd..1f52f91bd9d1c 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c +++ b/boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_bringup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c + * boards/tricore/tc4x/triboard_tc4x9_com/src/tc4da_bringup.c * * SPDX-License-Identifier: Apache-2.0 * From 13a2c46706e55ebcb8b11b196f9083e286099a85 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:28:30 +0000 Subject: [PATCH 06/16] sched: check the mask of nxsched_get_affinity() Return -EINVAL for a NULL mask or a wrong size instead of writing through the pointer when assertions are off. Signed-off-by: Santhosh Charles --- sched/sched/sched_getaffinity.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sched/sched/sched_getaffinity.c b/sched/sched/sched_getaffinity.c index 7b973183baa81..6518acfb9afb1 100644 --- a/sched/sched/sched_getaffinity.c +++ b/sched/sched/sched_getaffinity.c @@ -76,6 +76,11 @@ int nxsched_get_affinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask) DEBUGASSERT(cpusetsize == sizeof(cpu_set_t) && mask != NULL); + if (mask == NULL || cpusetsize != sizeof(cpu_set_t)) + { + return -EINVAL; + } + /* Verify that the PID corresponds to a real task */ flags = enter_critical_section(); From efff3d43f4496662ea09ced3b46a4b4e170954f8 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:28:30 +0000 Subject: [PATCH 07/16] sched: roundrobin: use one SMP call per CPU All CPUs shared one smp_call_data_s. When the time slices of tasks on two CPUs ended in the same tick, the second init cleared the data while it was still queued for the first CPU, and the pid of the first call was lost. Keep one call per target CPU and do not queue it again until that CPU has handled it. Signed-off-by: Santhosh Charles --- sched/sched/sched_roundrobin.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sched/sched/sched_roundrobin.c b/sched/sched/sched_roundrobin.c index 8400b40055772..1906ef3c1f15e 100644 --- a/sched/sched/sched_roundrobin.c +++ b/sched/sched/sched_roundrobin.c @@ -46,7 +46,8 @@ ****************************************************************************/ #ifdef CONFIG_SMP -static struct smp_call_data_s g_call_data; +static struct smp_call_data_s g_call_data[CONFIG_SMP_NCPUS]; +static volatile bool g_call_pending[CONFIG_SMP_NCPUS]; #endif /**************************************************************************** @@ -69,6 +70,7 @@ static int nxsched_roundrobin_handler(FAR void *cookie) irqstate_t flags; flags = enter_critical_section(); + g_call_pending[this_cpu()] = false; tcb = nxsched_get_tcb(pid); if (!tcb || tcb->task_state == TSTATE_TASK_INVALID || @@ -195,10 +197,15 @@ clock_t nxsched_process_roundrobin(FAR struct tcb_s *tcb, clock_t ticks, DEBUGASSERT(tcb->task_state == TSTATE_TASK_RUNNING); if (tcb->cpu != this_cpu()) { - nxsched_smp_call_init(&g_call_data, - nxsched_roundrobin_handler, - (FAR void *)(uintptr_t)tcb->pid); - nxsched_smp_call_single_async(tcb->cpu, &g_call_data); + if (!g_call_pending[tcb->cpu]) + { + g_call_pending[tcb->cpu] = true; + nxsched_smp_call_init(&g_call_data[tcb->cpu], + nxsched_roundrobin_handler, + (FAR void *)(uintptr_t)tcb->pid); + nxsched_smp_call_single_async(tcb->cpu, + &g_call_data[tcb->cpu]); + } } else if (nxsched_switch_running(tcb->cpu, true)) { From 2ca8bcfc798e8cd2f9d9ab55035ad1540f9122d2 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:28:30 +0000 Subject: [PATCH 08/16] mm: heap: free the delay lists of all CPUs on SMP A thread that exits frees its own stack while it still runs on it, so the free goes to the delay list of its CPU. Only a malloc on that same CPU ever freed that list, so a CPU that never calls malloc kept the memory forever and the heap ran out (ENOMEM in ostest on a 64 KiB heap). When malloc fails, take the lists of every CPU and free them before giving up. A spinlock now guards the lists, since any CPU may empty them. Signed-off-by: Santhosh Charles --- mm/mm_heap/mm.h | 7 +++++ mm/mm_heap/mm_lock.c | 8 ++++++ mm/mm_heap/mm_malloc.c | 64 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index 1753da304b463..f8d9daf9b6428 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -258,6 +259,12 @@ struct mm_heap_s size_t mm_delaycount[CONFIG_SMP_NCPUS]; #endif +#ifdef CONFIG_SMP + /* Protects the delay lists, which any CPU may drain */ + + spinlock_t mm_delaylock; +#endif + /* The is a multiple mempool of the heap */ #ifdef CONFIG_MM_HEAP_MEMPOOL diff --git a/mm/mm_heap/mm_lock.c b/mm/mm_heap/mm_lock.c index 431b68ba92af9..56b55fbe52522 100644 --- a/mm/mm_heap/mm_lock.c +++ b/mm/mm_heap/mm_lock.c @@ -138,8 +138,12 @@ void mm_unlock(FAR struct mm_heap_s *heap) irqstate_t mm_lock_irq(FAR struct mm_heap_s *heap) { +#ifdef CONFIG_SMP + return spin_lock_irqsave(&heap->mm_delaylock); +#else UNUSED(heap); return up_irq_save(); +#endif } /**************************************************************************** @@ -152,6 +156,10 @@ irqstate_t mm_lock_irq(FAR struct mm_heap_s *heap) void mm_unlock_irq(FAR struct mm_heap_s *heap, irqstate_t state) { +#ifdef CONFIG_SMP + spin_unlock_irqrestore(&heap->mm_delaylock, state); +#else UNUSED(heap); up_irq_restore(state); +#endif } diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index a91b4e6bd3cbf..31407f5ac25da 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -111,6 +112,62 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force) return ret; } +/**************************************************************************** + * Name: free_delaylist_all + * + * Description: + * Free the delay lists of all CPUs. A CPU frees the stack of an exiting + * thread while it still runs on it and holds the critical section until + * it has switched away, so the lists are taken inside the critical + * section. Returns true if there is memory freed. + * + ****************************************************************************/ + +#if defined(CONFIG_SMP) && (defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)) +static bool free_delaylist_all(FAR struct mm_heap_s *heap) +{ + FAR struct mm_delaynode_s *list[CONFIG_SMP_NCPUS]; + FAR struct mm_delaynode_s *tmp; + irqstate_t cflags; + irqstate_t flags; + bool ret = false; + int cpu; + + if (heap == NULL || up_interrupt_context()) + { + return false; + } + + cflags = enter_critical_section(); + flags = mm_lock_irq(heap); + + for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++) + { + list[cpu] = heap->mm_delaylist[cpu]; + heap->mm_delaylist[cpu] = NULL; +#if CONFIG_MM_FREE_DELAYCOUNT_MAX > 0 + heap->mm_delaycount[cpu] = 0; +#endif + } + + mm_unlock_irq(heap, flags); + leave_critical_section(cflags); + + for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++) + { + while (list[cpu] != NULL) + { + tmp = list[cpu]; + list[cpu] = tmp->flink; + mm_delayfree(heap, tmp, false); + ret = true; + } + } + + return ret; +} +#endif + #if CONFIG_MM_BACKTRACE >= 0 void mm_dump_handler(FAR struct tcb_s *tcb, FAR void *arg) { @@ -355,6 +412,13 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) } #endif +#if defined(CONFIG_SMP) && (defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)) + else if (free_delaylist_all(heap)) + { + return mm_malloc(heap, size); + } +#endif + #ifdef CONFIG_DEBUG_MM else if (MM_INTERNAL_HEAP(heap)) { From 3bfb490756c174ea3ba20a48caf7cc59fc9604b9 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:28:30 +0000 Subject: [PATCH 09/16] sched: add BMP, bound multi processing on SMP With BMP one kernel runs on all CPUs, but every task stays on one CPU. A new task or thread runs on the CPU of its creator, or on the single CPU named in its attributes. An affinity must name exactly one CPU that exists, and a task that has started cannot move to another CPU. The scheduler never moves a task. nxsched_set_affinity() now also returns -EINVAL for a NULL mask, a wrong size or a mask without any existing CPU. SCHED_ALL_CPUS moves to sched.h so these checks can use it. Signed-off-by: Santhosh Charles --- sched/Kconfig | 9 +++++++++ sched/init/nx_start.c | 4 ---- sched/pthread/pthread_create.c | 8 ++++++++ sched/sched/sched.h | 4 ++++ sched/sched/sched_setaffinity.c | 17 ++++++++++++++++- sched/task/task_setup.c | 4 ++++ 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/sched/Kconfig b/sched/Kconfig index b2177ba02a662..cf9b95e76feac 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -454,6 +454,15 @@ config SMP_DEFAULT_CPUSET Set the Default CPU bits. The way to use the unset CPU is to call the sched_setaffinity function to bind a task to the CPU. bit0 means CPU0. +config BMP + bool "Bound multi-processing (BMP)" + default n + ---help--- + Bound multi-processing on top of SMP: a new task or thread runs on + the CPU of its creator, or on the single CPU named in its creation + attributes. An affinity mask must name exactly one CPU, and once + a task has started its CPU can no longer be changed. + endif # SMP choice diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 3abae8bf71157..416cea35bc41e 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -68,10 +68,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* This set of all CPUs */ - -#define SCHED_ALL_CPUS ((1 << CONFIG_SMP_NCPUS) - 1) - /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index c06d3c104a23b..f0fe07a1a6453 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -226,6 +226,14 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, return EINVAL; } +#ifdef CONFIG_BMP + if ((attr->affinity & ~SCHED_ALL_CPUS) != 0 || + (attr->affinity & (attr->affinity - 1)) != 0) + { + return EINVAL; + } +#endif + #ifdef CONFIG_TLS_ALIGNED /* The TLS alignment limits the size of the stack */ diff --git a/sched/sched/sched.h b/sched/sched/sched.h index 8a2e38ca9cb58..abd160a66391a 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -78,6 +78,10 @@ # define current_task(cpu) ((FAR struct tcb_s *)list_readytorun()->head) #endif +/* This set of all CPUs */ + +#define SCHED_ALL_CPUS ((cpu_set_t)((1 << CONFIG_SMP_NCPUS) - 1)) + /* This macro returns the running task which may different from this_task() * during interrupt level context switches. */ diff --git a/sched/sched/sched_setaffinity.c b/sched/sched/sched_setaffinity.c index a488914524733..908734be253ac 100644 --- a/sched/sched/sched_setaffinity.c +++ b/sched/sched/sched_setaffinity.c @@ -82,7 +82,13 @@ int nxsched_set_affinity(pid_t pid, size_t cpusetsize, /* Make sure that affinity mask is valid */ - if (*mask == 0) +#ifdef CONFIG_BMP + if (mask == NULL || cpusetsize != sizeof(cpu_set_t) || *mask == 0 || + (*mask & ~SCHED_ALL_CPUS) != 0 || (*mask & (*mask - 1)) != 0) +#else + if (mask == NULL || cpusetsize != sizeof(cpu_set_t) || *mask == 0 || + (*mask & SCHED_ALL_CPUS) == 0) +#endif { return -EINVAL; } @@ -115,6 +121,15 @@ int nxsched_set_affinity(pid_t pid, size_t cpusetsize, goto errout_with_csection; } +#ifdef CONFIG_BMP + if (tcb->task_state != TSTATE_TASK_INACTIVE && + *mask != ((cpu_set_t)1 << tcb->cpu)) + { + ret = -EINVAL; + goto errout_with_csection; + } +#endif + /* Set the new affinity mask. */ tcb->affinity = *mask; diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c index 0203ad2ad4c79..c08a6684c037a 100644 --- a/sched/task/task_setup.c +++ b/sched/task/task_setup.c @@ -216,9 +216,13 @@ static int nxtask_assign_pid(FAR struct tcb_s *tcb) #ifdef CONFIG_SMP static inline void nxtask_inherit_affinity(FAR struct tcb_s *tcb) { +#ifdef CONFIG_BMP + tcb->affinity = (cpu_set_t)1 << this_cpu(); +#else FAR struct tcb_s *rtcb = this_task(); tcb->affinity = rtcb->affinity; +#endif } #else # define nxtask_inherit_affinity(tcb) From ea7bad016d4234f93b8b534b06080eb6f28dd217 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Thu, 19 Nov 2026 09:00:18 +0000 Subject: [PATCH 10/16] arch/tricore: Count the TC4x STM at 500 MHz. After tricore_clockconfig() the STM of CPU0 counts at the system PLL frequency, 500 MHz, but the systimer was set up for SCU_FREQUENCY, 100 MHz. NuttX time then ran five times too fast on TC4x: sleep(5) took one second. Pass the real STM frequency. Signed-off-by: Santhosh Charles --- arch/tricore/src/tc4x/tc4x_timerisr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/tricore/src/tc4x/tc4x_timerisr.c b/arch/tricore/src/tc4x/tc4x_timerisr.c index de8d7154584ed..66c31e284608d 100644 --- a/arch/tricore/src/tc4x/tc4x_timerisr.c +++ b/arch/tricore/src/tc4x/tc4x_timerisr.c @@ -32,6 +32,16 @@ #include "tricore_internal.h" #include "tricore_stm.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The STMs count at the system PLL frequency once + * tricore_clockconfig() has set up the clocks: 500 MHz. + */ + +#define TC4X_STM_FREQUENCY 500000000UL + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -52,7 +62,7 @@ void up_timer_initialize(void) lower = tricore_systimer_initialize(TRICORE_STM_BASE(cpu), 0, TRICORE_SRC2IRQ(TRICORE_STM_SRC(cpu)), - SCU_FREQUENCY); + TC4X_STM_FREQUENCY); DEBUGASSERT(lower != NULL); From cd29a7910a767c22d808035b5527a0a33a634f23 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:50:08 +0000 Subject: [PATCH 11/16] arch/tricore: Switch to the task an interrupt made ready. tricore_doirq() read this_task() before it dispatched the interrupt, so a task that the handler made ready only ran at the next interrupt of that CPU. Read it after the dispatch, as the other ports do. With SMP a CPU without its own tick would else not run a task that another CPU gave it. Signed-off-by: Santhosh Charles --- arch/tricore/src/common/tricore_doirq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/tricore/src/common/tricore_doirq.c b/arch/tricore/src/common/tricore_doirq.c index 271c844fbf15a..6b285e0791192 100644 --- a/arch/tricore/src/common/tricore_doirq.c +++ b/arch/tricore/src/common/tricore_doirq.c @@ -57,7 +57,7 @@ void tricore_doirq(void) { struct tcb_s **running_task = &g_running_tasks[this_cpu()]; - struct tcb_s *tcb = this_task(); + struct tcb_s *tcb; #ifdef CONFIG_SUPPRESS_INTERRUPTS PANIC(); @@ -79,6 +79,8 @@ void tricore_doirq(void) irq_dispatch(irq, regs); + tcb = this_task(); + /* Check for a context switch. */ if (*running_task != tcb) From e1c6e6629e2987a47bc405e989ebb5805f059af3 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:50:33 +0000 Subject: [PATCH 12/16] arch/tricore: Order memory accesses between CPUs on SMP. UP_DMB(), UP_RMB() and UP_WMB() only stopped the compiler. With more than one CPU sharing memory they must also order the accesses on the bus, so make them dsync when SMP is enabled. Single CPU builds keep the plain compiler barrier. Signed-off-by: Santhosh Charles --- arch/tricore/include/barriers.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/tricore/include/barriers.h b/arch/tricore/include/barriers.h index 146e1a79d0119..3a5dadec77750 100644 --- a/arch/tricore/include/barriers.h +++ b/arch/tricore/include/barriers.h @@ -21,10 +21,26 @@ #ifndef __ARCH_TRICORE_INCLUDE_BARRIERS_H #define __ARCH_TRICORE_INCLUDE_BARRIERS_H +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + #define UP_DSB() __asm__ __volatile__ ("dsync" : : : "memory") -#define UP_DMB() __asm__ __volatile__ ("" : : : "memory") -#define UP_RMB() __asm__ __volatile__ ("" : : : "memory") -#define UP_WMB() __asm__ __volatile__ ("" : : : "memory") +#ifdef CONFIG_SMP +# define UP_DMB() __asm__ __volatile__ ("dsync" : : : "memory") +# define UP_RMB() __asm__ __volatile__ ("dsync" : : : "memory") +# define UP_WMB() __asm__ __volatile__ ("dsync" : : : "memory") +#else +# define UP_DMB() __asm__ __volatile__ ("" : : : "memory") +# define UP_RMB() __asm__ __volatile__ ("" : : : "memory") +# define UP_WMB() __asm__ __volatile__ ("" : : : "memory") +#endif #define UP_ISB() __asm__ __volatile__ ("isync" : : : "memory") #endif /* __ARCH_TRICORE_INCLUDE_BARRIERS_H */ From 40c1181d4400aed636b1f6217533b5abaa58563e Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:53:58 +0000 Subject: [PATCH 13/16] arch/tricore: Keep the interrupt CPU in SRC TOS on SMP. On SMP an interrupt must reach the CPU that was chosen for it. Keep that CPU in the TOS field of its SRC: up_affinity_irq() only changes TOS and no longer enables the interrupt, up_disable_irq() only clears the enable bit, and up_enable_irq() keeps the TOS of an SRC that has a CPU and otherwise routes it to the CPU that enables it. An SRC that nobody routed reads TOS 0xf on TC4x, but TOS 0 on TC3x like one routed to CPU0, so TC3x keeps a 256 byte bitmap of the routed SRCs. CPU0 now routes the GPSRs of every CPU to that CPU. Single CPU builds work as before. Signed-off-by: Santhosh Charles --- arch/tricore/src/common/tricore_irq.c | 128 ++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-) diff --git a/arch/tricore/src/common/tricore_irq.c b/arch/tricore/src/common/tricore_irq.c index e4d3a3555ef35..4fac18659e4a2 100644 --- a/arch/tricore/src/common/tricore_irq.c +++ b/arch/tricore/src/common/tricore_irq.c @@ -31,6 +31,8 @@ #include #include +#include +#include #include #include @@ -66,6 +68,18 @@ static inline void tricore_color_intstack(void) # define tricore_color_intstack() #endif +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_SMP) && defined(CONFIG_ARCH_CHIP_TC3X) +# define TRICORE_IRQ_ROUTED_BITS 32 +# define TRICORE_IRQ_ROUTED_WORDS (NR_IRQS / TRICORE_IRQ_ROUTED_BITS) +#endif + +#define TRICORE_SRC_TOS_GET(regval) \ + (((regval) & TRICORE_SRC_TOS_MASK) >> TRICORE_SRC_TOS_SHIFT) + /**************************************************************************** * Private Data ****************************************************************************/ @@ -73,6 +87,15 @@ static inline void tricore_color_intstack(void) static spinlock_t g_irqlock = SP_UNLOCKED; static int g_irqmap_count = 1; +/* On TC3x an SRC that nobody routed still reads TOS 0, the same as one + * routed to CPU0, so a bitmap remembers which ones up_affinity_irq() + * routed. On TC4x an SRC that nobody routed reads TOS 0xf. + */ + +#if defined(CONFIG_SMP) && defined(CONFIG_ARCH_CHIP_TC3X) +static atomic_t g_irq_routed[TRICORE_IRQ_ROUTED_WORDS]; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -101,6 +124,54 @@ static void tricore_src_init(volatile uint32_t *src, int tos, int srpn) *src = regval | TRICORE_SRC_CLRR; } +/**************************************************************************** + * Name: tricore_irq_is_routed + * + * Description: + * Return true if the SRC of the IRQ has a CPU chosen for it, so that + * up_enable_irq() keeps its TOS instead of routing it to the caller. + * + ****************************************************************************/ + +#ifdef CONFIG_SMP +static bool tricore_irq_is_routed(int irq) +{ + if (irq < 0 || irq >= NR_IRQS) + { + return false; + } + +#ifdef CONFIG_ARCH_CHIP_TC3X + return (atomic_read(&g_irq_routed[irq / TRICORE_IRQ_ROUTED_BITS]) & + BIT(irq % TRICORE_IRQ_ROUTED_BITS)) != 0; +#else + return (*TRICORE_IRQ2SRC(irq) & TRICORE_SRC_TOS_MASK) != + TRICORE_SRC_TOS_MASK; +#endif +} + +/**************************************************************************** + * Name: tricore_irq_set_routed + * + * Description: + * Remember that the SRC of the IRQ has a CPU chosen for it. + * + ****************************************************************************/ + +static void tricore_irq_set_routed(int irq) +{ +#ifdef CONFIG_ARCH_CHIP_TC3X + if (irq >= 0 && irq < NR_IRQS) + { + atomic_or(&g_irq_routed[irq / TRICORE_IRQ_ROUTED_BITS], + BIT(irq % TRICORE_IRQ_ROUTED_BITS)); + } +#else + UNUSED(irq); +#endif +} +#endif + #ifdef CONFIG_ARCH_HAVE_IRQTRIGGER /**************************************************************************** * Name: tricore_gpsrinitialize @@ -110,19 +181,21 @@ static void tricore_src_init(volatile uint32_t *src, int tos, int srpn) * ****************************************************************************/ -static void tricore_gpsrinitialize(void) +static void tricore_gpsrinit_cpu(int cpu) { - int cpu = up_cpu_index(); int tos = TRICORE_SRC_TOS_CPU(cpu); + int irq; int i; /* Cpux gpsr init */ for (i = 0; i < 6; i++) { - int irq = TRICORE_GPSR_IRQNUM(i, cpu); - + irq = TRICORE_GPSR_IRQNUM(i, cpu); tricore_src_init(TRICORE_IRQ2SRC(irq), tos, IRQ_TO_NDX(irq)); +#ifdef CONFIG_SMP + tricore_irq_set_routed(irq); +#endif } /* Cpucs gpsr init */ @@ -132,6 +205,20 @@ static void tricore_gpsrinitialize(void) IRQ_TO_NDX(TRICORE_GPSR_IRQNUM(6, cpu))); #endif } + +static void tricore_gpsrinitialize(void) +{ +#ifdef CONFIG_SMP + int cpu; + + for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++) + { + tricore_gpsrinit_cpu(cpu); + } +#else + tricore_gpsrinit_cpu(up_cpu_index()); +#endif +} #endif /**************************************************************************** @@ -183,9 +270,13 @@ void up_disable_irq(int irq) { volatile uint32_t *src = TRICORE_IRQ2SRC(irq); +#ifdef CONFIG_SMP + *src &= ~TRICORE_SRC_SRE; +#else /* Disable and clear, keep SRPN */ *src = (*src & TRICORE_SRC_SRPN_MASK) | TRICORE_SRC_TOS_MASK; +#endif } /**************************************************************************** @@ -199,9 +290,16 @@ void up_disable_irq(int irq) void up_enable_irq(int irq) { volatile uint32_t *src = TRICORE_IRQ2SRC(irq); + int tos = TRICORE_SRC_TOS_CPU(up_cpu_index()); - tricore_src_init(src, TRICORE_SRC_TOS_CPU(up_cpu_index()), - IRQ_TO_NDX(irq)); +#ifdef CONFIG_SMP + if (tricore_irq_is_routed(irq)) + { + tos = TRICORE_SRC_TOS_GET(*src); + } +#endif + + tricore_src_init(src, tos, IRQ_TO_NDX(irq)); *src |= TRICORE_SRC_SRE; } @@ -216,7 +314,24 @@ void up_enable_irq(int irq) void up_affinity_irq(int irq, cpu_set_t cpuset) { volatile uint32_t *src = TRICORE_IRQ2SRC(irq); +#ifdef CONFIG_SMP + uint32_t enabled; + int cpu; + + cpu = ffs(cpuset) - 1; + if (irq < 0 || irq >= NR_IRQS || cpu < 0 || cpu >= CONFIG_SMP_NCPUS) + { + return; + } + enabled = *src & TRICORE_SRC_SRE; + *src &= ~TRICORE_SRC_SRE; + *src = (*src & ~TRICORE_SRC_TOS_MASK) | + ((TRICORE_SRC_TOS_CPU(cpu) << TRICORE_SRC_TOS_SHIFT) & + TRICORE_SRC_TOS_MASK); + tricore_irq_set_routed(irq); + *src |= enabled; +#else *src &= ~TRICORE_SRC_SRE; /* Only support interrupt routing mode 0, @@ -226,6 +341,7 @@ void up_affinity_irq(int irq, cpu_set_t cpuset) tricore_src_init(src, TRICORE_SRC_TOS_CPU(ffs(cpuset) - 1), *src & TRICORE_SRC_SRPN_MASK); *src |= TRICORE_SRC_SRE; +#endif } /**************************************************************************** From 2115cb3d389da0dc12c337a9a89042eee740e18c Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 17:58:02 +0000 Subject: [PATCH 14/16] arch/tricore: Give CSA frames back to their owner CPU. Each CPU links its own pool of context save areas. When a task moves to another CPU, or one CPU builds the first context of a task for another CPU, frames of one CPU end up in the free list of another, so one CPU slowly loses its frames and finally takes an FCD trap. A frame belongs to the CPU whose data scratchpad RAM holds it. At each context switch a CPU takes back its returned frames and gives back the foreign ones among its first free frames; every 64th switch it checks a low water mark and, when below it, asks the other CPUs by an inter-CPU interrupt to give back its frames. The idle loop does a full pass. tricore_smp.h describes the layout of the secondary CPUs. Signed-off-by: Santhosh Charles --- arch/tricore/Kconfig | 13 ++ arch/tricore/src/common/tricore_csa.c | 284 ++++++++++++++++++++++++++ arch/tricore/src/common/tricore_smp.h | 107 ++++++++++ 3 files changed, 404 insertions(+) create mode 100644 arch/tricore/src/common/tricore_smp.h diff --git a/arch/tricore/Kconfig b/arch/tricore/Kconfig index b382b90bf36be..ce9e0e067a6b1 100644 --- a/arch/tricore/Kconfig +++ b/arch/tricore/Kconfig @@ -182,6 +182,19 @@ config TRICORE_TRAP_ALERT source "arch/tricore/src/common/aurix/Kconfig" +if SMP + +config TRICORE_SMP_CSA_COUNT + int "CSA frames of each secondary CPU" + default 512 + ---help--- + CPU1 and up build their pool of context save areas at the start + of their own data scratchpad RAM, followed by their interrupt + stack and their idle stack. CPU0 keeps the pool of the linker + script. + +endif # SMP + if ARCH_CHIP_TC3X source "arch/tricore/src/tc3x/Kconfig" endif diff --git a/arch/tricore/src/common/tricore_csa.c b/arch/tricore/src/common/tricore_csa.c index 4f1a347dd8d9d..df889bdbf2fec 100644 --- a/arch/tricore/src/common/tricore_csa.c +++ b/arch/tricore/src/common/tricore_csa.c @@ -37,6 +37,216 @@ #include "tricore_internal.h" +#ifdef CONFIG_SMP +# include +# include "tricore_smp.h" +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* A CSA frame belongs to the CPU whose data scratchpad RAM holds it. When + * a task moves to another CPU, or a CPU builds the first context of a task + * for another CPU, frames of one CPU end up in the free list of another. + * Such frames are handed back to their owner through its return list. + */ + +#ifdef CONFIG_SMP +static spinlock_t g_csa_return_lock[CONFIG_SMP_NCPUS]; +static uintptr_t g_csa_return_head[CONFIG_SMP_NCPUS]; +static uintptr_t g_csa_return_tail[CONFIG_SMP_NCPUS]; +static volatile bool g_csa_reclaim_req[CONFIG_SMP_NCPUS]; +static uint32_t g_csa_switches[CONFIG_SMP_NCPUS]; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_SMP + +/**************************************************************************** + * Name: tricore_csa_owner + * + * Description: + * Return the CPU that owns the CSA frame of a link word, or -1. + * + ****************************************************************************/ + +static int tricore_csa_owner(uintptr_t link) +{ + int cpu; + + cpu = TRICORE_SMP_CPU_OF_CORE(TRICORE_SMP_DSPR_SEG_TOP - + (int)((link & FCX_FCXS_MASK) >> FCX_FCXS)); + if (cpu < 0 || cpu >= CONFIG_SMP_NCPUS) + { + return -1; + } + + return cpu; +} + +/**************************************************************************** + * Name: tricore_csa_take_returns + * + * Description: + * Put the frames that other CPUs gave back to this CPU on its free list. + * + ****************************************************************************/ + +static void tricore_csa_take_returns(int me) +{ + irqstate_t flags; + uintptr_t head; + uintptr_t tail; + + if (g_csa_return_head[me] == 0) + { + return; + } + + flags = spin_lock_irqsave(&g_csa_return_lock[me]); + head = g_csa_return_head[me]; + tail = g_csa_return_tail[me]; + g_csa_return_head[me] = 0; + g_csa_return_tail[me] = 0; + + if (head != 0) + { + tricore_csa2addr(tail)[0] = tricore_mfcr(TRICORE_CPU_FCX) & FCX_FREE; + tricore_mtcr(TRICORE_CPU_FCX, head); + UP_ISB(); + } + + spin_unlock_irqrestore(&g_csa_return_lock[me], flags); +} + +/**************************************************************************** + * Name: tricore_csa_give_foreign + * + * Description: + * Take the frames of other CPUs out of the first "limit" own frames of + * the free list and queue them on the return lists of their owners. + * Return true if fewer than "limit" own frames are free. + * + ****************************************************************************/ + +static bool tricore_csa_give_foreign(int me, unsigned int limit) +{ + uintptr_t head[CONFIG_SMP_NCPUS]; + uintptr_t tail[CONFIG_SMP_NCPUS]; + uintptr_t *prev; + uintptr_t *addr; + uintptr_t link; + uintptr_t next; + uintptr_t lcx; + unsigned int count; + irqstate_t flags; + int owner; + int cpu; + + for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++) + { + head[cpu] = 0; + tail[cpu] = 0; + } + + flags = up_irq_save(); + + prev = NULL; + link = tricore_mfcr(TRICORE_CPU_FCX) & FCX_FREE; + lcx = tricore_mfcr(TRICORE_CPU_LCX) & FCX_FREE; + count = 0; + + while (link != 0 && link != lcx && count < limit) + { + addr = tricore_csa2addr(link); + next = addr[0] & FCX_FREE; + owner = tricore_csa_owner(link); + + if (owner >= 0 && owner != me) + { + if (prev == NULL) + { + tricore_mtcr(TRICORE_CPU_FCX, next); + UP_ISB(); + } + else + { + prev[0] = next; + } + + addr[0] = head[owner]; + head[owner] = link; + if (tail[owner] == 0) + { + tail[owner] = link; + } + } + else + { + prev = addr; + count++; + } + + link = next; + } + + up_irq_restore(flags); + + for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++) + { + if (head[cpu] == 0) + { + continue; + } + + flags = spin_lock_irqsave(&g_csa_return_lock[cpu]); + tricore_csa2addr(tail[cpu])[0] = g_csa_return_head[cpu]; + if (g_csa_return_tail[cpu] == 0) + { + g_csa_return_tail[cpu] = tail[cpu]; + } + + g_csa_return_head[cpu] = head[cpu]; + spin_unlock_irqrestore(&g_csa_return_lock[cpu], flags); + } + + return count < limit; +} + +/**************************************************************************** + * Name: tricore_csa_ask_reclaim + * + * Description: + * Ask the other CPUs to give back the frames of this CPU. + * + ****************************************************************************/ + +static void tricore_csa_ask_reclaim(int me) +{ + cpu_set_t cpuset = 0; + int cpu; + + for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++) + { + if (cpu != me && !g_csa_reclaim_req[cpu]) + { + g_csa_reclaim_req[cpu] = true; + cpuset |= (cpu_set_t)1 << cpu; + } + } + + if (cpuset != 0) + { + up_trigger_irq(TRICORE_SMP_IPI_IRQ(me, me), cpuset); + } +} + +#endif /* CONFIG_SMP */ + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -153,3 +363,77 @@ void tricore_reclaim_csa(uintptr_t pcxi) tricore_mtcr(TRICORE_CPU_FCX, head); } + +#ifdef CONFIG_SMP + +/**************************************************************************** + * Name: tricore_csa_balance + * + * Description: + * Take back the own frames and give back all foreign ones. Called by + * the idle loop. + * + ****************************************************************************/ + +void tricore_csa_balance(void) +{ + int me = this_cpu(); + + tricore_csa_take_returns(me); + tricore_csa_give_foreign(me, TRICORE_SMP_CSA_SCAN_ALL); +} + +/**************************************************************************** + * Name: tricore_csa_switch_balance + * + * Description: + * Called at every context switch: take back the own frames and give back + * the foreign ones among the first few free frames. Every + * TRICORE_SMP_CSA_LOW_EVERY switches check the low water mark and, when + * below it, ask the other CPUs to give back the frames of this CPU. + * + ****************************************************************************/ + +void tricore_csa_switch_balance(void) +{ + int me = this_cpu(); + + tricore_csa_take_returns(me); + + g_csa_switches[me]++; + if ((g_csa_switches[me] % TRICORE_SMP_CSA_LOW_EVERY) != 0) + { + tricore_csa_give_foreign(me, TRICORE_SMP_CSA_SWITCH_SCAN); + + return; + } + + if (tricore_csa_give_foreign(me, TRICORE_SMP_CSA_LOW_WATER)) + { + tricore_csa_ask_reclaim(me); + } +} + +/**************************************************************************** + * Name: tricore_csa_reclaim_ipi + * + * Description: + * Called from the inter-CPU interrupt: give back foreign frames if + * another CPU asked for them. + * + ****************************************************************************/ + +void tricore_csa_reclaim_ipi(void) +{ + int me = this_cpu(); + + if (!g_csa_reclaim_req[me]) + { + return; + } + + g_csa_reclaim_req[me] = false; + tricore_csa_balance(); +} + +#endif /* CONFIG_SMP */ diff --git a/arch/tricore/src/common/tricore_smp.h b/arch/tricore/src/common/tricore_smp.h new file mode 100644 index 0000000000000..bf928ad7c6394 --- /dev/null +++ b/arch/tricore/src/common/tricore_smp.h @@ -0,0 +1,107 @@ +/**************************************************************************** + * arch/tricore/src/common/tricore_smp.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_TRICORE_SRC_COMMON_TRICORE_SMP_H +#define __ARCH_TRICORE_SRC_COMMON_TRICORE_SMP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Every secondary CPU keeps its CSA pool, its interrupt stack and its idle + * stack at the start of its own data scratchpad RAM, at the global address + * of that RAM: segment 7 for core 0, 6 for core 1 and so on. + */ + +#define TRICORE_SMP_SEG_SHIFT 28 +#define TRICORE_SMP_DSPR_SEG_TOP 7 +#define TRICORE_SMP_CSA_FRAME 64 +#define TRICORE_SMP_CSA_RESERVE 3 + +#define TRICORE_SMP_CSA_SIZE \ + (CONFIG_TRICORE_SMP_CSA_COUNT * TRICORE_SMP_CSA_FRAME) + +#define TRICORE_SMP_ISTACK_TOP \ + (TRICORE_SMP_CSA_SIZE + CONFIG_ARCH_INTERRUPTSTACK) + +#define TRICORE_SMP_USTACK_TOP \ + (TRICORE_SMP_ISTACK_TOP + CONFIG_IDLETHREAD_STACKSIZE) + +#define TRICORE_SMP_DSPR(coreid) \ + ((TRICORE_SMP_DSPR_SEG_TOP - (coreid)) << TRICORE_SMP_SEG_SHIFT) + +/* On TC3x CPU5 has the core ID 6 */ + +#ifdef CONFIG_ARCH_CHIP_TC3X +# define TRICORE_SMP_TC3X_CPU5 5 +# define TRICORE_SMP_TC3X_CORE_ID_CPU5 6 +# define TRICORE_SMP_CORE_ID(cpu) \ + ((cpu) == TRICORE_SMP_TC3X_CPU5 ? TRICORE_SMP_TC3X_CORE_ID_CPU5 : (cpu)) +# define TRICORE_SMP_CPU_OF_CORE(coreid) \ + ((coreid) == TRICORE_SMP_TC3X_CORE_ID_CPU5 ? \ + TRICORE_SMP_TC3X_CPU5 : (coreid)) +#else +# define TRICORE_SMP_CORE_ID(cpu) (cpu) +# define TRICORE_SMP_CPU_OF_CORE(coreid) (coreid) +#endif + +#define TRICORE_SMP_CPU_DSPR(cpu) \ + TRICORE_SMP_DSPR(TRICORE_SMP_CORE_ID(cpu)) + +/* CSA balance: free frames scanned at each context switch, the low water + * mark checked every TRICORE_SMP_CSA_LOW_EVERY switches, and a full scan + */ + +#define TRICORE_SMP_CSA_SWITCH_SCAN 8 +#define TRICORE_SMP_CSA_LOW_WATER 32 +#define TRICORE_SMP_CSA_LOW_EVERY 64 +#define TRICORE_SMP_CSA_SCAN_ALL UINT_MAX + +/* The inter-CPU interrupt from CPU "from" to CPU "to" is GPSR from/to */ + +#define TRICORE_SMP_IPI_IRQ(from, to) TRICORE_GPSR_IRQNUM(from, to) + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_SMP +void tricore_csa_balance(void); +void tricore_csa_switch_balance(void); +void tricore_csa_reclaim_ipi(void); +void tricore_smp_initialize(void); +void tricore_cpu_boot(void); +#endif + +#endif /* __ASSEMBLY__ */ + +#endif /* __ARCH_TRICORE_SRC_COMMON_TRICORE_SMP_H */ From 695a24b51ba732cb09159138596b3f3166d33afc Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Thu, 19 Nov 2026 06:34:38 +0000 Subject: [PATCH 15/16] arch/tricore: Disable the system watchdog on CPU0 only. tricore_wdt_disable() also disabled the system (safety) watchdog when CPU1 or higher called it. The other CPUs may not write that watchdog, and on TC4x the write from CPU1 reset the chip in a loop. Only CPU0 disables it now; every CPU still disables its own watchdog. Signed-off-by: Santhosh Charles --- arch/tricore/src/tc3x/tc3x_wdt.c | 5 ++++- arch/tricore/src/tc4x/tc4x_wdt.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/tricore/src/tc3x/tc3x_wdt.c b/arch/tricore/src/tc3x/tc3x_wdt.c index 4c94b37eb5f8c..85c217903df98 100644 --- a/arch/tricore/src/tc3x/tc3x_wdt.c +++ b/arch/tricore/src/tc3x/tc3x_wdt.c @@ -142,5 +142,8 @@ void tricore_wdt_disable(void) cpu = cpu > 5 ? 5 : cpu; tc3x_wdt_disable(TC3X_SCU_WDTCPU_CON0(cpu), TC3X_SCU_WDTCPU_CON1(cpu)); - tc3x_wdt_disable(TC3X_SCU_WDTS_CON0, TC3X_SCU_WDTS_CON1); + if (cpu == 0) + { + tc3x_wdt_disable(TC3X_SCU_WDTS_CON0, TC3X_SCU_WDTS_CON1); + } } diff --git a/arch/tricore/src/tc4x/tc4x_wdt.c b/arch/tricore/src/tc4x/tc4x_wdt.c index 444e96f7fb89c..da70949991f84 100644 --- a/arch/tricore/src/tc4x/tc4x_wdt.c +++ b/arch/tricore/src/tc4x/tc4x_wdt.c @@ -150,5 +150,8 @@ void tricore_wdt_disable(void) tc4x_wdt_disable(TC4X_WTU_WDTCPU_CTRLA(cpu), TC4X_WTU_WDTCPU_CTRLB(cpu)); - tc4x_wdt_disable(TC4X_WTU_WDTSYS_CTRLA, TC4X_WTU_WDTSYS_CTRLB); + if (cpu == 0) + { + tc4x_wdt_disable(TC4X_WTU_WDTSYS_CTRLA, TC4X_WTU_WDTSYS_CTRLB); + } } From da4cf226da2da414725b6fc006e6fb2d482a6bd4 Mon Sep 17 00:00:00 2001 From: Santhosh Charles Date: Wed, 18 Nov 2026 18:07:55 +0000 Subject: [PATCH 16/16] arch/tricore: Run one SMP kernel on all CPUs. With SMP the other CPUs run this image instead of their own: CPU0 no longer releases them to __start1 and up at boot, and up_cpu_start() starts them at __start_secondary once the kernel runs. A secondary CPU builds its CSA pool, interrupt stack and idle stack in its own data scratchpad RAM, takes the trap and interrupt vectors of CPU0 and joins as its idle task. CPU0 attaches and enables the GPSR of every CPU pair as inter-CPU interrupt; an IPI is one write to the software broadcast register. On TC4x CPU0 lets every CPU use the interrupt router, the scratchpad RAMs and DLMUs, the STM of CPU0 and the console UART. The data cache stays bypassed, since data in a cached segment would not be coherent. The context switch now also balances the CSA frames and restores the critical section of the new task, and the idle loop waits for an interrupt instead of spinning so it can balance too. The idle stacks of the secondary CPUs are colored like the other stacks, so the stack usage shows right. SMP needs the GNU toolchain, as the secondary entry is only in the GNU startup code; a build with SMP and another toolchain stops with an error. Signed-off-by: Santhosh Charles --- arch/tricore/src/common/CMakeLists.txt | 4 + arch/tricore/src/common/Make.defs | 4 + .../tricore/src/common/aurix/tricore_serial.c | 8 + arch/tricore/src/common/gnu/tricore_head.S | 122 +++++++ arch/tricore/src/common/tricore_cpustart.c | 333 ++++++++++++++++++ arch/tricore/src/common/tricore_doirq.c | 8 + arch/tricore/src/common/tricore_getintstack.c | 11 + arch/tricore/src/common/tricore_idle.c | 9 + arch/tricore/src/common/tricore_initialize.c | 10 +- arch/tricore/src/common/tricore_irq.c | 14 +- arch/tricore/src/common/tricore_main.c | 16 +- arch/tricore/src/common/tricore_smp.h | 4 +- arch/tricore/src/common/tricore_svcall.c | 8 + arch/tricore/src/tc4x/hardware/tc4x_asclin.h | 1 + arch/tricore/src/tc4x/hardware/tc4x_cpu.h | 62 ++++ 15 files changed, 609 insertions(+), 5 deletions(-) create mode 100644 arch/tricore/src/common/tricore_cpustart.c diff --git a/arch/tricore/src/common/CMakeLists.txt b/arch/tricore/src/common/CMakeLists.txt index 2342d1bdadf1d..e7abd03121acb 100644 --- a/arch/tricore/src/common/CMakeLists.txt +++ b/arch/tricore/src/common/CMakeLists.txt @@ -75,6 +75,10 @@ if(CONFIG_ARCH_HAVE_DEBUG) list(APPEND SRCS tricore_hwdebug.c) endif() +if(CONFIG_SMP) + list(APPEND SRCS tricore_cpustart.c) +endif() + target_sources(arch PRIVATE ${SRCS}) target_sources(nuttx PRIVATE tricore_doirq.c) diff --git a/arch/tricore/src/common/Make.defs b/arch/tricore/src/common/Make.defs index f3612104f4fae..8e29613248203 100644 --- a/arch/tricore/src/common/Make.defs +++ b/arch/tricore/src/common/Make.defs @@ -88,6 +88,10 @@ ifeq ($(CONFIG_ARCH_HAVE_DEBUG),y) CMN_CSRCS += tricore_hwdebug.c endif +ifeq ($(CONFIG_SMP),y) + CMN_CSRCS += tricore_cpustart.c +endif + # TASKING toolchain: build a fake libc_fpu.a to override the toolchain's # default C library and provide stubs for the symbols the linker still # references (see tricore_libc.c for details). diff --git a/arch/tricore/src/common/aurix/tricore_serial.c b/arch/tricore/src/common/aurix/tricore_serial.c index e446c55098282..25d3d43cb2fa3 100644 --- a/arch/tricore/src/common/aurix/tricore_serial.c +++ b/arch/tricore/src/common/aurix/tricore_serial.c @@ -49,6 +49,9 @@ # include "tc3x_wdt.h" #elif defined(CONFIG_ARCH_CHIP_TC4X) # include "hardware/tc4x_port.h" +# ifdef CONFIG_SMP +# include "hardware/tc4x_cpu.h" +# endif #endif #include @@ -361,6 +364,11 @@ static void asclin_init(struct up_dev_s *priv) tc3x_wdt_cpu_endinit(true); #endif +#if defined(CONFIG_SMP) && defined(CONFIG_ARCH_CHIP_TC4X) + asclin_modify(ASCLIN_REG(priv, ACCEN_WRA), 0, + TC4X_CPU_TAGS_ALL(CONFIG_SMP_NCPUS)); +#endif + /* Clock off, initialise mode, bit timing and baud rate */ asclin_set_clock(priv, ASCLIN_CSR_CLKSEL_NONE); diff --git a/arch/tricore/src/common/gnu/tricore_head.S b/arch/tricore/src/common/gnu/tricore_head.S index 13c39adf79d47..c5e9610caa8d4 100644 --- a/arch/tricore/src/common/gnu/tricore_head.S +++ b/arch/tricore/src/common/gnu/tricore_head.S @@ -26,6 +26,9 @@ #include #include +#ifdef CONFIG_SMP +# include "tricore_smp.h" +#endif /**************************************************************************** * Pre-processor Definitions @@ -34,6 +37,18 @@ #define TRICORE_PSW_RESET 0x980 /* Supervisor, call depth counting on */ #define TRICORE_BIV_VECTOR 0x1fe0 /* Single interrupt vector at INTTAB + 0x1fe0 */ +/* DCON0: with SMP the data cache stays bypassed, as data in a cached + * segment would not be coherent between the CPUs + */ + +#define TRICORE_DCON0_DCBYP 0x2 + +#ifdef CONFIG_SMP +# define TRICORE_DCON0_BOOT TRICORE_DCON0_DCBYP +#else +# define TRICORE_DCON0_BOOT 0 +#endif + #ifdef CONFIG_ARCH_CHIP_TC3X # define TC3X_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ #endif @@ -151,6 +166,7 @@ tricore_head: mov %d15, 0 mtcr TRICORE_CPU_PCON0, %d15 isync + mov %d15, TRICORE_DCON0_BOOT mtcr TRICORE_CPU_DCON0, %d15 isync @@ -243,6 +259,112 @@ tricore_head: lea %a15, [%a15]lo:tricore_start ji %a15 +#ifdef CONFIG_SMP +/**************************************************************************** + * Name: __start_secondary + * + * Description: + * Entry of CPU1 and up with SMP, where up_cpu_start() releases them from + * the boot halt once the kernel runs on CPU0. Set up the core registers + * like tricore_head, with the CSA pool, the interrupt stack and the idle + * stack at the start of the data scratchpad RAM of this core (see + * tricore_smp.h), disable the watchdog of this CPU and call + * tricore_cpu_boot. .data, .bss and the clocks are already set up. + * Only CPU0 has the hypervisor context, so the virtualization is left + * alone here. + * + ****************************************************************************/ + + .global __start_secondary + .type __start_secondary, %function +__start_secondary: +#ifdef CONFIG_ARCH_CHIP_TC3X + jl tc3x_endinit_clear +#endif + + /* D12 is the base of the data scratchpad RAM of this core */ + + mfcr %d12, TRICORE_CPU_CORE_ID + extr.u %d12, %d12, 0, 3 + rsub %d12, %d12, TRICORE_SMP_DSPR_SEG_TOP + sh %d12, %d12, TRICORE_SMP_SEG_SHIFT + + movh.a %a15, hi:__TRAPTAB_CPU0 + lea %a15, [%a15]lo:__TRAPTAB_CPU0 + mov.d %d15, %a15 + mtcr TRICORE_CPU_BTV, %d15 + isync + + mov %d15, 0 + mtcr TRICORE_CPU_PCON0, %d15 + isync + mov %d15, TRICORE_DCON0_BOOT + mtcr TRICORE_CPU_DCON0, %d15 + isync + + movh.a %a15, hi:__INTTAB_CPU0 + lea %a15, [%a15]lo:__INTTAB_CPU0 + lea %a15, [%a15]TRICORE_BIV_VECTOR + mov.d %d15, %a15 + mtcr TRICORE_CPU_BIV, %d15 + isync + + movh %d15, hi:TRICORE_SMP_ISTACK_TOP + addi %d15, %d15, lo:TRICORE_SMP_ISTACK_TOP + add %d15, %d15, %d12 + mtcr TRICORE_CPU_ISP, %d15 + isync + + /* Free CSA list over the pool of this core, LCX at the third last */ + + mov.a %a15, %d12 + movh %d15, hi:TRICORE_SMP_CSA_SIZE + addi %d15, %d15, lo:TRICORE_SMP_CSA_SIZE + add %d15, %d15, %d12 + mov.a %a14, %d15 + mov.d %d15, %a15 + tricore_csa_link %d15, %d14, %d13 + mtcr TRICORE_CPU_FCX, %d15 + isync +1: + addi %d15, %d15, 1 + st.w [%a15], %d15 + lea %a15, [%a15]TRICORE_SMP_CSA_FRAME + jne.a %a15, %a14, 1b + mov %d14, 0 + st.w [%a15]-TRICORE_SMP_CSA_FRAME, %d14 + addi %d15, %d15, -TRICORE_SMP_CSA_RESERVE + mtcr TRICORE_CPU_LCX, %d15 + isync + +#ifdef CONFIG_ARCH_CHIP_TC3X + jl tc3x_endinit_set +#endif + + movh %d15, hi:TRICORE_SMP_USTACK_TOP + addi %d15, %d15, lo:TRICORE_SMP_USTACK_TOP + add %d15, %d15, %d12 + mov.a %sp, %d15 + dsync + + movh.a %a1, hi:__a1_mem + lea %a1, [%a1]lo:__a1_mem + movh.a %a0, hi:__a0_mem + lea %a0, [%a0]lo:__a0_mem + movh.a %a8, hi:__a8_mem + lea %a8, [%a8]lo:__a8_mem + movh.a %a9, hi:__a9_mem + lea %a9, [%a9]lo:__a9_mem + + mov %d0, TRICORE_PSW_RESET + mtcr TRICORE_CPU_PSW, %d0 + isync + + call tricore_wdt_disable + call tricore_cpu_boot + debug +#endif + #ifdef CONFIG_ARCH_CHIP_TC3X /**************************************************************************** * Name: tc3x_endinit_clear, tc3x_endinit_set diff --git a/arch/tricore/src/common/tricore_cpustart.c b/arch/tricore/src/common/tricore_cpustart.c new file mode 100644 index 0000000000000..98f6414dc894c --- /dev/null +++ b/arch/tricore/src/common/tricore_cpustart.c @@ -0,0 +1,333 @@ +/**************************************************************************** + * arch/tricore/src/common/tricore_cpustart.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "init/init.h" +#include "sched/sched.h" +#include "tricore_internal.h" +#include "tricore_smp.h" +#include "chip.h" + +#ifdef CONFIG_ARCH_CHIP_TC4X +# include "hardware/tc4x_cpu.h" +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define TRICORE_SMP_STACK_ALIGN 8 +#define TRICORE_START_PC_HALT 1 + +#if (CONFIG_ARCH_INTERRUPTSTACK % TRICORE_SMP_STACK_ALIGN) != 0 || \ + (CONFIG_IDLETHREAD_STACKSIZE % TRICORE_SMP_STACK_ALIGN) != 0 +# error "The interrupt and idle stack sizes must be multiples of 8" +#endif + +#if CONFIG_ARCH_INTERRUPTSTACK < 4 +# error "SMP needs an interrupt stack for every CPU" +#endif + +#ifndef CONFIG_TRICORE_TOOLCHAIN_GNU +# error "SMP needs the GNU toolchain, the secondary entry is in gnu/tricore_head.S" +#endif + +/**************************************************************************** + * External Definitions + ****************************************************************************/ + +/* Entry of a secondary CPU in tricore_head.S */ + +extern void __start_secondary(void); + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tricore_smp_ipi_handler + * + * Description: + * Inter-CPU interrupt: give back CSA frames if asked to, run the SMP + * calls queued for this CPU and pick up the tasks given to it. The + * context switch, if any, happens on the way out of tricore_doirq(). + * + ****************************************************************************/ + +static int tricore_smp_ipi_handler(int irq, void *context, void *arg) +{ + tricore_csa_reclaim_ipi(); + nxsched_smp_call_handler(irq, context, arg); + nxsched_process_delivered(this_cpu()); + + return OK; +} + +/**************************************************************************** + * Name: tricore_smp_grant_access + * + * Description: + * On TC4x only CPU0 may write the peripherals and the memories of the + * other CPUs after reset. Let every CPU route and trigger interrupts + * to every CPU, use the data scratchpad RAM and the DLMU of every CPU, + * where the kernel data and the CSA frames are, and program the STM of + * CPU0, which is the system timer: every CPU arms its alarm, so they + * all need the STM and the SFRs of CPU0 the STM is in. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_CHIP_TC4X +static void tricore_smp_grant_ranges(uintptr_t prot, uintptr_t cfg, + uintptr_t active, int nranges, + int nwords, uint32_t tags) +{ + uintptr_t range; + int r; + int i; + + for (r = 0; r < nranges; r++) + { + range = active + r * TC4X_ACCEN_RANGE_SIZE; + + putreg32(TC4X_PROT_SET(r, TC4X_PROT_STATE_RUN), prot); + putreg32(TC4X_PROT_SET(r, TC4X_PROT_STATE_CONFIG), prot); + + for (i = 0; i < nwords; i++) + { + putreg32(getreg32(range + i * sizeof(uint32_t)), + cfg + i * sizeof(uint32_t)); + } + + modreg32(tags, tags, cfg + TC4X_ACCEN_WRA); + putreg32(TC4X_PROT_SET(r, TC4X_PROT_STATE_RUN), prot); + } +} + +static void tricore_smp_grant_access(void) +{ + uint32_t tags = TC4X_CPU_TAGS_ALL(CONFIG_SMP_NCPUS); + int cpu; + + for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++) + { + modreg32(tags, tags, TC4X_IR_ACCENSCFG_WRA(TRICORE_SRC_TOS_CPU(cpu))); + modreg32(tags, tags, TC4X_IR_ACCENSCTRL_WRA(TRICORE_SRC_TOS_CPU(cpu))); + modreg32(TC4X_CPU_TAGS(cpu), TC4X_CPU_TAGS(cpu), + TC4X_IR_ACCENSRB_WRA(cpu)); + + tricore_smp_grant_ranges(TC4X_CPU_PROTSPRSE(cpu), + TC4X_CPU_ACCENSPRCFG(cpu), + TC4X_CPU_ACCENSPR(cpu, 0), TC4X_PROT_RANGES, + TC4X_ACCEN_WORDS, tags); + tricore_smp_grant_ranges(TC4X_CPU_PROTDLMUSE(cpu), + TC4X_CPU_ACCENDLMUCFG(cpu), + TC4X_CPU_ACCENDLMU(cpu, 0), TC4X_PROT_RANGES, + TC4X_ACCEN_WORDS, tags); + } + + tricore_smp_grant_ranges(TC4X_CPU_PROTSFRSE(0), TC4X_CPU_ACCENSFRCFG(0), + TC4X_CPU_ACCENSFR(0), TC4X_PROT_SFR_RANGES, + TC4X_ACCEN_SFR_WORDS, tags); + + putreg32(TC4X_PROT_STM(TC4X_PROT_STATE_RUN), TC4X_CPU_PROTSTMSE(0)); + putreg32(TC4X_PROT_STM(TC4X_PROT_STATE_CONFIG), TC4X_CPU_PROTSTMSE(0)); + modreg32(tags, tags, TC4X_CPU_ACCENSTMCFG_WRA(0)); + putreg32(TC4X_PROT_STM(TC4X_PROT_STATE_RUN), TC4X_CPU_PROTSTMSE(0)); +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_cpu_idlestack + * + * Description: + * The idle stack of a secondary CPU is in its own data scratchpad RAM, + * above its CSA pool and its interrupt stack. + * + ****************************************************************************/ + +int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size) +{ + uintptr_t top; + + if (tcb == NULL || cpu <= 0 || cpu >= CONFIG_SMP_NCPUS || + stack_size > CONFIG_IDLETHREAD_STACKSIZE) + { + return -EINVAL; + } + + top = TRICORE_SMP_CPU_DSPR(cpu) + TRICORE_SMP_USTACK_TOP; + + tcb->stack_alloc_ptr = (void *)(top - CONFIG_IDLETHREAD_STACKSIZE); + tcb->stack_base_ptr = tcb->stack_alloc_ptr; + tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE; + +#ifdef CONFIG_STACK_COLORATION + tricore_stack_color(tcb->stack_alloc_ptr, CONFIG_IDLETHREAD_STACKSIZE); +#endif + + return OK; +} + +/**************************************************************************** + * Name: up_cpu_start + * + * Description: + * Start a secondary CPU at __start_secondary: set its PC and clear its + * boot halt bit. + * + ****************************************************************************/ + +int up_cpu_start(int cpu) +{ + uintptr_t pc = (uintptr_t)__start_secondary; + + if (cpu <= 0 || cpu >= CONFIG_SMP_NCPUS) + { + return -EINVAL; + } + + if ((getreg32(TRICORE_START_HALT(cpu)) & TRICORE_START_BHALT) == 0) + { + return -EBUSY; + } + + putreg32((getreg32(TRICORE_START_PC(cpu)) & TRICORE_START_PC_HALT) | + (pc & ~TRICORE_START_PC_HALT), TRICORE_START_PC(cpu)); + putreg32(getreg32(TRICORE_START_HALT(cpu)) & ~TRICORE_START_BHALT, + TRICORE_START_HALT(cpu)); + + return OK; +} + +/**************************************************************************** + * Name: up_send_smp_sched + * + * Description: + * Send the inter-CPU interrupt to one CPU. + * + ****************************************************************************/ + +int up_send_smp_sched(int cpu) +{ + if (cpu < 0 || cpu >= CONFIG_SMP_NCPUS) + { + return -EINVAL; + } + + up_trigger_irq(TRICORE_SMP_IPI_IRQ(this_cpu(), cpu), (cpu_set_t)1 << cpu); + + return OK; +} + +/**************************************************************************** + * Name: up_send_smp_call + * + * Description: + * Send the inter-CPU interrupt to a set of CPUs. One write to the + * software broadcast register of this CPU raises all of them. + * + ****************************************************************************/ + +void up_send_smp_call(cpu_set_t cpuset) +{ + cpuset &= ((cpu_set_t)1 << CONFIG_SMP_NCPUS) - 1; + if (cpuset != 0) + { + up_trigger_irq(TRICORE_SMP_IPI_IRQ(this_cpu(), this_cpu()), cpuset); + } +} + +/**************************************************************************** + * Name: tricore_smp_initialize + * + * Description: + * Called on CPU0 before the other CPUs start: give them access to the + * shared resources and attach and enable the inter-CPU interrupts of + * every CPU. up_irqinitialize() already routed each GPSR to its CPU. + * + ****************************************************************************/ + +void tricore_smp_initialize(void) +{ + int from; + int to; + +#ifdef CONFIG_ARCH_CHIP_TC4X + tricore_smp_grant_access(); +#endif + + for (to = 0; to < CONFIG_SMP_NCPUS; to++) + { + for (from = 0; from < CONFIG_SMP_NCPUS; from++) + { + irq_attach(TRICORE_SMP_IPI_IRQ(from, to), + tricore_smp_ipi_handler, NULL); + up_enable_irq(TRICORE_SMP_IPI_IRQ(from, to)); + } + } +} + +/**************************************************************************** + * Name: tricore_cpu_boot + * + * Description: + * C entry of a secondary CPU, called by __start_secondary on the idle + * stack of the CPU with its CSA pool and interrupt stack set up. + * + ****************************************************************************/ + +void tricore_cpu_boot(void) +{ +#ifdef CONFIG_ARCH_HAVE_FPU + tricore_fpuinit(); +#endif + +#ifdef CONFIG_ARCH_USE_MPU + tricore_mpuinit(); +#endif + +#ifdef CONFIG_SCHED_INSTRUMENTATION + sched_note_cpu_started(this_task()); +#endif + + up_irq_enable(); + + nx_idle_trampoline(); +} diff --git a/arch/tricore/src/common/tricore_doirq.c b/arch/tricore/src/common/tricore_doirq.c index 6b285e0791192..aa5794ddc32cd 100644 --- a/arch/tricore/src/common/tricore_doirq.c +++ b/arch/tricore/src/common/tricore_doirq.c @@ -41,6 +41,10 @@ #include "tricore_internal.h" +#ifdef CONFIG_SMP +# include "tricore_smp.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -112,6 +116,10 @@ void tricore_doirq(void) *running_task = tcb; +#ifdef CONFIG_SMP + tricore_csa_switch_balance(); +#endif + tricore_mtcr(TRICORE_CPU_PCXI, tricore_addr2csa(tcb->xcp.regs)); UP_ISB(); } diff --git a/arch/tricore/src/common/tricore_getintstack.c b/arch/tricore/src/common/tricore_getintstack.c index 5647e8380cad5..0635a1b393950 100644 --- a/arch/tricore/src/common/tricore_getintstack.c +++ b/arch/tricore/src/common/tricore_getintstack.c @@ -30,6 +30,10 @@ #include "tricore_internal.h" +#ifdef CONFIG_SMP +# include "tricore_smp.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -41,6 +45,13 @@ #if CONFIG_ARCH_INTERRUPTSTACK > 3 uintptr_t up_get_intstackbase(int cpu) { +#ifdef CONFIG_SMP + if (cpu > 0 && cpu < CONFIG_SMP_NCPUS) + { + return TRICORE_SMP_CPU_DSPR(cpu) + TRICORE_SMP_CSA_SIZE; + } +#endif + return (uintptr_t)g_intstackalloc; } #endif diff --git a/arch/tricore/src/common/tricore_idle.c b/arch/tricore/src/common/tricore_idle.c index 3f271e633ed2c..5bf80a1602b75 100644 --- a/arch/tricore/src/common/tricore_idle.c +++ b/arch/tricore/src/common/tricore_idle.c @@ -32,6 +32,10 @@ #include "tricore_internal.h" +#ifdef CONFIG_SMP +# include "tricore_smp.h" +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -77,7 +81,12 @@ void up_idle(void) board_autoled_off(LED_CPU); #endif +#ifdef CONFIG_SMP + tricore_csa_balance(); + __asm__ __volatile__ ("enable\n\twait" : : : "memory"); +#else tricore_idle_loop(); +#endif #endif } diff --git a/arch/tricore/src/common/tricore_initialize.c b/arch/tricore/src/common/tricore_initialize.c index b6f4625050ee7..79a138e0092e0 100644 --- a/arch/tricore/src/common/tricore_initialize.c +++ b/arch/tricore/src/common/tricore_initialize.c @@ -32,6 +32,10 @@ #include "tricore_internal.h" #include "tricore_vectors.h" +#ifdef CONFIG_SMP +# include "tricore_smp.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -65,7 +69,7 @@ void up_initialize(void) up_enable_icache(); #endif -#ifdef CONFIG_ARCH_DCACHE +#if defined(CONFIG_ARCH_DCACHE) && !defined(CONFIG_SMP) up_enable_dcache(); #endif @@ -78,4 +82,8 @@ void up_initialize(void) #ifdef CONFIG_ARCH_HAVE_DEBUG tricore_init_dbgmonitor(); #endif + +#ifdef CONFIG_SMP + tricore_smp_initialize(); +#endif } diff --git a/arch/tricore/src/common/tricore_irq.c b/arch/tricore/src/common/tricore_irq.c index 4fac18659e4a2..07417d29197d9 100644 --- a/arch/tricore/src/common/tricore_irq.c +++ b/arch/tricore/src/common/tricore_irq.c @@ -77,6 +77,16 @@ static inline void tricore_color_intstack(void) # define TRICORE_IRQ_ROUTED_WORDS (NR_IRQS / TRICORE_IRQ_ROUTED_BITS) #endif +/* GPSR groups, one per sending CPU, set up for each receiving CPU. With + * SMP only the CPUs of the kernel send. + */ + +#ifdef CONFIG_SMP +# define TRICORE_GPSR_NSRC CONFIG_SMP_NCPUS +#else +# define TRICORE_GPSR_NSRC 6 +#endif + #define TRICORE_SRC_TOS_GET(regval) \ (((regval) & TRICORE_SRC_TOS_MASK) >> TRICORE_SRC_TOS_SHIFT) @@ -189,7 +199,7 @@ static void tricore_gpsrinit_cpu(int cpu) /* Cpux gpsr init */ - for (i = 0; i < 6; i++) + for (i = 0; i < TRICORE_GPSR_NSRC; i++) { irq = TRICORE_GPSR_IRQNUM(i, cpu); tricore_src_init(TRICORE_IRQ2SRC(irq), tos, IRQ_TO_NDX(irq)); @@ -200,7 +210,7 @@ static void tricore_gpsrinit_cpu(int cpu) /* Cpucs gpsr init */ -#ifndef CONFIG_ARCH_CHIP_TC3X +#if !defined(CONFIG_ARCH_CHIP_TC3X) && !defined(CONFIG_SMP) tricore_src_init(TRICORE_IRQ2SRC(TRICORE_GPSR_IRQNUM(6, cpu)), tos, IRQ_TO_NDX(TRICORE_GPSR_IRQNUM(6, cpu))); #endif diff --git a/arch/tricore/src/common/tricore_main.c b/arch/tricore/src/common/tricore_main.c index 54d9f086d1d60..074b4548000a2 100644 --- a/arch/tricore/src/common/tricore_main.c +++ b/arch/tricore/src/common/tricore_main.c @@ -40,22 +40,28 @@ * Public Data ****************************************************************************/ -/* Entries of the other cores, provided by the linker script */ +/* Entries of the other cores, provided by the linker script. With SMP the + * other cores run this image instead, up_cpu_start() starts them. + */ +#ifndef CONFIG_SMP extern uintptr_t __start1[]; extern uintptr_t __start2[]; extern uintptr_t __start3[]; extern uintptr_t __start4[]; extern uintptr_t __start5[]; +#endif /**************************************************************************** * Private Data ****************************************************************************/ +#ifndef CONFIG_SMP static uintptr_t * const g_tricore_entry[] = { __start1, __start2, __start3, __start4, __start5 }; +#endif /**************************************************************************** * Private Functions @@ -71,6 +77,7 @@ static uintptr_t * const g_tricore_entry[] = * ****************************************************************************/ +#ifndef CONFIG_SMP static void tricore_core_sync(volatile uint32_t *sync) { uint32_t core = tricore_core_id(); @@ -99,6 +106,7 @@ static void tricore_core_sync(volatile uint32_t *sync) #endif } } +#endif /**************************************************************************** * Public Functions @@ -115,7 +123,9 @@ static void tricore_core_sync(volatile uint32_t *sync) void tricore_main(void) { +#ifndef CONFIG_SMP static volatile uint32_t g_sync_event; +#endif #ifdef CONFIG_ARCH_HAVE_FPU tricore_fpuinit(); @@ -131,7 +141,9 @@ void tricore_main(void) /* Wait for CPU sync event */ +#ifndef CONFIG_SMP tricore_core_sync(&g_sync_event); +#endif if (tricore_core_index() == 0) { @@ -159,6 +171,7 @@ void tricore_main(void) void tricore_start(void) { +#ifndef CONFIG_SMP int cpu; for (cpu = 1; cpu <= TRICORE_START_CORES; cpu++) @@ -173,6 +186,7 @@ void tricore_start(void) TRICORE_START_HALT(cpu)); } } +#endif tricore_main(); } diff --git a/arch/tricore/src/common/tricore_smp.h b/arch/tricore/src/common/tricore_smp.h index bf928ad7c6394..bc6e8201b56fc 100644 --- a/arch/tricore/src/common/tricore_smp.h +++ b/arch/tricore/src/common/tricore_smp.h @@ -29,7 +29,9 @@ #include -#include +#ifndef __ASSEMBLY__ +# include +#endif /**************************************************************************** * Pre-processor Definitions diff --git a/arch/tricore/src/common/tricore_svcall.c b/arch/tricore/src/common/tricore_svcall.c index 1f674e0eb30ba..51d6d4dcf2538 100644 --- a/arch/tricore/src/common/tricore_svcall.c +++ b/arch/tricore/src/common/tricore_svcall.c @@ -40,6 +40,10 @@ #include "tricore_internal.h" +#ifdef CONFIG_SMP +# include "tricore_smp.h" +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -126,6 +130,10 @@ void tricore_svcall(volatile void *trap) case SYS_restore_context: *running_task = tcb; +#ifdef CONFIG_SMP + tricore_csa_switch_balance(); + restore_critical_section(tcb, this_cpu()); +#endif tricore_mtcr(TRICORE_CPU_PCXI, tricore_addr2csa(tcb->xcp.regs)); UP_ISB(); break; diff --git a/arch/tricore/src/tc4x/hardware/tc4x_asclin.h b/arch/tricore/src/tc4x/hardware/tc4x_asclin.h index 4af8e6c26be3f..1e22bc9f66633 100644 --- a/arch/tricore/src/tc4x/hardware/tc4x_asclin.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_asclin.h @@ -32,6 +32,7 @@ #define TRICORE_ASCLIN0_BASE 0xf46c0000 #define ASCLIN_CLC_OFFSET 0x000 +#define ASCLIN_ACCEN_WRA_OFFSET 0x040 #define ASCLIN_IOCR_OFFSET 0x100 #define ASCLIN_TXFIFOCON_OFFSET 0x104 #define ASCLIN_RXFIFOCON_OFFSET 0x108 diff --git a/arch/tricore/src/tc4x/hardware/tc4x_cpu.h b/arch/tricore/src/tc4x/hardware/tc4x_cpu.h index e93bd0a3418de..526714b32011c 100644 --- a/arch/tricore/src/tc4x/hardware/tc4x_cpu.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_cpu.h @@ -33,4 +33,66 @@ #define TC4X_CPU_HRA_BOOTCON(n) (0xf881fe60 + (n) * 0x40000) #define TC4X_BOOTCON_BHALT (1 << 0) +/* Access protection of the memories and the STM of each CPU. A PROTxSE + * register selects the protection range and its state, an ACCENx_WRA/WRB + * pair has one bit per bus master tag; CPUn owns the tags 2n and 2n + 1. + */ + +#define TC4X_CPU_SFR(n) (0xf8800000 + (n) * 0x40000) +#define TC4X_CPU_PROTSPRSE(n) (TC4X_CPU_SFR(n) + 0xe008) +#define TC4X_CPU_ACCENSPRCFG(n) (TC4X_CPU_SFR(n) + 0xe020) +#define TC4X_CPU_ACCENSPR(n, r) (TC4X_CPU_SFR(n) + 0xe200 + \ + (r) * TC4X_ACCEN_RANGE_SIZE) +#define TC4X_CPU_PROTDLMUSE(n) (TC4X_CPU_SFR(n) + 0xe048) +#define TC4X_CPU_ACCENDLMUCFG(n) (TC4X_CPU_SFR(n) + 0xe060) +#define TC4X_CPU_ACCENDLMU(n, r) (TC4X_CPU_SFR(n) + 0xe400 + \ + (r) * TC4X_ACCEN_RANGE_SIZE) +#define TC4X_CPU_PROTSFRSE(n) (TC4X_CPU_SFR(n) + 0xe088) +#define TC4X_CPU_ACCENSFRCFG(n) (TC4X_CPU_SFR(n) + 0xe0a0) +#define TC4X_CPU_ACCENSFR(n) (TC4X_CPU_SFR(n) + 0xe600) +#define TC4X_CPU_PROTSTMSE(n) (TC4X_CPU_SFR(n) + 0xe0d8) +#define TC4X_CPU_ACCENSTMCFG_WRA(n) (TC4X_CPU_SFR(n) + 0xe0e0) + +/* A protected memory has TC4X_PROT_RANGES ranges. Each has an active + * ACCEN block of TC4X_ACCEN_WORDS registers (WRA, WRB, RDA, RDB, VM, PRS, + * RGNLA, RGNUA) and is changed through the CFG block of the same layout: + * select the range, go from Run to Config, write the CFG block and go + * back to Run, which makes it active. The SFRs of a CPU, where its STM + * is, have one range of TC4X_ACCEN_SFR_WORDS registers (no RGNLA, RGNUA). + */ + +#define TC4X_PROT_RANGES 16 +#define TC4X_PROT_SFR_RANGES 1 +#define TC4X_ACCEN_WORDS 8 +#define TC4X_ACCEN_SFR_WORDS 6 +#define TC4X_ACCEN_RANGE_SIZE (TC4X_ACCEN_WORDS * sizeof(uint32_t)) +#define TC4X_ACCEN_WRA 0 + +#define TC4X_PROT_RANGE(r) ((r) << 8) +#define TC4X_PROT_STM_RANGE 1 +#define TC4X_PROT_SWEN (1 << 3) +#define TC4X_PROT_STATE_CONFIG 1 +#define TC4X_PROT_STATE_RUN 4 +#define TC4X_PROT_SET(r, state) (TC4X_PROT_RANGE(r) | TC4X_PROT_SWEN | \ + (state)) +#define TC4X_PROT_STM(state) TC4X_PROT_SET(TC4X_PROT_STM_RANGE, state) + +#define TC4X_CPU_TAGS(n) (0x3 << ((n) * 2)) +#define TC4X_CPU_TAGS_ALL(n) ((0x1 << ((n) * 2)) - 1) + +/* Access protection of the interrupt router for each service provider + * (TOS): who may route an SRC to it, and who may enable or trigger it, + * and of the broadcast register INT_SRBn that CPUn writes to send IPIs + */ + +#define TC4X_IR_INT_BASE 0xf4430000 +#define TC4X_IR_TOS_STRIDE 0x30 +#define TC4X_IR_SRB_STRIDE 0x18 +#define TC4X_IR_ACCENSRB_WRA(n) \ + (TC4X_IR_INT_BASE + 0x100 + (n) * TC4X_IR_SRB_STRIDE) +#define TC4X_IR_ACCENSCFG_WRA(tos) \ + (TC4X_IR_INT_BASE + 0x300 + (tos) * TC4X_IR_TOS_STRIDE) +#define TC4X_IR_ACCENSCTRL_WRA(tos) \ + (TC4X_IR_INT_BASE + 0x318 + (tos) * TC4X_IR_TOS_STRIDE) + #endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_CPU_H */