drivers: pwm: nrf: Migrate Kconfig options to DT

1. Kconfig options CH pin removed.
2. Kconfig options CH inverted removed.
3. Modified pwm_nrfx.c driver to use DT
   defines instead of Kconfig.

Signed-off-by: Gaute Gamnes <gaute.gamnes@nordicsemi.no>
This commit is contained in:
Gaute Gamnes 2018-12-04 17:42:12 +01:00 committed by Carles Cufí
commit d6e66d0453
2 changed files with 84 additions and 252 deletions

View file

@ -13,7 +13,6 @@ menuconfig PWM_NRFX
if PWM_NRFX
if PWM_0
config PWM_0_NAME
string "PWM module 0 device name"
default "PWM_0"
@ -27,63 +26,9 @@ config PWM_0_NRF_CLOCK_PRESCALER
default 0
help
Clock = 16MHz / (2^prescaler).
config PWM_0_NRF_CH0_PIN
int "CH0 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH0 (set to -1 if not used).
config PWM_0_NRF_CH0_INVERTED
bool "CH0 inverted"
help
Inverses the polarity.
config PWM_0_NRF_CH1_PIN
int "CH1 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH1 (set to -1 if not used).
config PWM_0_NRF_CH1_INVERTED
bool "CH1 inverted"
help
Inverses the polarity.
config PWM_0_NRF_CH2_PIN
int "CH2 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH2 (set to -1 if not used).
config PWM_0_NRF_CH2_INVERTED
bool "CH2 inverted"
help
Inverses the polarity.
config PWM_0_NRF_CH3_PIN
int "CH3 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH3 (set to -1 if not used).
config PWM_0_NRF_CH3_INVERTED
bool "CH3 Inverted"
help
Inverses the polarity.
endif # PWM_0
if PWM_1
config PWM_1_NAME
string "PWM module 1 device name"
default "PWM_1"
@ -97,64 +42,10 @@ config PWM_1_NRF_CLOCK_PRESCALER
default 0
help
Clock = 16MHz / (2^prescaler).
config PWM_1_NRF_CH0_PIN
int "CH0 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH0
config PWM_1_NRF_CH0_INVERTED
bool "CH0 inverted"
help
Inverses the polarity.
config PWM_1_NRF_CH1_PIN
int "CH1 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH1 (set to -1 if not used).
config PWM_1_NRF_CH1_INVERTED
bool "CH1 inverted"
help
Inverses the polarity.
config PWM_1_NRF_CH2_PIN
int "CH2 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH2 (set to -1 if not used).
config PWM_1_NRF_CH2_INVERTED
bool "CH2 inverted"
help
Inverses the polarity.
config PWM_1_NRF_CH3_PIN
int "CH3 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH3 (set to -1 if not used).
config PWM_1_NRF_CH3_INVERTED
bool "CH3 Inverted"
help
Inverses the polarity.
endif # PWM_1
if PWM_2
config PWM_2_NAME
string "PWM module 2 device name"
default "PWM_2"
@ -168,63 +59,9 @@ config PWM_2_NRF_CLOCK_PRESCALER
default 0
help
Clock = 16MHz / (2^prescaler).
config PWM_2_NRF_CH0_PIN
int "CH0 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH0 (set to -1 if not used).
config PWM_2_NRF_CH0_INVERTED
bool "CH0 inverted"
help
Inverses the polarity.
config PWM_2_NRF_CH1_PIN
int "CH1 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH1 (set to -1 if not used).
config PWM_2_NRF_CH1_INVERTED
bool "CH1 inverted"
help
Inverses the polarity.
config PWM_2_NRF_CH2_PIN
int "CH2 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH2 (set to -1 if not used).
config PWM_2_NRF_CH2_INVERTED
bool "CH2 inverted"
help
Inverses the polarity.
config PWM_2_NRF_CH3_PIN
int "CH3 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH3 (set to -1 if not used).
config PWM_2_NRF_CH3_INVERTED
bool "CH3 Inverted"
help
Inverses the polarity.
endif # PWM_2
if PWM_3
config PWM_3_NAME
string "PWM module 3 device name"
default "PWM_3"
@ -238,59 +75,6 @@ config PWM_3_NRF_CLOCK_PRESCALER
default 0
help
Clock = 16MHz / (2^prescaler).
config PWM_3_NRF_CH0_PIN
int "CH0 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH0 (set to -1 if not used).
config PWM_3_NRF_CH0_INVERTED
bool "CH0 inverted"
help
Inverses the polarity.
config PWM_3_NRF_CH1_PIN
int "CH1 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH1.
config PWM_3_NRF_CH1_INVERTED
bool "CH1 inverted"
help
Inverses the polarity.
config PWM_3_NRF_CH2_PIN
int "CH2 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH2 (set to -1 if not used).
config PWM_3_NRF_CH2_INVERTED
bool "CH2 inverted"
help
Inverses the polarity.
config PWM_3_NRF_CH3_PIN
int "CH3 pin number"
range -1 47 if SOC_NRF52840_QIAA
range -1 31
default -1
help
GPIO pin number to use for CH3 (set to -1 if not used).
config PWM_3_NRF_CH3_INVERTED
bool "CH3 Inverted"
help
Inverses the polarity.
endif # PWM_3
endif # PWM_NRFX

View file

