diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2013-11-28 19:51:25 -0500 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2014-01-03 11:40:27 -0500 |
commit | 12097957a9ed13135bfa4c4a9c649e5c9e5ac9ec (patch) | |
tree | 16dada09190b1d71f91dfa1af701e3eeecf8bbcf /drivers/i2c/muxes | |
parent | 4215138e08489f2c1670c9118da2e62fcab2ffc6 (diff) |
i2c: pca954x: Add reset GPIO support
If a reset GPIO support is specified, request the GPIO and get the chip
out of reset at probe time.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/muxes')
-rw-r--r-- | drivers/i2c/muxes/i2c-mux-pca954x.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 2880c38543de..e835304e7b5a 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c | |||
@@ -36,11 +36,13 @@ | |||
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include <linux/device.h> | 38 | #include <linux/device.h> |
39 | #include <linux/gpio.h> | ||
39 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
40 | #include <linux/i2c-mux.h> | 41 | #include <linux/i2c-mux.h> |
41 | #include <linux/i2c/pca954x.h> | 42 | #include <linux/i2c/pca954x.h> |
42 | #include <linux/init.h> | 43 | #include <linux/init.h> |
43 | #include <linux/module.h> | 44 | #include <linux/module.h> |
45 | #include <linux/of_gpio.h> | ||
44 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
45 | 47 | ||
46 | #define PCA954X_MAX_NCHANS 8 | 48 | #define PCA954X_MAX_NCHANS 8 |
@@ -185,6 +187,7 @@ static int pca954x_probe(struct i2c_client *client, | |||
185 | { | 187 | { |
186 | struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); | 188 | struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); |
187 | struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); | 189 | struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); |
190 | struct device_node *np = client->dev.of_node; | ||
188 | int num, force, class; | 191 | int num, force, class; |
189 | struct pca954x *data; | 192 | struct pca954x *data; |
190 | int ret; | 193 | int ret; |
@@ -198,6 +201,22 @@ static int pca954x_probe(struct i2c_client *client, | |||
198 | 201 | ||
199 | i2c_set_clientdata(client, data); | 202 | i2c_set_clientdata(client, data); |
200 | 203 | ||
204 | if (IS_ENABLED(CONFIG_OF) && np) { | ||
205 | enum of_gpio_flags flags; | ||
206 | int gpio; | ||
207 | |||
208 | /* Get the mux out of reset if a reset GPIO is specified. */ | ||
209 | gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); | ||
210 | if (gpio_is_valid(gpio)) { | ||
211 | ret = devm_gpio_request_one(&client->dev, gpio, | ||
212 | flags & OF_GPIO_ACTIVE_LOW ? | ||
213 | GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, | ||
214 | "pca954x reset"); | ||
215 | if (ret < 0) | ||
216 | return ret; | ||
217 | } | ||
218 | } | ||
219 | |||
201 | /* Write the mux register at addr to verify | 220 | /* Write the mux register at addr to verify |
202 | * that the mux is in fact present. This also | 221 | * that the mux is in fact present. This also |
203 | * initializes the mux to disconnected state. | 222 | * initializes the mux to disconnected state. |