Lines Matching +full:buck +full:- +full:c
1 // SPDX-License-Identifier: GPL-2.0+
100 (const struct rtq2208_regulator_desc *)rdev->desc; in rtq2208_set_mode()
111 return -EINVAL; in rtq2208_set_mode()
114 shift = ffs(rdesc->mode_mask) - 1; in rtq2208_set_mode()
115 return regmap_update_bits(rdev->regmap, rdesc->mode_reg, in rtq2208_set_mode()
116 rdesc->mode_mask, val << shift); in rtq2208_set_mode()
122 (const struct rtq2208_regulator_desc *)rdev->desc; in rtq2208_get_mode()
126 ret = regmap_read(rdev->regmap, rdesc->mode_reg, &mode_val); in rtq2208_get_mode()
130 return (mode_val & rdesc->mode_mask) ? REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL; in rtq2208_get_mode()
135 const struct regulator_desc *desc = rdev->desc; in rtq2208_set_ramp_delay()
144 * fls(ramp_delay) - 1: doing LSB shift, let it starts from 0 in rtq2208_set_ramp_delay()
146 * RTQ2208_BUCK_RAMP_SEL_MASK - sel: doing descending order shifting. in rtq2208_set_ramp_delay()
154 * For example, if I would like to select 16mv, the fls(ramp_delay) - 1 will be 0b010, in rtq2208_set_ramp_delay()
155 * and I need to use 0b111 - sel to do the shifting in rtq2208_set_ramp_delay()
158 sel = fls(ramp_delay) - 1; in rtq2208_set_ramp_delay()
159 sel = RTQ2208_BUCK_RAMP_SEL_MASK - sel; in rtq2208_set_ramp_delay()
163 return regmap_update_bits(rdev->regmap, desc->ramp_reg, in rtq2208_set_ramp_delay()
170 (const struct rtq2208_regulator_desc *)rdev->desc; in rtq2208_set_suspend_enable()
172 return regmap_set_bits(rdev->regmap, rdesc->suspend_config_reg, rdesc->suspend_enable_mask); in rtq2208_set_suspend_enable()
178 (const struct rtq2208_regulator_desc *)rdev->desc; in rtq2208_set_suspend_disable()
180 return regmap_update_bits(rdev->regmap, rdesc->suspend_config_reg, rdesc->suspend_enable_mask, 0); in rtq2208_set_suspend_disable()
186 (const struct rtq2208_regulator_desc *)rdev->desc; in rtq2208_set_suspend_mode()
197 return -EINVAL; in rtq2208_set_suspend_mode()
200 shift = ffs(rdesc->suspend_mode_mask) - 1; in rtq2208_set_suspend_mode()
202 return regmap_update_bits(rdev->regmap, rdesc->suspend_config_reg, in rtq2208_set_suspend_mode()
203 rdesc->suspend_mode_mask, val << shift); in rtq2208_set_suspend_mode()
271 /* write clear all buck irq once */ in rtq2208_init_irq_mask()
272 ret = regmap_bulk_write(rdev_map->regmap, RTQ2208_REG_FLT_RECORDBUCK_CB, buck_clr_masks, 5); in rtq2208_init_irq_mask()
274 return dev_err_probe(rdev_map->dev, ret, "Failed to clr buck irqs\n"); in rtq2208_init_irq_mask()
277 ret = regmap_bulk_write(rdev_map->regmap, RTQ2208_REG_GLOBAL_INT1, sts_clr_masks, 2); in rtq2208_init_irq_mask()
279 return dev_err_probe(rdev_map->dev, ret, "Failed to clr general irqs\n"); in rtq2208_init_irq_mask()
281 /* unmask buck ov/uv irq */ in rtq2208_init_irq_mask()
282 ret = regmap_bulk_write(rdev_map->regmap, RTQ2208_REG_FLT_MASKBUCK_CB, buck_masks, 5); in rtq2208_init_irq_mask()
284 return dev_err_probe(rdev_map->dev, ret, "Failed to unmask buck irqs\n"); in rtq2208_init_irq_mask()
287 return regmap_bulk_write(rdev_map->regmap, RTQ2208_REG_GLOBAL_INT1_MASK, sts_masks, 2); in rtq2208_init_irq_mask()
301 ret = regmap_bulk_read(rdev_map->regmap, RTQ2208_REG_FLT_RECORDBUCK_CB, in rtq2208_irq_handler()
306 ret = regmap_bulk_read(rdev_map->regmap, RTQ2208_REG_GLOBAL_INT1, in rtq2208_irq_handler()
312 ret = regmap_bulk_write(rdev_map->regmap, RTQ2208_REG_FLT_RECORDBUCK_CB, in rtq2208_irq_handler()
317 ret = regmap_bulk_write(rdev_map->regmap, RTQ2208_REG_GLOBAL_INT1, in rtq2208_irq_handler()
323 if (!rdev_map->rdev[i]) in rtq2208_irq_handler()
326 rdev = rdev_map->rdev[i]; in rtq2208_irq_handler()
356 if (!dev->of_node) in rtq2208_of_get_ldo_dvs_ability()
357 return -ENODEV; in rtq2208_of_get_ldo_dvs_ability()
359 np = of_get_child_by_name(dev->of_node, "regulators"); in rtq2208_of_get_ldo_dvs_ability()
361 np = dev->of_node; in rtq2208_of_get_ldo_dvs_ability()
372 init_data = match->init_data; in rtq2208_of_get_ldo_dvs_ability()
373 desc = (struct regulator_desc *)match->desc; in rtq2208_of_get_ldo_dvs_ability()
379 ret = of_property_read_u32(match->of_node, "richtek,fixed-microvolt", &fixed_uV); in rtq2208_of_get_ldo_dvs_ability()
382 if (fixed_uV != init_data->constraints.min_uV || in rtq2208_of_get_ldo_dvs_ability()
383 fixed_uV != init_data->constraints.max_uV) in rtq2208_of_get_ldo_dvs_ability()
384 return -EINVAL; in rtq2208_of_get_ldo_dvs_ability()
385 desc->n_voltages = 1; in rtq2208_of_get_ldo_dvs_ability()
386 desc->fixed_uV = fixed_uV; in rtq2208_of_get_ldo_dvs_ability()
387 desc->fixed_uV = init_data->constraints.min_uV; in rtq2208_of_get_ldo_dvs_ability()
388 desc->ops = &rtq2208_regulator_ldo_fix_ops; in rtq2208_of_get_ldo_dvs_ability()
390 desc->n_voltages = ARRAY_SIZE(rtq2208_ldo_volt_table); in rtq2208_of_get_ldo_dvs_ability()
391 desc->volt_table = rtq2208_ldo_volt_table; in rtq2208_of_get_ldo_dvs_ability()
392 desc->ops = &rtq2208_regulator_ldo_adj_ops; in rtq2208_of_get_ldo_dvs_ability()
439 BUCK_INFO("buck-b", B), in rtq2208_init_regulator_desc()
440 BUCK_INFO("buck-c", C), in rtq2208_init_regulator_desc()
441 BUCK_INFO("buck-d", D), in rtq2208_init_regulator_desc()
442 BUCK_INFO("buck-a", A), in rtq2208_init_regulator_desc()
443 BUCK_INFO("buck-f", F), in rtq2208_init_regulator_desc()
444 BUCK_INFO("buck-g", G), in rtq2208_init_regulator_desc()
445 BUCK_INFO("buck-h", H), in rtq2208_init_regulator_desc()
446 BUCK_INFO("buck-e", E), in rtq2208_init_regulator_desc()
452 desc = &rdesc->desc; in rtq2208_init_regulator_desc()
453 desc->name = curr_info->name; in rtq2208_init_regulator_desc()
454 desc->of_match = of_match_ptr(curr_info->name); in rtq2208_init_regulator_desc()
455 desc->regulators_node = of_match_ptr("regulators"); in rtq2208_init_regulator_desc()
456 desc->id = idx; in rtq2208_init_regulator_desc()
457 desc->owner = THIS_MODULE; in rtq2208_init_regulator_desc()
458 desc->type = REGULATOR_VOLTAGE; in rtq2208_init_regulator_desc()
459 desc->enable_mask = mtp_sel ? MTP_SEL_MASK(1) : MTP_SEL_MASK(0); in rtq2208_init_regulator_desc()
460 desc->enable_reg = curr_info->enable_reg; in rtq2208_init_regulator_desc()
461 desc->active_discharge_off = 0; in rtq2208_init_regulator_desc()
463 rdesc->mode_mask = RTQ2208_BUCK_NRMODE_MASK; in rtq2208_init_regulator_desc()
466 /* init buck desc */ in rtq2208_init_regulator_desc()
467 desc->ops = &rtq2208_regulator_buck_ops; in rtq2208_init_regulator_desc()
468 desc->vsel_reg = curr_info->base + VSEL_SHIFT(mtp_sel); in rtq2208_init_regulator_desc()
469 desc->vsel_mask = RTQ2208_BUCK_NR_MTP_SEL_MASK; in rtq2208_init_regulator_desc()
470 desc->n_voltages = RTQ2208_VOUT_MAXNUM; in rtq2208_init_regulator_desc()
471 desc->linear_ranges = rtq2208_vout_range; in rtq2208_init_regulator_desc()
472 desc->n_linear_ranges = ARRAY_SIZE(rtq2208_vout_range); in rtq2208_init_regulator_desc()
473 desc->ramp_reg = BUCK_RG_SHIFT(curr_info->base, 5); in rtq2208_init_regulator_desc()
474 desc->of_map_mode = rtq2208_of_map_mode; in rtq2208_init_regulator_desc()
475 desc->active_discharge_reg = curr_info->dis_reg; in rtq2208_init_regulator_desc()
476 desc->active_discharge_on = RTQ2208_EN_DIS_MASK; in rtq2208_init_regulator_desc()
477 desc->active_discharge_mask = RTQ2208_EN_DIS_MASK; in rtq2208_init_regulator_desc()
479 rdesc->mode_reg = BUCK_RG_SHIFT(curr_info->base, 2); in rtq2208_init_regulator_desc()
480 rdesc->suspend_config_reg = BUCK_RG_SHIFT(curr_info->base, 4); in rtq2208_init_regulator_desc()
481 rdesc->suspend_enable_mask = RTQ2208_BUCK_EN_STR_MASK; in rtq2208_init_regulator_desc()
482 rdesc->suspend_mode_mask = RTQ2208_BUCK_STRMODE_MASK; in rtq2208_init_regulator_desc()
485 desc->active_discharge_reg = RTQ2208_REG_LDO_DVS_CTRL; in rtq2208_init_regulator_desc()
486 desc->active_discharge_on = curr_info->dis_on; in rtq2208_init_regulator_desc()
487 desc->active_discharge_mask = curr_info->dis_mask; in rtq2208_init_regulator_desc()
488 desc->vsel_reg = RTQ2208_REG_LDO_DVS_CTRL; in rtq2208_init_regulator_desc()
489 desc->vsel_mask = curr_info->vsel_mask; in rtq2208_init_regulator_desc()
491 rdesc->suspend_config_reg = curr_info->base; in rtq2208_init_regulator_desc()
492 rdesc->suspend_enable_mask = RTQ2208_LDO_EN_STR_MASK; in rtq2208_init_regulator_desc()
502 mtp_sel = device_property_read_bool(dev, "richtek,mtp-sel-high"); in rtq2208_parse_regulator_dt_data()
509 return -ENOMEM; in rtq2208_parse_regulator_dt_data()
515 rtq2208_ldo_match[idx - RTQ2208_LDO2].desc = &rdesc[i]->desc; in rtq2208_parse_regulator_dt_data()
528 * slave address 0x10: BUCK[BCA FGE]
529 * slave address 0x20: BUCK[BC FGHE]
530 * slave address 0x40: BUCK[C G]
536 /* BUCK[BCA FGE], LDO[12] */ in rtq2208_regulator_check()
538 /* BUCK[BC FGHE], LDO[12]*/ in rtq2208_regulator_check()
540 /* BUCK[C G], LDO[12] */ in rtq2208_regulator_check()
543 int i, idx = ffs(slave_addr >> 4) - 1; in rtq2208_regulator_check()
567 struct device *dev = &i2c->dev; in rtq2208_probe()
579 return -ENOMEM; in rtq2208_probe()
586 ret = rtq2208_regulator_check(i2c->addr, &n_regulator, regulator_idx_table, buck_masks); in rtq2208_probe()
590 rdev_map->regmap = regmap; in rtq2208_probe()
591 rdev_map->dev = dev; in rtq2208_probe()
604 rdev = devm_regulator_register(dev, &rdesc[i]->desc, &cfg); in rtq2208_probe()
608 rdev_map->rdev[idx] = rdev; in rtq2208_probe()
617 return devm_request_threaded_irq(dev, i2c->irq, NULL, rtq2208_irq_handler, in rtq2208_probe()