Lines Matching +full:0 +full:- +full:6

1 // SPDX-License-Identifier: GPL-2.0+
3 // da9052-regulator.c: Regulator driver for DA9052
28 #define DA9052_MIN_UA 0
33 #define DA9052_BUCK_ILIM_MASK_EVEN 0x0c
34 #define DA9052_BUCK_ILIM_MASK_ODD 0xc0
37 #define DA9052_ID_BUCK1 0
43 #define DA9052_ID_LDO3 6
53 {700000, 800000, 1000000, 1200000}, /* DA9052-BC BUCKs */
54 {1600000, 2000000, 2400000, 3000000}, /* DA9053-AA/Bx BUCK-CORE */
55 {800000, 1000000, 1200000, 1500000}, /* DA9053-AA/Bx BUCK-PRO,
56 * BUCK-MEM and BUCK-PERI
77 if (min_uV > info->max_uV || max_uV < info->min_uV) in verify_range()
78 return -EINVAL; in verify_range()
80 return 0; in verify_range()
89 ret = da9052_reg_read(regulator->da9052, DA9052_BUCKA_REG + offset/2); in da9052_dcdc_get_current_limit()
90 if (ret < 0) in da9052_dcdc_get_current_limit()
96 if (offset % 2 == 0) in da9052_dcdc_get_current_limit()
99 ret = (ret & DA9052_BUCK_ILIM_MASK_ODD) >> 6; in da9052_dcdc_get_current_limit()
102 if (regulator->da9052->chip_id == DA9052) in da9052_dcdc_get_current_limit()
103 row = 0; in da9052_dcdc_get_current_limit()
104 else if (offset == 0) in da9052_dcdc_get_current_limit()
115 int reg_val = 0; in da9052_dcdc_set_current_limit()
119 if (regulator->da9052->chip_id == DA9052) in da9052_dcdc_set_current_limit()
120 row = 0; in da9052_dcdc_set_current_limit()
121 else if (offset == 0) in da9052_dcdc_set_current_limit()
124 for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) { in da9052_dcdc_set_current_limit()
132 if (i < 0) in da9052_dcdc_set_current_limit()
133 return -EINVAL; in da9052_dcdc_set_current_limit()
138 if (offset % 2 == 0) in da9052_dcdc_set_current_limit()
139 return da9052_reg_update(regulator->da9052, in da9052_dcdc_set_current_limit()
144 return da9052_reg_update(regulator->da9052, in da9052_dcdc_set_current_limit()
147 reg_val << 6); in da9052_dcdc_set_current_limit()
154 struct da9052_regulator_info *info = regulator->info; in da9052_list_voltage()
158 if ((id == DA9052_ID_BUCK4) && (regulator->da9052->chip_id == DA9052) in da9052_list_voltage()
160 volt_uV = ((DA9052_BUCK_PERI_REG_MAP_UPTO_3uV * info->step_uV) in da9052_list_voltage()
161 + info->min_uV); in da9052_list_voltage()
162 volt_uV += (selector - DA9052_BUCK_PERI_REG_MAP_UPTO_3uV) in da9052_list_voltage()
165 volt_uV = (selector * info->step_uV) + info->min_uV; in da9052_list_voltage()
168 if (volt_uV > info->max_uV) in da9052_list_voltage()
169 return -EINVAL; in da9052_list_voltage()
178 struct da9052_regulator_info *info = regulator->info; in da9052_map_voltage()
183 if (ret < 0) in da9052_map_voltage()
186 if (min_uV < info->min_uV) in da9052_map_voltage()
187 min_uV = info->min_uV; in da9052_map_voltage()
189 if ((id == DA9052_ID_BUCK4) && (regulator->da9052->chip_id == DA9052) in da9052_map_voltage()
192 DIV_ROUND_UP(min_uV - DA9052_CONST_3uV, in da9052_map_voltage()
195 sel = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV); in da9052_map_voltage()
199 if (ret < 0) in da9052_map_voltage()
209 struct da9052_regulator_info *info = regulator->info; in da9052_regulator_set_voltage_sel()
213 ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg, in da9052_regulator_set_voltage_sel()
214 rdev->desc->vsel_mask, selector); in da9052_regulator_set_voltage_sel()
215 if (ret < 0) in da9052_regulator_set_voltage_sel()
227 ret = da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG, in da9052_regulator_set_voltage_sel()
228 info->activate_bit, info->activate_bit); in da9052_regulator_set_voltage_sel()
240 struct da9052_regulator_info *info = regulator->info; in da9052_regulator_set_voltage_time_sel()
242 int ret = 0; in da9052_regulator_set_voltage_time_sel()
253 ret = (new_sel - old_sel) * info->step_uV / 6250; in da9052_regulator_set_voltage_time_sel()
294 .n_voltages = (max - min) / step + 1, \
297 .vsel_mask = (1 << (sbits)) - 1,\
316 .n_voltages = (max - min) / step + 1, \
319 .vsel_mask = (1 << (sbits)) - 1,\
330 DA9052_DCDC(BUCK1, buck1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
331 DA9052_DCDC(BUCK2, buck2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
332 DA9052_DCDC(BUCK3, buck3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
333 DA9052_DCDC(BUCK4, buck4, 50, 1800, 3600, 5, 6, 0),
334 DA9052_LDO(LDO1, ldo1, 50, 600, 1800, 5, 6, 0),
335 DA9052_LDO(LDO2, ldo2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
336 DA9052_LDO(LDO3, ldo3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
337 DA9052_LDO(LDO4, ldo4, 25, 1725, 3300, 6, 6, 0),
338 DA9052_LDO(LDO5, ldo5, 50, 1200, 3600, 6, 6, 0),
339 DA9052_LDO(LDO6, ldo6, 50, 1200, 3600, 6, 6, 0),
340 DA9052_LDO(LDO7, ldo7, 50, 1200, 3600, 6, 6, 0),
341 DA9052_LDO(LDO8, ldo8, 50, 1200, 3600, 6, 6, 0),
342 DA9052_LDO(LDO9, ldo9, 50, 1250, 3650, 6, 6, 0),
343 DA9052_LDO(LDO10, ldo10, 50, 1200, 3600, 6, 6, 0),
347 DA9052_DCDC(BUCK1, buck1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
348 DA9052_DCDC(BUCK2, buck2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
349 DA9052_DCDC(BUCK3, buck3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
350 DA9052_DCDC(BUCK4, buck4, 25, 950, 2525, 6, 6, 0),
351 DA9052_LDO(LDO1, ldo1, 50, 600, 1800, 5, 6, 0),
352 DA9052_LDO(LDO2, ldo2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
353 DA9052_LDO(LDO3, ldo3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
354 DA9052_LDO(LDO4, ldo4, 25, 1725, 3300, 6, 6, 0),
355 DA9052_LDO(LDO5, ldo5, 50, 1200, 3600, 6, 6, 0),
356 DA9052_LDO(LDO6, ldo6, 50, 1200, 3600, 6, 6, 0),
357 DA9052_LDO(LDO7, ldo7, 50, 1200, 3600, 6, 6, 0),
358 DA9052_LDO(LDO8, ldo8, 50, 1200, 3600, 6, 6, 0),
359 DA9052_LDO(LDO9, ldo9, 50, 1250, 3650, 6, 6, 0),
360 DA9052_LDO(LDO10, ldo10, 50, 1200, 3600, 6, 6, 0),
371 for (i = 0; i < ARRAY_SIZE(da9052_regulator_info); i++) { in find_regulator_info()
373 if (info->reg_desc.id == id) in find_regulator_info()
381 for (i = 0; i < ARRAY_SIZE(da9053_regulator_info); i++) { in find_regulator_info()
383 if (info->reg_desc.id == id) in find_regulator_info()
400 regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator), in da9052_regulator_probe()
403 return -ENOMEM; in da9052_regulator_probe()
405 da9052 = dev_get_drvdata(pdev->dev.parent); in da9052_regulator_probe()
406 pdata = dev_get_platdata(da9052->dev); in da9052_regulator_probe()
407 regulator->da9052 = da9052; in da9052_regulator_probe()
409 regulator->info = find_regulator_info(regulator->da9052->chip_id, in da9052_regulator_probe()
410 cell->id); in da9052_regulator_probe()
411 if (regulator->info == NULL) { in da9052_regulator_probe()
412 dev_err(&pdev->dev, "invalid regulator ID specified\n"); in da9052_regulator_probe()
413 return -EINVAL; in da9052_regulator_probe()
416 config.dev = da9052->dev; in da9052_regulator_probe()
418 config.regmap = da9052->regmap; in da9052_regulator_probe()
420 config.init_data = pdata->regulators[cell->id]; in da9052_regulator_probe()
422 regulator->rdev = devm_regulator_register(&pdev->dev, in da9052_regulator_probe()
423 &regulator->info->reg_desc, in da9052_regulator_probe()
425 if (IS_ERR(regulator->rdev)) { in da9052_regulator_probe()
426 dev_err(&pdev->dev, "failed to register regulator %s\n", in da9052_regulator_probe()
427 regulator->info->reg_desc.name); in da9052_regulator_probe()
428 return PTR_ERR(regulator->rdev); in da9052_regulator_probe()
433 return 0; in da9052_regulator_probe()
439 .name = "da9052-regulator",
458 MODULE_ALIAS("platform:da9052-regulator");