]> git.sur5r.net Git - u-boot/blobdiff - drivers/gpio/pm8916_gpio.c
efi_loader: implement event groups
[u-boot] / drivers / gpio / pm8916_gpio.c
index 1abab7fef1701928d597b89884ed8aff0cace3f2..42f068ecb6516c8654db43d3536a9315d99e46a1 100644 (file)
@@ -29,7 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define REG_STATUS_VAL_MASK    0x1
 
 /* MODE_CTL */
-#define REG_CTL           0x40
+#define REG_CTL                0x40
 #define REG_CTL_MODE_MASK       0x70
 #define REG_CTL_MODE_INPUT      0x00
 #define REG_CTL_MODE_INOUT      0x20
@@ -50,7 +50,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define REG_EN_CTL_ENABLE      (1 << 7)
 
 struct pm8916_gpio_bank {
-       uint16_t pid; /* Peripheral ID on SPMI bus */
+       uint32_t pid; /* Peripheral ID on SPMI bus */
 };
 
 static int pm8916_gpio_set_direction(struct udevice *dev, unsigned offset,
@@ -173,7 +173,7 @@ static int pm8916_gpio_probe(struct udevice *dev)
        struct pm8916_gpio_bank *priv = dev_get_priv(dev);
        int reg;
 
-       priv->pid = dev_get_addr(dev);
+       priv->pid = dev_read_addr(dev);
        if (priv->pid == FDT_ADDR_T_NONE)
                return -EINVAL;
 
@@ -183,7 +183,7 @@ static int pm8916_gpio_probe(struct udevice *dev)
                return -ENODEV;
 
        reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE);
-       if (reg != 0x5)
+       if (reg != 0x5 && reg != 0x1)
                return -ENODEV;
 
        return 0;
@@ -193,10 +193,8 @@ static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-                                            "gpio-count", 0);
-       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
-                                        "gpio-bank-name", NULL);
+       uc_priv->gpio_count = dev_read_u32_default(dev, "gpio-count", 0);
+       uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name");
        if (uc_priv->bank_name == NULL)
                uc_priv->bank_name = "pm8916";
 
@@ -205,6 +203,7 @@ static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev)
 
 static const struct udevice_id pm8916_gpio_ids[] = {
        { .compatible = "qcom,pm8916-gpio" },
+       { .compatible = "qcom,pm8994-gpio" },   /* 22 GPIO's */
        { }
 };
 
@@ -259,7 +258,7 @@ static int pm8941_pwrkey_probe(struct udevice *dev)
        struct pm8916_gpio_bank *priv = dev_get_priv(dev);
        int reg;
 
-       priv->pid = dev_get_addr(dev);
+       priv->pid = devfdt_get_addr(dev);
        if (priv->pid == FDT_ADDR_T_NONE)
                return -EINVAL;
 
@@ -280,6 +279,7 @@ static int pm8941_pwrkey_ofdata_to_platdata(struct udevice *dev)
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
        uc_priv->gpio_count = 2;
+       uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name");
        if (uc_priv->bank_name == NULL)
                uc_priv->bank_name = "pm8916_key";
 
@@ -288,6 +288,7 @@ static int pm8941_pwrkey_ofdata_to_platdata(struct udevice *dev)
 
 static const struct udevice_id pm8941_pwrkey_ids[] = {
        { .compatible = "qcom,pm8916-pwrkey" },
+       { .compatible = "qcom,pm8994-pwrkey" },
        { }
 };