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