diff mbox series

[v3,5/5] pmic: qcom: dont use dev_read_addr to get USID

Message ID 20231114-b4-qcom-dt-compat-v3-5-88a92f8f00ba@linaro.org
State New
Headers show
Series Qualcomm PMIC fixes | expand

Commit Message

Caleb Connolly Nov. 14, 2023, 1:48 p.m. UTC
Linux DTs stuff a value indicating if the USID is a USID or a GSID in the
reg property, the Linux SPMI driver then reads the two address cells
separately. U-boot's dev_read_addr() doesn't know how to handle this, so
use ofnode_read_u32_index() to get just the USID.

The Qcom pmic driver doesn't have support for GSID handling, so just
ignore the second value for now.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 drivers/power/pmic/pmic_qcom.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Sumit Garg Nov. 17, 2023, 10:33 a.m. UTC | #1
On Tue, 14 Nov 2023 at 19:18, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>
> Linux DTs stuff a value indicating if the USID is a USID or a GSID in the
> reg property, the Linux SPMI driver then reads the two address cells
> separately. U-boot's dev_read_addr() doesn't know how to handle this, so
> use ofnode_read_u32_index() to get just the USID.
>
> The Qcom pmic driver doesn't have support for GSID handling, so just
> ignore the second value for now.
>

Since you are trying to add Linux DT bindings compatibility here, I
suggest you drop custom u-boot binding here:
doc/device-tree-bindings/pmic/qcom,spmi-pmic.txt.

-Sumit

> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>  drivers/power/pmic/pmic_qcom.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/power/pmic/pmic_qcom.c b/drivers/power/pmic/pmic_qcom.c
> index ad8daf43f06f..f2ac6494811d 100644
> --- a/drivers/power/pmic/pmic_qcom.c
> +++ b/drivers/power/pmic/pmic_qcom.c
> @@ -66,12 +66,19 @@ static const struct udevice_id pmic_qcom_ids[] = {
>  static int pmic_qcom_probe(struct udevice *dev)
>  {
>         struct pmic_qcom_priv *priv = dev_get_priv(dev);
> +       int ret;
>
> -       priv->usid = dev_read_addr(dev);
> -
> -       if (priv->usid == FDT_ADDR_T_NONE)
> +       /*
> +        * dev_read_addr() can't be used here because the reg property actually
> +        * contains two discrete values, not a single 64-bit address.
> +        * The address is the first value.
> +        */
> +       ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 0, &priv->usid);
> +       if (ret < 0)
>                 return -EINVAL;
>
> +       debug("usid: %d\n", priv->usid);
> +
>         return 0;
>  }
>
>
> --
> 2.42.1
>
diff mbox series

Patch

diff --git a/drivers/power/pmic/pmic_qcom.c b/drivers/power/pmic/pmic_qcom.c
index ad8daf43f06f..f2ac6494811d 100644
--- a/drivers/power/pmic/pmic_qcom.c
+++ b/drivers/power/pmic/pmic_qcom.c
@@ -66,12 +66,19 @@  static const struct udevice_id pmic_qcom_ids[] = {
 static int pmic_qcom_probe(struct udevice *dev)
 {
 	struct pmic_qcom_priv *priv = dev_get_priv(dev);
+	int ret;
 
-	priv->usid = dev_read_addr(dev);
-
-	if (priv->usid == FDT_ADDR_T_NONE)
+	/*
+	 * dev_read_addr() can't be used here because the reg property actually
+	 * contains two discrete values, not a single 64-bit address.
+	 * The address is the first value.
+	 */
+	ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 0, &priv->usid);
+	if (ret < 0)
 		return -EINVAL;
 
+	debug("usid: %d\n", priv->usid);
+
 	return 0;
 }