Lines Matching +full:ovp +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-only
82 brightness_val[0] = (brightness - 1) & priv->dim2_mask; in mt6370_bl_update_status()
83 brightness_val[1] = (brightness - 1) >> priv->dim2_shift; in mt6370_bl_update_status()
85 ret = regmap_raw_write(priv->regmap, MT6370_REG_BL_DIM2, in mt6370_bl_update_status()
91 gpiod_set_value(priv->enable_gpio, !!brightness); in mt6370_bl_update_status()
94 return regmap_update_bits(priv->regmap, MT6370_REG_BL_EN, in mt6370_bl_update_status()
101 unsigned int enable; in mt6370_bl_get_brightness() local
105 ret = regmap_read(priv->regmap, MT6370_REG_BL_EN, &enable); in mt6370_bl_get_brightness()
109 if (!(enable & MT6370_BL_EN_MASK)) in mt6370_bl_get_brightness()
112 ret = regmap_raw_read(priv->regmap, MT6370_REG_BL_DIM2, in mt6370_bl_get_brightness()
117 brightness = brightness_val[1] << priv->dim2_shift; in mt6370_bl_get_brightness()
118 brightness += brightness_val[0] & priv->dim2_mask; in mt6370_bl_get_brightness()
132 struct device *dev = priv->dev; in mt6370_init_backlight_properties()
140 if (device_property_read_bool(dev, "mediatek,bled-pwm-enable")) in mt6370_init_backlight_properties()
143 if (device_property_read_bool(dev, "mediatek,bled-pwm-hys-enable")) in mt6370_init_backlight_properties()
147 "mediatek,bled-pwm-hys-input-th-steps", in mt6370_init_backlight_properties()
159 ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_PWM, in mt6370_init_backlight_properties()
165 if (device_property_read_bool(dev, "mediatek,bled-ovp-shutdown")) in mt6370_init_backlight_properties()
168 ret = device_property_read_u32(dev, "mediatek,bled-ovp-microvolt", in mt6370_init_backlight_properties()
173 ovp_uV = DIV_ROUND_UP(ovp_uV - MT6370_BL_OVP_MIN_UV, in mt6370_init_backlight_properties()
178 if (device_property_read_bool(dev, "mediatek,bled-ocp-shutdown")) in mt6370_init_backlight_properties()
181 ret = device_property_read_u32(dev, "mediatek,bled-ocp-microamp", in mt6370_init_backlight_properties()
186 ocp_uA = DIV_ROUND_UP(ocp_uA - MT6370_BL_OCP_MIN_UA, in mt6370_init_backlight_properties()
191 ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, in mt6370_init_backlight_properties()
197 ret = device_property_read_u32(dev, "max-brightness", &brightness); in mt6370_init_backlight_properties()
199 brightness = priv->def_max_brightness; in mt6370_init_backlight_properties()
201 props->max_brightness = min_t(u32, brightness, priv->def_max_brightness); in mt6370_init_backlight_properties()
203 ret = device_property_read_u32(dev, "default-brightness", &brightness); in mt6370_init_backlight_properties()
205 brightness = props->max_brightness; in mt6370_init_backlight_properties()
207 props->brightness = min_t(u32, brightness, props->max_brightness); in mt6370_init_backlight_properties()
210 if (device_property_read_bool(dev, "mediatek,bled-exponential-mode-enable")) { in mt6370_init_backlight_properties()
212 props->scale = BACKLIGHT_SCALE_NON_LINEAR; in mt6370_init_backlight_properties()
214 props->scale = BACKLIGHT_SCALE_LINEAR; in mt6370_init_backlight_properties()
216 ret = device_property_read_u8(dev, "mediatek,bled-channel-use", in mt6370_init_backlight_properties()
219 dev_err(dev, "mediatek,bled-channel-use DT property missing\n"); in mt6370_init_backlight_properties()
227 return -EINVAL; in mt6370_init_backlight_properties()
233 if (priv->enable_gpio) in mt6370_init_backlight_properties()
236 return regmap_update_bits(priv->regmap, MT6370_REG_BL_EN, mask, val); in mt6370_init_backlight_properties()
251 ret = regmap_read(priv->regmap, MT6370_REG_DEV_INFO, &dev_info); in mt6370_check_vendor_info()
255 of_vid = (uintptr_t)device_get_match_data(priv->dev); in mt6370_check_vendor_info()
259 return dev_err_probe(priv->dev, -EINVAL, in mt6370_check_vendor_info()
263 priv->dim2_mask = MT6370_BL_DIM2_6372_MASK; in mt6370_check_vendor_info()
264 priv->dim2_shift = MT6370_BL_DIM2_6372_SHIFT; in mt6370_check_vendor_info()
265 priv->def_max_brightness = MT6370_BL_MAX_6372_BRIGHTNESS; in mt6370_check_vendor_info()
267 priv->dim2_mask = MT6370_BL_DIM2_COMMON_MASK; in mt6370_check_vendor_info()
268 priv->dim2_shift = MT6370_BL_DIM2_COMMON_SHIFT; in mt6370_check_vendor_info()
269 priv->def_max_brightness = MT6370_BL_MAX_COMMON_BRIGHTNESS; in mt6370_check_vendor_info()
280 struct device *dev = &pdev->dev; in mt6370_bl_probe()
284 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mt6370_bl_probe()
286 return -ENOMEM; in mt6370_bl_probe()
288 priv->dev = dev; in mt6370_bl_probe()
290 priv->regmap = dev_get_regmap(dev->parent, NULL); in mt6370_bl_probe()
291 if (!priv->regmap) in mt6370_bl_probe()
292 return dev_err_probe(dev, -ENODEV, "Failed to get regmap\n"); in mt6370_bl_probe()
298 priv->enable_gpio = devm_gpiod_get_optional(dev, "enable", in mt6370_bl_probe()
300 if (IS_ERR(priv->enable_gpio)) in mt6370_bl_probe()
301 return dev_err_probe(dev, PTR_ERR(priv->enable_gpio), in mt6370_bl_probe()
302 "Failed to get 'enable' gpio\n"); in mt6370_bl_probe()
309 priv->bl = devm_backlight_device_register(dev, pdev->name, dev, priv, in mt6370_bl_probe()
311 if (IS_ERR(priv->bl)) in mt6370_bl_probe()
312 return dev_err_probe(dev, PTR_ERR(priv->bl), in mt6370_bl_probe()
315 backlight_update_status(priv->bl); in mt6370_bl_probe()
324 struct backlight_device *bl_dev = priv->bl; in mt6370_bl_remove()
326 bl_dev->props.brightness = 0; in mt6370_bl_remove()
327 backlight_update_status(priv->bl); in mt6370_bl_remove()
331 { .compatible = "mediatek,mt6370-backlight", .data = (void *)MT6370_VID_COMMON },
332 { .compatible = "mediatek,mt6372-backlight", .data = (void *)MT6370_VID_6372 },
339 .name = "mt6370-backlight",