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>
This commit is contained in:
parent
4215138e08
commit
12097957a9
|
@ -13,6 +13,10 @@ Required Properties:
|
||||||
- Standard I2C mux properties. See i2c-mux.txt in this directory.
|
- Standard I2C mux properties. See i2c-mux.txt in this directory.
|
||||||
- I2C child bus nodes. See i2c-mux.txt in this directory.
|
- I2C child bus nodes. See i2c-mux.txt in this directory.
|
||||||
|
|
||||||
|
Optional Properties:
|
||||||
|
|
||||||
|
- reset-gpios: Reference to the GPIO connected to the reset input.
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/gpio.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/i2c-mux.h>
|
#include <linux/i2c-mux.h>
|
||||||
#include <linux/i2c/pca954x.h>
|
#include <linux/i2c/pca954x.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/of_gpio.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#define PCA954X_MAX_NCHANS 8
|
#define PCA954X_MAX_NCHANS 8
|
||||||
|
@ -185,6 +187,7 @@ static int pca954x_probe(struct i2c_client *client,
|
||||||
{
|
{
|
||||||
struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
|
struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
|
||||||
struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev);
|
struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev);
|
||||||
|
struct device_node *np = client->dev.of_node;
|
||||||
int num, force, class;
|
int num, force, class;
|
||||||
struct pca954x *data;
|
struct pca954x *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -198,6 +201,22 @@ static int pca954x_probe(struct i2c_client *client,
|
||||||
|
|
||||||
i2c_set_clientdata(client, data);
|
i2c_set_clientdata(client, data);
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_OF) && np) {
|
||||||
|
enum of_gpio_flags flags;
|
||||||
|
int gpio;
|
||||||
|
|
||||||
|
/* Get the mux out of reset if a reset GPIO is specified. */
|
||||||
|
gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);
|
||||||
|
if (gpio_is_valid(gpio)) {
|
||||||
|
ret = devm_gpio_request_one(&client->dev, gpio,
|
||||||
|
flags & OF_GPIO_ACTIVE_LOW ?
|
||||||
|
GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
|
||||||
|
"pca954x reset");
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Write the mux register at addr to verify
|
/* Write the mux register at addr to verify
|
||||||
* that the mux is in fact present. This also
|
* that the mux is in fact present. This also
|
||||||
* initializes the mux to disconnected state.
|
* initializes the mux to disconnected state.
|
||||||
|
|
Loading…
Reference in New Issue