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

config ZEPHYR_HAL_NORDIC_MODULE
	bool

config HAS_NORDIC_DRIVERS
	bool

menu "Nordic drivers"
	depends on HAS_NORDIC_DRIVERS

choice NRF_802154_SOURCE
	prompt "Source of the IEEE 802.15.4 radio driver"

config NRF_802154_SOURCE_HAL_NORDIC
	bool "Open source"

endchoice

menuconfig NRF_802154_RADIO_DRIVER
	bool "NRF IEEE 802.15.4 radio driver"
	depends on HAS_HW_NRF_RADIO_IEEE802154
	select DYNAMIC_INTERRUPTS
	select ENTROPY_GENERATOR
	select CLOCK_CONTROL
	depends on !$(dt_nodelabel_enabled,timer1)
	help
	  This option enables nRF IEEE 802.15.4 radio driver in Zephyr. Note,
	  that beside the radio peripheral itself, this drivers occupies several
	  other peripherals. A complete list can be found in the hal_nordic
	  repository, within drivers/nrf_radio_802154/nrf_802154_peripherals.h
	  file. As the nRF IEEE 802.15.4 radio driver defines IRQ configuration
	  abstraction layer API and its Zephyr-specific implementation uses dynamic
	  interrupts, the DYNAMIC_INTERRUPTS switch is selected unconditionally.

if NRF_802154_RADIO_DRIVER

config NRF_802154_CONSTLAT_CONTROL
	def_bool y
	depends on SOC_SERIES_NRF54LX && NRF_802154_SL_OPENSOURCE
	select NRF_SYS_EVENT
	help
	  Allows the nRF 802.15.4 radio driver to manage the constant latency state.

config NRF_802154_MULTIPROTOCOL_SUPPORT
	bool
	help
	  In dynamic multiprotocol applications, access to the radio peripheral
	  must be distributed by an arbiter. To support this arbitration
	  in the driver, this option must be enabled. Otherwise, the driver
	  assumes that access to the radio peripheral is granted indefinitely.

choice NRF_802154_SL_TYPE
	prompt "nRF IEEE 802.15.4 Service Layer Type"

config NRF_802154_SL_OPENSOURCE
	bool "Open source"
	select SENSOR if NRF_802154_TEMPERATURE_UPDATE
	select TEMP_NRF5 if NRF_802154_TEMPERATURE_UPDATE

endchoice

config NRF_802154_TEMPERATURE_UPDATE
	bool "nRF 802.15.4 temperature update"
	default y if !SOC_NRF54H20
	help
	  Enable temperature update for nRF 802.15.4 driver

config NRF_802154_TEMPERATURE_UPDATE_INIT_PRIO
	int "nRF52 IEEE 802.15.4 temperature update initialization priority"
	depends on NRF_802154_TEMPERATURE_UPDATE
	default 91
	help
	  Set the initialization priority of a temperature update for nRF 802.15.4 driver.

config NRF_802154_TEMPERATURE_UPDATE_PERIOD
	int "nRF 802.15.4 temperature update period in milliseconds"
	depends on NRF_802154_TEMPERATURE_UPDATE
	default 60000
	help
	  Period of a temperature update for nRF 802.15.4 driver in milliseconds

endif # NRF_802154_RADIO_DRIVER

config NRF_802154_SERIALIZATION
	bool
	select IPC_SERVICE
	select MBOX
	help
	  This helper symbol indicates that the nRF 802.15.4 serialization is available.

config NRF_802154_SER_HOST
	bool "nRF IEEE 802.15.4 Driver serialization host"
	depends on !NRF_802154_RADIO_DRIVER
	depends on !HAS_HW_NRF_RADIO_IEEE802154
	select IEEE802154_NRF5_EXT_IRQ_MGMT if IEEE802154_NRF5
	select NRF_802154_SERIALIZATION
	help
	  Enable serialization of nRF IEEE 802.15.4 Driver. This option is to be
	  used if radio is not available in the core, but radio services are
	  provided by a serialization backend.

menuconfig NRF_802154_SER_RADIO
	bool "nRF IEEE 802.15.4 Driver serialization radio"
	depends on HAS_HW_NRF_RADIO_IEEE802154
	depends on !IEEE802154_NRF5
	select NRF_802154_RADIO_DRIVER
	select NRF_802154_SERIALIZATION
	help
	  Enable serialization of nRF IEEE 802.15.4 Driver. This option is to be
	  used if radio is available in the core to provide radio services over
	  a serialization backend.

if NRF_802154_SER_RADIO

config NRF_802154_SER_RADIO_INIT_PRIO
	int "nRF52 IEEE 802.15.4 serialization initialization priority"
	default 53
	help
	  Set the initialization priority number. Do not mess with it unless
	  you know what you are doing.

endif

menu "nRF 802.15.4 serialization"
	depends on NRF_802154_SER_HOST || NRF_802154_SER_RADIO

config NRF_802154_SER_LOG
	bool "802.15.4 serialization logs"
	default n
	help
	  This option enable debug logs of 802.15.4 serialization module.

config NRF_802154_SER_DEFAULT_RESPONSE_TIMEOUT
	int "Default Spinel serialization response timeout in milliseconds"
	default 500
	help
	  This option specifies default timeout of spinel status response
	  in milliseconds.

endmenu # NRF_802154_SER_HOST || NRF_802154_SER_RADIO

if NRF_802154_RADIO_DRIVER || NRF_802154_SERIALIZATION

choice NRF_802154_CCA_MODE
	prompt "nRF IEEE 802.15.4 CCA mode"
	default NRF_802154_CCA_MODE_ED
	help
	  CCA mode

config NRF_802154_CCA_MODE_ED
	bool "Energy Above Threshold"

config NRF_802154_CCA_MODE_CARRIER
	bool "Carrier Seen"

config NRF_802154_CCA_MODE_CARRIER_AND_ED
	bool "Energy Above Threshold AND Carrier Seen"

config NRF_802154_CCA_MODE_CARRIER_OR_ED
	bool "Energy Above Threshold OR Carrier Seen"

endchoice

config NRF_802154_CCA_ED_THRESHOLD_DBM
	int "nRF IEEE 802.15.4 CCA Energy Detection threshold in dBm"
	default -75
	help
	  If energy detected in a given channel is above the value then the
	  channel is deemed busy. The unit is dBm.

config NRF_802154_CCA_CORR_THRESHOLD
	int "nRF IEEE 802.15.4 CCA Correlator threshold"
	default 45

config NRF_802154_CCA_CORR_LIMIT
	int "nRF IEEE 802.15.4 CCA Correlator limit"
	default 2
	help
	  Limit for occurrences above correlator threshold. When not equal to
	  zero the correlator based signal detect is enabled.

config NRF_802154_RX_BUFFERS
	int "nRF 802.15.4 receive buffers"
	default 20
	help
	  Number of buffers in nRF 802.15.4 driver serialization host's receive queue.
	  If this value is modified, its remote counterpart must be set to the exact same value.

config NRF_802154_PENDING_SHORT_ADDRESSES
	int "nRF 802.15.4 pending short addresses"
	default 16
	help
	  Number of slots containing short addresses of nodes for which pending data is stored

config NRF_802154_PENDING_EXTENDED_ADDRESSES
	int "nRF 802.15.4 pending extended addresses"
	default 16
	help
	  Number of slots containing extended addresses of nodes for which pending data is stored

config NRF_802154_ENCRYPTION
	bool "nRF 802.15.4 AES-CCM* authentication & encryption"
	depends on !CRYPTO_NRF_ECB
	select NRF_802154_IE_WRITER
	select NRF_802154_SECURITY_WRITER
	help
	  Enable module for encryption and authentication of outgoing frames and Acks.

config NRF_802154_IE_WRITER
	bool "Information element writer"
	help
	  Enable data injection for some Information Element types.

config NRF_802154_SECURITY_WRITER
	bool "Security frame counter writer"
	help
	  Enable injection of security frame counter.

config NRF_802154_SECURITY_KEY_STORAGE_SIZE
	int "nRF 802.15.4 security key storage size"
	default 3
	help
	  Number of encryption keys that the nRF 802.15.4 Radio Driver can store simultaneously.

config NRF_802154_CARRIER_FUNCTIONS
	bool "nRF 802.15.4 carrier functions"
	default y if (OPENTHREAD_DIAG || IEEE802154_CARRIER_FUNCTIONS)
	help
	  This option enables functions such as modulated carrier and continuous carrier.
	  If this option is modified on a multicore SoC, its remote counterpart must be set to the exact same value.

choice NRF_802154_ASSERT_CHOICE
	prompt "nRF 802.15.4 assert implementation"
	default NRF_802154_ASSERT_ZEPHYR_MINIMAL

config NRF_802154_ASSERT_ZEPHYR_MINIMAL
	bool "nRF 802.15.4 minimal assertions"
	help
	  This option provides minimal run-time checking of the nRF 802.15.4 Radio Driver's operation,
	  even if kernel-wide CONFIG_ASSERT is disabled. In case of an abnormal condition the function
	  `nrf_802154_assert_handler()` is called. File and line debug information are not provided
	  to save memory of the image file. Default implementation of the `nrf_802154_assert_handler`
	  involves a call to `k_panic`/`k_oops` and allows further tweaking of the behavior.
	  You can also provide your own implementation of `nrf_802154_assert_handler`.

config NRF_802154_ASSERT_ZEPHYR
	bool "nRF 802.15.4 Radio Driver assertions as Zephyr's standard __ASERT_NO_MSG"
	help
	  The run-time checking of the nRF 802.15.4 Radio Driver depends fully on the configuration
	  of the `__ASSERT_NO_MSG` macro, including the ability to completely turn off the run-time
	  checking.

endchoice # NRF_802154_ASSERT_CHOICE

endif # NRF_802154_RADIO_DRIVER || NRF_802154_SERIALIZATION

endmenu # HAS_NORDIC_DRIVERS

rsource "ironside/se/Kconfig"
rsource "nrfs/Kconfig"
rsource "nrfx/Kconfig"
rsource "Kconfig.nrf_regtool"
