Lines Matching +full:default +full:- +full:brightness
1 // SPDX-License-Identifier: GPL-2.0-only
22 * @name : Backlight driver name (NULL will use default)
23 * @initial_brightness : initial value of backlight brightness
48 #define ARCXCNN_CMD_OVP_MASK 0x0C /* --- Over Voltage Threshold */
63 #define ARCXCNN_LEDEN_ISETEXT 0x80 /* Full-scale current set extern */
99 ret = i2c_smbus_read_byte_data(lp->client, reg); in arcxcnn_update_field()
101 dev_err(lp->dev, "failed to read 0x%.2x\n", reg); in arcxcnn_update_field()
109 return i2c_smbus_write_byte_data(lp->client, reg, tmp); in arcxcnn_update_field()
112 static int arcxcnn_set_brightness(struct arcxcnn *lp, u32 brightness) in arcxcnn_set_brightness() argument
117 /* lower nibble of brightness goes in upper nibble of LSB register */ in arcxcnn_set_brightness()
118 val = (brightness & 0xF) << ARCXCNN_WLED_ISET_LSB_SHIFT; in arcxcnn_set_brightness()
119 ret = i2c_smbus_write_byte_data(lp->client, in arcxcnn_set_brightness()
124 /* remaining 8 bits of brightness go in MSB register */ in arcxcnn_set_brightness()
125 val = (brightness >> 4); in arcxcnn_set_brightness()
126 return i2c_smbus_write_byte_data(lp->client, in arcxcnn_set_brightness()
133 u32 brightness = bl->props.brightness; in arcxcnn_bl_update_status() local
136 if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) in arcxcnn_bl_update_status()
137 brightness = 0; in arcxcnn_bl_update_status()
139 ret = arcxcnn_set_brightness(lp, brightness); in arcxcnn_bl_update_status()
143 /* set power-on/off/save modes */ in arcxcnn_bl_update_status()
145 (bl->props.power == 0) ? 0 : ARCXCNN_CMD_STDBY); in arcxcnn_bl_update_status()
156 const char *name = lp->pdata->name ? : "arctic_bl"; in arcxcnn_backlight_register()
158 props = devm_kzalloc(lp->dev, sizeof(*props), GFP_KERNEL); in arcxcnn_backlight_register()
160 return -ENOMEM; in arcxcnn_backlight_register()
162 props->type = BACKLIGHT_PLATFORM; in arcxcnn_backlight_register()
163 props->max_brightness = MAX_BRIGHTNESS; in arcxcnn_backlight_register()
165 if (lp->pdata->initial_brightness > props->max_brightness) in arcxcnn_backlight_register()
166 lp->pdata->initial_brightness = props->max_brightness; in arcxcnn_backlight_register()
168 props->brightness = lp->pdata->initial_brightness; in arcxcnn_backlight_register()
170 lp->bl = devm_backlight_device_register(lp->dev, name, lp->dev, lp, in arcxcnn_backlight_register()
172 return PTR_ERR_OR_ZERO(lp->bl); in arcxcnn_backlight_register()
177 struct device *dev = lp->dev; in arcxcnn_parse_dt()
178 struct device_node *node = dev->of_node; in arcxcnn_parse_dt()
186 ret = of_property_read_string(node, "label", &lp->pdata->name); in arcxcnn_parse_dt()
188 lp->pdata->name = NULL; in arcxcnn_parse_dt()
190 ret = of_property_read_u32(node, "default-brightness", &prog_val); in arcxcnn_parse_dt()
192 lp->pdata->initial_brightness = prog_val; in arcxcnn_parse_dt()
194 ret = of_property_read_u32(node, "arc,led-config-0", &prog_val); in arcxcnn_parse_dt()
196 lp->pdata->led_config_0 = (u8)prog_val; in arcxcnn_parse_dt()
198 ret = of_property_read_u32(node, "arc,led-config-1", &prog_val); in arcxcnn_parse_dt()
200 lp->pdata->led_config_1 = (u8)prog_val; in arcxcnn_parse_dt()
202 ret = of_property_read_u32(node, "arc,dim-freq", &prog_val); in arcxcnn_parse_dt()
204 lp->pdata->dim_freq = (u8)prog_val; in arcxcnn_parse_dt()
206 ret = of_property_read_u32(node, "arc,comp-config", &prog_val); in arcxcnn_parse_dt()
208 lp->pdata->comp_config = (u8)prog_val; in arcxcnn_parse_dt()
210 ret = of_property_read_u32(node, "arc,filter-config", &prog_val); in arcxcnn_parse_dt()
212 lp->pdata->filter_config = (u8)prog_val; in arcxcnn_parse_dt()
214 ret = of_property_read_u32(node, "arc,trim-config", &prog_val); in arcxcnn_parse_dt()
216 lp->pdata->trim_config = (u8)prog_val; in arcxcnn_parse_dt()
218 ret = of_property_count_u32_elems(node, "led-sources"); in arcxcnn_parse_dt()
220 lp->pdata->leden = ARCXCNN_LEDEN_MASK; /* all on is default */ in arcxcnn_parse_dt()
226 ret = of_property_read_u32_array(node, "led-sources", sources, in arcxcnn_parse_dt()
229 dev_err(dev, "led-sources node is invalid.\n"); in arcxcnn_parse_dt()
233 lp->pdata->leden = 0; in arcxcnn_parse_dt()
239 lp->pdata->leden |= onbit; in arcxcnn_parse_dt()
249 if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in arcxcnn_probe()
250 return -EIO; in arcxcnn_probe()
252 lp = devm_kzalloc(&cl->dev, sizeof(*lp), GFP_KERNEL); in arcxcnn_probe()
254 return -ENOMEM; in arcxcnn_probe()
256 lp->client = cl; in arcxcnn_probe()
257 lp->dev = &cl->dev; in arcxcnn_probe()
258 lp->pdata = dev_get_platdata(&cl->dev); in arcxcnn_probe()
261 ret = i2c_smbus_write_byte_data(lp->client, in arcxcnn_probe()
266 if (!lp->pdata) { in arcxcnn_probe()
267 lp->pdata = devm_kzalloc(lp->dev, in arcxcnn_probe()
268 sizeof(*lp->pdata), GFP_KERNEL); in arcxcnn_probe()
269 if (!lp->pdata) in arcxcnn_probe()
270 return -ENOMEM; in arcxcnn_probe()
272 /* Setup defaults based on power-on defaults */ in arcxcnn_probe()
273 lp->pdata->name = NULL; in arcxcnn_probe()
274 lp->pdata->initial_brightness = INIT_BRIGHT; in arcxcnn_probe()
275 lp->pdata->leden = ARCXCNN_LEDEN_MASK; in arcxcnn_probe()
277 lp->pdata->led_config_0 = i2c_smbus_read_byte_data( in arcxcnn_probe()
278 lp->client, ARCXCNN_FADECTRL); in arcxcnn_probe()
280 lp->pdata->led_config_1 = i2c_smbus_read_byte_data( in arcxcnn_probe()
281 lp->client, ARCXCNN_ILED_CONFIG); in arcxcnn_probe()
282 /* insure dim mode is not default pwm */ in arcxcnn_probe()
283 lp->pdata->led_config_1 |= ARCXCNN_ILED_DIM_INT; in arcxcnn_probe()
285 lp->pdata->dim_freq = i2c_smbus_read_byte_data( in arcxcnn_probe()
286 lp->client, ARCXCNN_DIMFREQ); in arcxcnn_probe()
288 lp->pdata->comp_config = i2c_smbus_read_byte_data( in arcxcnn_probe()
289 lp->client, ARCXCNN_COMP_CONFIG); in arcxcnn_probe()
291 lp->pdata->filter_config = i2c_smbus_read_byte_data( in arcxcnn_probe()
292 lp->client, ARCXCNN_FILT_CONFIG); in arcxcnn_probe()
294 lp->pdata->trim_config = i2c_smbus_read_byte_data( in arcxcnn_probe()
295 lp->client, ARCXCNN_IMAXTUNE); in arcxcnn_probe()
304 if (lp->pdata->initial_brightness > MAX_BRIGHTNESS) in arcxcnn_probe()
305 lp->pdata->initial_brightness = MAX_BRIGHTNESS; in arcxcnn_probe()
307 /* set initial brightness */ in arcxcnn_probe()
308 ret = arcxcnn_set_brightness(lp, lp->pdata->initial_brightness); in arcxcnn_probe()
313 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_FADECTRL, in arcxcnn_probe()
314 lp->pdata->led_config_0); in arcxcnn_probe()
318 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_ILED_CONFIG, in arcxcnn_probe()
319 lp->pdata->led_config_1); in arcxcnn_probe()
323 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_DIMFREQ, in arcxcnn_probe()
324 lp->pdata->dim_freq); in arcxcnn_probe()
328 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_COMP_CONFIG, in arcxcnn_probe()
329 lp->pdata->comp_config); in arcxcnn_probe()
333 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_FILT_CONFIG, in arcxcnn_probe()
334 lp->pdata->filter_config); in arcxcnn_probe()
338 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_IMAXTUNE, in arcxcnn_probe()
339 lp->pdata->trim_config); in arcxcnn_probe()
345 ARCXCNN_LEDEN_MASK, lp->pdata->leden); in arcxcnn_probe()
351 backlight_update_status(lp->bl); in arcxcnn_probe()
356 dev_err(lp->dev, in arcxcnn_probe()
360 dev_err(lp->dev, in arcxcnn_probe()
370 i2c_smbus_write_byte_data(lp->client, in arcxcnn_remove()
373 i2c_smbus_write_byte_data(lp->client, in arcxcnn_remove()
376 lp->bl->props.brightness = 0; in arcxcnn_remove()
378 backlight_update_status(lp->bl); in arcxcnn_remove()