drivers: i2c: enable pinctrl for kinetis i2c

Enable pinctrl for kinetis i2c mcux driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2022-03-07 10:59:15 -06:00 committed by Carles Cufí
commit e11bed5ff2
3 changed files with 13 additions and 1 deletions

View file

@ -91,6 +91,7 @@ config I2C_SAM_TWI
config I2C_MCUX config I2C_MCUX
bool "MCUX I2C driver" bool "MCUX I2C driver"
depends on HAS_MCUX depends on HAS_MCUX
select PINCTRL
help help
Enable the mcux I2C driver. Enable the mcux I2C driver.

View file

@ -13,6 +13,8 @@
#include <fsl_clock.h> #include <fsl_clock.h>
#include <sys/util.h> #include <sys/util.h>
#include <drivers/pinctrl.h>
#include <logging/log.h> #include <logging/log.h>
LOG_MODULE_REGISTER(i2c_mcux); LOG_MODULE_REGISTER(i2c_mcux);
@ -26,6 +28,7 @@ struct i2c_mcux_config {
clock_name_t clock_source; clock_name_t clock_source;
void (*irq_config_func)(const struct device *dev); void (*irq_config_func)(const struct device *dev);
uint32_t bitrate; uint32_t bitrate;
const struct pinctrl_dev_config *pincfg;
}; };
struct i2c_mcux_data { struct i2c_mcux_data {
@ -199,6 +202,11 @@ static int i2c_mcux_init(const struct device *dev)
bitrate_cfg = i2c_map_dt_bitrate(config->bitrate); bitrate_cfg = i2c_map_dt_bitrate(config->bitrate);
error = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
if (error) {
return error;
}
error = i2c_mcux_configure(dev, I2C_MODE_MASTER | bitrate_cfg); error = i2c_mcux_configure(dev, I2C_MODE_MASTER | bitrate_cfg);
if (error) { if (error) {
return error; return error;
@ -215,6 +223,8 @@ static const struct i2c_driver_api i2c_mcux_driver_api = {
}; };
#define I2C_DEVICE_INIT_MCUX(n) \ #define I2C_DEVICE_INIT_MCUX(n) \
PINCTRL_DT_INST_DEFINE(n); \
\
static void i2c_mcux_config_func_ ## n(const struct device *dev); \ static void i2c_mcux_config_func_ ## n(const struct device *dev); \
\ \
static const struct i2c_mcux_config i2c_mcux_config_ ## n = { \ static const struct i2c_mcux_config i2c_mcux_config_ ## n = { \
@ -222,6 +232,7 @@ static const struct i2c_driver_api i2c_mcux_driver_api = {
.clock_source = I2C ## n ## _CLK_SRC, \ .clock_source = I2C ## n ## _CLK_SRC, \
.irq_config_func = i2c_mcux_config_func_ ## n, \ .irq_config_func = i2c_mcux_config_func_ ## n, \
.bitrate = DT_INST_PROP(n, clock_frequency), \ .bitrate = DT_INST_PROP(n, clock_frequency), \
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
}; \ }; \
\ \
static struct i2c_mcux_data i2c_mcux_data_ ## n; \ static struct i2c_mcux_data i2c_mcux_data_ ## n; \

View file

@ -5,7 +5,7 @@ description: Kinetis I2C node
compatible: "nxp,kinetis-i2c" compatible: "nxp,kinetis-i2c"
include: i2c-controller.yaml include: ["i2c-controller.yaml", "pinctrl-device.yaml"]
properties: properties:
reg: reg: