Lines Matching refs:pchip

59 static int lm3630a_read(struct lm3630a_chip *pchip, unsigned int reg)
64 rval = regmap_read(pchip->regmap, reg, &reg_val);
70 static int lm3630a_write(struct lm3630a_chip *pchip,
73 return regmap_write(pchip->regmap, reg, data);
76 static int lm3630a_update(struct lm3630a_chip *pchip,
80 return regmap_update_bits(pchip->regmap, reg, mask, data);
84 static int lm3630a_chip_init(struct lm3630a_chip *pchip)
87 struct lm3630a_platform_data *pdata = pchip->pdata;
91 rval = lm3630a_write(pchip, REG_FILTER_STRENGTH, 0x03);
93 rval |= lm3630a_update(pchip, REG_CONFIG, 0x07, pdata->pwm_ctrl);
95 rval |= lm3630a_write(pchip, REG_BOOST, 0x38);
97 rval |= lm3630a_update(pchip, REG_I_A, 0x1F, 0x1F);
99 rval |= lm3630a_write(pchip, REG_I_B, 0x1F);
101 rval |= lm3630a_update(pchip, REG_CTRL, 0x14, pdata->leda_ctrl);
102 rval |= lm3630a_update(pchip, REG_CTRL, 0x0B, pdata->ledb_ctrl);
105 rval |= lm3630a_write(pchip, REG_BRT_A, pdata->leda_init_brt);
106 rval |= lm3630a_write(pchip, REG_BRT_B, pdata->ledb_init_brt);
109 dev_err(pchip->dev, "i2c failed to access register\n");
117 struct lm3630a_chip *pchip;
119 pchip = container_of(work, struct lm3630a_chip, work.work);
121 rval = lm3630a_read(pchip, REG_INT_STATUS);
123 dev_err(pchip->dev,
128 dev_info(pchip->dev, "REG_INT_STATUS Register is 0x%x\n", rval);
134 struct lm3630a_chip *pchip = chip;
137 queue_delayed_work(pchip->irqthread, &pchip->work, delay);
139 rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
141 dev_err(pchip->dev, "i2c failed to access register\n");
147 static int lm3630a_intr_config(struct lm3630a_chip *pchip)
151 rval = lm3630a_write(pchip, REG_INT_EN, 0x87);
155 INIT_DELAYED_WORK(&pchip->work, lm3630a_delayed_func);
156 pchip->irqthread = create_singlethread_workqueue("lm3630a-irqthd");
157 if (!pchip->irqthread) {
158 dev_err(pchip->dev, "create irq thread fail\n");
162 (pchip->irq, NULL, lm3630a_isr_func,
163 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "lm3630a_irq", pchip)) {
164 dev_err(pchip->dev, "request threaded irq fail\n");
165 destroy_workqueue(pchip->irqthread);
171 static int lm3630a_pwm_ctrl(struct lm3630a_chip *pchip, int br, int br_max)
175 pchip->pwmd_state.period = pchip->pdata->pwm_period;
177 err = pwm_set_relative_duty_cycle(&pchip->pwmd_state, br, br_max);
181 pchip->pwmd_state.enabled = pchip->pwmd_state.duty_cycle ? true : false;
183 return pwm_apply_state(pchip->pwmd, &pchip->pwmd_state);
190 struct lm3630a_chip *pchip = bl_get_data(bl);
191 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
195 return lm3630a_pwm_ctrl(pchip, bl->props.brightness,
199 ret = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
204 ret = lm3630a_write(pchip, REG_BRT_A, bl->props.brightness);
208 ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDA_ENABLE, 0);
210 ret |= lm3630a_update(pchip, REG_CTRL,
217 dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
224 struct lm3630a_chip *pchip = bl_get_data(bl);
225 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
228 rval = lm3630a_read(pchip, REG_PWM_OUTHIGH);
232 rval = lm3630a_read(pchip, REG_PWM_OUTLOW);
240 rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
244 rval = lm3630a_read(pchip, REG_BRT_A);
250 dev_err(pchip->dev, "i2c failed to access register\n");
264 struct lm3630a_chip *pchip = bl_get_data(bl);
265 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
269 return lm3630a_pwm_ctrl(pchip, bl->props.brightness,
273 ret = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
278 ret = lm3630a_write(pchip, REG_BRT_B, bl->props.brightness);
282 ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDB_ENABLE, 0);
284 ret |= lm3630a_update(pchip, REG_CTRL,
291 dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
298 struct lm3630a_chip *pchip = bl_get_data(bl);
299 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
302 rval = lm3630a_read(pchip, REG_PWM_OUTHIGH);
306 rval = lm3630a_read(pchip, REG_PWM_OUTLOW);
314 rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00);
318 rval = lm3630a_read(pchip, REG_BRT_B);
324 dev_err(pchip->dev, "i2c failed to access register\n");
334 static int lm3630a_backlight_register(struct lm3630a_chip *pchip)
336 struct lm3630a_platform_data *pdata = pchip->pdata;
346 pchip->bleda =
347 devm_backlight_device_register(pchip->dev, label,
348 pchip->dev, pchip,
350 if (IS_ERR(pchip->bleda))
351 return PTR_ERR(pchip->bleda);
359 pchip->bledb =
360 devm_backlight_device_register(pchip->dev, label,
361 pchip->dev, pchip,
363 if (IS_ERR(pchip->bledb))
364 return PTR_ERR(pchip->bledb);
476 static int lm3630a_parse_node(struct lm3630a_chip *pchip,
482 device_for_each_child_node(pchip->dev, node) {
496 struct lm3630a_chip *pchip;
504 pchip = devm_kzalloc(&client->dev, sizeof(struct lm3630a_chip),
506 if (!pchip)
508 pchip->dev = &client->dev;
510 pchip->regmap = devm_regmap_init_i2c(client, &lm3630a_regmap);
511 if (IS_ERR(pchip->regmap)) {
512 rval = PTR_ERR(pchip->regmap);
517 i2c_set_clientdata(client, pchip);
519 pdata = devm_kzalloc(pchip->dev,
531 rval = lm3630a_parse_node(pchip, pdata);
537 pchip->pdata = pdata;
539 pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
541 if (IS_ERR(pchip->enable_gpio)) {
542 rval = PTR_ERR(pchip->enable_gpio);
547 rval = lm3630a_chip_init(pchip);
553 rval = lm3630a_backlight_register(pchip);
560 pchip->pwmd = devm_pwm_get(pchip->dev, "lm3630a-pwm");
561 if (IS_ERR(pchip->pwmd)) {
563 return PTR_ERR(pchip->pwmd);
566 pwm_init_state(pchip->pwmd, &pchip->pwmd_state);
570 pchip->irq = client->irq;
571 if (pchip->irq) {
572 rval = lm3630a_intr_config(pchip);
583 struct lm3630a_chip *pchip = i2c_get_clientdata(client);
585 rval = lm3630a_write(pchip, REG_BRT_A, 0);
587 dev_err(pchip->dev, "i2c failed to access register\n");
589 rval = lm3630a_write(pchip, REG_BRT_B, 0);
591 dev_err(pchip->dev, "i2c failed to access register\n");
593 if (pchip->irq) {
594 free_irq(pchip->irq, pchip);
595 destroy_workqueue(pchip->irqthread);