sandbox: spmi: Add ranges property for address translation
authorSimon Glass <sjg@chromium.org>
Wed, 25 Sep 2019 14:55:59 +0000 (08:55 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Tue, 8 Oct 2019 05:57:39 +0000 (13:57 +0800)
At present address translation does not work since there is no ranges
property in the spmi nodes. Add empty ranges properties and a little more
logging so that this shows the error:

   /tmp/b/sandbox/u-boot -d /tmp/b/sandbox/arch/sandbox/dts/test.dtb \
-c "ut dm spmi_access_peripheral" -L7 -v
   ...
   pm8916_gpio_probe() bad address: returning err=-22

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
arch/sandbox/dts/test.dts
drivers/gpio/pm8916_gpio.c

index 27b0baab2781717ddbaf2a9128666275f4bb6ef0..50d245ae91760114b5a507aecedcb0fedb462975 100644 (file)
                compatible = "sandbox,spmi";
                #address-cells = <0x1>;
                #size-cells = <0x1>;
+               ranges;
                pm8916@0 {
                        compatible = "qcom,spmi-pmic";
                        reg = <0x0 0x1>;
                        #address-cells = <0x1>;
                        #size-cells = <0x1>;
+                       ranges;
 
                        spmi_gpios: gpios@c000 {
                                compatible = "qcom,pm8916-gpio";
index bbe214d5eea972c71596794ffba62d2fdb3e1602..74a773c099b9d5871ea078564bc6e9cf53cc6265 100644 (file)
@@ -172,16 +172,16 @@ static int pm8916_gpio_probe(struct udevice *dev)
 
        priv->pid = dev_read_addr(dev);
        if (priv->pid == FDT_ADDR_T_NONE)
-               return -EINVAL;
+               return log_msg_ret("bad address", -EINVAL);
 
        /* Do a sanity check */
        reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE);
        if (reg != 0x10)
-               return -ENODEV;
+               return log_msg_ret("bad type", -ENXIO);
 
        reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE);
        if (reg != 0x5 && reg != 0x1)
-               return -ENODEV;
+               return log_msg_ret("bad subtype", -ENXIO);
 
        return 0;
 }
@@ -257,16 +257,16 @@ static int pm8941_pwrkey_probe(struct udevice *dev)
 
        priv->pid = devfdt_get_addr(dev);
        if (priv->pid == FDT_ADDR_T_NONE)
-               return -EINVAL;
+               return log_msg_ret("bad address", -EINVAL);
 
        /* Do a sanity check */
        reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE);
        if (reg != 0x1)
-               return -ENODEV;
+               return log_msg_ret("bad type", -ENXIO);
 
        reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE);
        if (reg != 0x1)
-               return -ENODEV;
+               return log_msg_ret("bad subtype", -ENXIO);
 
        return 0;
 }