leds-lp5521.c (e3a700d8aae190e09fb06abe0ddd2e172a682508) | leds-lp5521.c (ffbdccdbbaee814963a09d25b1cc598cfe131366) |
---|---|
1/* 2 * LP5521 LED chip driver. 3 * 4 * Copyright (C) 2010 Nokia Corporation 5 * 6 * Contact: Samu Onkalo <samu.p.onkalo@nokia.com> 7 * 8 * This program is free software; you can redistribute it and/or --- 224 unchanged lines hidden (view full) --- 233 234static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr) 235{ 236 return lp5521_write(chip->client, 237 LP5521_REG_LED_CURRENT_BASE + chip->leds[led].chan_nr, 238 curr); 239} 240 | 1/* 2 * LP5521 LED chip driver. 3 * 4 * Copyright (C) 2010 Nokia Corporation 5 * 6 * Contact: Samu Onkalo <samu.p.onkalo@nokia.com> 7 * 8 * This program is free software; you can redistribute it and/or --- 224 unchanged lines hidden (view full) --- 233 234static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr) 235{ 236 return lp5521_write(chip->client, 237 LP5521_REG_LED_CURRENT_BASE + chip->leds[led].chan_nr, 238 curr); 239} 240 |
241static int lp5521_configure(struct i2c_client *client) | 241static int lp5521_post_init_device(struct lp55xx_chip *chip) |
242{ | 242{ |
243 struct lp5521_chip *chip = i2c_get_clientdata(client); | |
244 int ret; | 243 int ret; |
245 u8 cfg; | |
246 u8 val; 247 248 /* 249 * Make sure that the chip is reset by reading back the r channel 250 * current reg. This is dummy read is required on some platforms - 251 * otherwise further access to the R G B channels in the 252 * LP5521_REG_ENABLE register will not have any effect - strange! 253 */ | 244 u8 val; 245 246 /* 247 * Make sure that the chip is reset by reading back the r channel 248 * current reg. This is dummy read is required on some platforms - 249 * otherwise further access to the R G B channels in the 250 * LP5521_REG_ENABLE register will not have any effect - strange! 251 */ |
254 ret = lp5521_read(client, LP5521_REG_R_CURRENT, &val); | 252 ret = lp55xx_read(chip, LP5521_REG_R_CURRENT, &val); |
255 if (ret) { | 253 if (ret) { |
256 dev_err(&client->dev, "error in resetting chip\n"); | 254 dev_err(&chip->cl->dev, "error in resetting chip\n"); |
257 return ret; 258 } 259 if (val != LP5521_REG_R_CURR_DEFAULT) { | 255 return ret; 256 } 257 if (val != LP5521_REG_R_CURR_DEFAULT) { |
260 dev_err(&client->dev, | 258 dev_err(&chip->cl->dev, |
261 "unexpected data in register (expected 0x%x got 0x%x)\n", 262 LP5521_REG_R_CURR_DEFAULT, val); 263 ret = -EINVAL; 264 return ret; 265 } 266 usleep_range(10000, 20000); 267 268 /* Set all PWMs to direct control mode */ | 259 "unexpected data in register (expected 0x%x got 0x%x)\n", 260 LP5521_REG_R_CURR_DEFAULT, val); 261 ret = -EINVAL; 262 return ret; 263 } 264 usleep_range(10000, 20000); 265 266 /* Set all PWMs to direct control mode */ |
269 ret = lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); | 267 ret = lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); |
270 | 268 |
271 cfg = chip->pdata->update_config ? | 269 val = chip->pdata->update_config ? |
272 : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); | 270 : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); |
273 ret = lp5521_write(client, LP5521_REG_CONFIG, cfg); | 271 ret = lp55xx_write(chip, LP5521_REG_CONFIG, val); |
274 if (ret) 275 return ret; 276 277 /* Initialize all channels PWM to zero -> leds off */ | 272 if (ret) 273 return ret; 274 275 /* Initialize all channels PWM to zero -> leds off */ |
278 lp5521_write(client, LP5521_REG_R_PWM, 0); 279 lp5521_write(client, LP5521_REG_G_PWM, 0); 280 lp5521_write(client, LP5521_REG_B_PWM, 0); | 276 lp55xx_write(chip, LP5521_REG_R_PWM, 0); 277 lp55xx_write(chip, LP5521_REG_G_PWM, 0); 278 lp55xx_write(chip, LP5521_REG_B_PWM, 0); |
281 282 /* Set engines are set to run state when OP_MODE enables engines */ | 279 280 /* Set engines are set to run state when OP_MODE enables engines */ |
283 ret = lp5521_write(client, LP5521_REG_ENABLE, 284 LP5521_ENABLE_RUN_PROGRAM); | 281 ret = lp55xx_write(chip, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM); |
285 if (ret) 286 return ret; 287 288 lp5521_wait_enable_done(); 289 290 return 0; 291} 292 --- 398 unchanged lines hidden (view full) --- 691 sysfs_remove_group(&chip->leds[i].cdev.dev->kobj, 692 &lp5521_led_attribute_group); 693} 694 695static void lp5521_deinit_device(struct lp5521_chip *chip); 696static int lp5521_init_device(struct lp5521_chip *chip) 697{ 698 struct i2c_client *client = chip->client; | 282 if (ret) 283 return ret; 284 285 lp5521_wait_enable_done(); 286 287 return 0; 288} 289 --- 398 unchanged lines hidden (view full) --- 688 sysfs_remove_group(&chip->leds[i].cdev.dev->kobj, 689 &lp5521_led_attribute_group); 690} 691 692static void lp5521_deinit_device(struct lp5521_chip *chip); 693static int lp5521_init_device(struct lp5521_chip *chip) 694{ 695 struct i2c_client *client = chip->client; |
696 struct lp55xx_chip *temp; |
|
699 int ret; 700 | 697 int ret; 698 |
701 ret = lp5521_configure(client); | 699 ret = lp5521_post_init_device(temp); |
702 if (ret < 0) { 703 dev_err(&client->dev, "error configuring chip\n"); 704 goto err_config; 705 } 706 707 return 0; 708 709err_config: --- 113 unchanged lines hidden (view full) --- 823 .reset = { 824 .addr = LP5521_REG_RESET, 825 .val = LP5521_RESET, 826 }, 827 .enable = { 828 .addr = LP5521_REG_ENABLE, 829 .val = LP5521_ENABLE_DEFAULT, 830 }, | 700 if (ret < 0) { 701 dev_err(&client->dev, "error configuring chip\n"); 702 goto err_config; 703 } 704 705 return 0; 706 707err_config: --- 113 unchanged lines hidden (view full) --- 821 .reset = { 822 .addr = LP5521_REG_RESET, 823 .val = LP5521_RESET, 824 }, 825 .enable = { 826 .addr = LP5521_REG_ENABLE, 827 .val = LP5521_ENABLE_DEFAULT, 828 }, |
829 .post_init_device = lp5521_post_init_device, |
|
831}; 832 833static int lp5521_probe(struct i2c_client *client, 834 const struct i2c_device_id *id) 835{ 836 struct lp5521_chip *old_chip = NULL; 837 int ret; 838 struct lp55xx_chip *chip; --- 81 unchanged lines hidden --- | 830}; 831 832static int lp5521_probe(struct i2c_client *client, 833 const struct i2c_device_id *id) 834{ 835 struct lp5521_chip *old_chip = NULL; 836 int ret; 837 struct lp55xx_chip *chip; --- 81 unchanged lines hidden --- |