13
13
#include <zephyr/linker/devicetree_regions.h>
14
14
#include <zephyr/cache.h>
15
15
#include <zephyr/mem_mgmt/mem_attr.h>
16
- #ifdef CONFIG_CLOCK_CONTROL
17
- #include <zephyr/drivers/clock_control/nrf_clock_control.h>
18
- #endif
19
16
#ifdef CONFIG_SOC_NRF54H20_GPD
20
17
#include <nrf/gpd.h>
21
18
#endif
@@ -38,26 +35,6 @@ LOG_MODULE_REGISTER(pwm_nrfx, CONFIG_PWM_LOG_LEVEL);
38
35
#define ANOMALY_109_EGU_IRQ_CONNECT (idx )
39
36
#endif
40
37
41
- #define PWM (dev_idx ) DT_NODELABEL(pwm##dev_idx)
42
- #define PWM_PROP (dev_idx , prop ) DT_PROP(PWM(dev_idx), prop)
43
- #define PWM_HAS_PROP (idx , prop ) DT_NODE_HAS_PROP(PWM(idx), prop)
44
-
45
- #define PWM_NRFX_IS_FAST (unused , prefix , idx , _ ) \
46
- COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(PWM(idx)), \
47
- (COND_CODE_1(PWM_HAS_PROP(idx, power_domains), \
48
- (IS_EQ(DT_PHA(PWM(idx), power_domains, id), NRF_GPD_FAST_ACTIVE1)), \
49
- (0))), (0))
50
-
51
- #if NRFX_FOREACH_PRESENT (PWM , PWM_NRFX_IS_FAST , (|| ), (0 ))
52
- #if CONFIG_CLOCK_CONTROL
53
- #define PWM_NRFX_USE_CLOCK_CONTROL 1
54
- #endif
55
- #define PWM_NRFX_INIT_PRIORITY 99
56
- #else
57
- #define PWM_NRFX_INIT_PRIORITY CONFIG_PWM_INIT_PRIORITY
58
- #endif
59
-
60
-
61
38
#define PWM_NRFX_CH_POLARITY_MASK BIT(15)
62
39
#define PWM_NRFX_CH_COMPARE_MASK BIT_MASK(15)
63
40
#define PWM_NRFX_CH_VALUE (compare_value , inverted ) \
@@ -72,10 +49,6 @@ struct pwm_nrfx_config {
72
49
#ifdef CONFIG_DCACHE
73
50
uint32_t mem_attr ;
74
51
#endif
75
- #ifdef PWM_NRFX_USE_CLOCK_CONTROL
76
- const struct device * clk_dev ;
77
- struct nrf_clock_spec clk_spec ;
78
- #endif
79
52
};
80
53
81
54
struct pwm_nrfx_data {
@@ -84,9 +57,6 @@ struct pwm_nrfx_data {
84
57
uint8_t pwm_needed ;
85
58
uint8_t prescaler ;
86
59
bool stop_requested ;
87
- #ifdef PWM_NRFX_USE_CLOCK_CONTROL
88
- bool clock_requested ;
89
- #endif
90
60
};
91
61
/* Ensure the pwm_needed bit mask can accommodate all available channels. */
92
62
#if (NRF_PWM_CHANNEL_COUNT > 8 )
@@ -259,18 +229,6 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
259
229
* ensure it is stopped before starting the next playback.
260
230
*/
261
231
nrfx_pwm_stop (& config -> pwm , false);
262
- #if PWM_NRFX_USE_CLOCK_CONTROL
263
- if (data -> clock_requested ) {
264
- int ret = nrf_clock_control_release (config -> clk_dev , & config -> clk_spec );
265
-
266
- if (ret < 0 ) {
267
- LOG_ERR ("Global HSFLL release failed: %d" , ret );
268
- return ret ;
269
- }
270
-
271
- data -> clock_requested = false;
272
- }
273
- #endif
274
232
data -> stop_requested = true;
275
233
} else {
276
234
if (data -> stop_requested ) {
@@ -290,18 +248,6 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
290
248
* until another playback is requested (new values will be
291
249
* loaded then) or the PWM peripheral is stopped.
292
250
*/
293
- #if PWM_NRFX_USE_CLOCK_CONTROL
294
-
295
- int ret = nrf_clock_control_request_sync (config -> clk_dev , & config -> clk_spec ,
296
- K_FOREVER );
297
-
298
- if (ret < 0 ) {
299
- LOG_ERR ("Global HSFLL request failed: %d" , ret );
300
- return ret ;
301
- }
302
-
303
- data -> clock_requested = true;
304
- #endif
305
251
nrfx_pwm_simple_playback (& config -> pwm , & config -> seq , 1 ,
306
252
NRFX_PWM_FLAG_NO_EVT_FINISHED );
307
253
}
@@ -360,14 +306,6 @@ static void pwm_suspend(const struct device *dev)
360
306
const struct pwm_nrfx_config * config = dev -> config ;
361
307
362
308
nrfx_pwm_stop (& config -> pwm , false);
363
- #if PWM_NRFX_USE_CLOCK_CONTROL
364
-
365
- int ret = nrf_clock_control_release (config -> clk_dev , & config -> clk_spec );
366
-
367
- if (ret < 0 ) {
368
- LOG_ERR ("Global HSFLL release failed: %d" , ret );
369
- }
370
- #endif
371
309
while (!nrfx_pwm_stopped_check (& config -> pwm )) {
372
310
}
373
311
@@ -413,6 +351,9 @@ static int pwm_nrfx_init(const struct device *dev)
413
351
return pm_device_driver_init (dev , pwm_nrfx_pm_action );
414
352
}
415
353
354
+ #define PWM (dev_idx ) DT_NODELABEL(pwm##dev_idx)
355
+ #define PWM_PROP (dev_idx , prop ) DT_PROP(PWM(dev_idx), prop)
356
+ #define PWM_HAS_PROP (idx , prop ) DT_NODE_HAS_PROP(PWM(idx), prop)
416
357
#define PWM_MEM_REGION (idx ) DT_PHANDLE(PWM(idx), memory_regions)
417
358
418
359
#define PWM_MEMORY_SECTION (idx ) \
@@ -452,15 +393,6 @@ static int pwm_nrfx_init(const struct device *dev)
452
393
(16ul * 1000ul * 1000ul)), \
453
394
IF_ENABLED(CONFIG_DCACHE, \
454
395
(.mem_attr = PWM_GET_MEM_ATTR(idx),)) \
455
- IF_ENABLED(PWM_NRFX_USE_CLOCK_CONTROL, \
456
- (.clk_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(PWM(idx))), \
457
- .clk_spec = { \
458
- .frequency = \
459
- NRF_PERIPH_GET_FREQUENCY(PWM(idx)), \
460
- .accuracy = 0, \
461
- .precision = \
462
- NRF_CLOCK_CONTROL_PRECISION_DEFAULT, \
463
- },)) \
464
396
}; \
465
397
static int pwm_nrfx_init##idx(const struct device *dev) \
466
398
{ \
@@ -473,7 +405,7 @@ static int pwm_nrfx_init(const struct device *dev)
473
405
pwm_nrfx_init##idx, PM_DEVICE_DT_GET(PWM(idx)), \
474
406
&pwm_nrfx_##idx##_data, \
475
407
&pwm_nrfx_##idx##_config, \
476
- POST_KERNEL, PWM_NRFX_INIT_PRIORITY , \
408
+ POST_KERNEL, CONFIG_PWM_INIT_PRIORITY , \
477
409
&pwm_nrfx_drv_api_funcs)
478
410
479
411
#define COND_PWM_NRFX_DEVICE (unused , prefix , i , _ ) \
0 commit comments