aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 04:08:49 -0500
committerBryan Wu <cooloney@gmail.com>2013-02-06 18:59:27 -0500
commit48068d5de16c23c256c085b2cd3ff03bec393900 (patch)
tree08307d1f09040ef20677b15db0a21113a3ba7842 /drivers/leds/leds-lp5523.c
parenta85908dd7799e4fa242812ce27a8f774c721d1fb (diff)
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-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 8e602047ce35..00547783db77 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -87,6 +87,7 @@
87#define LP5523_AUTO_CLK 0x02 87#define LP5523_AUTO_CLK 0x02
88#define LP5523_EN_LEDTEST 0x80 88#define LP5523_EN_LEDTEST 0x80
89#define LP5523_LEDTEST_DONE 0x80 89#define LP5523_LEDTEST_DONE 0x80
90#define LP5523_RESET 0xFF
90 91
91#define LP5523_DEFAULT_CURRENT 50 /* microAmps */ 92#define LP5523_DEFAULT_CURRENT 50 /* microAmps */
92#define LP5523_PROGRAM_LENGTH 32 /* in bytes */ 93#define LP5523_PROGRAM_LENGTH 32 /* in bytes */
@@ -900,25 +901,12 @@ static void lp5523_unregister_leds(struct lp5523_chip *chip)
900 } 901 }
901} 902}
902 903
903static void lp5523_reset_device(struct lp5523_chip *chip)
904{
905 struct i2c_client *client = chip->client;
906
907 lp5523_write(client, LP5523_REG_RESET, 0xff);
908}
909
910static void lp5523_deinit_device(struct lp5523_chip *chip); 904static void lp5523_deinit_device(struct lp5523_chip *chip);
911static int lp5523_init_device(struct lp5523_chip *chip) 905static int lp5523_init_device(struct lp5523_chip *chip)
912{ 906{
913 struct i2c_client *client = chip->client; 907 struct i2c_client *client = chip->client;
914 int ret; 908 int ret;
915 909
916 lp5523_reset_device(chip);
917
918 usleep_range(10000, 20000); /*
919 * Exact value is not available. 10 - 20ms
920 * appears to be enough for reset.
921 */
922 ret = lp5523_detect(client); 910 ret = lp5523_detect(client);
923 if (ret) 911 if (ret)
924 goto err; 912 goto err;
@@ -947,6 +935,14 @@ static void lp5523_deinit_device(struct lp5523_chip *chip)
947 pdata->release_resources(); 935 pdata->release_resources();
948} 936}
949 937
938/* Chip specific configurations */
939static struct lp55xx_device_config lp5523_cfg = {
940 .reset = {
941 .addr = LP5523_REG_RESET,
942 .val = LP5523_RESET,
943 },
944};
945
950static int lp5523_probe(struct i2c_client *client, 946static int lp5523_probe(struct i2c_client *client,
951 const struct i2c_device_id *id) 947 const struct i2c_device_id *id)
952{ 948{
@@ -972,6 +968,7 @@ static int lp5523_probe(struct i2c_client *client,
972 968
973 chip->cl = client; 969 chip->cl = client;
974 chip->pdata = pdata; 970 chip->pdata = pdata;
971 chip->cfg = &lp5523_cfg;
975 972
976 mutex_init(&chip->lock); 973 mutex_init(&chip->lock);
977 974