Re: [PATCH 2/3] regulator: qcom_usb_vbus: Add support for PMI8998 VBUS

Bryan O'Donoghue
2025-02-11T23:55:50Z

On 11/02/2025 19:49, James A. MacInnes wrote:
> + // Determine PMIC type
> + pmic_type = of_device_get_match_data(dev);
> + if (pmic_type && strcmp(pmic_type, "pmi8998") == 0) {
> + qcom_usb_vbus_rdesc.curr_table = curr_table_pmi8998;
> + qcom_usb_vbus_rdesc.n_current_limits =
> + ARRAY_SIZE(curr_table_pmi8998);
> + } else if (pmic_type && strcmp(pmic_type, "pm8150b") == 0) {
> + qcom_usb_vbus_rdesc.curr_table = curr_table_pm8150b;
> + qcom_usb_vbus_rdesc.n_current_limits =
> + ARRAY_SIZE(curr_table_pm8150b);
> + } else {
> + return -ENODEV;
> + }
> qcom_usb_vbus_rdesc.enable_reg = base + CMD_OTG;
> qcom_usb_vbus_rdesc.enable_mask = OTG_EN;
> qcom_usb_vbus_rdesc.csel_reg = base + OTG_CURRENT_LIMIT_CFG;
> @@ -80,18 +99,22 @@ static int qcom_usb_vbus_regulator_probe(struct platform_device *pdev)
> rdev = devm_regulator_register(dev, &qcom_usb_vbus_rdesc, &config);
> if (IS_ERR(rdev)) {
> ret = PTR_ERR(rdev);
> - dev_err(dev, "not able to register vbus reg %d\n", ret);
> + dev_err(dev, "Failed to register vbus reg %d\n", ret);
> return ret;
> }
>
> /* Disable HW logic for VBUS enable */
> regmap_update_bits(regmap, base + OTG_CFG, OTG_EN_SRC_CFG, 0);
>
> + dev_info(dev, "Registered QCOM %s VBUS regulator\n",
> + pmic_type);
> +
> return 0;
> }
>
> static const struct of_device_id qcom_usb_vbus_regulator_match[] = {
> - { .compatible = "qcom,pm8150b-vbus-reg" },
> + { .compatible = "qcom,pm8150b-vbus-reg", .data = "pm8150b" },
> + { .compatible = "qcom,pmi8998-vbus-reg", .data = "pmi8998" },

I think the other two said much the same thing but .data should point to
the differentiator instead of being a string which you disjoin on and
then hook your differentiated data.

i.e.

.data = &my_driver_specific_static_data_here.

---
bod