Lines Matching full:lp

94 static int arcxcnn_update_field(struct arcxcnn *lp, u8 reg, u8 mask, u8 data)  in arcxcnn_update_field()  argument
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
119 ret = i2c_smbus_write_byte_data(lp->client, in arcxcnn_set_brightness()
126 return i2c_smbus_write_byte_data(lp->client, in arcxcnn_set_brightness()
132 struct arcxcnn *lp = bl_get_data(bl); in arcxcnn_bl_update_status() local
136 ret = arcxcnn_set_brightness(lp, brightness); in arcxcnn_bl_update_status()
141 return arcxcnn_update_field(lp, ARCXCNN_CMD, ARCXCNN_CMD_STDBY, in arcxcnn_bl_update_status()
150 static int arcxcnn_backlight_register(struct arcxcnn *lp) in arcxcnn_backlight_register() argument
153 const char *name = lp->pdata->name ? : "arctic_bl"; in arcxcnn_backlight_register()
155 props = devm_kzalloc(lp->dev, sizeof(*props), GFP_KERNEL); in arcxcnn_backlight_register()
162 if (lp->pdata->initial_brightness > props->max_brightness) in arcxcnn_backlight_register()
163 lp->pdata->initial_brightness = props->max_brightness; in arcxcnn_backlight_register()
165 props->brightness = lp->pdata->initial_brightness; in arcxcnn_backlight_register()
167 lp->bl = devm_backlight_device_register(lp->dev, name, lp->dev, lp, in arcxcnn_backlight_register()
169 return PTR_ERR_OR_ZERO(lp->bl); in arcxcnn_backlight_register()
172 static void arcxcnn_parse_dt(struct arcxcnn *lp) in arcxcnn_parse_dt() argument
174 struct device *dev = lp->dev; in arcxcnn_parse_dt()
183 ret = of_property_read_string(node, "label", &lp->pdata->name); in arcxcnn_parse_dt()
185 lp->pdata->name = NULL; in arcxcnn_parse_dt()
189 lp->pdata->initial_brightness = prog_val; in arcxcnn_parse_dt()
193 lp->pdata->led_config_0 = (u8)prog_val; in arcxcnn_parse_dt()
197 lp->pdata->led_config_1 = (u8)prog_val; in arcxcnn_parse_dt()
201 lp->pdata->dim_freq = (u8)prog_val; in arcxcnn_parse_dt()
205 lp->pdata->comp_config = (u8)prog_val; in arcxcnn_parse_dt()
209 lp->pdata->filter_config = (u8)prog_val; in arcxcnn_parse_dt()
213 lp->pdata->trim_config = (u8)prog_val; in arcxcnn_parse_dt()
217 lp->pdata->leden = ARCXCNN_LEDEN_MASK; /* all on is default */ in arcxcnn_parse_dt()
230 lp->pdata->leden = 0; in arcxcnn_parse_dt()
236 lp->pdata->leden |= onbit; in arcxcnn_parse_dt()
243 struct arcxcnn *lp; in arcxcnn_probe() local
249 lp = devm_kzalloc(&cl->dev, sizeof(*lp), GFP_KERNEL); in arcxcnn_probe()
250 if (!lp) in arcxcnn_probe()
253 lp->client = cl; in arcxcnn_probe()
254 lp->dev = &cl->dev; in arcxcnn_probe()
255 lp->pdata = dev_get_platdata(&cl->dev); in arcxcnn_probe()
258 ret = i2c_smbus_write_byte_data(lp->client, in arcxcnn_probe()
263 if (!lp->pdata) { in arcxcnn_probe()
264 lp->pdata = devm_kzalloc(lp->dev, in arcxcnn_probe()
265 sizeof(*lp->pdata), GFP_KERNEL); in arcxcnn_probe()
266 if (!lp->pdata) in arcxcnn_probe()
270 lp->pdata->name = NULL; in arcxcnn_probe()
271 lp->pdata->initial_brightness = INIT_BRIGHT; in arcxcnn_probe()
272 lp->pdata->leden = ARCXCNN_LEDEN_MASK; in arcxcnn_probe()
274 lp->pdata->led_config_0 = i2c_smbus_read_byte_data( in arcxcnn_probe()
275 lp->client, ARCXCNN_FADECTRL); in arcxcnn_probe()
277 lp->pdata->led_config_1 = i2c_smbus_read_byte_data( in arcxcnn_probe()
278 lp->client, ARCXCNN_ILED_CONFIG); in arcxcnn_probe()
280 lp->pdata->led_config_1 |= ARCXCNN_ILED_DIM_INT; in arcxcnn_probe()
282 lp->pdata->dim_freq = i2c_smbus_read_byte_data( in arcxcnn_probe()
283 lp->client, ARCXCNN_DIMFREQ); in arcxcnn_probe()
285 lp->pdata->comp_config = i2c_smbus_read_byte_data( in arcxcnn_probe()
286 lp->client, ARCXCNN_COMP_CONFIG); in arcxcnn_probe()
288 lp->pdata->filter_config = i2c_smbus_read_byte_data( in arcxcnn_probe()
289 lp->client, ARCXCNN_FILT_CONFIG); in arcxcnn_probe()
291 lp->pdata->trim_config = i2c_smbus_read_byte_data( in arcxcnn_probe()
292 lp->client, ARCXCNN_IMAXTUNE); in arcxcnn_probe()
295 arcxcnn_parse_dt(lp); in arcxcnn_probe()
298 i2c_set_clientdata(cl, lp); in arcxcnn_probe()
301 if (lp->pdata->initial_brightness > MAX_BRIGHTNESS) in arcxcnn_probe()
302 lp->pdata->initial_brightness = MAX_BRIGHTNESS; in arcxcnn_probe()
305 ret = arcxcnn_set_brightness(lp, lp->pdata->initial_brightness); in arcxcnn_probe()
310 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_FADECTRL, in arcxcnn_probe()
311 lp->pdata->led_config_0); in arcxcnn_probe()
315 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_ILED_CONFIG, in arcxcnn_probe()
316 lp->pdata->led_config_1); in arcxcnn_probe()
320 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_DIMFREQ, in arcxcnn_probe()
321 lp->pdata->dim_freq); in arcxcnn_probe()
325 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_COMP_CONFIG, in arcxcnn_probe()
326 lp->pdata->comp_config); in arcxcnn_probe()
330 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_FILT_CONFIG, in arcxcnn_probe()
331 lp->pdata->filter_config); in arcxcnn_probe()
335 ret = i2c_smbus_write_byte_data(lp->client, ARCXCNN_IMAXTUNE, in arcxcnn_probe()
336 lp->pdata->trim_config); in arcxcnn_probe()
341 arcxcnn_update_field(lp, ARCXCNN_LEDEN, in arcxcnn_probe()
342 ARCXCNN_LEDEN_MASK, lp->pdata->leden); in arcxcnn_probe()
344 ret = arcxcnn_backlight_register(lp); in arcxcnn_probe()
348 backlight_update_status(lp->bl); in arcxcnn_probe()
353 dev_err(lp->dev, in arcxcnn_probe()
357 dev_err(lp->dev, in arcxcnn_probe()
364 struct arcxcnn *lp = i2c_get_clientdata(cl); in arcxcnn_remove() local
367 i2c_smbus_write_byte_data(lp->client, in arcxcnn_remove()
370 i2c_smbus_write_byte_data(lp->client, in arcxcnn_remove()
373 lp->bl->props.brightness = 0; in arcxcnn_remove()
375 backlight_update_status(lp->bl); in arcxcnn_remove()