@@ -62,7 +62,6 @@ struct i2c_esp32_data {
6262
6363	struct  k_sem  fifo_sem ;
6464	struct  k_sem  transfer_sem ;
65- 	const  struct  device  * clock_dev ;
6665};
6766
6867typedef  void  (* irq_connect_cb )(void );
@@ -71,7 +70,7 @@ struct i2c_esp32_config {
7170	int  index ;
7271
7372	irq_connect_cb  connect_irq ;
74- 	const  char   * clock_name ;
73+ 	const  struct   device   * clock_dev ;
7574
7675	const  struct  {
7776		int  sda_out ;
@@ -141,7 +140,6 @@ static int i2c_esp32_configure_speed(const struct device *dev,
141140	};
142141
143142	const  struct  i2c_esp32_config  * config  =  dev -> config ;
144- 	struct  i2c_esp32_data  * data  =  dev -> data ;
145143
146144	uint32_t  sys_clk_freq  =  0 ;
147145	uint32_t  freq_hz  =  speed_to_freq_tbl [speed ];
@@ -151,7 +149,7 @@ static int i2c_esp32_configure_speed(const struct device *dev,
151149		return  - ENOTSUP ;
152150	}
153151
154- 	if  (clock_control_get_rate (data -> clock_dev ,
152+ 	if  (clock_control_get_rate (config -> clock_dev ,
155153				   config -> peripheral_id ,
156154				   & sys_clk_freq )) {
157155		return  - EINVAL ;
@@ -205,7 +203,7 @@ static int i2c_esp32_configure(const struct device *dev, uint32_t dev_config)
205203		return  ret ;
206204	}
207205
208- 	clock_control_on (data -> clock_dev , config -> peripheral_id );
206+ 	clock_control_on (config -> clock_dev , config -> peripheral_id );
209207
210208	/* MSB or LSB first is configurable for both TX and RX */ 
211209	if  (config -> mode .tx_lsb_first ) {
@@ -588,7 +586,7 @@ static void i2c_esp32_connect_irq_0(void)
588586static  const  struct  i2c_esp32_config  i2c_esp32_config_0  =  {
589587	.index  =  0 ,
590588	.connect_irq  =  i2c_esp32_connect_irq_0 ,
591- 	.clock_name  =  DT_INST_CLOCKS_LABEL ( 0 ),
589+ 	.clock_dev  =  DEVICE_DT_GET ( DT_INST_CLOCKS_CTLR ( 0 ) ),
592590	.peripheral_id  =  (clock_control_subsys_t )DT_INST_CLOCKS_CELL (0 , offset ),
593591	.sig  =  {
594592		.sda_out  =  I2CEXT0_SDA_OUT_IDX ,
@@ -632,7 +630,7 @@ static void i2c_esp32_connect_irq_1(void)
632630static  const  struct  i2c_esp32_config  i2c_esp32_config_1  =  {
633631	.index  =  1 ,
634632	.connect_irq  =  i2c_esp32_connect_irq_1 ,
635- 	.clock_name  =  DT_INST_CLOCKS_LABEL ( 1 ),
633+ 	.clock_dev  =  DEVICE_DT_GET ( DT_INST_CLOCKS_CTLR ( 1 ) ),
636634	.peripheral_id  =  (clock_control_subsys_t )DT_INST_CLOCKS_CELL (1 , offset ),
637635	.sig  =  {
638636		.sda_out  =  I2CEXT1_SDA_OUT_IDX ,
@@ -671,9 +669,6 @@ static int i2c_esp32_init(const struct device *dev)
671669	const  struct  i2c_esp32_config  * config  =  dev -> config ;
672670	struct  i2c_esp32_data  * data  =  dev -> data ;
673671	uint32_t  bitrate_cfg  =  i2c_map_dt_bitrate (config -> bitrate );
674- 	data -> clock_dev  =  device_get_binding (config -> clock_name );
675- 
676- 	__ASSERT_NO_MSG (data -> clock_dev );
677672
678673	unsigned int   key  =  irq_lock ();
679674
0 commit comments