diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 13:08:49 +0400 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-07 03:59:27 +0400 |
commit | 48068d5de16c23c256c085b2cd3ff03bec393900 (patch) | |
tree | 08307d1f09040ef20677b15db0a21113a3ba7842 /drivers/leds/leds-lp55xx-common.c | |
parent | a85908dd7799e4fa242812ce27a8f774c721d1fb (diff) | |
download | linux-48068d5de16c23c256c085b2cd3ff03bec393900.tar.xz |
leds-lp55xx: use lp55xx common init function - reset
LP5521/5523 reset device functions are moved to lp55xx common driver.
Value of register address and value are chip dependent.
Those are configured in each driver.
In init function, reset command is executed.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp55xx-common.c')
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 05a854c0d9b2..bbf2bbf03807 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -20,6 +20,16 @@ #include "leds-lp55xx-common.h" +static void lp55xx_reset_device(struct lp55xx_chip *chip) +{ + struct lp55xx_device_config *cfg = chip->cfg; + u8 addr = cfg->reset.addr; + u8 val = cfg->reset.val; + + /* no error checking here because no ACK from the device after reset */ + lp55xx_write(chip, addr, val); +} + int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val) { return i2c_smbus_write_byte_data(chip->cl, reg, val); @@ -58,14 +68,16 @@ EXPORT_SYMBOL_GPL(lp55xx_update_bits); int lp55xx_init_device(struct lp55xx_chip *chip) { struct lp55xx_platform_data *pdata; + struct lp55xx_device_config *cfg; struct device *dev = &chip->cl->dev; int ret = 0; WARN_ON(!chip); pdata = chip->pdata; + cfg = chip->cfg; - if (!pdata) + if (!pdata || !cfg) return -EINVAL; if (pdata->setup_resources) { @@ -83,6 +95,14 @@ int lp55xx_init_device(struct lp55xx_chip *chip) usleep_range(1000, 2000); /* 500us abs min. */ } + lp55xx_reset_device(chip); + + /* + * Exact value is not available. 10 - 20ms + * appears to be enough for reset. + */ + usleep_range(10000, 20000); + err: return ret; } |