drivers: i2c: enable pinctrl for mcux lpi2c driver
Enable pinctrl for mcux lpi2c driver Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
7d2cc130f4
commit
756abe308c
2 changed files with 27 additions and 1 deletions
|
@ -12,9 +12,14 @@
|
||||||
#include <drivers/clock_control.h>
|
#include <drivers/clock_control.h>
|
||||||
#include <fsl_lpi2c.h>
|
#include <fsl_lpi2c.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
#include <drivers/pinctrl.h>
|
||||||
|
#endif /* CONFIG_PINCTRL */
|
||||||
|
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
LOG_MODULE_REGISTER(mcux_lpi2c);
|
LOG_MODULE_REGISTER(mcux_lpi2c);
|
||||||
|
|
||||||
|
|
||||||
#include "i2c-priv.h"
|
#include "i2c-priv.h"
|
||||||
/* Wait for the duration of 12 bits to detect a NAK after a bus
|
/* Wait for the duration of 12 bits to detect a NAK after a bus
|
||||||
* address scan. (10 appears sufficient, 20% safety factor.)
|
* address scan. (10 appears sufficient, 20% safety factor.)
|
||||||
|
@ -28,6 +33,9 @@ struct mcux_lpi2c_config {
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
uint32_t bitrate;
|
uint32_t bitrate;
|
||||||
uint32_t bus_idle_timeout_ns;
|
uint32_t bus_idle_timeout_ns;
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
const struct pinctrl_dev_config *pincfg;
|
||||||
|
#endif /* CONFIG_PINCTRL */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mcux_lpi2c_data {
|
struct mcux_lpi2c_data {
|
||||||
|
@ -233,6 +241,13 @@ static int mcux_lpi2c_init(const struct device *dev)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
error = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_PINCTRL */
|
||||||
|
|
||||||
config->irq_config_func(dev);
|
config->irq_config_func(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -243,7 +258,17 @@ static const struct i2c_driver_api mcux_lpi2c_driver_api = {
|
||||||
.transfer = mcux_lpi2c_transfer,
|
.transfer = mcux_lpi2c_transfer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
#define I2C_MCUX_LPI2C_PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
||||||
|
#define I2C_MCUX_LPI2C_PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
||||||
|
#else
|
||||||
|
#define I2C_MCUX_LPI2C_PINCTRL_DEFINE(n)
|
||||||
|
#define I2C_MCUX_LPI2C_PINCTRL_INIT(n)
|
||||||
|
#endif /* CONFIG_PINCTRL */
|
||||||
|
|
||||||
#define I2C_MCUX_LPI2C_INIT(n) \
|
#define I2C_MCUX_LPI2C_INIT(n) \
|
||||||
|
I2C_MCUX_LPI2C_PINCTRL_DEFINE(n) \
|
||||||
|
\
|
||||||
static void mcux_lpi2c_config_func_##n(const struct device *dev); \
|
static void mcux_lpi2c_config_func_##n(const struct device *dev); \
|
||||||
\
|
\
|
||||||
static const struct mcux_lpi2c_config mcux_lpi2c_config_##n = { \
|
static const struct mcux_lpi2c_config mcux_lpi2c_config_##n = { \
|
||||||
|
@ -253,6 +278,7 @@ static const struct i2c_driver_api mcux_lpi2c_driver_api = {
|
||||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||||
.irq_config_func = mcux_lpi2c_config_func_##n, \
|
.irq_config_func = mcux_lpi2c_config_func_##n, \
|
||||||
.bitrate = DT_INST_PROP(n, clock_frequency), \
|
.bitrate = DT_INST_PROP(n, clock_frequency), \
|
||||||
|
I2C_MCUX_LPI2C_PINCTRL_INIT(n) \
|
||||||
.bus_idle_timeout_ns = \
|
.bus_idle_timeout_ns = \
|
||||||
UTIL_AND(DT_INST_NODE_HAS_PROP(n, bus_idle_timeout),\
|
UTIL_AND(DT_INST_NODE_HAS_PROP(n, bus_idle_timeout),\
|
||||||
DT_INST_PROP(n, bus_idle_timeout)), \
|
DT_INST_PROP(n, bus_idle_timeout)), \
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: NXP i.MX LPI2C controller
|
||||||
|
|
||||||
compatible: "nxp,imx-lpi2c"
|
compatible: "nxp,imx-lpi2c"
|
||||||
|
|
||||||
include: i2c-controller.yaml
|
include: [i2c-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue