Skip to content

Commit 6645fa9

Browse files
drivers: pwm: nordic: move to new DT API
DT API conversion only. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 5dbfbbc commit 6645fa9

File tree

1 file changed

+13
-53
lines changed

1 file changed

+13
-53
lines changed

drivers/pwm/pwm_nrfx.c

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -363,19 +363,27 @@ static int pwm_nrfx_pm_control(struct device *dev,
363363

364364
#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */
365365

366-
#define PWM_NRFX_IS_INVERTED(dev_idx, ch_idx) \
367-
IS_ENABLED(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_INVERTED)
366+
#define PWM(dev_idx) DT_NODELABEL(pwm##dev_idx)
367+
#define PWM_PROP(dev_idx, prop) DT_PROP(PWM(dev_idx), prop)
368+
369+
#define PWM_NRFX_IS_INVERTED(dev_idx, ch_idx) \
370+
PWM_PROP(dev_idx, ch##ch_idx##_inverted)
371+
372+
#define PWM_NRFX_CH_PIN(dev_idx, ch_idx) \
373+
COND_CODE_1(DT_NODE_HAS_PROP(PWM(dev_idx), ch##ch_idx##_pin), \
374+
(PWM_PROP(dev_idx, ch##ch_idx##_pin)), \
375+
(NRFX_PWM_PIN_NOT_USED))
368376

369377
#define PWM_NRFX_OUTPUT_PIN(dev_idx, ch_idx) \
370-
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_PIN | \
378+
(PWM_NRFX_CH_PIN(dev_idx, ch_idx) | \
371379
(PWM_NRFX_IS_INVERTED(dev_idx, ch_idx) ? NRFX_PWM_PIN_INVERTED : 0))
372380

373381
#define PWM_NRFX_DEFAULT_VALUE(dev_idx, ch_idx) \
374382
(PWM_NRFX_IS_INVERTED(dev_idx, ch_idx) ? \
375383
PWM_NRFX_CH_VALUE_INVERTED : PWM_NRFX_CH_VALUE_NORMAL)
376384

377385
#define PWM_NRFX_COUNT_MODE(dev_idx) \
378-
(IS_ENABLED(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CENTER_ALIGNED) ? \
386+
(PWM_PROP(dev_idx, center_aligned) ? \
379387
NRF_PWM_MODE_UP_AND_DOWN : NRF_PWM_MODE_UP)
380388

381389
#define PWM_NRFX_DEVICE(idx) \
@@ -407,73 +415,25 @@ static int pwm_nrfx_pm_control(struct device *dev,
407415
}; \
408416
PWM_NRFX_PM_CONTROL(idx) \
409417
DEVICE_DEFINE(pwm_nrfx_##idx, \
410-
DT_NORDIC_NRF_PWM_PWM_##idx##_LABEL, \
418+
DT_LABEL(PWM(idx)), \
411419
pwm_nrfx_init, pwm_##idx##_nrfx_pm_control, \
412420
&pwm_nrfx_##idx##_data, \
413421
&pwm_nrfx_##idx##config, \
414422
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
415423
&pwm_nrfx_drv_api_funcs)
416424

417425
#ifdef CONFIG_PWM_0
418-
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH0_PIN
419-
#define DT_NORDIC_NRF_PWM_PWM_0_CH0_PIN NRFX_PWM_PIN_NOT_USED
420-
#endif
421-
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH1_PIN
422-
#define DT_NORDIC_NRF_PWM_PWM_0_CH1_PIN NRFX_PWM_PIN_NOT_USED
423-
#endif
424-
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH2_PIN
425-
#define DT_NORDIC_NRF_PWM_PWM_0_CH2_PIN NRFX_PWM_PIN_NOT_USED
426-
#endif
427-
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH3_PIN
428-
#define DT_NORDIC_NRF_PWM_PWM_0_CH3_PIN NRFX_PWM_PIN_NOT_USED
429-
#endif
430426
PWM_NRFX_DEVICE(0);
431427
#endif
432428

433429
#ifdef CONFIG_PWM_1
434-
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH0_PIN
435-
#define DT_NORDIC_NRF_PWM_PWM_1_CH0_PIN NRFX_PWM_PIN_NOT_USED
436-
#endif
437-
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH1_PIN
438-
#define DT_NORDIC_NRF_PWM_PWM_1_CH1_PIN NRFX_PWM_PIN_NOT_USED
439-
#endif
440-
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH2_PIN
441-
#define DT_NORDIC_NRF_PWM_PWM_1_CH2_PIN NRFX_PWM_PIN_NOT_USED
442-
#endif
443-
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH3_PIN
444-
#define DT_NORDIC_NRF_PWM_PWM_1_CH3_PIN NRFX_PWM_PIN_NOT_USED
445-
#endif
446430
PWM_NRFX_DEVICE(1);
447431
#endif
448432

449433
#ifdef CONFIG_PWM_2
450-
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH0_PIN
451-
#define DT_NORDIC_NRF_PWM_PWM_2_CH0_PIN NRFX_PWM_PIN_NOT_USED
452-
#endif
453-
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH1_PIN
454-
#define DT_NORDIC_NRF_PWM_PWM_2_CH1_PIN NRFX_PWM_PIN_NOT_USED
455-
#endif
456-
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH2_PIN
457-
#define DT_NORDIC_NRF_PWM_PWM_2_CH2_PIN NRFX_PWM_PIN_NOT_USED
458-
#endif
459-
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH3_PIN
460-
#define DT_NORDIC_NRF_PWM_PWM_2_CH3_PIN NRFX_PWM_PIN_NOT_USED
461-
#endif
462434
PWM_NRFX_DEVICE(2);
463435
#endif
464436

465437
#ifdef CONFIG_PWM_3
466-
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH0_PIN
467-
#define DT_NORDIC_NRF_PWM_PWM_3_CH0_PIN NRFX_PWM_PIN_NOT_USED
468-
#endif
469-
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH1_PIN
470-
#define DT_NORDIC_NRF_PWM_PWM_3_CH1_PIN NRFX_PWM_PIN_NOT_USED
471-
#endif
472-
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH2_PIN
473-
#define DT_NORDIC_NRF_PWM_PWM_3_CH2_PIN NRFX_PWM_PIN_NOT_USED
474-
#endif
475-
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH3_PIN
476-
#define DT_NORDIC_NRF_PWM_PWM_3_CH3_PIN NRFX_PWM_PIN_NOT_USED
477-
#endif
478438
PWM_NRFX_DEVICE(3);
479439
#endif

0 commit comments

Comments
 (0)