Lines Matching refs:led
140 static int lp8860_unlock_eeprom(struct lp8860_led *led, int lock) in lp8860_unlock_eeprom() argument
144 mutex_lock(&led->lock); in lp8860_unlock_eeprom()
147 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
151 dev_err(&led->client->dev, "EEPROM Unlock failed\n"); in lp8860_unlock_eeprom()
155 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
159 dev_err(&led->client->dev, "EEPROM Unlock failed\n"); in lp8860_unlock_eeprom()
162 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
166 dev_err(&led->client->dev, "EEPROM Unlock failed\n"); in lp8860_unlock_eeprom()
170 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
176 mutex_unlock(&led->lock); in lp8860_unlock_eeprom()
180 static int lp8860_fault_check(struct lp8860_led *led) in lp8860_fault_check() argument
185 ret = regmap_read(led->regmap, LP8860_LED_FAULT, &read_buf); in lp8860_fault_check()
191 ret = regmap_read(led->regmap, LP8860_FAULT, &read_buf); in lp8860_fault_check()
199 ret = regmap_write(led->regmap, LP8860_FAULT_CLEAR, in lp8860_fault_check()
208 struct lp8860_led *led = in lp8860_brightness_set() local
213 mutex_lock(&led->lock); in lp8860_brightness_set()
215 ret = lp8860_fault_check(led); in lp8860_brightness_set()
217 dev_err(&led->client->dev, "Cannot read/clear faults\n"); in lp8860_brightness_set()
221 ret = regmap_write(led->regmap, LP8860_DISP_CL1_BRT_MSB, in lp8860_brightness_set()
224 dev_err(&led->client->dev, "Cannot write CL1 MSB\n"); in lp8860_brightness_set()
228 ret = regmap_write(led->regmap, LP8860_DISP_CL1_BRT_LSB, in lp8860_brightness_set()
231 dev_err(&led->client->dev, "Cannot write CL1 LSB\n"); in lp8860_brightness_set()
235 mutex_unlock(&led->lock); in lp8860_brightness_set()
239 static int lp8860_init(struct lp8860_led *led) in lp8860_init() argument
244 if (led->regulator) { in lp8860_init()
245 ret = regulator_enable(led->regulator); in lp8860_init()
247 dev_err(&led->client->dev, in lp8860_init()
253 if (led->enable_gpio) in lp8860_init()
254 gpiod_direction_output(led->enable_gpio, 1); in lp8860_init()
256 ret = lp8860_fault_check(led); in lp8860_init()
260 ret = regmap_read(led->regmap, LP8860_STATUS, &read_buf); in lp8860_init()
264 ret = lp8860_unlock_eeprom(led, LP8860_UNLOCK_EEPROM); in lp8860_init()
266 dev_err(&led->client->dev, "Failed unlocking EEPROM\n"); in lp8860_init()
272 ret = regmap_write(led->eeprom_regmap, in lp8860_init()
276 dev_err(&led->client->dev, "Failed writing EEPROM\n"); in lp8860_init()
281 ret = lp8860_unlock_eeprom(led, LP8860_LOCK_EEPROM); in lp8860_init()
285 ret = regmap_write(led->regmap, in lp8860_init()
289 dev_err(&led->client->dev, "Failed programming EEPROM\n"); in lp8860_init()
297 if (led->enable_gpio) in lp8860_init()
298 gpiod_direction_output(led->enable_gpio, 0); in lp8860_init()
300 if (led->regulator) { in lp8860_init()
301 ret = regulator_disable(led->regulator); in lp8860_init()
303 dev_err(&led->client->dev, in lp8860_init()
382 struct lp8860_led *led; in lp8860_probe() local
387 led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); in lp8860_probe()
388 if (!led) in lp8860_probe()
395 led->enable_gpio = devm_gpiod_get_optional(&client->dev, in lp8860_probe()
397 if (IS_ERR(led->enable_gpio)) { in lp8860_probe()
398 ret = PTR_ERR(led->enable_gpio); in lp8860_probe()
403 led->regulator = devm_regulator_get(&client->dev, "vled"); in lp8860_probe()
404 if (IS_ERR(led->regulator)) in lp8860_probe()
405 led->regulator = NULL; in lp8860_probe()
407 led->client = client; in lp8860_probe()
408 led->led_dev.brightness_set_blocking = lp8860_brightness_set; in lp8860_probe()
410 mutex_init(&led->lock); in lp8860_probe()
412 i2c_set_clientdata(client, led); in lp8860_probe()
414 led->regmap = devm_regmap_init_i2c(client, &lp8860_regmap_config); in lp8860_probe()
415 if (IS_ERR(led->regmap)) { in lp8860_probe()
416 ret = PTR_ERR(led->regmap); in lp8860_probe()
422 led->eeprom_regmap = devm_regmap_init_i2c(client, &lp8860_eeprom_regmap_config); in lp8860_probe()
423 if (IS_ERR(led->eeprom_regmap)) { in lp8860_probe()
424 ret = PTR_ERR(led->eeprom_regmap); in lp8860_probe()
430 ret = lp8860_init(led); in lp8860_probe()
438 ret = devm_led_classdev_register_ext(&client->dev, &led->led_dev, in lp8860_probe()
450 struct lp8860_led *led = i2c_get_clientdata(client); in lp8860_remove() local
453 if (led->enable_gpio) in lp8860_remove()
454 gpiod_direction_output(led->enable_gpio, 0); in lp8860_remove()
456 if (led->regulator) { in lp8860_remove()
457 ret = regulator_disable(led->regulator); in lp8860_remove()
459 dev_err(&led->client->dev, in lp8860_remove()
463 mutex_destroy(&led->lock); in lp8860_remove()