Skip to content

Commit c8bf20c

Browse files
maje-embrlubos
authored andcommitted
nfc: lib: Add clock handling for nRF54H20
For the nRF54H20, added clock handling when a field is detected or lost. Ref: NCSDK-30629 Signed-off-by: Marcin Jelinski <marcin.jelinski@nordicsemi.no>
1 parent 2f872f4 commit c8bf20c

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

subsys/nfc/lib/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config NFC_PLATFORM
77
bool "Common NFC configuration"
88
default y if NFC_T2T_NRFXLIB || NFC_T4T_NRFXLIB
99
select NRFX_NFCT
10+
select CLOCK_CONTROL
1011
help
1112
Enable common configuration for the NFC
1213

subsys/nfc/lib/platform.c

+22-23
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
#include <zephyr/kernel.h>
88
#include <zephyr/linker/devicetree_regions.h>
99

10-
#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX)
10+
#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF)
1111
#include <zephyr/drivers/clock_control.h>
1212
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
13-
#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */
13+
#elif IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF2)
14+
#include <zephyr/devicetree.h>
15+
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
16+
#endif /* IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) */
1417

1518
#include <zephyr/sys/__assert.h>
1619
#include <zephyr/sys/onoff.h>
@@ -49,12 +52,14 @@ LOG_MODULE_REGISTER(nfc_platform, CONFIG_NFC_PLATFORM_LOG_LEVEL);
4952
_irq_handler)
5053
#endif /* NFC_PLATFORM_USE_TIMER_WORKAROUND */
5154

52-
#define DT_DRV_COMPAT nordic_nrf_clock
53-
54-
#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX)
55+
#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF)
5556
static struct onoff_manager *hf_mgr;
57+
#elif IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF2)
58+
static const struct device *clk_dev = DEVICE_DT_GET(DT_NODELABEL(hfxo));
59+
#else
60+
BUILD_ASSERT(false, "No Clock Control driver");
61+
#endif /* IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) */
5662
static struct onoff_client cli;
57-
#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */
5863

5964
#define NFCT DT_NODELABEL(nfct)
6065
#define NFCT_HAS_PROPERTY(_property) \
@@ -109,10 +114,10 @@ nrfx_err_t nfc_platform_setup(nfc_lib_cb_resolve_t nfc_lib_cb_resolve, uint8_t *
109114
{
110115
int err;
111116

112-
#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX)
117+
#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF)
113118
hf_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
114119
__ASSERT_NO_MSG(hf_mgr);
115-
#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */
120+
#endif /* IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) */
116121

117122
IRQ_DIRECT_CONNECT(DT_IRQN(NFCT), DT_IRQ(NFCT, priority),
118123
nfc_isr_wrapper, 0);
@@ -240,31 +245,25 @@ void nfc_platform_event_handler(nrfx_nfct_evt_t const *event)
240245
case NRFX_NFCT_EVT_FIELD_DETECTED:
241246
LOG_DBG("Field detected");
242247

243-
#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX)
244-
/* For now, assume HFXO clock is running all the time on nRF54h20
245-
* and currently clock handling is not implemented on this platform.
246-
*/
248+
#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF)
247249
sys_notify_init_callback(&cli.notify, clock_handler);
248250
err = onoff_request(hf_mgr, &cli);
251+
#elif IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF2)
252+
sys_notify_init_callback(&cli.notify, clock_handler);
253+
err = nrf_clock_control_request(clk_dev, NULL, &cli);
254+
#endif /* IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) */
249255
__ASSERT_NO_MSG(err >= 0);
250-
#else
251-
ARG_UNUSED(err);
252-
/* HFXO is running, switch NFCT to active state immediately. */
253-
clock_handler(NULL, 0);
254-
#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */
255-
256256
break;
257-
258257
case NRFX_NFCT_EVT_FIELD_LOST:
259258
LOG_DBG("Field lost");
260259

261-
#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX)
260+
#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF)
262261
err = onoff_cancel_or_release(hf_mgr, &cli);
262+
#elif IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF2)
263+
err = nrf_clock_control_cancel_or_release(clk_dev, NULL, &cli);
264+
#endif /* IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) */
263265
__ASSERT_NO_MSG(err >= 0);
264-
#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */
265-
266266
break;
267-
268267
default:
269268
/* No implementation required */
270269
break;

0 commit comments

Comments
 (0)