# Nordic Semiconductor nRFx MCU line

# Copyright (c) 2016-2018 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

# This file contains Zephyr build system Kconfig references and is not
# re-usable outside the Zephyr tree.

# These SOC_COMPATIBLE_NRF* options are common between real and simulated targets.
# Most code and kconfig options use the COMPATIBLE option, but the few places which are specific
# for real HW or simulated HW will use the corresponding real SOC_NRF* or BSIM option.

config SOC_COMPATIBLE_NRF
	bool

config SOC_COMPATIBLE_NRF52X
	bool

config SOC_COMPATIBLE_NRF53X
	bool

config SOC_COMPATIBLE_NRF54LX
	bool

config SOC_COMPATIBLE_NRF52833
	bool

config SOC_COMPATIBLE_NRF5340_CPUNET
	bool

config SOC_COMPATIBLE_NRF5340_CPUAPP
	bool

config SOC_COMPATIBLE_NRF54L15
	bool

config SOC_COMPATIBLE_NRF54L15_CPUAPP
	bool

config SOC_COMPATIBLE_NRF54LM20A
	bool

config SOC_COMPATIBLE_NRF54LM20A_CPUAPP
	bool

config SOC_COMPATIBLE_NRF71
	bool

config SOC_COMPATIBLE_NRF7120_ENGA
	bool

config SOC_COMPATIBLE_NRF7120_ENGA_CPUAPP
	bool

config SOC_FAMILY_NORDIC_NRF
	select SOC_COMPATIBLE_NRF
	select SOC_RESET_HOOK
	select CMSIS_CORE_HAS_SYSTEM_CORE_CLOCK if ARM

if SOC_FAMILY_NORDIC_NRF

rsource "common/Kconfig.peripherals"
rsource "*/Kconfig"

config NRF_SOC_SECURE_SUPPORTED
	def_bool !TRUSTED_EXECUTION_NONSECURE || (BUILD_WITH_TFM && TFM_PARTITION_PLATFORM)
	depends on !SOC_SERIES_NRF54H
	depends on !SOC_SERIES_NRF92
	help
	  Hidden function to indicate that the soc_secure functions are
	  available.
	  The functions are always available when not in non-secure.
	  For non-secure the functions must redirect to secure services exposed
	  by the secure firmware.

config BUILD_WITH_TFM
	default y if TRUSTED_EXECUTION_NONSECURE
	help
	  By default, if we build for a Non-Secure version of the board,
	  enable building with TF-M as the Secure Execution Environment.

if BUILD_WITH_TFM

config TFM_FLASH_MERGED_BINARY
	default y
	help
	  By default, if we build with TF-M, instruct build system to
	  flash the combined TF-M (Secure) & Zephyr (Non Secure) image

config TFM_LOG_LEVEL_SILENCE
	default y if !$(dt_nodelabel_has_prop,uart1,pinctrl-names)
	help
	  Disable TF-M secure output if the uart1 node has not assigned GPIO
	  pins using pinctrl.

config TFM_NRF_NS_STORAGE
	bool "TF-M non-secure storage partition"
	default y

endif # BUILD_WITH_TFM

config NRF_MPU_FLASH_REGION_SIZE
	hex
	default 0x1000
	depends on HAS_HW_NRF_MPU
	help
	  FLASH region size for the NRF_MPU peripheral.

DT_CHOSEN_ZEPHYR_FLASH := zephyr,flash
DT_CHOSEN_ZEPHYR_FLASH_PATH := $(dt_chosen_path,$(DT_CHOSEN_ZEPHYR_FLASH))

config NRF_BPROT_FLASH_REGION_SIZE
	hex
	default $(dt_node_int_prop_hex,$(DT_CHOSEN_ZEPHYR_FLASH_PATH),erase-block-size)
	depends on HAS_HW_NRF_BPROT
	help
	  FLASH region size for the NRF_BPROT peripheral (nRF52).

config NRF_ACL_FLASH_REGION_SIZE
	hex
	default $(dt_node_int_prop_hex,$(DT_CHOSEN_ZEPHYR_FLASH_PATH),erase-block-size)
	depends on HAS_HW_NRF_ACL
	help
	  FLASH region size for the NRF_ACL peripheral.

choice NRF_APPROTECT_HANDLING
	bool "AP-Protect handling"
	depends on SOC_SERIES_NRF52 || SOC_SERIES_NRF53 || SOC_NRF54L_CPUAPP_COMMON || \
		   SOC_SERIES_NRF91
	default NRF_APPROTECT_DISABLE if SOC_NRF54L_CPUAPP_COMMON
	default NRF_APPROTECT_USE_UICR
	help
	  Specifies how the SystemInit() function handles the AP-Protect
	  mechanism.
	  This choice does not apply to nRF9160 and older HW build codes
	  of nRF52 Series devices where AP-Protect is controlled solely by
	  hardware, i.e. the UICR.APPROTECT register.

config NRF_APPROTECT_DISABLE
	bool "Disable"
	depends on SOC_NRF54L_CPUAPP_COMMON
	help
	  When this option is selected, the SystemInit() disables
	  the AP-Protect mechanism and allows for debugging.

config NRF_APPROTECT_USE_UICR
	bool "Use UICR (default)"
	depends on SOC_SERIES_NRF52 || SOC_SERIES_NRF53 || SOC_SERIES_NRF91
	help
	  When this option is selected, the SystemInit() function sets
	  CTRL-AP.APPROTECT.DISABLE to the UICR.APPROTECT value.
	  If AP-Protect is disabled in UICR, AP-Protect is kept disabled.
	  If AP-Protect is enabled in UICR, AP-Protect is kept enabled.

