linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Satya Priya <quic_c_skakit@quicinc.com>
Cc: Lee Jones <lee.jones@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, quic_collinsd@quicinc.com,
	quic_subbaram@quicinc.com, quic_jprakash@quicinc.com
Subject: Re: [PATCH V10 7/9] regulator: Add a regulator driver for the PM8008 PMIC
Date: Thu, 14 Apr 2022 17:25:49 -0700	[thread overview]
Message-ID: <CAE-0n533obTi995x_rJG_ihUUquF3MQLJt6VMf7=oxyzMUL5DQ@mail.gmail.com> (raw)
In-Reply-To: <1649939418-19861-8-git-send-email-quic_c_skakit@quicinc.com>

Quoting Satya Priya (2022-04-14 05:30:16)
> diff --git a/drivers/regulator/qcom-pm8008-regulator.c b/drivers/regulator/qcom-pm8008-regulator.c
> new file mode 100644
> index 0000000..4375ac5
> --- /dev/null
> +++ b/drivers/regulator/qcom-pm8008-regulator.c
> @@ -0,0 +1,201 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (c) 2022, The Linux Foundation. All rights reserved. */
> +
[..]
> +
> +static int pm8008_regulator_probe(struct platform_device *pdev)
> +{
> +       struct pm8008_data *chip = dev_get_drvdata(pdev->dev.parent);
> +       struct device *dev = &pdev->dev;
> +       struct regulator_dev    *rdev;
> +       struct pm8008_regulator *pm8008_reg;
> +       struct regmap *regmap;
> +       struct regulator_config reg_config = {};
> +       int rc, i;
> +       unsigned int reg;
> +
> +       regmap = pm8008_get_regmap(chip, PM8008_REGULATORS_SID);

Can we use dev_get_regmap(pdev->dev.parent, "regulators") here
instead? The benefit to that is we don't tightly couple this driver to
the pm8008_data structure or header file.

> +       if (!regmap) {
> +               dev_err(dev, "parent regmap is missing\n");
> +               return -EINVAL;
> +       }
> +
> +       for (i = 0; i < ARRAY_SIZE(reg_data); i++) {
> +               pm8008_reg = devm_kzalloc(dev, sizeof(*pm8008_reg), GFP_KERNEL);
> +               if (!pm8008_reg)
> +                       return -ENOMEM;
> +
> +               pm8008_reg->regmap = regmap;
> +               pm8008_reg->dev = dev;
> +               pm8008_reg->base = reg_data[i].base;
> +
> +               /* get slew rate */
> +               rc = regmap_bulk_read(pm8008_reg->regmap,
> +                               LDO_STEPPER_CTL_REG(pm8008_reg->base), &reg, 1);
> +               if (rc < 0) {
> +                       dev_err(dev, "failed to read step rate configuration rc=%d\n", rc);
> +                       return rc;
> +               }
> +               reg &= STEP_RATE_MASK;
> +               pm8008_reg->step_rate = DEFAULT_VOLTAGE_STEPPER_RATE >> reg;
> +
> +               pm8008_reg->rdesc.type = REGULATOR_VOLTAGE;
> +               pm8008_reg->rdesc.ops = &pm8008_regulator_ops;
> +               pm8008_reg->rdesc.name = reg_data[i].name;
> +               pm8008_reg->rdesc.supply_name = reg_data[i].supply_name;
> +               pm8008_reg->rdesc.of_match = reg_data[i].name;
> +               pm8008_reg->rdesc.uV_step = VSET_STEP_UV;
> +               pm8008_reg->rdesc.min_uV = reg_data[i].min_uv;
> +               pm8008_reg->rdesc.n_voltages
> +                       = ((reg_data[i].max_uv - reg_data[i].min_uv)
> +                               / pm8008_reg->rdesc.uV_step) + 1;
> +               pm8008_reg->rdesc.linear_ranges = reg_data[i].voltage_range;
> +               pm8008_reg->rdesc.n_linear_ranges = 1;
> +               pm8008_reg->rdesc.enable_reg = LDO_ENABLE_REG(pm8008_reg->base);
> +               pm8008_reg->rdesc.enable_mask = ENABLE_BIT;
> +               pm8008_reg->rdesc.min_dropout_uV = reg_data[i].min_dropout_uv;
> +               pm8008_reg->voltage_selector = -ENOTRECOVERABLE;
> +               pm8008_reg->rdesc.regulators_node = of_match_ptr("regulators");
> +
> +               reg_config.dev = dev->parent;
> +               reg_config.driver_data = pm8008_reg;
> +
> +               rdev = devm_regulator_register(dev, &pm8008_reg->rdesc, &reg_config);
> +               if (IS_ERR(rdev)) {
> +                       rc = PTR_ERR(rdev);
> +                       dev_err(dev, "%s: failed to register regulator rc=%d\n",
> +                                       reg_data[i].name, rc);
> +                       return rc;
> +               }
> +       }
> +
> +       return 0;
> +}
> +
> +static struct platform_driver pm8008_regulator_driver = {
> +       .driver = {
> +               .name           = "qcom-pm8008-regulator",

I'd prefer to use an of_device_id table here. That would let us populate
a "qcom,pm8008-regulators" node that had the ldo nodes as children and
avoid mfd cells.

  reply	other threads:[~2022-04-15  0:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 12:30 [PATCH V10 0/9] Add Qualcomm Technologies, Inc. PM8008 regulator driver Satya Priya
2022-04-14 12:30 ` [PATCH V10 1/9] dt-bindings: mfd: pm8008: Add reset-gpios Satya Priya
2022-04-14 12:30 ` [PATCH V10 2/9] dt-bindings: regulator: pm8008: Add pm8008 regulator bindings Satya Priya
2022-04-19 17:57   ` Rob Herring
2022-04-14 12:30 ` [PATCH V10 3/9] dt-bindings: mfd: pm8008: Add regulators Satya Priya
2022-04-19 17:57   ` Rob Herring
2022-04-14 12:30 ` [PATCH V10 4/9] mfd: pm8008: Add reset-gpios Satya Priya
2022-04-15  0:10   ` Stephen Boyd
2022-04-18  5:04     ` Satya Priya Kakitapalli (Temp)
     [not found]       ` <a4cbdb4c-dbba-75ee-202a-6b429c0eb390@quicinc.com>
2022-04-27  6:03         ` Satya Priya Kakitapalli (Temp)
2022-04-27  6:30           ` Stephen Boyd
2022-04-27 13:48             ` Satya Priya Kakitapalli (Temp)
2022-04-14 12:30 ` [PATCH V10 5/9] mfd: pm8008: Use i2c_new_dummy_device() API Satya Priya
2022-04-15  0:21   ` Stephen Boyd
2022-04-18 15:08     ` Satya Priya Kakitapalli (Temp)
2022-04-18 19:23       ` Stephen Boyd
2022-04-19  6:04         ` Satya Priya Kakitapalli (Temp)
2022-04-14 12:30 ` [PATCH V10 6/9] mfd: pm8008: Add mfd_cell struct to register LDOs Satya Priya
2022-04-15  0:23   ` Stephen Boyd
2022-04-18 15:09     ` Satya Priya Kakitapalli (Temp)
2022-04-14 12:30 ` [PATCH V10 7/9] regulator: Add a regulator driver for the PM8008 PMIC Satya Priya
2022-04-15  0:25   ` Stephen Boyd [this message]
2022-04-19 14:55     ` Mark Brown
2022-04-19 15:45       ` Stephen Boyd
2022-04-19 16:44         ` Mark Brown
2022-04-14 12:30 ` [PATCH V10 8/9] arm64: dts: qcom: pm8008: Add base dts file Satya Priya
2022-04-15  0:27   ` Stephen Boyd
2022-04-14 12:30 ` [PATCH V10 9/9] arm64: dts: qcom: sc7280: Add pm8008 support for sc7280-idp Satya Priya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAE-0n533obTi995x_rJG_ihUUquF3MQLJt6VMf7=oxyzMUL5DQ@mail.gmail.com' \
    --to=swboyd@chromium.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_c_skakit@quicinc.com \
    --cc=quic_collinsd@quicinc.com \
    --cc=quic_jprakash@quicinc.com \
    --cc=quic_subbaram@quicinc.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).