summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2018-09-13 14:08:13 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2020-02-09 22:49:20 +0100
commit0e53439459b3ec8863b71bc58e0111b20f782835 (patch)
treebeb4e34102f27af7b157dd2887e92c2833809231
parent33401ceffc8ea49db1dd8e2840a5571f0771022e (diff)
gpio-fxl6408.c: add of properties to set inital direction and state
inital_io_dir: a 1 at a bit positions sets the corresponding pin as output. inital_output: a 1 sets a gpio which is set to output with inital_io_dir to 1. Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> (cherry picked from commit a7d303d7d63d444ed012200e98e6575814439101) (cherry picked from commit 990f8c1dcb28cdc8eb6551b86621e1b29067136b)
-rw-r--r--drivers/gpio/gpio-fxl6408.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
index e68c8a49f868..22d193c4d9d5 100644
--- a/drivers/gpio/gpio-fxl6408.c
+++ b/drivers/gpio/gpio-fxl6408.c
@@ -154,6 +154,7 @@ static int fxl6408_probe(struct i2c_client *client,
struct device *dev = &client->dev;
struct fxl6408_chip *chip;
struct gpio_chip *gc;
+ unsigned int val;
int ret;
u8 device_id;
@@ -182,8 +183,21 @@ static int fxl6408_probe(struct i2c_client *client,
chip->client = client;
mutex_init(&chip->i2c_lock);
- chip->reg_io_dir = i2c_smbus_read_byte_data(client, FXL6408_IO_DIR);
- chip->reg_output = i2c_smbus_read_byte_data(client, FXL6408_OUTPUT);
+
+ /* if configured, set initial output state and direction,
+ * otherwise read them from the chip */
+ if (of_property_read_u32(dev->of_node, "inital_io_dir", &val)) {
+ chip->reg_io_dir = i2c_smbus_read_byte_data(client, FXL6408_IO_DIR);
+ } else {
+ chip->reg_io_dir = val & 0xff;
+ i2c_smbus_write_byte_data(client, FXL6408_IO_DIR, chip->reg_io_dir);
+ }
+ if (of_property_read_u32(dev->of_node, "inital_output", &val)) {
+ chip->reg_output = i2c_smbus_read_byte_data(client, FXL6408_OUTPUT);
+ } else {
+ chip->reg_output = val & 0xff;
+ i2c_smbus_write_byte_data(client, FXL6408_OUTPUT, chip->reg_output);
+ }
gc = &chip->gpio_chip;
gc->direction_input = fxl6408_gpio_direction_input;