From b2d9212ea06868c000ab0ee910777c261b63c45f Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 19 Apr 2023 16:43:37 +0200 Subject: [PATCH] drivers: all: mchp_xec: remove conditional support for pinctrl The Microchip XEC platform always uses pinctrl, there's no need to keep extra macrology around pinctrl. Also updated driver's Kconfig options to `select PINCTRL`. Signed-off-by: Gerard Marull-Paretas --- drivers/eeprom/Kconfig.xec | 1 + drivers/eeprom/eeprom_mchp_xec.c | 10 --------- drivers/kscan/Kconfig.xec | 1 + drivers/kscan/kscan_mchp_xec.c | 10 --------- drivers/peci/Kconfig.xec | 1 + drivers/peci/peci_mchp_xec.c | 10 --------- drivers/ps2/Kconfig.xec | 1 + drivers/ps2/ps2_mchp_xec.c | 23 +------------------- drivers/pwm/Kconfig.xec | 2 ++ drivers/pwm/pwm_mchp_xec.c | 22 +------------------ drivers/pwm/pwm_mchp_xec_bbled.c | 6 +---- drivers/sensor/mchp_tach_xec/Kconfig | 1 + drivers/sensor/mchp_tach_xec/tach_mchp_xec.c | 21 +----------------- 13 files changed, 11 insertions(+), 98 deletions(-) diff --git a/drivers/eeprom/Kconfig.xec b/drivers/eeprom/Kconfig.xec index 953d87cdfd0..42dbb6d35b1 100644 --- a/drivers/eeprom/Kconfig.xec +++ b/drivers/eeprom/Kconfig.xec @@ -7,5 +7,6 @@ config EEPROM_XEC bool "MCHP XEC EEPROM driver" default y depends on DT_HAS_MICROCHIP_XEC_EEPROM_ENABLED + select PINCTRL help Enable support for Microchip XEC EEPROM driver. diff --git a/drivers/eeprom/eeprom_mchp_xec.c b/drivers/eeprom/eeprom_mchp_xec.c index cd03edc50ca..226f0aabd1e 100644 --- a/drivers/eeprom/eeprom_mchp_xec.c +++ b/drivers/eeprom/eeprom_mchp_xec.c @@ -11,9 +11,7 @@ #include #include -#ifdef CONFIG_PINCTRL #include -#endif #include LOG_MODULE_REGISTER(eeprom_xec, CONFIG_EEPROM_LOG_LEVEL); @@ -64,9 +62,7 @@ struct eeprom_xec_regs { struct eeprom_xec_config { struct eeprom_xec_regs * const regs; size_t size; -#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pcfg; -#endif }; struct eeprom_xec_data { @@ -307,14 +303,12 @@ static int eeprom_xec_init(const struct device *dev) k_mutex_init(&data->lock_mtx); -#ifdef CONFIG_PINCTRL int ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); if (ret != 0) { LOG_ERR("XEC EEPROM pinctrl init failed (%d)", ret); return ret; } -#endif regs->mode |= XEC_EEPROM_MODE_ACTIVATE; @@ -327,16 +321,12 @@ static const struct eeprom_driver_api eeprom_xec_api = { .size = eeprom_xec_size, }; -#ifdef CONFIG_PINCTRL PINCTRL_DT_INST_DEFINE(0); -#endif static const struct eeprom_xec_config eeprom_config = { .regs = (struct eeprom_xec_regs * const)DT_INST_REG_ADDR(0), .size = DT_INST_REG_SIZE(0), -#ifdef CONFIG_PINCTRL .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0), -#endif }; static struct eeprom_xec_data eeprom_data; diff --git a/drivers/kscan/Kconfig.xec b/drivers/kscan/Kconfig.xec index a6b9eb7ca76..10188e8c931 100644 --- a/drivers/kscan/Kconfig.xec +++ b/drivers/kscan/Kconfig.xec @@ -8,6 +8,7 @@ menuconfig KSCAN_XEC default y depends on DT_HAS_MICROCHIP_XEC_KSCAN_ENABLED select MULTITHREADING + select PINCTRL help Enable the Microchip XEC Kscan IO driver. diff --git a/drivers/kscan/kscan_mchp_xec.c b/drivers/kscan/kscan_mchp_xec.c index f5422b89668..8b9231ba2d3 100644 --- a/drivers/kscan/kscan_mchp_xec.c +++ b/drivers/kscan/kscan_mchp_xec.c @@ -14,9 +14,7 @@ #include #endif #include -#ifdef CONFIG_PINCTRL #include -#endif #include #include #include @@ -50,9 +48,7 @@ struct kscan_xec_config { uint8_t pcr_idx; uint8_t pcr_pos; uint8_t rsvd[3]; -#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pcfg; -#endif }; struct kscan_xec_data { @@ -465,14 +461,12 @@ static int kscan_xec_init(const struct device *dev) struct kscan_xec_data *const data = dev->data; struct kscan_regs *regs = cfg->regs; -#ifdef CONFIG_PINCTRL int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); if (ret != 0) { LOG_ERR("XEC KSCAN pinctrl init failed (%d)", ret); return ret; } -#endif kscan_clr_slp_en(dev); @@ -509,9 +503,7 @@ static int kscan_xec_init(const struct device *dev) static struct kscan_xec_data kbd_data; -#ifdef CONFIG_PINCTRL PINCTRL_DT_INST_DEFINE(0); -#endif static struct kscan_xec_config kscan_xec_cfg_0 = { .regs = (struct kscan_regs *)(DT_INST_REG_ADDR(0)), @@ -519,9 +511,7 @@ static struct kscan_xec_config kscan_xec_cfg_0 = { .girq_pos = (uint8_t)(DT_INST_PROP_BY_IDX(0, girqs, 1)), .pcr_idx = (uint8_t)(DT_INST_PROP_BY_IDX(0, pcrs, 0)), .pcr_pos = (uint8_t)(DT_INST_PROP_BY_IDX(0, pcrs, 1)), -#ifdef CONFIG_PINCTRL .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0), -#endif }; DEVICE_DT_INST_DEFINE(0, kscan_xec_init, diff --git a/drivers/peci/Kconfig.xec b/drivers/peci/Kconfig.xec index 21d09927833..de0ac21667b 100644 --- a/drivers/peci/Kconfig.xec +++ b/drivers/peci/Kconfig.xec @@ -7,5 +7,6 @@ config PECI_XEC bool "XEC Microchip PECI driver" default y depends on DT_HAS_MICROCHIP_XEC_PECI_ENABLED + select PINCTRL help Enable the Microchip XEC PECI IO driver. diff --git a/drivers/peci/peci_mchp_xec.c b/drivers/peci/peci_mchp_xec.c index d77cb2c5c83..e03181e0f6b 100644 --- a/drivers/peci/peci_mchp_xec.c +++ b/drivers/peci/peci_mchp_xec.c @@ -14,9 +14,7 @@ #include #endif #include -#ifdef CONFIG_PINCTRL #include -#endif #include #include #include @@ -52,9 +50,7 @@ struct peci_xec_config { uint8_t girq_pos; uint8_t pcr_idx; uint8_t pcr_pos; -#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pcfg; -#endif }; enum peci_pm_policy_state_flag { @@ -525,14 +521,12 @@ static int peci_xec_init(const struct device *dev) struct peci_regs * const regs = cfg->regs; struct ecs_regs * const ecs_regs = (struct ecs_regs *)(DT_REG_ADDR(DT_NODELABEL(ecs))); -#ifdef CONFIG_PINCTRL int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); if (ret != 0) { LOG_ERR("XEC PECI pinctrl init failed (%d)", ret); return ret; } -#endif #ifdef CONFIG_PECI_INTERRUPT_DRIVEN k_sem_init(&data->tx_lock, 0, 1); @@ -568,9 +562,7 @@ static int peci_xec_init(const struct device *dev) static struct peci_xec_data peci_data; -#ifdef CONFIG_PINCTRL PINCTRL_DT_INST_DEFINE(0); -#endif static const struct peci_xec_config peci_xec_config = { .regs = (struct peci_regs * const)(DT_INST_REG_ADDR(0)), @@ -579,9 +571,7 @@ static const struct peci_xec_config peci_xec_config = { .girq_pos = DT_INST_PROP_BY_IDX(0, girqs, 1), .pcr_idx = DT_INST_PROP_BY_IDX(0, pcrs, 0), .pcr_pos = DT_INST_PROP_BY_IDX(0, pcrs, 1), -#ifdef CONFIG_PINCTRL .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0), -#endif }; PM_DEVICE_DT_INST_DEFINE(0, peci_xec_pm_action); diff --git a/drivers/ps2/Kconfig.xec b/drivers/ps2/Kconfig.xec index 89a23b97da4..86643b11e84 100644 --- a/drivers/ps2/Kconfig.xec +++ b/drivers/ps2/Kconfig.xec @@ -6,6 +6,7 @@ config PS2_XEC bool "XEC Microchip PS2 driver" depends on SOC_FAMILY_MEC && ESPI_PERIPHERAL_8042_KBC + select PINCTRL help Enable the Microchip XEC PS2 IO driver. The driver also depends on the KBC 8042 keyboard controller. Note, MEC15xx diff --git a/drivers/ps2/ps2_mchp_xec.c b/drivers/ps2/ps2_mchp_xec.c index 40d596d3407..dd977590c9e 100644 --- a/drivers/ps2/ps2_mchp_xec.c +++ b/drivers/ps2/ps2_mchp_xec.c @@ -15,9 +15,7 @@ #include #include #endif -#ifdef CONFIG_PINCTRL #include -#endif #include #include #include @@ -37,9 +35,7 @@ struct ps2_xec_config { uint8_t pcr_idx; uint8_t pcr_pos; void (*irq_config_func)(void); -#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pcfg; -#endif }; struct ps2_xec_data { @@ -261,14 +257,12 @@ static int ps2_xec_init(const struct device *dev) const struct ps2_xec_config * const cfg = dev->config; struct ps2_xec_data * const data = dev->data; -#ifdef CONFIG_PINCTRL int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); if (ret != 0) { LOG_ERR("XEC PS2 pinctrl init failed (%d)", ret); return ret; } -#endif ps2_xec_slp_en_clr(dev); @@ -279,8 +273,6 @@ static int ps2_xec_init(const struct device *dev) return 0; } -#ifdef CONFIG_PINCTRL -#define XEC_PS2_PINCTRL_CFG(inst) PINCTRL_DT_INST_DEFINE(inst) #define XEC_PS2_CONFIG(inst) \ static const struct ps2_xec_config ps2_xec_config_##inst = { \ .regs = (struct ps2_regs * const)(DT_INST_REG_ADDR(inst)), \ @@ -292,19 +284,6 @@ static int ps2_xec_init(const struct device *dev) .irq_config_func = ps2_xec_irq_config_func_##inst, \ .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \ } -#else -#define XEC_PS2_PINCTRL_CFG(inst) -#define XEC_PS2_CONFIG(inst) \ - static const struct ps2_xec_config ps2_xec_config_##inst = { \ - .regs = (struct ps2_regs * const)(DT_INST_REG_ADDR(inst)), \ - .isr_nvic = DT_INST_IRQN(inst), \ - .girq_id = (uint8_t)(DT_INST_PROP_BY_IDX(inst, girqs, 0)), \ - .girq_bit = (uint8_t)(DT_INST_PROP_BY_IDX(inst, girqs, 1)), \ - .pcr_idx = (uint8_t)(DT_INST_PROP_BY_IDX(inst, pcrs, 0)), \ - .pcr_pos = (uint8_t)(DT_INST_PROP_BY_IDX(inst, pcrs, 1)), \ - .irq_config_func = ps2_xec_irq_config_func_##inst, \ - } -#endif #define PS2_XEC_DEVICE(i) \ \ @@ -319,7 +298,7 @@ static int ps2_xec_init(const struct device *dev) \ static struct ps2_xec_data ps2_xec_port_data_##i; \ \ - XEC_PS2_PINCTRL_CFG(i); \ + PINCTRL_DT_INST_DEFINE(i); \ \ XEC_PS2_CONFIG(i); \ \ diff --git a/drivers/pwm/Kconfig.xec b/drivers/pwm/Kconfig.xec index 5830dc9e514..e1e479731d2 100644 --- a/drivers/pwm/Kconfig.xec +++ b/drivers/pwm/Kconfig.xec @@ -7,6 +7,7 @@ config PWM_XEC bool "Microchip XEC PWM" default y depends on DT_HAS_MICROCHIP_XEC_PWM_ENABLED + select PINCTRL help Enable driver to utilize PWM on the Microchip XEC IP block. @@ -14,6 +15,7 @@ config PWM_BBLED_XEC bool "Microchip XEC PWM-BBLED" default y depends on DT_HAS_MICROCHIP_XEC_PWMBBLED_ENABLED + select PINCTRL help Enable driver to utilize the Microchip XEC Breathing-Blinking LED as a PWM diff --git a/drivers/pwm/pwm_mchp_xec.c b/drivers/pwm/pwm_mchp_xec.c index 3bdccb6dd6d..5595c7e6f1c 100644 --- a/drivers/pwm/pwm_mchp_xec.c +++ b/drivers/pwm/pwm_mchp_xec.c @@ -17,9 +17,7 @@ #include #include #endif -#ifdef CONFIG_PINCTRL #include -#endif #include #include @@ -55,9 +53,7 @@ struct pwm_xec_config { struct pwm_regs * const regs; uint8_t pcr_idx; uint8_t pcr_pos; -#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pcfg; -#endif }; struct xec_params { @@ -379,7 +375,6 @@ static const struct pwm_driver_api pwm_xec_driver_api = { static int pwm_xec_init(const struct device *dev) { -#ifdef CONFIG_PINCTRL const struct pwm_xec_config * const cfg = dev->config; int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); @@ -387,15 +382,10 @@ static int pwm_xec_init(const struct device *dev) LOG_ERR("XEC PWM pinctrl init failed (%d)", ret); return ret; } -#else - ARG_UNUSED(dev); -#endif return 0; } -#ifdef CONFIG_PINCTRL -#define XEC_PWM_PINCTRL_DEF(inst) PINCTRL_DT_INST_DEFINE(inst) #define XEC_PWM_CONFIG(inst) \ static struct pwm_xec_config pwm_xec_config_##inst = { \ .regs = (struct pwm_regs * const)DT_INST_REG_ADDR(inst), \ @@ -404,19 +394,9 @@ static int pwm_xec_init(const struct device *dev) .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \ }; -#else -#define XEC_PWM_PINCTRL_DEF(inst) -#define XEC_PWM_CONFIG(inst) \ - static struct pwm_xec_config pwm_xec_config_##inst = { \ - .regs = (struct pwm_regs * const)DT_INST_REG_ADDR(inst), \ - .pcr_idx = (uint8_t)DT_INST_PROP_BY_IDX(inst, pcrs, 0), \ - .pcr_pos = (uint8_t)DT_INST_PROP_BY_IDX(inst, pcrs, 1), \ - }; -#endif - #define XEC_PWM_DEVICE_INIT(index) \ \ - XEC_PWM_PINCTRL_DEF(index); \ + PINCTRL_DT_INST_DEFINE(index); \ \ XEC_PWM_CONFIG(index); \ \ diff --git a/drivers/pwm/pwm_mchp_xec_bbled.c b/drivers/pwm/pwm_mchp_xec_bbled.c index 2a82df7796b..0b1083e0e31 100644 --- a/drivers/pwm/pwm_mchp_xec_bbled.c +++ b/drivers/pwm/pwm_mchp_xec_bbled.c @@ -123,9 +123,7 @@ struct pwm_bbled_xec_config { uint8_t pcr_idx; uint8_t pcr_pos; uint8_t clk_sel; -#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pcfg; -#endif }; /* Compute BBLED PWM delay factor to produce requested frequency. @@ -346,8 +344,6 @@ static int pwm_bbled_xec_init(const struct device *dev) return 0; } -#define XEC_PWM_BBLED_PINCTRL_DEF(inst) PINCTRL_DT_INST_DEFINE(inst) - #define XEC_PWM_BBLED_CLKSEL(n) \ COND_CODE_1(DT_INST_NODE_HAS_PROP(n, clock_select), \ (DT_INST_ENUM_IDX(n, clock_select)), (0)) @@ -365,7 +361,7 @@ static int pwm_bbled_xec_init(const struct device *dev) #define XEC_PWM_BBLED_DEVICE_INIT(index) \ \ - XEC_PWM_BBLED_PINCTRL_DEF(index); \ + PINCTRL_DT_INST_DEFINE(index); \ \ XEC_PWM_BBLED_CONFIG(index); \ \ diff --git a/drivers/sensor/mchp_tach_xec/Kconfig b/drivers/sensor/mchp_tach_xec/Kconfig index ef2031ed1e5..d0ce0827e40 100644 --- a/drivers/sensor/mchp_tach_xec/Kconfig +++ b/drivers/sensor/mchp_tach_xec/Kconfig @@ -8,6 +8,7 @@ config TACH_XEC default y depends on DT_HAS_MICROCHIP_XEC_TACH_ENABLED depends on SOC_FAMILY_MEC + select PINCTRL help Enable the Microchip XEC tachometer sensor. diff --git a/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c b/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c index 30de5c0740a..ae9288964bb 100644 --- a/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c +++ b/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c @@ -15,9 +15,7 @@ #include #include #endif -#ifdef CONFIG_PINCTRL #include -#endif #include #include #include @@ -31,9 +29,7 @@ struct tach_xec_config { uint8_t girq_pos; uint8_t pcr_idx; uint8_t pcr_pos; -#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pcfg; -#endif }; struct tach_xec_data { @@ -126,14 +122,12 @@ static int tach_xec_init(const struct device *dev) const struct tach_xec_config * const cfg = dev->config; struct tach_regs * const tach = cfg->regs; -#ifdef CONFIG_PINCTRL int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); if (ret != 0) { LOG_ERR("XEC TACH pinctrl init failed (%d)", ret); return ret; } -#endif tach_xec_sleep_clr(dev); @@ -150,8 +144,6 @@ static const struct sensor_driver_api tach_xec_driver_api = { .channel_get = tach_xec_channel_get, }; -#ifdef CONFIG_PINCTRL -#define XEC_TACH_PINCTRL_DEF(inst) PINCTRL_DT_INST_DEFINE(inst) #define XEC_TACH_CONFIG(inst) \ static const struct tach_xec_config tach_xec_config_##inst = { \ .regs = (struct tach_regs * const)DT_INST_REG_ADDR(inst), \ @@ -161,22 +153,11 @@ static const struct sensor_driver_api tach_xec_driver_api = { .pcr_pos = DT_INST_PROP_BY_IDX(inst, pcrs, 1), \ .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \ } -#else -#define XEC_TACH_PINCTRL_DEF(inst) -#define XEC_TACH_CONFIG(inst) \ - static const struct tach_xec_config tach_xec_config_##inst = { \ - .regs = (struct tach_regs * const)DT_INST_REG_ADDR(inst), \ - .girq = DT_INST_PROP_BY_IDX(inst, girqs, 0), \ - .girq_pos = DT_INST_PROP_BY_IDX(inst, girqs, 1), \ - .pcr_idx = DT_INST_PROP_BY_IDX(inst, pcrs, 0), \ - .pcr_pos = DT_INST_PROP_BY_IDX(inst, pcrs, 1), \ - } -#endif #define TACH_XEC_DEVICE(id) \ static struct tach_xec_data tach_xec_data_##id; \ \ - XEC_TACH_PINCTRL_DEF(id); \ + PINCTRL_DT_INST_DEFINE(id); \ \ XEC_TACH_CONFIG(id); \ \