Lines Matching refs:pchip
58 static int lm3630a_read(struct lm3630a_chip *pchip, unsigned int reg)
63 rval = regmap_read(pchip->regmap, reg, ®_val);
69 static int lm3630a_write(struct lm3630a_chip *pchip,
72 return regmap_write(pchip->regmap, reg, data);
75 static int lm3630a_update(struct lm3630a_chip *pchip,
79 return regmap_update_bits(pchip->regmap, reg, mask, data);
83 static int lm3630a_chip_init(struct lm3630a_chip *pchip)
86 struct lm3630a_platform_data *pdata = pchip->pdata;
90 rval = lm3630a_write(pchip, REG_FILTER_STRENGTH, 0x03);
92 rval |= lm3630a_update(pchip, REG_CONFIG, 0x07, pdata->pwm_ctrl);
94 rval |= lm3630a_write(pchip, REG_BOOST, 0x38);
96 rval |= lm3630a_update(pchip, REG_I_A, 0x1F, 0x1F);
98 rval |= lm3630a_write(pchip, REG_I_B, 0x1F);
100 rval |= lm3630a_update(pchip, REG_CTRL, 0x14, pdata->leda_ctrl);
101 rval |= lm3630a_update(pchip, REG_CTRL, 0x0B, pdata->ledb_ctrl);
104 rval |= lm3630a_write(pchip, REG_BRT_A, pdata->leda_init_brt);
105 rval |= lm3630a_write(pchip, REG_BRT_B, pdata->ledb_init_brt);
108 dev_err(pchip->dev, "i2c failed to access register\n");
116 struct lm3630a_chip *pchip;
118 pchip = container_of(work, struct lm3630a_chip, work.work);
120 rval = lm3630a_read(pchip, REG_INT_STATUS);
122 dev_err(pchip->dev,
127 dev_info(pchip->dev, "REG_INT_STATUS Register is 0x%x\n", rval);
133 struct lm3630a_chip *pchip = chip;
136 queue_delayed_work(pchip->irqthread, &pchip->work, delay);
138 rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
140 dev_err(pchip->dev, "i2c failed to access register\n");
146 static int lm3630a_intr_config(struct lm3630a_chip *pchip)
150 rval = lm3630a_write(pchip, REG_INT_EN, 0x87);
154 INIT_DELAYED_WORK(&pchip->work, lm3630a_delayed_func);
155 pchip->irqthread = create_singlethread_workqueue("lm3630a-irqthd");
156 if (!pchip->irqthread) {
157 dev_err(pchip->dev, "create irq thread fail\n");
161 (pchip->irq, NULL, lm3630a_isr_func,
162 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "lm3630a_irq", pchip)) {
163 dev_err(pchip->dev, "request threaded irq fail\n");
164 destroy_workqueue(pchip->irqthread);
170 static void lm3630a_pwm_ctrl(struct lm3630a_chip *pchip, int br, int br_max)
172 unsigned int period = pchip->pdata->pwm_period;
175 pwm_config(pchip->pwmd, duty, period);
177 pwm_enable(pchip->pwmd);
179 pwm_disable(pchip->pwmd);
186 struct lm3630a_chip *pchip = bl_get_data(bl);
187 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
191 lm3630a_pwm_ctrl(pchip, bl->props.brightness,
197 ret = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
202 ret = lm3630a_write(pchip, REG_BRT_A, bl->props.brightness);
204 ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDA_ENABLE, 0);
206 ret |= lm3630a_update(pchip, REG_CTRL,
213 dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
220 struct lm3630a_chip *pchip = bl_get_data(bl);
221 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
224 rval = lm3630a_read(pchip, REG_PWM_OUTHIGH);
228 rval = lm3630a_read(pchip, REG_PWM_OUTLOW);
236 rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
240 rval = lm3630a_read(pchip, REG_BRT_A);
249 dev_err(pchip->dev, "i2c failed to access register\n");
263 struct lm3630a_chip *pchip = bl_get_data(bl);
264 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
268 lm3630a_pwm_ctrl(pchip, bl->props.brightness,
274 ret = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
279 ret = lm3630a_write(pchip, REG_BRT_B, bl->props.brightness);
281 ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDB_ENABLE, 0);
283 ret |= lm3630a_update(pchip, REG_CTRL,
290 dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
297 struct lm3630a_chip *pchip = bl_get_data(bl);
298 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
301 rval = lm3630a_read(pchip, REG_PWM_OUTHIGH);
305 rval = lm3630a_read(pchip, REG_PWM_OUTLOW);
313 rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
317 rval = lm3630a_read(pchip, REG_BRT_B);
326 dev_err(pchip->dev, "i2c failed to access register\n");
336 static int lm3630a_backlight_register(struct lm3630a_chip *pchip)
338 struct lm3630a_platform_data *pdata = pchip->pdata;
347 pchip->bleda =
348 devm_backlight_device_register(pchip->dev, label,
349 pchip->dev, pchip,
351 if (IS_ERR(pchip->bleda))
352 return PTR_ERR(pchip->bleda);
360 pchip->bledb =
361 devm_backlight_device_register(pchip->dev, label,
362 pchip->dev, pchip,
364 if (IS_ERR(pchip->bledb))
365 return PTR_ERR(pchip->bledb);
477 static int lm3630a_parse_node(struct lm3630a_chip *pchip,
483 device_for_each_child_node(pchip->dev, node) {
498 struct lm3630a_chip *pchip;
506 pchip = devm_kzalloc(&client->dev, sizeof(struct lm3630a_chip),
508 if (!pchip)
510 pchip->dev = &client->dev;
512 pchip->regmap = devm_regmap_init_i2c(client, &lm3630a_regmap);
513 if (IS_ERR(pchip->regmap)) {
514 rval = PTR_ERR(pchip->regmap);
519 i2c_set_clientdata(client, pchip);
521 pdata = devm_kzalloc(pchip->dev,
533 rval = lm3630a_parse_node(pchip, pdata);
539 pchip->pdata = pdata;
541 pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
543 if (IS_ERR(pchip->enable_gpio)) {
544 rval = PTR_ERR(pchip->enable_gpio);
549 rval = lm3630a_chip_init(pchip);
555 rval = lm3630a_backlight_register(pchip);
562 pchip->pwmd = devm_pwm_get(pchip->dev, "lm3630a-pwm");
563 if (IS_ERR(pchip->pwmd)) {
565 return PTR_ERR(pchip->pwmd);
572 pwm_apply_args(pchip->pwmd);
576 pchip->irq = client->irq;
577 if (pchip->irq) {
578 rval = lm3630a_intr_config(pchip);
589 struct lm3630a_chip *pchip = i2c_get_clientdata(client);
591 rval = lm3630a_write(pchip, REG_BRT_A, 0);
593 dev_err(pchip->dev, "i2c failed to access register\n");
595 rval = lm3630a_write(pchip, REG_BRT_B, 0);
597 dev_err(pchip->dev, "i2c failed to access register\n");
599 if (pchip->irq) {
600 free_irq(pchip->irq, pchip);
601 flush_workqueue(pchip->irqthread);
602 destroy_workqueue(pchip->irqthread);