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 <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
989d103d53
commit
b2d9212ea0
|
@ -7,5 +7,6 @@ config EEPROM_XEC
|
||||||
bool "MCHP XEC EEPROM driver"
|
bool "MCHP XEC EEPROM driver"
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_XEC_EEPROM_ENABLED
|
depends on DT_HAS_MICROCHIP_XEC_EEPROM_ENABLED
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable support for Microchip XEC EEPROM driver.
|
Enable support for Microchip XEC EEPROM driver.
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
LOG_MODULE_REGISTER(eeprom_xec, CONFIG_EEPROM_LOG_LEVEL);
|
LOG_MODULE_REGISTER(eeprom_xec, CONFIG_EEPROM_LOG_LEVEL);
|
||||||
|
@ -64,9 +62,7 @@ struct eeprom_xec_regs {
|
||||||
struct eeprom_xec_config {
|
struct eeprom_xec_config {
|
||||||
struct eeprom_xec_regs * const regs;
|
struct eeprom_xec_regs * const regs;
|
||||||
size_t size;
|
size_t size;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct eeprom_xec_data {
|
struct eeprom_xec_data {
|
||||||
|
@ -307,14 +303,12 @@ static int eeprom_xec_init(const struct device *dev)
|
||||||
|
|
||||||
k_mutex_init(&data->lock_mtx);
|
k_mutex_init(&data->lock_mtx);
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
int ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
int ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG_ERR("XEC EEPROM pinctrl init failed (%d)", ret);
|
LOG_ERR("XEC EEPROM pinctrl init failed (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
regs->mode |= XEC_EEPROM_MODE_ACTIVATE;
|
regs->mode |= XEC_EEPROM_MODE_ACTIVATE;
|
||||||
|
|
||||||
|
@ -327,16 +321,12 @@ static const struct eeprom_driver_api eeprom_xec_api = {
|
||||||
.size = eeprom_xec_size,
|
.size = eeprom_xec_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
PINCTRL_DT_INST_DEFINE(0);
|
PINCTRL_DT_INST_DEFINE(0);
|
||||||
#endif
|
|
||||||
|
|
||||||
static const struct eeprom_xec_config eeprom_config = {
|
static const struct eeprom_xec_config eeprom_config = {
|
||||||
.regs = (struct eeprom_xec_regs * const)DT_INST_REG_ADDR(0),
|
.regs = (struct eeprom_xec_regs * const)DT_INST_REG_ADDR(0),
|
||||||
.size = DT_INST_REG_SIZE(0),
|
.size = DT_INST_REG_SIZE(0),
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct eeprom_xec_data eeprom_data;
|
static struct eeprom_xec_data eeprom_data;
|
||||||
|
|
|
@ -8,6 +8,7 @@ menuconfig KSCAN_XEC
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_XEC_KSCAN_ENABLED
|
depends on DT_HAS_MICROCHIP_XEC_KSCAN_ENABLED
|
||||||
select MULTITHREADING
|
select MULTITHREADING
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the Microchip XEC Kscan IO driver.
|
Enable the Microchip XEC Kscan IO driver.
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
||||||
#endif
|
#endif
|
||||||
#include <zephyr/drivers/kscan.h>
|
#include <zephyr/drivers/kscan.h>
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <zephyr/sys/atomic.h>
|
#include <zephyr/sys/atomic.h>
|
||||||
|
@ -50,9 +48,7 @@ struct kscan_xec_config {
|
||||||
uint8_t pcr_idx;
|
uint8_t pcr_idx;
|
||||||
uint8_t pcr_pos;
|
uint8_t pcr_pos;
|
||||||
uint8_t rsvd[3];
|
uint8_t rsvd[3];
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kscan_xec_data {
|
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_xec_data *const data = dev->data;
|
||||||
struct kscan_regs *regs = cfg->regs;
|
struct kscan_regs *regs = cfg->regs;
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG_ERR("XEC KSCAN pinctrl init failed (%d)", ret);
|
LOG_ERR("XEC KSCAN pinctrl init failed (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
kscan_clr_slp_en(dev);
|
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;
|
static struct kscan_xec_data kbd_data;
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
PINCTRL_DT_INST_DEFINE(0);
|
PINCTRL_DT_INST_DEFINE(0);
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct kscan_xec_config kscan_xec_cfg_0 = {
|
static struct kscan_xec_config kscan_xec_cfg_0 = {
|
||||||
.regs = (struct kscan_regs *)(DT_INST_REG_ADDR(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)),
|
.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_idx = (uint8_t)(DT_INST_PROP_BY_IDX(0, pcrs, 0)),
|
||||||
.pcr_pos = (uint8_t)(DT_INST_PROP_BY_IDX(0, pcrs, 1)),
|
.pcr_pos = (uint8_t)(DT_INST_PROP_BY_IDX(0, pcrs, 1)),
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEVICE_DT_INST_DEFINE(0, kscan_xec_init,
|
DEVICE_DT_INST_DEFINE(0, kscan_xec_init,
|
||||||
|
|
|
@ -7,5 +7,6 @@ config PECI_XEC
|
||||||
bool "XEC Microchip PECI driver"
|
bool "XEC Microchip PECI driver"
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_XEC_PECI_ENABLED
|
depends on DT_HAS_MICROCHIP_XEC_PECI_ENABLED
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the Microchip XEC PECI IO driver.
|
Enable the Microchip XEC PECI IO driver.
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
||||||
#endif
|
#endif
|
||||||
#include <zephyr/drivers/peci.h>
|
#include <zephyr/drivers/peci.h>
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
#include <zephyr/pm/device.h>
|
#include <zephyr/pm/device.h>
|
||||||
#include <zephyr/pm/policy.h>
|
#include <zephyr/pm/policy.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
@ -52,9 +50,7 @@ struct peci_xec_config {
|
||||||
uint8_t girq_pos;
|
uint8_t girq_pos;
|
||||||
uint8_t pcr_idx;
|
uint8_t pcr_idx;
|
||||||
uint8_t pcr_pos;
|
uint8_t pcr_pos;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum peci_pm_policy_state_flag {
|
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 peci_regs * const regs = cfg->regs;
|
||||||
struct ecs_regs * const ecs_regs = (struct ecs_regs *)(DT_REG_ADDR(DT_NODELABEL(ecs)));
|
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);
|
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG_ERR("XEC PECI pinctrl init failed (%d)", ret);
|
LOG_ERR("XEC PECI pinctrl init failed (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_PECI_INTERRUPT_DRIVEN
|
#ifdef CONFIG_PECI_INTERRUPT_DRIVEN
|
||||||
k_sem_init(&data->tx_lock, 0, 1);
|
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;
|
static struct peci_xec_data peci_data;
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
PINCTRL_DT_INST_DEFINE(0);
|
PINCTRL_DT_INST_DEFINE(0);
|
||||||
#endif
|
|
||||||
|
|
||||||
static const struct peci_xec_config peci_xec_config = {
|
static const struct peci_xec_config peci_xec_config = {
|
||||||
.regs = (struct peci_regs * const)(DT_INST_REG_ADDR(0)),
|
.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),
|
.girq_pos = DT_INST_PROP_BY_IDX(0, girqs, 1),
|
||||||
.pcr_idx = DT_INST_PROP_BY_IDX(0, pcrs, 0),
|
.pcr_idx = DT_INST_PROP_BY_IDX(0, pcrs, 0),
|
||||||
.pcr_pos = DT_INST_PROP_BY_IDX(0, pcrs, 1),
|
.pcr_pos = DT_INST_PROP_BY_IDX(0, pcrs, 1),
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PM_DEVICE_DT_INST_DEFINE(0, peci_xec_pm_action);
|
PM_DEVICE_DT_INST_DEFINE(0, peci_xec_pm_action);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
config PS2_XEC
|
config PS2_XEC
|
||||||
bool "XEC Microchip PS2 driver"
|
bool "XEC Microchip PS2 driver"
|
||||||
depends on SOC_FAMILY_MEC && ESPI_PERIPHERAL_8042_KBC
|
depends on SOC_FAMILY_MEC && ESPI_PERIPHERAL_8042_KBC
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the Microchip XEC PS2 IO driver. The driver also
|
Enable the Microchip XEC PS2 IO driver. The driver also
|
||||||
depends on the KBC 8042 keyboard controller. Note, MEC15xx
|
depends on the KBC 8042 keyboard controller. Note, MEC15xx
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
#include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
|
#include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
|
||||||
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
#include <zephyr/drivers/ps2.h>
|
#include <zephyr/drivers/ps2.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
|
@ -37,9 +35,7 @@ struct ps2_xec_config {
|
||||||
uint8_t pcr_idx;
|
uint8_t pcr_idx;
|
||||||
uint8_t pcr_pos;
|
uint8_t pcr_pos;
|
||||||
void (*irq_config_func)(void);
|
void (*irq_config_func)(void);
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ps2_xec_data {
|
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;
|
const struct ps2_xec_config * const cfg = dev->config;
|
||||||
struct ps2_xec_data * const data = dev->data;
|
struct ps2_xec_data * const data = dev->data;
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG_ERR("XEC PS2 pinctrl init failed (%d)", ret);
|
LOG_ERR("XEC PS2 pinctrl init failed (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ps2_xec_slp_en_clr(dev);
|
ps2_xec_slp_en_clr(dev);
|
||||||
|
|
||||||
|
@ -279,8 +273,6 @@ static int ps2_xec_init(const struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#define XEC_PS2_PINCTRL_CFG(inst) PINCTRL_DT_INST_DEFINE(inst)
|
|
||||||
#define XEC_PS2_CONFIG(inst) \
|
#define XEC_PS2_CONFIG(inst) \
|
||||||
static const struct ps2_xec_config ps2_xec_config_##inst = { \
|
static const struct ps2_xec_config ps2_xec_config_##inst = { \
|
||||||
.regs = (struct ps2_regs * const)(DT_INST_REG_ADDR(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, \
|
.irq_config_func = ps2_xec_irq_config_func_##inst, \
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(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) \
|
#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; \
|
static struct ps2_xec_data ps2_xec_port_data_##i; \
|
||||||
\
|
\
|
||||||
XEC_PS2_PINCTRL_CFG(i); \
|
PINCTRL_DT_INST_DEFINE(i); \
|
||||||
\
|
\
|
||||||
XEC_PS2_CONFIG(i); \
|
XEC_PS2_CONFIG(i); \
|
||||||
\
|
\
|
||||||
|
|
|
@ -7,6 +7,7 @@ config PWM_XEC
|
||||||
bool "Microchip XEC PWM"
|
bool "Microchip XEC PWM"
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_XEC_PWM_ENABLED
|
depends on DT_HAS_MICROCHIP_XEC_PWM_ENABLED
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable driver to utilize PWM on the Microchip XEC IP block.
|
Enable driver to utilize PWM on the Microchip XEC IP block.
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ config PWM_BBLED_XEC
|
||||||
bool "Microchip XEC PWM-BBLED"
|
bool "Microchip XEC PWM-BBLED"
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_XEC_PWMBBLED_ENABLED
|
depends on DT_HAS_MICROCHIP_XEC_PWMBBLED_ENABLED
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable driver to utilize the Microchip XEC Breathing-Blinking LED
|
Enable driver to utilize the Microchip XEC Breathing-Blinking LED
|
||||||
as a PWM
|
as a PWM
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
#include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
|
#include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
|
||||||
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
|
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
@ -55,9 +53,7 @@ struct pwm_xec_config {
|
||||||
struct pwm_regs * const regs;
|
struct pwm_regs * const regs;
|
||||||
uint8_t pcr_idx;
|
uint8_t pcr_idx;
|
||||||
uint8_t pcr_pos;
|
uint8_t pcr_pos;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xec_params {
|
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)
|
static int pwm_xec_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pwm_xec_config * const cfg = dev->config;
|
const struct pwm_xec_config * const cfg = dev->config;
|
||||||
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
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);
|
LOG_ERR("XEC PWM pinctrl init failed (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
ARG_UNUSED(dev);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#define XEC_PWM_PINCTRL_DEF(inst) PINCTRL_DT_INST_DEFINE(inst)
|
|
||||||
#define XEC_PWM_CONFIG(inst) \
|
#define XEC_PWM_CONFIG(inst) \
|
||||||
static struct pwm_xec_config pwm_xec_config_##inst = { \
|
static struct pwm_xec_config pwm_xec_config_##inst = { \
|
||||||
.regs = (struct pwm_regs * const)DT_INST_REG_ADDR(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), \
|
.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) \
|
#define XEC_PWM_DEVICE_INIT(index) \
|
||||||
\
|
\
|
||||||
XEC_PWM_PINCTRL_DEF(index); \
|
PINCTRL_DT_INST_DEFINE(index); \
|
||||||
\
|
\
|
||||||
XEC_PWM_CONFIG(index); \
|
XEC_PWM_CONFIG(index); \
|
||||||
\
|
\
|
||||||
|
|
|
@ -123,9 +123,7 @@ struct pwm_bbled_xec_config {
|
||||||
uint8_t pcr_idx;
|
uint8_t pcr_idx;
|
||||||
uint8_t pcr_pos;
|
uint8_t pcr_pos;
|
||||||
uint8_t clk_sel;
|
uint8_t clk_sel;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Compute BBLED PWM delay factor to produce requested frequency.
|
/* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define XEC_PWM_BBLED_PINCTRL_DEF(inst) PINCTRL_DT_INST_DEFINE(inst)
|
|
||||||
|
|
||||||
#define XEC_PWM_BBLED_CLKSEL(n) \
|
#define XEC_PWM_BBLED_CLKSEL(n) \
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(n, clock_select), \
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(n, clock_select), \
|
||||||
(DT_INST_ENUM_IDX(n, clock_select)), (0))
|
(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) \
|
#define XEC_PWM_BBLED_DEVICE_INIT(index) \
|
||||||
\
|
\
|
||||||
XEC_PWM_BBLED_PINCTRL_DEF(index); \
|
PINCTRL_DT_INST_DEFINE(index); \
|
||||||
\
|
\
|
||||||
XEC_PWM_BBLED_CONFIG(index); \
|
XEC_PWM_BBLED_CONFIG(index); \
|
||||||
\
|
\
|
||||||
|
|
|
@ -8,6 +8,7 @@ config TACH_XEC
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_XEC_TACH_ENABLED
|
depends on DT_HAS_MICROCHIP_XEC_TACH_ENABLED
|
||||||
depends on SOC_FAMILY_MEC
|
depends on SOC_FAMILY_MEC
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the Microchip XEC tachometer sensor.
|
Enable the Microchip XEC tachometer sensor.
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
#include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
|
#include <zephyr/drivers/clock_control/mchp_xec_clock_control.h>
|
||||||
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
#include <zephyr/drivers/sensor.h>
|
#include <zephyr/drivers/sensor.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <zephyr/sys/sys_io.h>
|
#include <zephyr/sys/sys_io.h>
|
||||||
|
@ -31,9 +29,7 @@ struct tach_xec_config {
|
||||||
uint8_t girq_pos;
|
uint8_t girq_pos;
|
||||||
uint8_t pcr_idx;
|
uint8_t pcr_idx;
|
||||||
uint8_t pcr_pos;
|
uint8_t pcr_pos;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tach_xec_data {
|
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;
|
const struct tach_xec_config * const cfg = dev->config;
|
||||||
struct tach_regs * const tach = cfg->regs;
|
struct tach_regs * const tach = cfg->regs;
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
int ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG_ERR("XEC TACH pinctrl init failed (%d)", ret);
|
LOG_ERR("XEC TACH pinctrl init failed (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
tach_xec_sleep_clr(dev);
|
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,
|
.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) \
|
#define XEC_TACH_CONFIG(inst) \
|
||||||
static const struct tach_xec_config tach_xec_config_##inst = { \
|
static const struct tach_xec_config tach_xec_config_##inst = { \
|
||||||
.regs = (struct tach_regs * const)DT_INST_REG_ADDR(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), \
|
.pcr_pos = DT_INST_PROP_BY_IDX(inst, pcrs, 1), \
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
|
.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) \
|
#define TACH_XEC_DEVICE(id) \
|
||||||
static struct tach_xec_data tach_xec_data_##id; \
|
static struct tach_xec_data tach_xec_data_##id; \
|
||||||
\
|
\
|
||||||
XEC_TACH_PINCTRL_DEF(id); \
|
PINCTRL_DT_INST_DEFINE(id); \
|
||||||
\
|
\
|
||||||
XEC_TACH_CONFIG(id); \
|
XEC_TACH_CONFIG(id); \
|
||||||
\
|
\
|
||||||
|
|
Loading…
Reference in New Issue