summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2018-09-13 14:08:13 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2019-06-21 14:30:49 +0200
commitc54f80473bcd637639287071a392ada7fdad4746 (patch)
tree63bc06d11eee8b91b5d868ad5f37de664c11e934 /drivers
parent3cbe22dabe851d61e7f2071c6329ab6c2da1f960 (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)
Diffstat (limited to 'drivers')
-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;