]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
pinctrl: qcom: pmic-gpio/mpp: of_irq_count() == npins
authorStephen Boyd <sboyd@codeaurora.org>
Wed, 18 Nov 2015 19:33:17 +0000 (11:33 -0800)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 1 Dec 2015 09:00:53 +0000 (10:00 +0100)
The number of interrupts is always equal to the number of pins
provided by the PMIC gpio and MPP hardware blocks. Count the
number of irqs to figure out the number of pins instead of adding
more compatible strings or doing math on the reg property. This
should make the code more generic and ease the number of changes
we have to make to the driver for each new pmic revision.

Cc: Ivan T. Ivanov <iivanov@mm-sol.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Reviewed-by: Andy Gross <agross@codeaurora.org>
Reviewed-by: Björn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c

index 6c42ca14d2fd315d9e43faca2a48315815d53bd8..543cdd6097888ec35ce8db9384668777c43a3cfb 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_irq.h>
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinconf.h>
 #include <linux/pinctrl/pinmux.h>
@@ -693,16 +694,15 @@ static int pmic_gpio_probe(struct platform_device *pdev)
        struct pmic_gpio_pad *pad, *pads;
        struct pmic_gpio_state *state;
        int ret, npins, i;
-       u32 res[2];
+       u32 reg;
 
-       ret = of_property_read_u32_array(dev->of_node, "reg", res, 2);
+       ret = of_property_read_u32(dev->of_node, "reg", &reg);
        if (ret < 0) {
-               dev_err(dev, "missing base address and/or range");
+               dev_err(dev, "missing base address");
                return ret;
        }
 
-       npins = res[1] / PMIC_GPIO_ADDRESS_RANGE;
-
+       npins = of_irq_count(dev->of_node);
        if (!npins)
                return -EINVAL;
 
@@ -752,7 +752,7 @@ static int pmic_gpio_probe(struct platform_device *pdev)
                if (pad->irq < 0)
                        return pad->irq;
 
-               pad->base = res[0] + i * PMIC_GPIO_ADDRESS_RANGE;
+               pad->base = reg + i * PMIC_GPIO_ADDRESS_RANGE;
 
                ret = pmic_gpio_populate(state, pad);
                if (ret < 0)
index 9ce0e30e33e81b024ecee8169d86b165ce1d69d7..d778fb9c9dbf87be61f5f727582bbb410aa80c37 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_irq.h>
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinconf.h>
 #include <linux/pinctrl/pinmux.h>
@@ -795,15 +796,15 @@ static int pmic_mpp_probe(struct platform_device *pdev)
        struct pmic_mpp_pad *pad, *pads;
        struct pmic_mpp_state *state;
        int ret, npins, i;
-       u32 res[2];
+       u32 reg;
 
-       ret = of_property_read_u32_array(dev->of_node, "reg", res, 2);
+       ret = of_property_read_u32(dev->of_node, "reg", &reg);
        if (ret < 0) {
-               dev_err(dev, "missing base address and/or range");
+               dev_err(dev, "missing base address");
                return ret;
        }
 
-       npins = res[1] / PMIC_MPP_ADDRESS_RANGE;
+       npins = of_irq_count(dev->of_node);
        if (!npins)
                return -EINVAL;
 
@@ -854,7 +855,7 @@ static int pmic_mpp_probe(struct platform_device *pdev)
                if (pad->irq < 0)
                        return pad->irq;
 
-               pad->base = res[0] + i * PMIC_MPP_ADDRESS_RANGE;
+               pad->base = reg + i * PMIC_MPP_ADDRESS_RANGE;
 
                ret = pmic_mpp_populate(state, pad);
                if (ret < 0)
index d809c9eaa3231817512bdda858ad208d0f1138e4..78fa2281116d684f39cd6313fe48de048dd0379a 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
 
 #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
 
@@ -650,11 +651,12 @@ static int pm8xxx_pin_populate(struct pm8xxx_gpio *pctrl,
 }
 
 static const struct of_device_id pm8xxx_gpio_of_match[] = {
-       { .compatible = "qcom,pm8018-gpio", .data = (void *)6 },
-       { .compatible = "qcom,pm8038-gpio", .data = (void *)12 },
-       { .compatible = "qcom,pm8058-gpio", .data = (void *)40 },
-       { .compatible = "qcom,pm8917-gpio", .data = (void *)38 },
-       { .compatible = "qcom,pm8921-gpio", .data = (void *)44 },
+       { .compatible = "qcom,pm8018-gpio" },
+       { .compatible = "qcom,pm8038-gpio" },
+       { .compatible = "qcom,pm8058-gpio" },
+       { .compatible = "qcom,pm8917-gpio" },
+       { .compatible = "qcom,pm8921-gpio" },
+       { .compatible = "qcom,ssbi-gpio" },
        { },
 };
 MODULE_DEVICE_TABLE(of, pm8xxx_gpio_of_match);
@@ -672,7 +674,9 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        pctrl->dev = &pdev->dev;
-       pctrl->npins = (unsigned)of_device_get_match_data(&pdev->dev);
+       pctrl->npins = of_irq_count(pdev->dev.of_node);
+       if (!pctrl->npins)
+               return -EINVAL;
 
        pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL);
        if (!pctrl->regmap) {
index 8982027de8e8b528f026f38d58ccdf692901635c..0831063da54cc088ea4d66bd2422eb06647ab273 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
 
 #include <dt-bindings/pinctrl/qcom,pmic-mpp.h>
 
@@ -741,11 +742,12 @@ static int pm8xxx_pin_populate(struct pm8xxx_mpp *pctrl,
 }
 
 static const struct of_device_id pm8xxx_mpp_of_match[] = {
-       { .compatible = "qcom,pm8018-mpp", .data = (void *)6 },
-       { .compatible = "qcom,pm8038-mpp", .data = (void *)6 },
-       { .compatible = "qcom,pm8917-mpp", .data = (void *)10 },
-       { .compatible = "qcom,pm8821-mpp", .data = (void *)4 },
-       { .compatible = "qcom,pm8921-mpp", .data = (void *)12 },
+       { .compatible = "qcom,pm8018-mpp" },
+       { .compatible = "qcom,pm8038-mpp" },
+       { .compatible = "qcom,pm8917-mpp" },
+       { .compatible = "qcom,pm8821-mpp" },
+       { .compatible = "qcom,pm8921-mpp" },
+       { .compatible = "qcom,ssbi-mpp" },
        { },
 };
 MODULE_DEVICE_TABLE(of, pm8xxx_mpp_of_match);
@@ -763,7 +765,9 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        pctrl->dev = &pdev->dev;
-       pctrl->npins = (unsigned)of_device_get_match_data(&pdev->dev);
+       pctrl->npins = of_irq_count(pdev->dev.of_node);
+       if (!pctrl->npins)
+               return -EINVAL;
 
        pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL);
        if (!pctrl->regmap) {