@@ -118,6 +118,7 @@ struct pca954x {
118118 raw_spinlock_t lock ;
119119 struct regulator * supply ;
120120
121+ struct gpio_desc * reset_gpio ;
121122 struct reset_control * reset_cont ;
122123};
123124
@@ -315,25 +316,6 @@ static u8 pca954x_regval(struct pca954x *data, u8 chan)
315316 return 1 << chan ;
316317}
317318
318- static void pca954x_reset_assert (struct pca954x * data )
319- {
320- if (data -> reset_cont )
321- reset_control_assert (data -> reset_cont );
322- }
323-
324- static void pca954x_reset_deassert (struct pca954x * data )
325- {
326- if (data -> reset_cont )
327- reset_control_deassert (data -> reset_cont );
328- }
329-
330- static void pca954x_reset_mux (struct pca954x * data )
331- {
332- pca954x_reset_assert (data );
333- udelay (1 );
334- pca954x_reset_deassert (data );
335- }
336-
337319static int pca954x_select_chan (struct i2c_mux_core * muxc , u32 chan )
338320{
339321 struct pca954x * data = i2c_mux_priv (muxc );
@@ -347,8 +329,6 @@ static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan)
347329 ret = pca954x_reg_write (muxc -> parent , client , regval );
348330 data -> last_chan = ret < 0 ? 0 : regval ;
349331 }
350- if (ret == - ETIMEDOUT && data -> reset_cont )
351- pca954x_reset_mux (data );
352332
353333 return ret ;
354334}
@@ -358,7 +338,6 @@ static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan)
358338 struct pca954x * data = i2c_mux_priv (muxc );
359339 struct i2c_client * client = data -> client ;
360340 s32 idle_state ;
361- int ret = 0 ;
362341
363342 idle_state = READ_ONCE (data -> idle_state );
364343 if (idle_state >= 0 )
@@ -368,10 +347,8 @@ static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan)
368347 if (idle_state == MUX_IDLE_DISCONNECT ) {
369348 /* Deselect active channel */
370349 data -> last_chan = 0 ;
371- ret = pca954x_reg_write (muxc -> parent , client ,
372- data -> last_chan );
373- if (ret == - ETIMEDOUT && data -> reset_cont )
374- pca954x_reset_mux (data );
350+ return pca954x_reg_write (muxc -> parent , client ,
351+ data -> last_chan );
375352 }
376353
377354 /* otherwise leave as-is */
@@ -550,10 +527,29 @@ static int pca954x_get_reset(struct device *dev, struct pca954x *data)
550527 if (IS_ERR (data -> reset_cont ))
551528 return dev_err_probe (dev , PTR_ERR (data -> reset_cont ),
552529 "Failed to get reset\n" );
530+ else if (data -> reset_cont )
531+ return 0 ;
532+
533+ /*
534+ * fallback to legacy reset-gpios
535+ */
536+ data -> reset_gpio = devm_gpiod_get_optional (dev , "reset" , GPIOD_OUT_HIGH );
537+ if (IS_ERR (data -> reset_gpio )) {
538+ return dev_err_probe (dev , PTR_ERR (data -> reset_gpio ),
539+ "Failed to get reset gpio" );
540+ }
553541
554542 return 0 ;
555543}
556544
545+ static void pca954x_reset_deassert (struct pca954x * data )
546+ {
547+ if (data -> reset_cont )
548+ reset_control_deassert (data -> reset_cont );
549+ else
550+ gpiod_set_value_cansleep (data -> reset_gpio , 0 );
551+ }
552+
557553/*
558554 * I2C init/probing/exit functions
559555 */
@@ -593,7 +589,7 @@ static int pca954x_probe(struct i2c_client *client)
593589 if (ret )
594590 goto fail_cleanup ;
595591
596- if (data -> reset_cont ) {
592+ if (data -> reset_cont || data -> reset_gpio ) {
597593 udelay (1 );
598594 pca954x_reset_deassert (data );
599595 /* Give the chip some time to recover. */
0 commit comments