diff options
author | Anders Darander <anders@chargestorm.se> | 2017-04-27 08:37:33 +0200 |
---|---|---|
committer | Jacek Anaszewski <jacek.anaszewski@gmail.com> | 2017-05-14 13:01:29 +0200 |
commit | bb29b9cccd95feeb43e11e9b1c2479777082e28a (patch) | |
tree | a4d68a91a58dccdd88eae6265ff30a50671d5d12 /drivers/leds | |
parent | Linux 4.12-rc1 (diff) | |
download | linux-bb29b9cccd95feeb43e11e9b1c2479777082e28a.tar.xz linux-bb29b9cccd95feeb43e11e9b1c2479777082e28a.zip |
leds: pca963x: Add bindings to invert polarity
Add a new DT property, nxp,inverted-out, to invert the polarity
of the output.
Tested on PCA9634.
Signed-off-by: Anders Darander <anders@chargestorm.se>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-pca963x.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index ded1e4dac36a..3bf9a1271819 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -342,6 +342,12 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) if (of_property_read_u32(np, "nxp,period-scale", &chip->scaling)) chip->scaling = 1000; + /* default to non-inverted output, unless inverted is specified */ + if (of_property_read_bool(np, "nxp,inverted-out")) + pdata->dir = PCA963X_INVERTED; + else + pdata->dir = PCA963X_NORMAL; + return pdata; } @@ -452,11 +458,18 @@ static int pca963x_probe(struct i2c_client *client, i2c_smbus_write_byte_data(client, PCA963X_MODE1, BIT(4)); if (pdata) { + u8 mode2 = i2c_smbus_read_byte_data(pca963x->chip->client, + PCA963X_MODE2); /* Configure output: open-drain or totem pole (push-pull) */ if (pdata->outdrv == PCA963X_OPEN_DRAIN) - i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x01); + mode2 |= 0x01; else - i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x05); + mode2 |= 0x05; + /* Configure direction: normal or inverted */ + if (pdata->dir == PCA963X_INVERTED) + mode2 |= 0x10; + i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2, + mode2); } return 0; |