Lines Matching +full:- +full:5300000

1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/mfd/rohm-bd957x.h>
11 #include <linux/mfd/rohm-generic.h>
35 5200000, 5300000, 5400000, 5500000, 5500000,
137 const struct regulator_desc *desc = rdev->desc; in bd957x_vout34_list_voltage()
138 int multiplier = selector & desc->vsel_mask & 0x7f; in bd957x_vout34_list_voltage()
145 return desc->fixed_uV - tune; in bd957x_vout34_list_voltage()
147 return desc->fixed_uV + tune; in bd957x_vout34_list_voltage()
153 const struct regulator_desc *desc = rdev->desc; in bd957x_list_voltage()
154 int index = selector & desc->vsel_mask & 0x7f; in bd957x_list_voltage()
157 index += desc->n_voltages/2; in bd957x_list_voltage()
159 if (index >= desc->n_voltages) in bd957x_list_voltage()
160 return -EINVAL; in bd957x_list_voltage()
162 return desc->volt_table[index]; in bd957x_list_voltage()
169 data->ovd_notif = REGULATOR_EVENT_OVER_VOLTAGE_WARN; in bd9576_fill_ovd_flags()
170 data->ovd_err = REGULATOR_ERROR_OVER_VOLTAGE_WARN; in bd9576_fill_ovd_flags()
172 data->ovd_notif = REGULATOR_EVENT_REGULATION_OUT; in bd9576_fill_ovd_flags()
173 data->ovd_err = REGULATOR_ERROR_REGULATION_OUT; in bd9576_fill_ovd_flags()
181 data->uvd_notif = REGULATOR_EVENT_OVER_CURRENT_WARN; in bd9576_fill_ocp_flags()
182 data->uvd_err = REGULATOR_ERROR_OVER_CURRENT_WARN; in bd9576_fill_ocp_flags()
184 data->uvd_notif = REGULATOR_EVENT_OVER_CURRENT; in bd9576_fill_ocp_flags()
185 data->uvd_err = REGULATOR_ERROR_OVER_CURRENT; in bd9576_fill_ocp_flags()
193 data->uvd_notif = REGULATOR_EVENT_UNDER_VOLTAGE_WARN; in bd9576_fill_uvd_flags()
194 data->uvd_err = REGULATOR_ERROR_UNDER_VOLTAGE_WARN; in bd9576_fill_uvd_flags()
196 data->uvd_notif = REGULATOR_EVENT_UNDER_VOLTAGE; in bd9576_fill_uvd_flags()
197 data->uvd_err = REGULATOR_ERROR_UNDER_VOLTAGE; in bd9576_fill_uvd_flags()
205 data->temp_notif = 0; in bd9576_fill_temp_flags()
206 data->temp_err = 0; in bd9576_fill_temp_flags()
208 data->temp_notif = REGULATOR_EVENT_OVER_TEMP_WARN; in bd9576_fill_temp_flags()
209 data->temp_err = REGULATOR_ERROR_OVER_TEMP_WARN; in bd9576_fill_temp_flags()
211 data->temp_notif = REGULATOR_EVENT_OVER_TEMP; in bd9576_fill_temp_flags()
212 data->temp_err = REGULATOR_ERROR_OVER_TEMP; in bd9576_fill_temp_flags()
243 r->uvd_notif != REGULATOR_EVENT_OVER_CURRENT) || in check_ocp_flag_mismatch()
245 r->uvd_notif != REGULATOR_EVENT_OVER_CURRENT_WARN)) { in check_ocp_flag_mismatch()
262 r->uvd_notif != REGULATOR_EVENT_UNDER_VOLTAGE) || in check_uvd_flag_mismatch()
264 r->uvd_notif != REGULATOR_EVENT_UNDER_VOLTAGE_WARN)) { in check_uvd_flag_mismatch()
280 r->ovd_notif != REGULATOR_EVENT_REGULATION_OUT) || in check_ovd_flag_mismatch()
282 r->ovd_notif != REGULATOR_EVENT_OVER_VOLTAGE_WARN)) { in check_ovd_flag_mismatch()
298 r->temp_notif != REGULATOR_EVENT_OVER_TEMP) || in check_temp_flag_mismatch()
300 r->temp_notif != REGULATOR_EVENT_OVER_TEMP_WARN)) { in check_temp_flag_mismatch()
321 return -EINVAL; in bd9576_set_ocp()
323 r = container_of(rdev->desc, struct bd957x_regulator_data, desc); in bd9576_set_ocp()
324 if (!r->oc_supported) in bd9576_set_ocp()
325 return -EINVAL; in bd9576_set_ocp()
330 reg = r->ocp_reg; in bd9576_set_ocp()
331 mask = r->ocp_mask; in bd9576_set_ocp()
332 if (r->ocw_rfet) { in bd9576_set_ocp()
335 rfet = r->ocw_rfet / 1000; in bd9576_set_ocp()
339 /* Internal values are already micro-amperes */ in bd9576_set_ocp()
343 reg = r->ocw_reg; in bd9576_set_ocp()
344 mask = r->ocw_mask; in bd9576_set_ocp()
346 if (r->ocw_rfet) { in bd9576_set_ocp()
349 rfet = r->ocw_rfet / 1000; in bd9576_set_ocp()
353 /* Internal values are already micro-amperes */ in bd9576_set_ocp()
358 if (r->uvd_notif) { in bd9576_set_ocp()
380 return bd9576_set_limit(range, num_ranges, d->regmap, in bd9576_set_ocp()
393 return -EINVAL; in bd9576_set_uvp()
402 return -EINVAL; in bd9576_set_uvp()
404 r = container_of(rdev->desc, struct bd957x_regulator_data, desc); in bd9576_set_uvp()
407 mask = r->xvd_mask; in bd9576_set_uvp()
408 reg = r->uvd_reg; in bd9576_set_uvp()
413 if (r->uvd_notif) { in bd9576_set_uvp()
420 return bd9576_set_limit(r->xvd_ranges, r->num_xvd_ranges, d->regmap, in bd9576_set_uvp()
433 return -EINVAL; in bd9576_set_ovp()
442 return -EINVAL; in bd9576_set_ovp()
444 r = container_of(rdev->desc, struct bd957x_regulator_data, desc); in bd9576_set_ovp()
447 mask = r->xvd_mask; in bd9576_set_ovp()
448 reg = r->ovd_reg; in bd9576_set_ovp()
453 if (r->ovd_notif) { in bd9576_set_ovp()
460 return bd9576_set_limit(r->xvd_ranges, r->num_xvd_ranges, d->regmap, in bd9576_set_ovp()
477 return -EINVAL; in bd9576_set_tw()
482 return -EINVAL; in bd9576_set_tw()
487 r = container_of(rdev->desc, struct bd957x_regulator_data, desc); in bd9576_set_tw()
494 if (r->temp_notif) in bd9576_set_tw()
501 return regmap_update_bits(d->regmap, BD957X_REG_INT_THERM_MASK, in bd9576_set_tw()
509 if (d->regulator_data[i].temp_notif) in bd9576_set_tw()
512 return regmap_update_bits(d->regmap, BD957X_REG_INT_THERM_MASK, in bd9576_set_tw()
584 ret = of_property_read_u32(np, "rohm,ocw-fet-ron-micro-ohms", &uohms); in vouts1_get_fet_res()
586 if (ret != -EINVAL) in vouts1_get_fet_res()
591 data->ocw_rfet = uohms; in vouts1_get_fet_res()
600 .of_match = of_match_ptr("regulator-vd50"),
623 .of_match = of_match_ptr("regulator-vd18"),
646 .of_match = of_match_ptr("regulator-vdddr"),
668 .of_match = of_match_ptr("regulator-vd10"),
691 .of_match = of_match_ptr("regulator-voutl1"),
714 .of_match = of_match_ptr("regulator-vouts1"),
739 struct bd957x_data *d = (struct bd957x_data *)rid->data; in bd9576_renable()
741 ret = regmap_read(d->regmap, reg, &val); in bd9576_renable()
745 if (rid->opaque && rid->opaque == (val & mask)) { in bd9576_renable()
751 regmap_write(d->regmap, reg, mask & val); in bd9576_renable()
754 rid->opaque = 0; in bd9576_renable()
757 * Let's re-enable IRQs and be prepared to report problems again in bd9576_renable()
782 struct bd957x_data *d = (struct bd957x_data *)rid->data; in bd9576_uvd_handler()
784 ret = regmap_read(d->regmap, BD957X_REG_INT_UVD_STAT, &val); in bd9576_uvd_handler()
790 rid->opaque = val & UVD_IRQ_VALID_MASK; in bd9576_uvd_handler()
809 rdata = &d->regulator_data[i]; in bd9576_uvd_handler()
810 stat = &rid->states[i]; in bd9576_uvd_handler()
812 stat->notifs = rdata->uvd_notif; in bd9576_uvd_handler()
813 stat->errors = rdata->uvd_err; in bd9576_uvd_handler()
816 ret = regmap_write(d->regmap, BD957X_REG_INT_UVD_STAT, in bd9576_uvd_handler()
826 struct bd957x_data *d = (struct bd957x_data *)rid->data; in bd9576_ovd_handler()
828 ret = regmap_read(d->regmap, BD957X_REG_INT_OVD_STAT, &val); in bd9576_ovd_handler()
832 rid->opaque = val & OVD_IRQ_VALID_MASK; in bd9576_ovd_handler()
846 rdata = &d->regulator_data[i]; in bd9576_ovd_handler()
847 stat = &rid->states[i]; in bd9576_ovd_handler()
849 stat->notifs = rdata->ovd_notif; in bd9576_ovd_handler()
850 stat->errors = rdata->ovd_err; in bd9576_ovd_handler()
853 /* Clear the sub-IRQ status */ in bd9576_ovd_handler()
854 regmap_write(d->regmap, BD957X_REG_INT_OVD_STAT, in bd9576_ovd_handler()
866 struct bd957x_data *d = (struct bd957x_data *)rid->data; in bd9576_thermal_handler()
868 ret = regmap_read(d->regmap, BD957X_REG_INT_THERM_STAT, &val); in bd9576_thermal_handler()
883 rdata = &d->regulator_data[i]; in bd9576_thermal_handler()
884 stat = &rid->states[i]; in bd9576_thermal_handler()
886 stat->notifs = rdata->temp_notif; in bd9576_thermal_handler()
887 stat->errors = rdata->temp_err; in bd9576_thermal_handler()
890 /* Clear the sub-IRQ status */ in bd9576_thermal_handler()
891 regmap_write(d->regmap, BD957X_REG_INT_THERM_STAT, in bd9576_thermal_handler()
910 .name = "bd9576-uvd", in bd957x_probe()
917 .name = "bd9576-ovd", in bd957x_probe()
924 .name = "bd9576-temp", in bd957x_probe()
930 enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data; in bd957x_probe()
936 regmap = dev_get_regmap(pdev->dev.parent, NULL); in bd957x_probe()
938 dev_err(&pdev->dev, "No regmap\n"); in bd957x_probe()
939 return -EINVAL; in bd957x_probe()
942 ic_data->regmap = regmap; in bd957x_probe()
943 vout_mode = device_property_read_bool(pdev->dev.parent, in bd957x_probe()
944 "rohm,vout1-en-low"); in bd957x_probe()
948 dev_dbg(&pdev->dev, "GPIO controlled mode\n"); in bd957x_probe()
952 en = devm_fwnode_gpiod_get(&pdev->dev, in bd957x_probe()
953 dev_fwnode(pdev->dev.parent), in bd957x_probe()
954 "rohm,vout1-en", GPIOD_OUT_LOW, in bd957x_probe()
955 "vout1-en"); in bd957x_probe()
963 * In theory it is possible someone wants to set vout1-en LOW in bd957x_probe()
964 * during OTP loading and set VOUT1 to be controlled by GPIO - in bd957x_probe()
969 * I believe such case where rohm,vout1-en-low is set and in bd957x_probe()
970 * vout1-en-gpios is not is likely to be a misconfiguration. in bd957x_probe()
976 return dev_err_probe(&pdev->dev, PTR_ERR(en), in bd957x_probe()
983 * template. At the moment I see no such use-case so I spare some in bd957x_probe()
984 * bytes and use bd9576_regulators directly for non-constant configs in bd957x_probe()
988 ddr_sel = device_property_read_bool(pdev->dev.parent, in bd957x_probe()
989 "rohm,ddr-sel-low"); in bd957x_probe()
991 ic_data->regulator_data[2].desc.fixed_uV = 1350000; in bd957x_probe()
993 ic_data->regulator_data[2].desc.fixed_uV = 1500000; in bd957x_probe()
998 dev_dbg(&pdev->dev, "Found BD9576MUF\n"); in bd957x_probe()
1001 dev_dbg(&pdev->dev, "Found BD9573MUF\n"); in bd957x_probe()
1004 dev_err(&pdev->dev, "Unsupported chip type\n"); in bd957x_probe()
1005 return -EINVAL; in bd957x_probe()
1011 d = &ic_data->regulator_data[i].desc; in bd957x_probe()
1015 if (d->id >= ARRAY_SIZE(bd9576_ops_arr)) in bd957x_probe()
1016 return -EINVAL; in bd957x_probe()
1018 d->ops = bd9576_ops_arr[d->id]; in bd957x_probe()
1020 if (d->id >= ARRAY_SIZE(bd9573_ops_arr)) in bd957x_probe()
1021 return -EINVAL; in bd957x_probe()
1023 d->ops = bd9573_ops_arr[d->id]; in bd957x_probe()
1027 config.dev = pdev->dev.parent; in bd957x_probe()
1033 struct bd957x_regulator_data *r = &ic_data->regulator_data[i]; in bd957x_probe()
1034 const struct regulator_desc *desc = &r->desc; in bd957x_probe()
1036 r->rdev = devm_regulator_register(&pdev->dev, desc, in bd957x_probe()
1038 if (IS_ERR(r->rdev)) in bd957x_probe()
1039 return dev_err_probe(&pdev->dev, PTR_ERR(r->rdev), in bd957x_probe()
1041 desc->name); in bd957x_probe()
1043 * Clear the VOUT1 GPIO setting - rest of the regulators do not in bd957x_probe()
1051 rdevs[i] = r->rdev; in bd957x_probe()
1053 ovd_devs[i] = r->rdev; in bd957x_probe()
1060 * if we use warnings - errors are always clear and the other in bd957x_probe()
1063 * to setting UVD for VoutS1 - it is not accidentally cleared in bd957x_probe()
1076 irq = platform_get_irq_byname(pdev, "bd9576-uvd"); in bd957x_probe()
1078 /* Register notifiers - can fail if IRQ is not given */ in bd957x_probe()
1079 ret = devm_regulator_irq_helper(&pdev->dev, &bd9576_notif_uvd, in bd957x_probe()
1084 if (PTR_ERR(ret) == -EPROBE_DEFER) in bd957x_probe()
1085 return -EPROBE_DEFER; in bd957x_probe()
1087 dev_warn(&pdev->dev, "UVD disabled %pe\n", ret); in bd957x_probe()
1090 irq = platform_get_irq_byname(pdev, "bd9576-ovd"); in bd957x_probe()
1092 ret = devm_regulator_irq_helper(&pdev->dev, &bd9576_notif_ovd, in bd957x_probe()
1097 if (PTR_ERR(ret) == -EPROBE_DEFER) in bd957x_probe()
1098 return -EPROBE_DEFER; in bd957x_probe()
1100 dev_warn(&pdev->dev, "OVD disabled %pe\n", ret); in bd957x_probe()
1102 irq = platform_get_irq_byname(pdev, "bd9576-temp"); in bd957x_probe()
1104 ret = devm_regulator_irq_helper(&pdev->dev, &bd9576_notif_temp, in bd957x_probe()
1109 if (PTR_ERR(ret) == -EPROBE_DEFER) in bd957x_probe()
1110 return -EPROBE_DEFER; in bd957x_probe()
1112 dev_warn(&pdev->dev, "Thermal warning disabled %pe\n", in bd957x_probe()
1120 { "bd9573-regulator", ROHM_CHIP_TYPE_BD9573 },
1121 { "bd9576-regulator", ROHM_CHIP_TYPE_BD9576 },
1128 .name = "bd957x-pmic",
1140 MODULE_ALIAS("platform:bd957x-pmic");