1212#include <zephyr/logging/log.h>
1313#include <zephyr/irq.h>
1414#include <zephyr/drivers/i2c.h>
15+ #include <zephyr/drivers/pinctrl.h>
1516
1617#ifdef CONFIG_I2C_OMAP_BUS_RECOVERY
1718#include "i2c_bitbang.h"
@@ -104,6 +105,7 @@ struct i2c_omap_cfg {
104105 DEVICE_MMIO_NAMED_ROM (base );
105106 uint32_t irq ;
106107 uint32_t speed ;
108+ const struct pinctrl_dev_config * pcfg ;
107109};
108110
109111enum i2c_omap_speed {
@@ -680,6 +682,13 @@ static int i2c_omap_init(const struct device *dev)
680682{
681683 struct i2c_omap_data * data = DEV_DATA (dev );
682684 const struct i2c_omap_cfg * cfg = DEV_CFG (dev );
685+ int ret ;
686+
687+ ret = pinctrl_apply_state (cfg -> pcfg , PINCTRL_STATE_DEFAULT );
688+ if (ret < 0 ) {
689+ LOG_ERR ("failed to apply pinctrl" );
690+ return ret ;
691+ }
683692
684693 k_sem_init (& data -> lock , 1 , 1 );
685694 /* Set the speed for I2C */
@@ -692,17 +701,24 @@ static int i2c_omap_init(const struct device *dev)
692701}
693702
694703#define I2C_OMAP_INIT (inst ) \
704+ PINCTRL_DT_INST_DEFINE(inst); \
695705 LOG_INSTANCE_REGISTER(omap_i2c, inst, CONFIG_I2C_LOG_LEVEL); \
696706 static const struct i2c_omap_cfg i2c_omap_cfg_##inst = { \
697707 DEVICE_MMIO_NAMED_ROM_INIT(base, DT_DRV_INST(inst)), \
698708 .irq = DT_INST_IRQN(inst), \
699709 .speed = DT_INST_PROP(inst, clock_frequency), \
710+ .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
700711 }; \
701712 \
702713 static struct i2c_omap_data i2c_omap_data_##inst; \
703714 \
704- I2C_DEVICE_DT_INST_DEFINE(inst, i2c_omap_init, NULL, &i2c_omap_data_##inst, \
705- &i2c_omap_cfg_##inst, POST_KERNEL, CONFIG_I2C_INIT_PRIORITY, \
706- &i2c_omap_api);
715+ I2C_DEVICE_DT_INST_DEFINE(inst, \
716+ i2c_omap_init, \
717+ NULL, \
718+ &i2c_omap_data_##inst, \
719+ &i2c_omap_cfg_##inst, \
720+ POST_KERNEL, \
721+ CONFIG_I2C_INIT_PRIORITY, \
722+ &i2c_omap_api);
707723
708724DT_INST_FOREACH_STATUS_OKAY (I2C_OMAP_INIT )
0 commit comments