diff --git a/drivers/crypto/Kconfig.nrf_ecb b/drivers/crypto/Kconfig.nrf_ecb index 85c8b94680e..5181cdc3d1b 100644 --- a/drivers/crypto/Kconfig.nrf_ecb +++ b/drivers/crypto/Kconfig.nrf_ecb @@ -3,16 +3,15 @@ # Copyright (c) 2020 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 +# Workaround for not being able to have commas in macro arguments +DT_COMPAT_NORDIC_NRF_ECB := nordic,nrf-ecb -menuconfig CRYPTO_NRF_ECB +config CRYPTO_NRF_ECB bool "nRF AES electronic codebook mode encryption" - depends on HAS_HW_NRF_ECB && !BT_CTLR + depends on $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_ECB)) + # Bluetooth controller uses the ECB peripheral directly + # (see subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c), + # hence this driver cannot be enabled together with it. + depends on !BT_CTLR help Enable nRF HAL-based AES ECB encryption driver - -config CRYPTO_NRF_ECB_DRV_NAME - string "nRF AES ECB driver name" - default "CRYPTO_NRF_ECB" - depends on CRYPTO_NRF_ECB - help - Driver name for nRF AES ECB diff --git a/drivers/crypto/crypto_nrf_ecb.c b/drivers/crypto/crypto_nrf_ecb.c index 94b3abfb857..254e6b7fe04 100644 --- a/drivers/crypto/crypto_nrf_ecb.c +++ b/drivers/crypto/crypto_nrf_ecb.c @@ -9,6 +9,8 @@ #include #include +#define DT_DRV_COMPAT nordic_nrf_ecb + #define ECB_AES_KEY_SIZE 16 #define ECB_AES_BLOCK_SIZE 16 @@ -137,7 +139,7 @@ static const struct crypto_driver_api crypto_enc_funcs = { .query_hw_caps = nrf_ecb_query_caps, }; -DEVICE_DEFINE(nrf_ecb, CONFIG_CRYPTO_NRF_ECB_DRV_NAME, - nrf_ecb_driver_init, device_pm_control_nop, NULL, NULL, - POST_KERNEL, CONFIG_CRYPTO_INIT_PRIORITY, - &crypto_enc_funcs); +DEVICE_DT_INST_DEFINE(0, nrf_ecb_driver_init, device_pm_control_nop, + NULL, NULL, + POST_KERNEL, CONFIG_CRYPTO_INIT_PRIORITY, + &crypto_enc_funcs); diff --git a/samples/drivers/crypto/src/main.c b/samples/drivers/crypto/src/main.c index 0f09a52e6e0..fc404dc2051 100644 --- a/samples/drivers/crypto/src/main.c +++ b/samples/drivers/crypto/src/main.c @@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(main); #elif CONFIG_CRYPTO_STM32 #define CRYPTO_DRV_NAME DT_LABEL(DT_INST(0, st_stm32_cryp)) #elif CONFIG_CRYPTO_NRF_ECB -#define CRYPTO_DRV_NAME CONFIG_CRYPTO_NRF_ECB_DRV_NAME +#define CRYPTO_DRV_NAME DT_LABEL(DT_INST(0, nordic_nrf_ecb)) #else #error "You need to enable one crypto device" #endif