Lines Matching +full:default +full:- +full:brightness

1 // SPDX-License-Identifier: GPL-2.0-only
3 #include <dt-bindings/leds/rt4831-backlight.h>
42 int brightness = backlight_get_brightness(bl_dev); in rt4831_bl_update_status() local
43 unsigned int enable = brightness ? RT4831_BLEN_MASK : 0; in rt4831_bl_update_status()
47 if (brightness) { in rt4831_bl_update_status()
48 v[0] = (brightness - 1) & RT4831_BLDIML_MASK; in rt4831_bl_update_status()
49 v[1] = ((brightness - 1) & RT4831_BLDIMH_MASK) >> RT4831_BLDIMH_SHIFT; in rt4831_bl_update_status()
51 ret = regmap_raw_write(priv->regmap, RT4831_REG_BLDIML, v, sizeof(v)); in rt4831_bl_update_status()
56 return regmap_update_bits(priv->regmap, RT4831_REG_ENABLE, RT4831_BLEN_MASK, enable); in rt4831_bl_update_status()
67 ret = regmap_read(priv->regmap, RT4831_REG_ENABLE, &val); in rt4831_bl_get_brightness()
74 ret = regmap_raw_read(priv->regmap, RT4831_REG_BLDIML, v, sizeof(v)); in rt4831_bl_get_brightness()
92 struct device *dev = priv->dev; in rt4831_parse_backlight_properties()
94 u32 brightness, ocp_uA; in rt4831_parse_backlight_properties() local
99 ret = device_property_read_u32(dev, "max-brightness", &brightness); in rt4831_parse_backlight_properties()
101 brightness = RT4831_BLMAX_BRIGHTNESS; in rt4831_parse_backlight_properties()
103 bl_props->max_brightness = min_t(u32, brightness, RT4831_BLMAX_BRIGHTNESS); in rt4831_parse_backlight_properties()
105 ret = device_property_read_u32(dev, "default-brightness", &brightness); in rt4831_parse_backlight_properties()
107 brightness = bl_props->max_brightness; in rt4831_parse_backlight_properties()
109 bl_props->brightness = min_t(u32, brightness, bl_props->max_brightness); in rt4831_parse_backlight_properties()
112 if (device_property_read_bool(dev, "richtek,pwm-enable")) in rt4831_parse_backlight_properties()
115 ret = regmap_update_bits(priv->regmap, RT4831_REG_BLCFG, RT4831_BLPWMEN_MASK, val); in rt4831_parse_backlight_properties()
119 ret = device_property_read_u8(dev, "richtek,bled-ovp-sel", &propval); in rt4831_parse_backlight_properties()
124 ret = regmap_update_bits(priv->regmap, RT4831_REG_BLCFG, RT4831_BLOVP_MASK, in rt4831_parse_backlight_properties()
131 * If inductor peak current reach the level, low-side MOSFET will be in rt4831_parse_backlight_properties()
136 * Not like the OVP level, the default 21V can be used in the most in rt4831_parse_backlight_properties()
141 ret = device_property_read_u32(dev, "richtek,bled-ocp-microamp", in rt4831_parse_backlight_properties()
146 val = DIV_ROUND_UP(ocp_uA - RT4831_BLOCP_MINUA, in rt4831_parse_backlight_properties()
148 ret = regmap_update_bits(priv->regmap, RT4831_REG_BLOPT2, in rt4831_parse_backlight_properties()
154 ret = device_property_read_u8(dev, "richtek,channel-use", &propval); in rt4831_parse_backlight_properties()
156 dev_err(dev, "richtek,channel-use DT property missing\n"); in rt4831_parse_backlight_properties()
162 return -EINVAL; in rt4831_parse_backlight_properties()
165 return regmap_update_bits(priv->regmap, RT4831_REG_ENABLE, RT4831_BLCH_MASK, propval); in rt4831_parse_backlight_properties()
175 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in rt4831_bl_probe()
177 return -ENOMEM; in rt4831_bl_probe()
179 priv->dev = &pdev->dev; in rt4831_bl_probe()
181 priv->regmap = dev_get_regmap(pdev->dev.parent, NULL); in rt4831_bl_probe()
182 if (!priv->regmap) { in rt4831_bl_probe()
183 dev_err(&pdev->dev, "Failed to init regmap\n"); in rt4831_bl_probe()
184 return -ENODEV; in rt4831_bl_probe()
189 dev_err(&pdev->dev, "Failed to parse backlight properties\n"); in rt4831_bl_probe()
193 priv->bl = devm_backlight_device_register(&pdev->dev, pdev->name, &pdev->dev, priv, in rt4831_bl_probe()
195 if (IS_ERR(priv->bl)) { in rt4831_bl_probe()
196 dev_err(&pdev->dev, "Failed to register backlight\n"); in rt4831_bl_probe()
197 return PTR_ERR(priv->bl); in rt4831_bl_probe()
200 backlight_update_status(priv->bl); in rt4831_bl_probe()
209 struct backlight_device *bl_dev = priv->bl; in rt4831_bl_remove()
211 bl_dev->props.brightness = 0; in rt4831_bl_remove()
212 backlight_update_status(priv->bl); in rt4831_bl_remove()
216 { .compatible = "richtek,rt4831-backlight", },
223 .name = "rt4831-backlight",