Skip to content

Commit

Permalink
i2c: pca954x: put the mux to disconnected state after resume
Browse files Browse the repository at this point in the history
pca954x may be power lost during suspend, so after resume we also suffer
the issue fixed by commit cd823db,

 "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>
  • Loading branch information
Jisheng Zhang authored and Wolfram Sang committed Aug 1, 2014
1 parent 52976fa commit f5e596c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/i2c/muxes/i2c-mux-pca954x.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <linux/i2c-mux.h>
#include <linux/i2c/pca954x.h>
#include <linux/module.h>
#include <linux/pm.h>
#include <linux/slab.h>

#define PCA954X_MAX_NCHANS 8
Expand Down Expand Up @@ -273,9 +274,23 @@ static int pca954x_remove(struct i2c_client *client)
return 0;
}

#ifdef CONFIG_PM_SLEEP
static int pca954x_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct pca954x *data = i2c_get_clientdata(client);

data->last_chan = 0;
return i2c_smbus_write_byte(client, 0);
}
#endif

static SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume);

static struct i2c_driver pca954x_driver = {
.driver = {
.name = "pca954x",
.pm = &pca954x_pm,
.owner = THIS_MODULE,
},
.probe = pca954x_probe,
Expand Down

0 comments on commit f5e596c

Please sign in to comment.