@ -197,12 +197,12 @@ static int pwm_nrfx_pm_control(struct device *dev,
#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */
#define PWM_NRFX_OUTPUT_PIN(dev_idx, ch_idx) \
(CONFIG_PWM_##dev_idx##_NRF_CH##ch_idx##_PIN | \
(CONFIG_PWM_##dev_idx##_NRF_CH##ch_idx##_INVERTED ? \
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_PIN | \
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_INVERTED ? \
NRFX_PWM_PIN_INVERTED : 0))
#define PWM_NRFX_DEFAULT_VALUE(dev_idx, ch_idx) \
(CONFIG_PWM_##dev_idx##_NRF_CH##ch_idx##_INVERTED ? \
(DT_NORDIC_NRF_PWM_PWM_##dev_idx##_CH##ch_idx##_INVERTED ? \
PWM_NRFX_CH_VALUE_INVERTED : PWM_NRFX_CH_VALUE_NORMAL)
#define PWM_NRFX_DEVICE(idx) \
@ -243,65 +243,113 @@ static int pwm_nrfx_pm_control(struct device *dev,
&pwm_nrfx_drv_api_funcs)
#ifdef CONFIG_PWM_0
#ifndef CONFIG_PWM_0_NRF_CH0_INVERTED
#define CONFIG_PWM_0_NRF_CH0_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH0_PIN
#define DT_NORDIC_NRF_PWM_PWM_0_CH0_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_0_NRF_CH1_INVERTED
#define CONFIG_PWM_0_NRF_CH1_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH0_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_0_CH0_INVERTED 0
#endif
#ifndef CONFIG_PWM_0_NRF_CH2_INVERTED
#define CONFIG_PWM_0_NRF_CH2_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH1_PIN
#define DT_NORDIC_NRF_PWM_PWM_0_CH1_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_0_NRF_CH3_INVERTED
#define CONFIG_PWM_0_NRF_CH3_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH1_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_0_CH1_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH2_PIN
#define DT_NORDIC_NRF_PWM_PWM_0_CH2_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH2_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_0_CH2_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH3_PIN
#define DT_NORDIC_NRF_PWM_PWM_0_CH3_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_0_CH3_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_0_CH3_INVERTED 0
#endif
PWM_NRFX_DEVICE(0);
#endif
#ifdef CONFIG_PWM_1
#ifndef CONFIG_PWM_1_NRF_CH0_INVERTED
#define CONFIG_PWM_1_NRF_CH0_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH0_PIN
#define DT_NORDIC_NRF_PWM_PWM_1_CH0_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_1_NRF_CH1_INVERTED
#define CONFIG_PWM_1_NRF_CH1_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH0_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_1_CH0_INVERTED 0
#endif
#ifndef CONFIG_PWM_1_NRF_CH2_INVERTED
#define CONFIG_PWM_1_NRF_CH2_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH1_PIN
#define DT_NORDIC_NRF_PWM_PWM_1_CH1_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_1_NRF_CH3_INVERTED
#define CONFIG_PWM_1_NRF_CH3_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH1_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_1_CH1_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH2_PIN
#define DT_NORDIC_NRF_PWM_PWM_1_CH2_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH2_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_1_CH2_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH3_PIN
#define DT_NORDIC_NRF_PWM_PWM_1_CH3_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_1_CH3_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_1_CH3_INVERTED 0
#endif
PWM_NRFX_DEVICE(1);
#endif
#ifdef CONFIG_PWM_2
#ifndef CONFIG_PWM_2_NRF_CH0_INVERTED
#define CONFIG_PWM_2_NRF_CH0_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH0_PIN
#define DT_NORDIC_NRF_PWM_PWM_2_CH0_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_2_NRF_CH1_INVERTED
#define CONFIG_PWM_2_NRF_CH1_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH0_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_2_CH0_INVERTED 0
#endif
#ifndef CONFIG_PWM_2_NRF_CH2_INVERTED
#define CONFIG_PWM_2_NRF_CH2_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH1_PIN
#define DT_NORDIC_NRF_PWM_PWM_2_CH1_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_2_NRF_CH3_INVERTED
#define CONFIG_PWM_2_NRF_CH3_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH1_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_2_CH1_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH2_PIN
#define DT_NORDIC_NRF_PWM_PWM_2_CH2_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH2_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_2_CH2_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH3_PIN
#define DT_NORDIC_NRF_PWM_PWM_2_CH3_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_2_CH3_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_2_CH3_INVERTED 0
#endif
PWM_NRFX_DEVICE(2);
#endif
#ifdef CONFIG_PWM_3
#ifndef CONFIG_PWM_3_NRF_CH0_INVERTED
#define CONFIG_PWM_3_NRF_CH0_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH0_PIN
#define DT_NORDIC_NRF_PWM_PWM_3_CH0_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_3_NRF_CH1_INVERTED
#define CONFIG_PWM_3_NRF_CH1_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH0_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_3_CH0_INVERTED 0
#endif
#ifndef CONFIG_PWM_3_NRF_CH2_INVERTED
#define CONFIG_PWM_3_NRF_CH2_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH1_PIN
#define DT_NORDIC_NRF_PWM_PWM_3_CH1_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef CONFIG_PWM_3_NRF_CH3_INVERTED
#define CONFIG_PWM_3_NRF_CH3_INVERTED 0
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH1_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_3_CH1_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH2_PIN
#define DT_NORDIC_NRF_PWM_PWM_3_CH2_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH2_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_3_CH2_INVERTED 0
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH3_PIN
#define DT_NORDIC_NRF_PWM_PWM_3_CH3_PIN NRFX_PWM_PIN_NOT_USED
#endif
#ifndef DT_NORDIC_NRF_PWM_PWM_3_CH3_INVERTED
#define DT_NORDIC_NRF_PWM_PWM_3_CH3_INVERTED 0
#endif
PWM_NRFX_DEVICE(3);
#endif