drivers: all: rv32m1: remove conditional support for pinctrl
The rvm32m1 platform always uses pinctrl, there's no need to keep extra macrology around pinctrl. Also updated driver's Kconfig to `select PINCTRL`. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
c4c5f57d59
commit
c66f594c41
8 changed files with 13 additions and 68 deletions
|
@ -172,6 +172,7 @@ config I2C_RV32M1_LPI2C
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_OPENISA_RV32M1_LPI2C_ENABLED
|
depends on DT_HAS_OPENISA_RV32M1_LPI2C_ENABLED
|
||||||
depends on CLOCK_CONTROL
|
depends on CLOCK_CONTROL
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the RV32M1 LPI2C driver.
|
Enable the RV32M1 LPI2C driver.
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
#include <zephyr/irq.h>
|
#include <zephyr/irq.h>
|
||||||
#include <fsl_lpi2c.h>
|
#include <fsl_lpi2c.h>
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(rv32m1_lpi2c);
|
LOG_MODULE_REGISTER(rv32m1_lpi2c);
|
||||||
|
|
||||||
|
@ -31,9 +29,7 @@ struct rv32m1_lpi2c_config {
|
||||||
uint32_t clock_ip_src;
|
uint32_t clock_ip_src;
|
||||||
uint32_t bitrate;
|
uint32_t bitrate;
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pincfg;
|
const struct pinctrl_dev_config *pincfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rv32m1_lpi2c_data {
|
struct rv32m1_lpi2c_data {
|
||||||
|
@ -248,12 +244,11 @@ static int rv32m1_lpi2c_init(const struct device *dev)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
config->irq_config_func(dev);
|
config->irq_config_func(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -264,16 +259,8 @@ static const struct i2c_driver_api rv32m1_lpi2c_driver_api = {
|
||||||
.transfer = rv32m1_lpi2c_transfer,
|
.transfer = rv32m1_lpi2c_transfer,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
|
||||||
#define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
|
||||||
#else
|
|
||||||
#define PINCTRL_DEFINE(n)
|
|
||||||
#define PINCTRL_INIT(n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RV32M1_LPI2C_DEVICE(id) \
|
#define RV32M1_LPI2C_DEVICE(id) \
|
||||||
PINCTRL_DEFINE(id) \
|
PINCTRL_DT_INST_DEFINE(n); \
|
||||||
static void rv32m1_lpi2c_irq_config_func_##id(const struct device *dev); \
|
static void rv32m1_lpi2c_irq_config_func_##id(const struct device *dev); \
|
||||||
static const struct rv32m1_lpi2c_config rv32m1_lpi2c_##id##_config = { \
|
static const struct rv32m1_lpi2c_config rv32m1_lpi2c_##id##_config = { \
|
||||||
.base = \
|
.base = \
|
||||||
|
@ -285,7 +272,7 @@ static const struct i2c_driver_api rv32m1_lpi2c_driver_api = {
|
||||||
.clock_ip_src = kCLOCK_IpSrcFircAsync, \
|
.clock_ip_src = kCLOCK_IpSrcFircAsync, \
|
||||||
.bitrate = DT_INST_PROP(id, clock_frequency), \
|
.bitrate = DT_INST_PROP(id, clock_frequency), \
|
||||||
.irq_config_func = rv32m1_lpi2c_irq_config_func_##id, \
|
.irq_config_func = rv32m1_lpi2c_irq_config_func_##id, \
|
||||||
PINCTRL_INIT(id) \
|
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||||
}; \
|
}; \
|
||||||
static struct rv32m1_lpi2c_data rv32m1_lpi2c_##id##_data = { \
|
static struct rv32m1_lpi2c_data rv32m1_lpi2c_##id##_data = { \
|
||||||
.transfer_sync = Z_SEM_INITIALIZER( \
|
.transfer_sync = Z_SEM_INITIALIZER( \
|
||||||
|
|
|
@ -8,5 +8,6 @@ config PWM_RV32M1_TPM
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_OPENISA_RV32M1_TPM_ENABLED
|
depends on DT_HAS_OPENISA_RV32M1_TPM_ENABLED
|
||||||
depends on CLOCK_CONTROL
|
depends on CLOCK_CONTROL
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the RV32M1 TPM PWM driver.
|
Enable the RV32M1 TPM PWM driver.
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <fsl_tpm.h>
|
#include <fsl_tpm.h>
|
||||||
#include <fsl_clock.h>
|
#include <fsl_clock.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>
|
||||||
|
|
||||||
|
@ -33,9 +31,7 @@ struct rv32m1_tpm_config {
|
||||||
tpm_clock_prescale_t prescale;
|
tpm_clock_prescale_t prescale;
|
||||||
uint8_t channel_count;
|
uint8_t channel_count;
|
||||||
tpm_pwm_mode_t mode;
|
tpm_pwm_mode_t mode;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pincfg;
|
const struct pinctrl_dev_config *pincfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rv32m1_tpm_data {
|
struct rv32m1_tpm_data {
|
||||||
|
@ -137,9 +133,7 @@ static int rv32m1_tpm_init(const struct device *dev)
|
||||||
struct rv32m1_tpm_data *data = dev->data;
|
struct rv32m1_tpm_data *data = dev->data;
|
||||||
tpm_chnl_pwm_signal_param_t *channel = data->channel;
|
tpm_chnl_pwm_signal_param_t *channel = data->channel;
|
||||||
tpm_config_t tpm_config;
|
tpm_config_t tpm_config;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
int err;
|
int err;
|
||||||
#endif
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (config->channel_count > ARRAY_SIZE(data->channel)) {
|
if (config->channel_count > ARRAY_SIZE(data->channel)) {
|
||||||
|
@ -171,12 +165,10 @@ static int rv32m1_tpm_init(const struct device *dev)
|
||||||
channel++;
|
channel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
TPM_GetDefaultConfig(&tpm_config);
|
TPM_GetDefaultConfig(&tpm_config);
|
||||||
tpm_config.prescale = config->prescale;
|
tpm_config.prescale = config->prescale;
|
||||||
|
@ -191,16 +183,8 @@ static const struct pwm_driver_api rv32m1_tpm_driver_api = {
|
||||||
.get_cycles_per_sec = rv32m1_tpm_get_cycles_per_sec,
|
.get_cycles_per_sec = rv32m1_tpm_get_cycles_per_sec,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
|
||||||
#define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
|
||||||
#else
|
|
||||||
#define PINCTRL_DEFINE(n)
|
|
||||||
#define PINCTRL_INIT(n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TPM_DEVICE(n) \
|
#define TPM_DEVICE(n) \
|
||||||
PINCTRL_DEFINE(n) \
|
PINCTRL_DT_INST_DEFINE(n); \
|
||||||
static const struct rv32m1_tpm_config rv32m1_tpm_config_##n = { \
|
static const struct rv32m1_tpm_config rv32m1_tpm_config_##n = { \
|
||||||
.base = (TPM_Type *) \
|
.base = (TPM_Type *) \
|
||||||
DT_INST_REG_ADDR(n), \
|
DT_INST_REG_ADDR(n), \
|
||||||
|
@ -212,7 +196,7 @@ static const struct pwm_driver_api rv32m1_tpm_driver_api = {
|
||||||
.channel_count = FSL_FEATURE_TPM_CHANNEL_COUNTn((TPM_Type *) \
|
.channel_count = FSL_FEATURE_TPM_CHANNEL_COUNTn((TPM_Type *) \
|
||||||
DT_INST_REG_ADDR(n)), \
|
DT_INST_REG_ADDR(n)), \
|
||||||
.mode = kTPM_EdgeAlignedPwm, \
|
.mode = kTPM_EdgeAlignedPwm, \
|
||||||
PINCTRL_INIT(n) \
|
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||||
}; \
|
}; \
|
||||||
static struct rv32m1_tpm_data rv32m1_tpm_data_##n; \
|
static struct rv32m1_tpm_data rv32m1_tpm_data_##n; \
|
||||||
DEVICE_DT_INST_DEFINE(n, &rv32m1_tpm_init, NULL, \
|
DEVICE_DT_INST_DEFINE(n, &rv32m1_tpm_init, NULL, \
|
||||||
|
|
|
@ -10,5 +10,6 @@ config UART_RV32M1_LPUART
|
||||||
depends on CLOCK_CONTROL
|
depends on CLOCK_CONTROL
|
||||||
select SERIAL_HAS_DRIVER
|
select SERIAL_HAS_DRIVER
|
||||||
select SERIAL_SUPPORT_INTERRUPT
|
select SERIAL_SUPPORT_INTERRUPT
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the RV32M1 LPUART driver.
|
Enable the RV32M1 LPUART driver.
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
#include <zephyr/irq.h>
|
#include <zephyr/irq.h>
|
||||||
#include <fsl_lpuart.h>
|
#include <fsl_lpuart.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
struct rv32m1_lpuart_config {
|
struct rv32m1_lpuart_config {
|
||||||
LPUART_Type *base;
|
LPUART_Type *base;
|
||||||
|
@ -29,9 +27,7 @@ struct rv32m1_lpuart_config {
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pincfg;
|
const struct pinctrl_dev_config *pincfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rv32m1_lpuart_data {
|
struct rv32m1_lpuart_data {
|
||||||
|
@ -247,9 +243,7 @@ static int rv32m1_lpuart_init(const struct device *dev)
|
||||||
const struct rv32m1_lpuart_config *config = dev->config;
|
const struct rv32m1_lpuart_config *config = dev->config;
|
||||||
lpuart_config_t uart_config;
|
lpuart_config_t uart_config;
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
int err;
|
int err;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* set clock source */
|
/* set clock source */
|
||||||
/* TODO: Don't change if another core has configured */
|
/* TODO: Don't change if another core has configured */
|
||||||
|
@ -275,12 +269,10 @@ static int rv32m1_lpuart_init(const struct device *dev)
|
||||||
|
|
||||||
LPUART_Init(config->base, &uart_config, clock_freq);
|
LPUART_Init(config->base, &uart_config, clock_freq);
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
config->irq_config_func(dev);
|
config->irq_config_func(dev);
|
||||||
|
@ -311,14 +303,6 @@ static const struct uart_driver_api rv32m1_lpuart_driver_api = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
|
||||||
#define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
|
||||||
#else
|
|
||||||
#define PINCTRL_DEFINE(n)
|
|
||||||
#define PINCTRL_INIT(n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RV32M1_LPUART_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
#define RV32M1_LPUART_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
||||||
static const struct rv32m1_lpuart_config rv32m1_lpuart_##n##_cfg = {\
|
static const struct rv32m1_lpuart_config rv32m1_lpuart_##n##_cfg = {\
|
||||||
.base = (LPUART_Type *)DT_INST_REG_ADDR(n), \
|
.base = (LPUART_Type *)DT_INST_REG_ADDR(n), \
|
||||||
|
@ -329,7 +313,7 @@ static const struct uart_driver_api rv32m1_lpuart_driver_api = {
|
||||||
.clock_ip_src = kCLOCK_IpSrcFircAsync, \
|
.clock_ip_src = kCLOCK_IpSrcFircAsync, \
|
||||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||||
.hw_flow_control = DT_INST_PROP(n, hw_flow_control), \
|
.hw_flow_control = DT_INST_PROP(n, hw_flow_control), \
|
||||||
PINCTRL_INIT(n) \
|
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||||
IRQ_FUNC_INIT \
|
IRQ_FUNC_INIT \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +338,7 @@ static const struct uart_driver_api rv32m1_lpuart_driver_api = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RV32M1_LPUART_INIT(n) \
|
#define RV32M1_LPUART_INIT(n) \
|
||||||
PINCTRL_DEFINE(n) \
|
PINCTRL_DT_INST_DEFINE(n); \
|
||||||
\
|
\
|
||||||
static struct rv32m1_lpuart_data rv32m1_lpuart_##n##_data; \
|
static struct rv32m1_lpuart_data rv32m1_lpuart_##n##_data; \
|
||||||
\
|
\
|
||||||
|
|
|
@ -8,5 +8,6 @@ config SPI_RV32M1_LPSPI
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_OPENISA_RV32M1_LPSPI_ENABLED
|
depends on DT_HAS_OPENISA_RV32M1_LPSPI_ENABLED
|
||||||
depends on CLOCK_CONTROL
|
depends on CLOCK_CONTROL
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the RV32M1 LPSPI driver.
|
Enable the RV32M1 LPSPI driver.
|
||||||
|
|
|
@ -12,9 +12,7 @@
|
||||||
#include <zephyr/drivers/spi.h>
|
#include <zephyr/drivers/spi.h>
|
||||||
#include <zephyr/drivers/clock_control.h>
|
#include <zephyr/drivers/clock_control.h>
|
||||||
#include <fsl_lpspi.h>
|
#include <fsl_lpspi.h>
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
|
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
|
@ -33,9 +31,7 @@ struct spi_mcux_config {
|
||||||
clock_ip_name_t clock_ip_name;
|
clock_ip_name_t clock_ip_name;
|
||||||
uint32_t clock_ip_src;
|
uint32_t clock_ip_src;
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
const struct pinctrl_dev_config *pincfg;
|
const struct pinctrl_dev_config *pincfg;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct spi_mcux_data {
|
struct spi_mcux_data {
|
||||||
|
@ -288,12 +284,10 @@ static int spi_mcux_init(const struct device *dev)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
spi_context_unlock_unconditionally(&data->ctx);
|
spi_context_unlock_unconditionally(&data->ctx);
|
||||||
|
|
||||||
|
@ -308,16 +302,8 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
||||||
.release = spi_mcux_release,
|
.release = spi_mcux_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PINCTRL
|
|
||||||
#define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
|
||||||
#define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
|
||||||
#else
|
|
||||||
#define PINCTRL_DEFINE(n)
|
|
||||||
#define PINCTRL_INIT(n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SPI_RV32M1_INIT(n) \
|
#define SPI_RV32M1_INIT(n) \
|
||||||
PINCTRL_DEFINE(n) \
|
PINCTRL_DT_INST_DEFINE(n); \
|
||||||
\
|
\
|
||||||
static void spi_mcux_config_func_##n(const struct device *dev); \
|
static void spi_mcux_config_func_##n(const struct device *dev); \
|
||||||
\
|
\
|
||||||
|
@ -329,7 +315,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
||||||
.irq_config_func = spi_mcux_config_func_##n, \
|
.irq_config_func = spi_mcux_config_func_##n, \
|
||||||
.clock_ip_name = INST_DT_CLOCK_IP_NAME(n), \
|
.clock_ip_name = INST_DT_CLOCK_IP_NAME(n), \
|
||||||
.clock_ip_src = kCLOCK_IpSrcFircAsync, \
|
.clock_ip_src = kCLOCK_IpSrcFircAsync, \
|
||||||
PINCTRL_INIT(n) \
|
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
static struct spi_mcux_data spi_mcux_data_##n = { \
|
static struct spi_mcux_data spi_mcux_data_##n = { \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue