Lines Matching +full:bl +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
51 struct lm3639_platform_data *pdata = pchip->pdata; in lm3639_chip_init()
55 regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x08, in lm3639_chip_init()
56 pdata->pin_pwm); in lm3639_chip_init()
60 reg_val = (pdata->pin_pwm & 0x40) | pdata->pin_strobe | pdata->pin_tx; in lm3639_chip_init()
61 ret = regmap_update_bits(pchip->regmap, REG_IO_CTRL, 0x7C, reg_val); in lm3639_chip_init()
66 ret = regmap_write(pchip->regmap, REG_BL_CONF_4, pdata->init_brt_led); in lm3639_chip_init()
70 ret = regmap_write(pchip->regmap, REG_BL_CONF_3, pdata->init_brt_led); in lm3639_chip_init()
75 if (!pdata->init_brt_led) { in lm3639_chip_init()
76 reg_val = pdata->fled_pins; in lm3639_chip_init()
77 reg_val |= pdata->bled_pins; in lm3639_chip_init()
79 reg_val = pdata->fled_pins; in lm3639_chip_init()
80 reg_val |= pdata->bled_pins | 0x01; in lm3639_chip_init()
83 ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x79, reg_val); in lm3639_chip_init()
89 dev_err(pchip->dev, "i2c failed to access register\n"); in lm3639_chip_init()
94 static int lm3639_bled_update_status(struct backlight_device *bl) in lm3639_bled_update_status() argument
98 struct lm3639_chip_data *pchip = bl_get_data(bl); in lm3639_bled_update_status()
99 struct lm3639_platform_data *pdata = pchip->pdata; in lm3639_bled_update_status()
101 ret = regmap_read(pchip->regmap, REG_FLAG, ®_val); in lm3639_bled_update_status()
106 dev_info(pchip->dev, "last flag is 0x%x\n", reg_val); in lm3639_bled_update_status()
109 if (pdata->pin_pwm) { in lm3639_bled_update_status()
110 if (pdata->pwm_set_intensity) in lm3639_bled_update_status()
111 pdata->pwm_set_intensity(bl->props.brightness, in lm3639_bled_update_status()
112 pdata->max_brt_led); in lm3639_bled_update_status()
114 dev_err(pchip->dev, in lm3639_bled_update_status()
115 "No pwm control func. in plat-data\n"); in lm3639_bled_update_status()
116 return bl->props.brightness; in lm3639_bled_update_status()
120 ret = regmap_write(pchip->regmap, REG_BL_CONF_4, bl->props.brightness); in lm3639_bled_update_status()
123 ret = regmap_write(pchip->regmap, REG_BL_CONF_3, bl->props.brightness); in lm3639_bled_update_status()
127 if (!bl->props.brightness) in lm3639_bled_update_status()
128 ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x01, 0x00); in lm3639_bled_update_status()
130 ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x01, 0x01); in lm3639_bled_update_status()
134 return bl->props.brightness; in lm3639_bled_update_status()
136 dev_err(pchip->dev, "i2c failed to access registers\n"); in lm3639_bled_update_status()
137 return bl->props.brightness; in lm3639_bled_update_status()
140 static int lm3639_bled_get_brightness(struct backlight_device *bl) in lm3639_bled_get_brightness() argument
144 struct lm3639_chip_data *pchip = bl_get_data(bl); in lm3639_bled_get_brightness()
145 struct lm3639_platform_data *pdata = pchip->pdata; in lm3639_bled_get_brightness()
147 if (pdata->pin_pwm) { in lm3639_bled_get_brightness()
148 if (pdata->pwm_get_intensity) in lm3639_bled_get_brightness()
149 bl->props.brightness = pdata->pwm_get_intensity(); in lm3639_bled_get_brightness()
151 dev_err(pchip->dev, in lm3639_bled_get_brightness()
152 "No pwm control func. in plat-data\n"); in lm3639_bled_get_brightness()
153 return bl->props.brightness; in lm3639_bled_get_brightness()
156 ret = regmap_read(pchip->regmap, REG_BL_CONF_1, ®_val); in lm3639_bled_get_brightness()
160 ret = regmap_read(pchip->regmap, REG_BL_CONF_4, ®_val); in lm3639_bled_get_brightness()
162 ret = regmap_read(pchip->regmap, REG_BL_CONF_3, ®_val); in lm3639_bled_get_brightness()
165 bl->props.brightness = reg_val; in lm3639_bled_get_brightness()
167 return bl->props.brightness; in lm3639_bled_get_brightness()
169 dev_err(pchip->dev, "i2c failed to access register\n"); in lm3639_bled_get_brightness()
170 return bl->props.brightness; in lm3639_bled_get_brightness()
194 regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x10, in lm3639_bled_mode_store()
198 regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x10, in lm3639_bled_mode_store()
207 dev_err(pchip->dev, "%s:i2c access fail to register\n", __func__); in lm3639_bled_mode_store()
211 dev_err(pchip->dev, "%s:input conversion fail\n", __func__); in lm3639_bled_mode_store()
228 ret = regmap_read(pchip->regmap, REG_FLAG, ®_val); in lm3639_torch_brightness_set()
232 dev_info(pchip->dev, "last flag is 0x%x\n", reg_val); in lm3639_torch_brightness_set()
236 ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x00); in lm3639_torch_brightness_set()
242 ret = regmap_update_bits(pchip->regmap, in lm3639_torch_brightness_set()
243 REG_FL_CONF_1, 0x70, (brightness - 1) << 4); in lm3639_torch_brightness_set()
246 ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x02); in lm3639_torch_brightness_set()
252 dev_err(pchip->dev, "i2c failed to access register\n"); in lm3639_torch_brightness_set()
265 ret = regmap_read(pchip->regmap, REG_FLAG, ®_val); in lm3639_flash_brightness_set()
269 dev_info(pchip->dev, "last flag is 0x%x\n", reg_val); in lm3639_flash_brightness_set()
272 ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x00); in lm3639_flash_brightness_set()
280 ret = regmap_update_bits(pchip->regmap, in lm3639_flash_brightness_set()
281 REG_FL_CONF_1, 0x0F, brightness - 1); in lm3639_flash_brightness_set()
284 ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x06); in lm3639_flash_brightness_set()
290 dev_err(pchip->dev, "i2c failed to access register\n"); in lm3639_flash_brightness_set()
303 struct lm3639_platform_data *pdata = dev_get_platdata(&client->dev); in lm3639_probe()
306 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in lm3639_probe()
307 dev_err(&client->dev, "i2c functionality check fail.\n"); in lm3639_probe()
308 return -EOPNOTSUPP; in lm3639_probe()
312 dev_err(&client->dev, "Needs Platform Data.\n"); in lm3639_probe()
313 return -ENODATA; in lm3639_probe()
316 pchip = devm_kzalloc(&client->dev, in lm3639_probe()
319 return -ENOMEM; in lm3639_probe()
321 pchip->pdata = pdata; in lm3639_probe()
322 pchip->dev = &client->dev; in lm3639_probe()
324 pchip->regmap = devm_regmap_init_i2c(client, &lm3639_regmap); in lm3639_probe()
325 if (IS_ERR(pchip->regmap)) { in lm3639_probe()
326 ret = PTR_ERR(pchip->regmap); in lm3639_probe()
327 dev_err(&client->dev, "fail : allocate register map: %d\n", in lm3639_probe()
336 dev_err(&client->dev, "fail : chip init\n"); in lm3639_probe()
343 props.brightness = pdata->init_brt_led; in lm3639_probe()
344 props.max_brightness = pdata->max_brt_led; in lm3639_probe()
345 pchip->bled = in lm3639_probe()
346 devm_backlight_device_register(pchip->dev, "lm3639_bled", in lm3639_probe()
347 pchip->dev, pchip, &lm3639_bled_ops, in lm3639_probe()
349 if (IS_ERR(pchip->bled)) { in lm3639_probe()
350 dev_err(&client->dev, "fail : backlight register\n"); in lm3639_probe()
351 ret = PTR_ERR(pchip->bled); in lm3639_probe()
355 ret = device_create_file(&(pchip->bled->dev), &dev_attr_bled_mode); in lm3639_probe()
357 dev_err(&client->dev, "failed : add sysfs entries\n"); in lm3639_probe()
362 pchip->cdev_flash.name = "lm3639_flash"; in lm3639_probe()
363 pchip->cdev_flash.max_brightness = 16; in lm3639_probe()
364 pchip->cdev_flash.brightness_set = lm3639_flash_brightness_set; in lm3639_probe()
366 &client->dev, &pchip->cdev_flash); in lm3639_probe()
368 dev_err(&client->dev, "fail : flash register\n"); in lm3639_probe()
373 pchip->cdev_torch.name = "lm3639_torch"; in lm3639_probe()
374 pchip->cdev_torch.max_brightness = 8; in lm3639_probe()
375 pchip->cdev_torch.brightness_set = lm3639_torch_brightness_set; in lm3639_probe()
377 &client->dev, &pchip->cdev_torch); in lm3639_probe()
379 dev_err(&client->dev, "fail : torch register\n"); in lm3639_probe()
386 led_classdev_unregister(&pchip->cdev_flash); in lm3639_probe()
388 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); in lm3639_probe()
397 regmap_write(pchip->regmap, REG_ENABLE, 0x00); in lm3639_remove()
399 led_classdev_unregister(&pchip->cdev_torch); in lm3639_remove()
400 led_classdev_unregister(&pchip->cdev_flash); in lm3639_remove()
401 if (pchip->bled) in lm3639_remove()
402 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); in lm3639_remove()
413 .name = LM3639_NAME,
424 MODULE_AUTHOR("Ldd Mlp <ldd-mlp@list.ti.com>");