diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2018-09-13 14:08:13 +0200 |
---|---|---|
committer | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2021-01-27 20:36:22 +0200 |
commit | 713c8f21703f85e777522506d0651ab72363fd3a (patch) | |
tree | bfd4534f9ecf002ba39c296d46e44b5d15a64b76 /drivers/gpio | |
parent | 9d2ec3485014c63b7dd040337031a1d419bb8198 (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)
(cherry picked from commit 96c8a4d5918709aa63e32f627bf3225a87585794)
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-fxl6408.c | 18 |
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; |