Lines Matching refs:vreg

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