aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2014-04-16 05:01:37 -0400
committerMark Brown <broonie@linaro.org>2014-04-18 13:34:20 -0400
commite4fcb1d6148284a10c314fce2a488cf19ce886f6 (patch)
treecb0cfdf7693b33029c47afeed84423aebd18764c
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
mfd: arizona: Factor out read of device tree GPIOs
This patch factors out the reading of GPIOs for the Arizona devices into a helper function. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/mfd/arizona-core.c31
-rw-r--r--include/linux/mfd/arizona/core.h3
2 files changed, 25 insertions, 9 deletions
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 1c3ae57082ed..37b5e1447d02 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -508,19 +508,32 @@ int arizona_of_get_type(struct device *dev)
508} 508}
509EXPORT_SYMBOL_GPL(arizona_of_get_type); 509EXPORT_SYMBOL_GPL(arizona_of_get_type);
510 510
511int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
512 bool mandatory)
513{
514 int gpio;
515
516 gpio = of_get_named_gpio(arizona->dev->of_node, prop, 0);
517 if (gpio < 0) {
518 if (mandatory)
519 dev_err(arizona->dev,
520 "Mandatory DT gpio %s missing/malformed: %d\n",
521 prop, gpio);
522
523 gpio = 0;
524 }
525
526 return gpio;
527}
528EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);
529
511static int arizona_of_get_core_pdata(struct arizona *arizona) 530static int arizona_of_get_core_pdata(struct arizona *arizona)
512{ 531{
532 struct arizona_pdata *pdata = &arizona->pdata;
513 int ret, i; 533 int ret, i;
514 534
515 arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node, 535 pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true);
516 "wlf,reset", 0); 536 pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);
517 if (arizona->pdata.reset < 0)
518 arizona->pdata.reset = 0;
519
520 arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
521 "wlf,ldoena", 0);
522 if (arizona->pdata.ldoena < 0)
523 arizona->pdata.ldoena = 0;
524 537
525 ret = of_property_read_u32_array(arizona->dev->of_node, 538 ret = of_property_read_u32_array(arizona->dev->of_node,
526 "wlf,gpio-defaults", 539 "wlf,gpio-defaults",
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
index 5cf8b91ce996..6d9371f88875 100644
--- a/include/linux/mfd/arizona/core.h
+++ b/include/linux/mfd/arizona/core.h
@@ -124,4 +124,7 @@ int wm5102_patch(struct arizona *arizona);
124int wm5110_patch(struct arizona *arizona); 124int wm5110_patch(struct arizona *arizona);
125int wm8997_patch(struct arizona *arizona); 125int wm8997_patch(struct arizona *arizona);
126 126
127extern int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
128 bool mandatory);
129
127#endif 130#endif