Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring the Zephyr HWinfo driver changes into NCS #1985

Merged
merged 5 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/hwinfo/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ config HWINFO_NRF
bool "NRF device ID"
default y
depends on SOC_FAMILY_NORDIC_NRF
depends on NRF_SOC_SECURE_SUPPORTED
depends on SOC_SERIES_NRF54HX || NRF_SOC_SECURE_SUPPORTED
help
Enable Nordic NRF hwinfo driver.

Expand Down
33 changes: 25 additions & 8 deletions drivers/hwinfo/hwinfo_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <zephyr/drivers/hwinfo.h>
#include <string.h>
#include <zephyr/sys/byteorder.h>
#ifndef CONFIG_BOARD_QEMU_CORTEX_M0
#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0)
#include <helpers/nrfx_reset_reason.h>
#endif

Expand All @@ -25,17 +25,34 @@ struct nrf_uid {
ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
{
struct nrf_uid dev_id;
uint32_t deviceid[2];
uint32_t buf[2];

#if NRF_FICR_HAS_DEVICE_ID || NRF_FICR_HAS_INFO_DEVICE_ID
/* DEVICEID is accessible, use this */
#if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && defined(NRF_FICR_S)
soc_secure_read_deviceid(deviceid);
soc_secure_read_deviceid(buf);
#else
deviceid[0] = nrf_ficr_deviceid_get(NRF_FICR, 0);
deviceid[1] = nrf_ficr_deviceid_get(NRF_FICR, 1);
buf[0] = nrf_ficr_deviceid_get(NRF_FICR, 0);
buf[1] = nrf_ficr_deviceid_get(NRF_FICR, 1);
#endif
#elif NRF_FICR_HAS_DEVICE_ADDR || NRF_FICR_HAS_BLE_ADDR
/* DEVICEID is not accessible, use device/ble address instead.
* Assume that it is always accessible from the non-secure image.
*/
buf[0] = nrf_ficr_deviceaddr_get(NRF_FICR, 0);
buf[1] = nrf_ficr_deviceaddr_get(NRF_FICR, 1);

/* Assume that ER and IR are available whenever deviceaddr is.
* Use the LSBytes from ER and IR to complete the device id.
*/
buf[1] |= (nrf_ficr_er_get(NRF_FICR, 0) & 0xFF) << 16;
buf[1] |= (nrf_ficr_ir_get(NRF_FICR, 0) & 0xFF) << 24;
#else
#error "No suitable source for hwinfo device_id generation"
#endif

dev_id.id[0] = sys_cpu_to_be32(deviceid[1]);
dev_id.id[1] = sys_cpu_to_be32(deviceid[0]);
dev_id.id[0] = sys_cpu_to_be32(buf[1]);
dev_id.id[1] = sys_cpu_to_be32(buf[0]);

if (length > sizeof(dev_id.id)) {
length = sizeof(dev_id.id);
Expand All @@ -46,7 +63,7 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
return length;
}

#ifndef CONFIG_BOARD_QEMU_CORTEX_M0
#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0)
int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
{
uint32_t flags = 0;
Expand Down
4 changes: 4 additions & 0 deletions drivers/serial/uart_nrfx_uarte.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ static int uarte_nrfx_configure(const struct device *dev,
struct uarte_nrfx_data *data = dev->data;
nrf_uarte_config_t uarte_cfg;

#if NRF_UARTE_HAS_FRAME_TIMEOUT
uarte_cfg.frame_timeout = NRF_UARTE_FRAME_TIMEOUT_DIS;
#endif

#if defined(UARTE_CONFIG_STOP_Msk)
switch (cfg->stop_bits) {
case UART_CFG_STOP_BITS_1:
Expand Down
4 changes: 4 additions & 0 deletions drivers/serial/uart_nrfx_uarte2.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,10 @@ static int uarte_nrfx_configure(const struct device *dev,
struct uarte_nrfx_data *data = dev->data;
nrf_uarte_config_t uarte_cfg;

#if NRF_UARTE_HAS_FRAME_TIMEOUT
uarte_cfg.frame_timeout = NRF_UARTE_FRAME_TIMEOUT_DIS;
#endif

#if defined(UARTE_CONFIG_STOP_Msk)
switch (cfg->stop_bits) {
case UART_CFG_STOP_BITS_1:
Expand Down
2 changes: 1 addition & 1 deletion modules/hal_nordic/nrfx/nrfx_config_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/** @brief Symbol specifying minor version of the nrfx API to be used. */
#ifndef NRFX_CONFIG_API_VER_MINOR
#define NRFX_CONFIG_API_VER_MINOR 3
#define NRFX_CONFIG_API_VER_MINOR 6
#endif

/** @brief Symbol specifying micro version of the nrfx API to be used. */
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf52805.h
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf52810.h
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf52811.h
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf52820.h
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf52832.h
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf52833.h
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf52840.h
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf5340_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf5340_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf54h20_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,15 @@
#define NRFX_UARTE_CONFIG_RX_CACHE_ENABLED 1
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf54h20_ppr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,15 @@
#define NRFX_UARTE_CONFIG_RX_CACHE_ENABLED 1
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf54h20_radiocore.h
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,15 @@
#define NRFX_UARTE_CONFIG_RX_CACHE_ENABLED 1
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1518,12 +1518,12 @@
#endif

/**
* @brief NRFX_UARTE_CONFIG_RX_CACHE_ENABLED
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Boolean. Accepted values: 0 and 1.
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_CONFIG_RX_CACHE_ENABLED
#define NRFX_UARTE_CONFIG_RX_CACHE_ENABLED 1
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
Expand Down
8 changes: 4 additions & 4 deletions modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_flpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1510,12 +1510,12 @@
#endif

/**
* @brief NRFX_UARTE_CONFIG_RX_CACHE_ENABLED
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Boolean. Accepted values: 0 and 1.
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_CONFIG_RX_CACHE_ENABLED
#define NRFX_UARTE_CONFIG_RX_CACHE_ENABLED 1
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config_nrf91.h
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,15 @@
#define NRFX_UARTE_ENABLED 0
#endif

/**
* @brief NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
*
* Integer value. Minimum: 0. Maximum: 255.
*/
#ifndef NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE
#define NRFX_UARTE_RX_FIFO_FLUSH_WORKAROUND_MAGIC_BYTE 171
#endif

/**
* @brief NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY
*
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ manifest:
groups:
- hal
- name: hal_nordic
revision: ab5cb2e2faeb1edfad7a25286dcb513929ae55da
revision: d4030afcc0befef645eda11e82c0d7c0e1d604f1
path: modules/hal/nordic
groups:
- hal
Expand Down
Loading