config NRF_APPROTECT_LOCK
	bool "Lock"
	help
	  When this option is selected, the SystemInit() function locks
	  the AP-Protect mechanism. This permanently prevents debugger
	  from accessing the device. Only the ERASEALL operation through CTRL-AP
	  can restore the access.

config NRF_APPROTECT_USER_HANDLING
	bool "Allow user handling"
	depends on !SOC_SERIES_NRF52
	help
	  When this option is selected, the SystemInit() function does not
	  touch the AP-Protect mechanism. This allows the user code to handle it
	  at later stages, for example, to implement authenticated debug.

endchoice

choice NRF_SECURE_APPROTECT_HANDLING
	bool "Secure AP-Protect handling"
	depends on SOC_NRF5340_CPUAPP || SOC_NRF54L_CPUAPP_COMMON || SOC_SERIES_NRF91
	default NRF_SECURE_APPROTECT_DISABLE if SOC_NRF54L_CPUAPP_COMMON
	default NRF_SECURE_APPROTECT_USE_UICR
	help
	  Specifies how the SystemInit() function handles the Secure
	  AP-Protect mechanism. Secure AP-Protect is available for SoCs or SiPs
	  that support ARM TrustZone and different processing environments.
	  This choice does not apply to nRF9160 where AP-Protect is controlled
	  solely by hardware, i.e. the UICR.APPROTECT register.

config NRF_SECURE_APPROTECT_DISABLE
	bool "Disable"
	depends on SOC_NRF54L_CPUAPP_COMMON
	help
	  When this option is selected, the SystemInit() disables
	  the Secure AP-Protect mechanism. This allows debugging of the Secure
	  Processing Environment (SPE).

config NRF_SECURE_APPROTECT_USE_UICR
	bool "Use UICR (default)"
	depends on SOC_NRF5340_CPUAPP || SOC_SERIES_NRF91
	help
	  When this option is selected, the SystemInit() function sets
	  CTRL-AP.SECUREAPPROTECT.DISABLE to the UICR.SECUREAPPROTECT value.
	  If Secure AP-Protect is disabled in UICR, Secure AP-Protect is kept
	  disabled. If Secure AP-Protect is enabled in UICR, Secure AP-Protect
	  is kept enabled and access to the Secure Processing Environment (SPE)
	  is blocked.

config NRF_SECURE_APPROTECT_LOCK
	bool "Lock"
	help
	  When this option is selected, the SystemInit() function locks the
	  Secure AP-Protect mechanism. This permanently prevents debugger
	  from accessing the Secure Processing Environment (SPE).
	  Only the ERASEALL operation through CTRL-AP can restore the SPE access.

config NRF_SECURE_APPROTECT_USER_HANDLING
	bool "Allow user handling"
	depends on !SOC_SERIES_NRF52
	help
	  When this option is selected, the SystemInit() function does not
	  touch the Secure AP-Protect mechanism. This allows the user code to
	  handle it at later stages, for example, to implement authenticated
	  debug of the Secure Processing Environment (SPE).

endchoice

config NRF_SKIP_CLOCK_CONFIG
	bool
	prompt "Skip clock frequency configuration" if TRUSTED_EXECUTION_SECURE
	depends on SOC_SERIES_NRF54L || SOC_SERIES_NRF71
	default y if TRUSTED_EXECUTION_NONSECURE
	help
	  With this option, the CPU clock frequency is not set during system initialization.
	  The CPU runs with the default, hardware-selected frequency.

config NRF_TRACE_PORT
	bool "nRF TPIU"
	depends on !SOC_SERIES_NRF51
	help
	  Enable this option to initialize the TPIU (Trace Port Interface
	  Unit) for tracing using a hardware probe. If disabled, the trace
	  pins will be used as GPIO.

config NRF_CUSTOM_ON_ENTER_CPU_IDLE_HOOK
	bool "Custom on enter CPU idle hook"
	depends on ARM_ON_ENTER_CPU_IDLE_HOOK
	help
	  Select this option to use a custom on enter CPU idle hook. If enabled,
	  the hook is implemented by the user. It is the user's responsibility to
	  implement the SoC-specific code in the hook that is present in the default
	  implementation.

# Backward-compatibility aliases for symbols removed during the Haltium / Lumos
# Kconfig cleanup. Slated for removal in a future release.

config NRF_PLATFORM_DEPRECATED_SYMBOLS
	bool "Generate the deprecated HALTIUM/LUMOS symbols for downstream compatibility"

config NRF_PLATFORM_HALTIUM
	bool "[DEPRECATED] Replaced by SOC_SERIES_NRF54H / SOC_SERIES_NRF92"
	default y if SOC_SERIES_NRF54H || SOC_SERIES_NRF92
	depends on NRF_PLATFORM_DEPRECATED_SYMBOLS
	select DEPRECATED
	help
	  This option has been removed. Use SOC_SERIES_NRF54H or SOC_SERIES_NRF92
	  directly. The symbol is kept temporarily so that out-of-tree code that
	  still references it continues to build, with a deprecation warning.

config NRF_PLATFORM_LUMOS
	bool "[DEPRECATED] Replaced by SOC_SERIES_NRF54L / SOC_SERIES_NRF71"
	default y if SOC_SERIES_NRF54L || SOC_SERIES_NRF71
	depends on NRF_PLATFORM_DEPRECATED_SYMBOLS
	select DEPRECATED
	help
	  This option has been removed. Use SOC_SERIES_NRF54L or SOC_SERIES_NRF71
	  directly. The symbol is kept temporarily so that out-of-tree code that
	  still references it continues to build, with a deprecation warning.

endif # SOC_FAMILY_NORDIC_NRF
