|
7 | 7 | #include <zephyr/kernel.h>
|
8 | 8 | #include <zephyr/linker/devicetree_regions.h>
|
9 | 9 |
|
10 |
| -#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) |
| 10 | +#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) |
11 | 11 | #include <zephyr/drivers/clock_control.h>
|
12 | 12 | #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) */ |
14 | 17 |
|
15 | 18 | #include <zephyr/sys/__assert.h>
|
16 | 19 | #include <zephyr/sys/onoff.h>
|
@@ -49,12 +52,14 @@ LOG_MODULE_REGISTER(nfc_platform, CONFIG_NFC_PLATFORM_LOG_LEVEL);
|
49 | 52 | _irq_handler)
|
50 | 53 | #endif /* NFC_PLATFORM_USE_TIMER_WORKAROUND */
|
51 | 54 |
|
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) |
55 | 56 | 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) */ |
56 | 62 | static struct onoff_client cli;
|
57 |
| -#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */ |
58 | 63 |
|
59 | 64 | #define NFCT DT_NODELABEL(nfct)
|
60 | 65 | #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 *
|
109 | 114 | {
|
110 | 115 | int err;
|
111 | 116 |
|
112 |
| -#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) |
| 117 | +#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) |
113 | 118 | hf_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
|
114 | 119 | __ASSERT_NO_MSG(hf_mgr);
|
115 |
| -#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */ |
| 120 | +#endif /* IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) */ |
116 | 121 |
|
117 | 122 | IRQ_DIRECT_CONNECT(DT_IRQN(NFCT), DT_IRQ(NFCT, priority),
|
118 | 123 | nfc_isr_wrapper, 0);
|
@@ -240,31 +245,25 @@ void nfc_platform_event_handler(nrfx_nfct_evt_t const *event)
|
240 | 245 | case NRFX_NFCT_EVT_FIELD_DETECTED:
|
241 | 246 | LOG_DBG("Field detected");
|
242 | 247 |
|
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) |
247 | 249 | sys_notify_init_callback(&cli.notify, clock_handler);
|
248 | 250 | 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) */ |
249 | 255 | __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 |
| - |
256 | 256 | break;
|
257 |
| - |
258 | 257 | case NRFX_NFCT_EVT_FIELD_LOST:
|
259 | 258 | LOG_DBG("Field lost");
|
260 | 259 |
|
261 |
| -#if !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) |
| 260 | +#if IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF) |
262 | 261 | 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) */ |
263 | 265 | __ASSERT_NO_MSG(err >= 0);
|
264 |
| -#endif /* !IS_ENABLED(CONFIG_SOC_SERIES_NRF54HX) */ |
265 |
| - |
266 | 266 | break;
|
267 |
| - |
268 | 267 | default:
|
269 | 268 | /* No implementation required */
|
270 | 269 | break;
|
|
0 commit comments