From: Stephan Gerhold <stephan@gerhold.net>
To: Caleb Connolly <caleb.connolly@linaro.org>
Cc: Ramon Fried <rfried.dev@gmail.com>,
Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Sumit Garg <sumit.garg@linaro.org>,
Mateusz Kulikowski <mateusz.kulikowski@gmail.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Dzmitry Sankouski <dsankouski@gmail.com>,
u-boot@lists.denx.de
Subject: Re: [PATCH v2 3/5] gpio: qcom_pmic: fix support for upstream DT
Date: Thu, 9 Nov 2023 15:35:56 +0100 [thread overview]
Message-ID: <ZUzuTFFiz2KdpODs@gerhold.net> (raw)
In-Reply-To: <20231108-b4-qcom-dt-compat-v2-3-713233c72948@linaro.org>
On Wed, Nov 08, 2023 at 04:20:55PM +0000, Caleb Connolly wrote:
> Linux devicetrees use the "gpio-ranges" property, add support for
> parsing it instead of "gpio-count" so that upstream DTs can be used with
> U-Boot.
>
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
> drivers/gpio/qcom_pmic_gpio.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c
> index 7b83c67fa464..647d4143ce14 100644
> --- a/drivers/gpio/qcom_pmic_gpio.c
> +++ b/drivers/gpio/qcom_pmic_gpio.c
> @@ -245,11 +245,37 @@ static int qcom_gpio_probe(struct udevice *dev)
> return 0;
> }
>
> +/*
> + * Parse basic GPIO count specified via the gpio-ranges property
> + * as specified in Linux devicetrees
> + * Returns < 0 on error, otherwise gpio count
> + */
> +static int qcom_gpio_of_parse_ranges(struct udevice *dev)
> +{
> + int ret;
> + struct ofnode_phandle_args args;
> +
> + ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), "gpio-ranges",
> + NULL, 3, 0, &args);
> + if (ret)
> + return log_msg_ret("gpio-ranges", ret);
> +
> + return args.args[2];
> +}
> +
> static int qcom_gpio_of_to_plat(struct udevice *dev)
> {
> struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> + int ret;
>
> uc_priv->gpio_count = dev_read_u32_default(dev, "gpio-count", 0);
> + if (!uc_priv->gpio_count) {
> + ret = qcom_gpio_of_parse_ranges(dev);
> + if (ret > 0)
> + uc_priv->gpio_count = ret;
> + else
> + printf("gpio-ranges error: %d\n", ret);
> + }
I would drop support for the non-standard gpio-count and instead adjust
the existing device trees to use gpio-ranges (copied from the upstream
DTs).
> uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name");
> if (uc_priv->bank_name == NULL)
> uc_priv->bank_name = "qcom_pmic";
>
Maybe you can replace this property as well while you're at it. Perhaps
the default fallback name is sufficient. Alternatively one could
obtain the actual PMIC name from the compatible or similar.
Thanks,
Stephan
next prev parent reply other threads:[~2023-11-09 14:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 16:20 [PATCH v2 0/5] Qualcomm PMIC fixes Caleb Connolly
2023-11-08 16:20 ` [PATCH v2 1/5] gpio: qcom_pmic: fix silent dev_read_addr downcast Caleb Connolly
2023-11-08 16:20 ` [PATCH v2 2/5] gpio: qcom_pmic: rework pwrkey driver into a button driver Caleb Connolly
2023-11-09 14:27 ` Stephan Gerhold
2023-11-08 16:20 ` [PATCH v2 3/5] gpio: qcom_pmic: fix support for upstream DT Caleb Connolly
2023-11-09 14:35 ` Stephan Gerhold [this message]
2023-11-08 16:20 ` [PATCH v2 4/5] spmi: msm: fix register range names Caleb Connolly
2023-11-08 16:20 ` [PATCH v2 5/5] pmic: qcom: dont use dev_read_addr to get USID Caleb Connolly
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=ZUzuTFFiz2KdpODs@gerhold.net \
--to=stephan@gerhold.net \
--cc=caleb.connolly@linaro.org \
--cc=dsankouski@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=jorge.ramirez.ortiz@gmail.com \
--cc=mateusz.kulikowski@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=rfried.dev@gmail.com \
--cc=sumit.garg@linaro.org \
--cc=u-boot@lists.denx.de \
/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