Lines Matching +full:feedback +full:- +full:pin
1 // SPDX-License-Identifier: GPL-2.0
42 switch (su->type) { in to_supply()
55 struct as3711 *as3711 = supply->as3711; in as3711_set_brightness_auto_i()
56 const struct as3711_bl_pdata *pdata = supply->pdata; in as3711_set_brightness_auto_i()
60 if (pdata->su2_auto_curr1) in as3711_set_brightness_auto_i()
61 ret = regmap_write(as3711->regmap, AS3711_CURR1_VALUE, in as3711_set_brightness_auto_i()
63 if (!ret && pdata->su2_auto_curr2) in as3711_set_brightness_auto_i()
64 ret = regmap_write(as3711->regmap, AS3711_CURR2_VALUE, in as3711_set_brightness_auto_i()
66 if (!ret && pdata->su2_auto_curr3) in as3711_set_brightness_auto_i()
67 ret = regmap_write(as3711->regmap, AS3711_CURR3_VALUE, in as3711_set_brightness_auto_i()
78 return -EINVAL; in as3711_set_brightness_v()
80 return regmap_update_bits(as3711->regmap, reg, 0xf0, in as3711_set_brightness_v()
86 struct as3711 *as3711 = supply->as3711; in as3711_bl_su2_reset()
87 int ret = regmap_update_bits(as3711->regmap, AS3711_STEPUP_CONTROL_5, in as3711_bl_su2_reset()
88 3, supply->pdata->su2_fbprot); in as3711_bl_su2_reset()
90 ret = regmap_update_bits(as3711->regmap, in as3711_bl_su2_reset()
93 ret = regmap_update_bits(as3711->regmap, in as3711_bl_su2_reset()
106 struct as3711 *as3711 = supply->as3711; in as3711_bl_update_status()
112 if (data->type == AS3711_BL_SU1) { in as3711_bl_update_status()
116 const struct as3711_bl_pdata *pdata = supply->pdata; in as3711_bl_update_status()
118 switch (pdata->su2_feedback) { in as3711_bl_update_status()
134 ret = regmap_update_bits(as3711->regmap, in as3711_bl_update_status()
138 /* Manual one current feedback pin below */ in as3711_bl_update_status()
140 ret = regmap_write(as3711->regmap, AS3711_CURR1_VALUE, in as3711_bl_update_status()
144 ret = regmap_write(as3711->regmap, AS3711_CURR2_VALUE, in as3711_bl_update_status()
148 ret = regmap_write(as3711->regmap, AS3711_CURR3_VALUE, in as3711_bl_update_status()
152 ret = -EINVAL; in as3711_bl_update_status()
156 data->brightness = brightness; in as3711_bl_update_status()
165 return data->brightness; in as3711_bl_get_brightness()
175 struct as3711 *as3711 = supply->as3711; in as3711_bl_init_su2()
176 const struct as3711_bl_pdata *pdata = supply->pdata; in as3711_bl_init_su2()
180 dev_dbg(as3711->dev, "%s(): use %u\n", __func__, pdata->su2_feedback); in as3711_bl_init_su2()
183 ret = regmap_write(as3711->regmap, AS3711_STEPUP_CONTROL_2, 0); in as3711_bl_init_su2()
187 switch (pdata->su2_feedback) { in as3711_bl_init_su2()
189 ret = regmap_update_bits(as3711->regmap, AS3711_STEPUP_CONTROL_4, 3, 0); in as3711_bl_init_su2()
193 ret = regmap_update_bits(as3711->regmap, AS3711_STEPUP_CONTROL_4, 3, 1); in as3711_bl_init_su2()
197 ret = regmap_update_bits(as3711->regmap, AS3711_STEPUP_CONTROL_4, 3, 2); in as3711_bl_init_su2()
201 ret = regmap_update_bits(as3711->regmap, AS3711_STEPUP_CONTROL_4, 3, 3); in as3711_bl_init_su2()
204 if (pdata->su2_auto_curr1) in as3711_bl_init_su2()
206 if (pdata->su2_auto_curr2) in as3711_bl_init_su2()
208 if (pdata->su2_auto_curr3) in as3711_bl_init_su2()
213 return -EINVAL; in as3711_bl_init_su2()
217 ret = regmap_write(as3711->regmap, AS3711_CURR_CONTROL, ctl); in as3711_bl_init_su2()
228 /* max tuning I = 31uA for voltage- and 38250uA for current-feedback */ in as3711_bl_register()
231 bl = devm_backlight_device_register(&pdev->dev, in as3711_bl_register()
232 su->type == AS3711_BL_SU1 ? in as3711_bl_register()
233 "as3711-su1" : "as3711-su2", in as3711_bl_register()
234 &pdev->dev, su, in as3711_bl_register()
237 dev_err(&pdev->dev, "failed to register backlight\n"); in as3711_bl_register()
241 bl->props.brightness = props.max_brightness; in as3711_bl_register()
245 su->bl = bl; in as3711_bl_register()
256 bl = of_get_child_by_name(dev->parent->of_node, "backlight"); in as3711_backlight_parse_dt()
259 return -ENODEV; in as3711_backlight_parse_dt()
262 fb = of_parse_phandle(bl, "su1-dev", 0); in as3711_backlight_parse_dt()
266 pdata->su1_fb = true; in as3711_backlight_parse_dt()
268 ret = of_property_read_u32(bl, "su1-max-uA", &pdata->su1_max_uA); in as3711_backlight_parse_dt()
269 if (pdata->su1_max_uA <= 0) in as3711_backlight_parse_dt()
270 ret = -EINVAL; in as3711_backlight_parse_dt()
275 fb = of_parse_phandle(bl, "su2-dev", 0); in as3711_backlight_parse_dt()
281 pdata->su2_fb = true; in as3711_backlight_parse_dt()
283 ret = of_property_read_u32(bl, "su2-max-uA", &pdata->su2_max_uA); in as3711_backlight_parse_dt()
284 if (pdata->su2_max_uA <= 0) in as3711_backlight_parse_dt()
285 ret = -EINVAL; in as3711_backlight_parse_dt()
289 if (of_property_read_bool(bl, "su2-feedback-voltage")) { in as3711_backlight_parse_dt()
290 pdata->su2_feedback = AS3711_SU2_VOLTAGE; in as3711_backlight_parse_dt()
293 if (of_property_read_bool(bl, "su2-feedback-curr1")) { in as3711_backlight_parse_dt()
294 pdata->su2_feedback = AS3711_SU2_CURR1; in as3711_backlight_parse_dt()
297 if (of_property_read_bool(bl, "su2-feedback-curr2")) { in as3711_backlight_parse_dt()
298 pdata->su2_feedback = AS3711_SU2_CURR2; in as3711_backlight_parse_dt()
301 if (of_property_read_bool(bl, "su2-feedback-curr3")) { in as3711_backlight_parse_dt()
302 pdata->su2_feedback = AS3711_SU2_CURR3; in as3711_backlight_parse_dt()
305 if (of_property_read_bool(bl, "su2-feedback-curr-auto")) { in as3711_backlight_parse_dt()
306 pdata->su2_feedback = AS3711_SU2_CURR_AUTO; in as3711_backlight_parse_dt()
310 ret = -EINVAL; in as3711_backlight_parse_dt()
315 if (of_property_read_bool(bl, "su2-fbprot-lx-sd4")) { in as3711_backlight_parse_dt()
316 pdata->su2_fbprot = AS3711_SU2_LX_SD4; in as3711_backlight_parse_dt()
319 if (of_property_read_bool(bl, "su2-fbprot-gpio2")) { in as3711_backlight_parse_dt()
320 pdata->su2_fbprot = AS3711_SU2_GPIO2; in as3711_backlight_parse_dt()
323 if (of_property_read_bool(bl, "su2-fbprot-gpio3")) { in as3711_backlight_parse_dt()
324 pdata->su2_fbprot = AS3711_SU2_GPIO3; in as3711_backlight_parse_dt()
327 if (of_property_read_bool(bl, "su2-fbprot-gpio4")) { in as3711_backlight_parse_dt()
328 pdata->su2_fbprot = AS3711_SU2_GPIO4; in as3711_backlight_parse_dt()
332 ret = -EINVAL; in as3711_backlight_parse_dt()
337 if (of_property_read_bool(bl, "su2-auto-curr1")) { in as3711_backlight_parse_dt()
338 pdata->su2_auto_curr1 = true; in as3711_backlight_parse_dt()
341 if (of_property_read_bool(bl, "su2-auto-curr2")) { in as3711_backlight_parse_dt()
342 pdata->su2_auto_curr2 = true; in as3711_backlight_parse_dt()
345 if (of_property_read_bool(bl, "su2-auto-curr3")) { in as3711_backlight_parse_dt()
346 pdata->su2_auto_curr3 = true; in as3711_backlight_parse_dt()
351 * At least one su2-auto-curr* must be specified iff in as3711_backlight_parse_dt()
354 if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) { in as3711_backlight_parse_dt()
355 ret = -EINVAL; in as3711_backlight_parse_dt()
372 struct as3711_bl_pdata *pdata = dev_get_platdata(&pdev->dev); in as3711_backlight_probe()
373 struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent); in as3711_backlight_probe()
380 dev_err(&pdev->dev, "No platform data, exiting...\n"); in as3711_backlight_probe()
381 return -ENODEV; in as3711_backlight_probe()
384 if (pdev->dev.parent->of_node) { in as3711_backlight_probe()
385 ret = as3711_backlight_parse_dt(&pdev->dev); in as3711_backlight_probe()
387 return dev_err_probe(&pdev->dev, ret, "DT parsing failed\n"); in as3711_backlight_probe()
390 if (!pdata->su1_fb && !pdata->su2_fb) { in as3711_backlight_probe()
391 dev_err(&pdev->dev, "No framebuffer specified\n"); in as3711_backlight_probe()
392 return -EINVAL; in as3711_backlight_probe()
400 if (pdata->su1_fb || in as3711_backlight_probe()
401 pdata->su2_fbprot != AS3711_SU2_GPIO4 || in as3711_backlight_probe()
402 pdata->su2_feedback != AS3711_SU2_CURR_AUTO) { in as3711_backlight_probe()
403 dev_warn(&pdev->dev, in as3711_backlight_probe()
405 "Please, review the code, enable, test, and report success:-)\n"); in as3711_backlight_probe()
406 return -EINVAL; in as3711_backlight_probe()
409 supply = devm_kzalloc(&pdev->dev, sizeof(*supply), GFP_KERNEL); in as3711_backlight_probe()
411 return -ENOMEM; in as3711_backlight_probe()
413 supply->as3711 = as3711; in as3711_backlight_probe()
414 supply->pdata = pdata; in as3711_backlight_probe()
416 if (pdata->su1_fb) { in as3711_backlight_probe()
417 su = &supply->su1; in as3711_backlight_probe()
418 su->type = AS3711_BL_SU1; in as3711_backlight_probe()
420 max_brightness = min(pdata->su1_max_uA, 31); in as3711_backlight_probe()
426 if (pdata->su2_fb) { in as3711_backlight_probe()
427 su = &supply->su2; in as3711_backlight_probe()
428 su->type = AS3711_BL_SU2; in as3711_backlight_probe()
430 switch (pdata->su2_fbprot) { in as3711_backlight_probe()
437 return -EINVAL; in as3711_backlight_probe()
440 switch (pdata->su2_feedback) { in as3711_backlight_probe()
442 max_brightness = min(pdata->su2_max_uA, 31); in as3711_backlight_probe()
448 max_brightness = min(pdata->su2_max_uA / 150, 255); in as3711_backlight_probe()
451 return -EINVAL; in as3711_backlight_probe()
470 .name = "as3711-backlight",
480 MODULE_ALIAS("platform:as3711-backlight");