Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: pca954x: put the mux to disconnected state after resume

pca954x may be power lost during suspend, so after resume we also suffer
the issue fixed by commit cd823db8b1161ef0d756514d280715a576d65cc3,

"pca954x power-on default is channel 0 connected. If multiple pca954x
muxes are connected to the same physical I2C bus, the parent bus will
see channel 0 devices behind both muxes by default."

What's more, when resume bootloader may also operate the mux, so the
the channel connected after that may not be the one driver thought.

We fix this problem by putting the mux to disconnected state and
clearing last_chan in the resume hook.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Jisheng Zhang and committed by
Wolfram Sang
f5e596cd 52976fa7

+15
+15
drivers/i2c/muxes/i2c-mux-pca954x.c
··· 41 41 #include <linux/i2c-mux.h> 42 42 #include <linux/i2c/pca954x.h> 43 43 #include <linux/module.h> 44 + #include <linux/pm.h> 44 45 #include <linux/slab.h> 45 46 46 47 #define PCA954X_MAX_NCHANS 8 ··· 274 273 return 0; 275 274 } 276 275 276 + #ifdef CONFIG_PM_SLEEP 277 + static int pca954x_resume(struct device *dev) 278 + { 279 + struct i2c_client *client = to_i2c_client(dev); 280 + struct pca954x *data = i2c_get_clientdata(client); 281 + 282 + data->last_chan = 0; 283 + return i2c_smbus_write_byte(client, 0); 284 + } 285 + #endif 286 + 287 + static SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume); 288 + 277 289 static struct i2c_driver pca954x_driver = { 278 290 .driver = { 279 291 .name = "pca954x", 292 + .pm = &pca954x_pm, 280 293 .owner = THIS_MODULE, 281 294 }, 282 295 .probe = pca954x_probe,