aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpio/gpio-tps65910.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c
index af6dc837ffca..c1ad2884f2ed 100644
--- a/drivers/gpio/gpio-tps65910.c
+++ b/drivers/gpio/gpio-tps65910.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/mfd/tps65910.h> 22#include <linux/mfd/tps65910.h>
23#include <linux/of_device.h>
23 24
24struct tps65910_gpio { 25struct tps65910_gpio {
25 struct gpio_chip gpio_chip; 26 struct gpio_chip gpio_chip;
@@ -81,6 +82,37 @@ static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset)
81 GPIO_CFG_MASK); 82 GPIO_CFG_MASK);
82} 83}
83 84
85#ifdef CONFIG_OF
86static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
87 struct tps65910 *tps65910, int chip_ngpio)
88{
89 struct tps65910_board *tps65910_board = tps65910->of_plat_data;
90 unsigned int prop_array[TPS6591X_MAX_NUM_GPIO];
91 int ngpio = min(chip_ngpio, TPS6591X_MAX_NUM_GPIO);
92 int ret;
93 int idx;
94
95 tps65910_board->gpio_base = -1;
96 ret = of_property_read_u32_array(tps65910->dev->of_node,
97 "ti,en-gpio-sleep", prop_array, ngpio);
98 if (ret < 0) {
99 dev_dbg(dev, "ti,en-gpio-sleep not specified\n");
100 return tps65910_board;
101 }
102
103 for (idx = 0; idx < ngpio; idx++)
104 tps65910_board->en_gpio_sleep[idx] = (prop_array[idx] != 0);
105
106 return tps65910_board;
107}
108#else
109static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
110 struct tps65910 *tps65910, int chip_ngpio)
111{
112 return NULL;
113}
114#endif
115
84static int __devinit tps65910_gpio_probe(struct platform_device *pdev) 116static int __devinit tps65910_gpio_probe(struct platform_device *pdev)
85{ 117{
86 struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); 118 struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent);
@@ -122,6 +154,10 @@ static int __devinit tps65910_gpio_probe(struct platform_device *pdev)
122 else 154 else
123 tps65910_gpio->gpio_chip.base = -1; 155 tps65910_gpio->gpio_chip.base = -1;
124 156
157 if (!pdata && tps65910->dev->of_node)
158 pdata = tps65910_parse_dt_for_gpio(&pdev->dev, tps65910,
159 tps65910_gpio->gpio_chip.ngpio);
160
125 if (!pdata) 161 if (!pdata)
126 goto skip_init; 162 goto skip_init;
127 163