drivers: crypto_nrf_ecb: Convert to use devicetree

Convert the driver so that it creates its instance basing on DT.
Remove no longer needed Kconfig option CRYPTO_NRF_ECB_NAME.
Also update accordingly the crypto sample.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
Andrzej Głąbek 2020-12-21 13:09:05 +01:00 committed by Ioannis Glaropoulos
commit d855d47288
3 changed files with 15 additions and 14 deletions

View file

@ -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

View file

@ -9,6 +9,8 @@
#include <logging/log.h>
#include <hal/nrf_ecb.h>
#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);

View file

@ -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