Lines Matching refs:vreg

110 	struct labibb_regulator *vreg = rdev_get_drvdata(rdev);
115 vreg->base + REG_LABIBB_INT_LATCHED_CLR,
122 vreg->base + REG_LABIBB_INT_EN_SET,
128 struct labibb_regulator *vreg = rdev_get_drvdata(rdev);
131 vreg->base + REG_LABIBB_INT_EN_CLR,
137 * @vreg: Main driver structure
145 static int qcom_labibb_check_ocp_status(struct labibb_regulator *vreg)
150 ret = regmap_read(vreg->rdev->regmap, vreg->base + REG_LABIBB_STATUS1,
181 struct labibb_regulator *vreg;
185 vreg = container_of(work, struct labibb_regulator,
187 ops = vreg->rdev->desc->ops;
189 if (vreg->ocp_irq_count >= LABIBB_MAX_OCP_COUNT) {
196 * regmap write to disable the vreg is almost impossible,
199 BUG_ON(vreg->fatal_count > LABIBB_MAX_FATAL_COUNT);
200 dev_err(&vreg->rdev->dev, "LABIBB: CRITICAL: Disabling regulator\n");
203 ret = ops->disable(vreg->rdev);
205 vreg->fatal_count++;
208 enable_irq(vreg->ocp_irq);
209 vreg->fatal_count = 0;
213 ret = qcom_labibb_check_ocp_status(vreg);
215 vreg->ocp_irq_count++;
219 ret = qcom_labibb_ocp_hw_enable(vreg->rdev);
222 dev_err(vreg->dev, "Cannot enable OCP IRQ\n");
223 vreg->ocp_irq_count++;
227 enable_irq(vreg->ocp_irq);
229 vreg->ocp_irq_count = 0;
233 mod_delayed_work(system_wq, &vreg->ocp_recovery_work,
257 struct labibb_regulator *vreg = chip;
258 const struct regulator_ops *ops = vreg->rdev->desc->ops;
262 if (!ops->is_enabled(vreg->rdev))
266 if (vreg->ocp_irq_count > LABIBB_MAX_OCP_COUNT)
275 ret = qcom_labibb_check_ocp_status(vreg);
277 vreg->ocp_irq_count = 0;
280 vreg->ocp_irq_count++;
289 dev_warn(vreg->dev, "Over-Current interrupt fired!\n");
292 ret = qcom_labibb_ocp_hw_disable(vreg->rdev);
297 regulator_notifier_call_chain(vreg->rdev,
302 schedule_delayed_work(&vreg->ocp_recovery_work,
313 struct labibb_regulator *vreg = rdev_get_drvdata(rdev);
326 if (vreg->ocp_irq <= 0)
329 ocp_irq_name = devm_kasprintf(vreg->dev, GFP_KERNEL, "%s-over-current",
330 vreg->desc.name);
335 switch (vreg->type) {
350 vreg->base + REG_LABIBB_INT_SET_TYPE,
358 vreg->base + REG_LABIBB_INT_POLARITY_HIGH,
363 vreg->base + REG_LABIBB_INT_POLARITY_LOW,
372 return devm_request_threaded_irq(vreg->dev, vreg->ocp_irq, NULL,
374 ocp_irq_name, vreg);
379 * @vreg: Main driver structure
388 static int qcom_labibb_check_sc_status(struct labibb_regulator *vreg)
394 lab_reg = ibb_reg = vreg->base + REG_LABIBB_STATUS1;
395 if (vreg->type == QCOM_LAB_TYPE)
400 ret = regmap_read(vreg->rdev->regmap, lab_reg, &lab_status);
403 ret = regmap_read(vreg->rdev->regmap, ibb_reg, &ibb_status);
430 struct labibb_regulator *vreg;
436 vreg = container_of(work, struct labibb_regulator,
438 ops = vreg->rdev->desc->ops;
445 if (vreg->fatal_count > LABIBB_MAX_FATAL_COUNT)
449 if (vreg->sc_count > LABIBB_MAX_SC_COUNT)
457 lab_reg = ibb_reg = vreg->base + REG_LABIBB_ENABLE_CTL;
458 if (vreg->type == QCOM_LAB_TYPE)
463 sc = qcom_labibb_check_sc_status(vreg);
468 ret = regmap_read(vreg->regmap, lab_reg, &lab_val);
470 vreg->fatal_count++;
474 ret = regmap_read(vreg->regmap, ibb_reg, &ibb_val);
476 vreg->fatal_count++;
497 ret = ops->enable(vreg->rdev);
502 vreg->sc_count = 0;
503 enable_irq(vreg->sc_irq);
512 vreg->sc_count++;
513 mod_delayed_work(system_wq, &vreg->sc_recovery_work,
535 struct labibb_regulator *vreg = chip;
537 if (vreg->sc_count > LABIBB_MAX_SC_COUNT)
541 dev_warn(vreg->dev, "Short-Circuit interrupt fired!\n");
550 regulator_notifier_call_chain(vreg->rdev,
554 mod_delayed_work(system_highpri_wq, &vreg->sc_recovery_work,
563 struct labibb_regulator *vreg = rdev_get_drvdata(rdev);
564 struct regulator_desc *desc = &vreg->desc;
565 struct labibb_current_limits *lim = &vreg->uA_limits;
582 ret = regmap_write(vreg->regmap, vreg->base + REG_LABIBB_SEC_ACCESS,
592 return regmap_update_bits(vreg->regmap, desc->csel_reg, mask, val);
597 struct labibb_regulator *vreg = rdev_get_drvdata(rdev);
598 struct regulator_desc *desc = &vreg->desc;
599 struct labibb_current_limits *lim = &vreg->uA_limits;
603 ret = regmap_read(vreg->regmap, desc->csel_reg, &cur_step);
613 struct labibb_regulator *vreg = rdev_get_drvdata(rdev);
616 if (vreg->type == QCOM_IBB_TYPE)
617 val = vreg->dischg_sel;
619 val = vreg->soft_start_sel;
644 struct labibb_regulator *vreg = config->driver_data;
658 vreg->dischg_sel = (u8)ret;
670 vreg->soft_start_sel = (u8)ret;
763 struct labibb_regulator *vreg;
803 vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg),
805 if (!vreg)
826 return dev_err_probe(vreg->dev, irq,
829 vreg->sc_irq = irq;
833 vreg->ocp_irq = irq;
834 vreg->ocp_irq_count = 0;
837 vreg->regmap = reg_regmap;
838 vreg->dev = dev;
839 vreg->base = reg_data->base;
840 vreg->type = reg_data->type;
841 INIT_DELAYED_WORK(&vreg->sc_recovery_work,
844 if (vreg->ocp_irq > 0)
845 INIT_DELAYED_WORK(&vreg->ocp_recovery_work,
848 switch (vreg->type) {
851 vreg->uA_limits.uA_min = 200000;
852 vreg->uA_limits.uA_step = 200000;
853 vreg->uA_limits.ovr_val = LAB_CURRENT_LIMIT_OVERRIDE_EN;
857 vreg->uA_limits.uA_min = 0;
858 vreg->uA_limits.uA_step = 50000;
859 vreg->uA_limits.ovr_val = 0; /* No override bit */
865 memcpy(&vreg->desc, reg_data->desc, sizeof(vreg->desc));
866 vreg->desc.of_match = reg_data->name;
867 vreg->desc.name = reg_data->name;
869 cfg.dev = vreg->dev;
870 cfg.driver_data = vreg;
871 cfg.regmap = vreg->regmap;
873 vreg->rdev = devm_regulator_register(vreg->dev, &vreg->desc,
876 if (IS_ERR(vreg->rdev)) {
879 return PTR_ERR(vreg->rdev);
882 ret = devm_request_threaded_irq(vreg->dev, vreg->sc_irq, NULL,
886 sc_irq_name, vreg);