16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/errno.h>
20 #include <linux/i2c.h>
49 static void tps65910_gpio_set(
struct gpio_chip *gc,
unsigned offset,
52 struct tps65910_gpio *tps65910_gpio = to_tps65910_gpio(gc);
53 struct tps65910 *tps65910 = tps65910_gpio->
tps65910;
63 static int tps65910_gpio_output(
struct gpio_chip *gc,
unsigned offset,
66 struct tps65910_gpio *tps65910_gpio = to_tps65910_gpio(gc);
67 struct tps65910 *tps65910 = tps65910_gpio->
tps65910;
70 tps65910_gpio_set(gc, offset, value);
76 static int tps65910_gpio_input(
struct gpio_chip *gc,
unsigned offset)
78 struct tps65910_gpio *tps65910_gpio = to_tps65910_gpio(gc);
79 struct tps65910 *tps65910 = tps65910_gpio->
tps65910;
87 struct tps65910 *tps65910,
int chip_ngpio)
97 "ti,en-gpio-sleep", prop_array, ngpio);
99 dev_dbg(dev,
"ti,en-gpio-sleep not specified\n");
100 return tps65910_board;
103 for (idx = 0; idx < ngpio; idx++)
106 return tps65910_board;
109 static struct tps65910_board *tps65910_parse_dt_for_gpio(
struct device *dev,
110 struct tps65910 *tps65910,
int chip_ngpio)
119 struct tps65910_board *
pdata = dev_get_platdata(tps65910->
dev);
120 struct tps65910_gpio *tps65910_gpio;
126 if (!tps65910_gpio) {
127 dev_err(&pdev->
dev,
"Could not allocate tps65910_gpio\n");
136 switch(tps65910_chip_id(tps65910)) {
147 tps65910_gpio->
gpio_chip.direction_input = tps65910_gpio_input;
148 tps65910_gpio->
gpio_chip.direction_output = tps65910_gpio_output;
149 tps65910_gpio->
gpio_chip.set = tps65910_gpio_set;
150 tps65910_gpio->
gpio_chip.get = tps65910_gpio_get;
152 #ifdef CONFIG_OF_GPIO
153 tps65910_gpio->
gpio_chip.of_node = tps65910->
dev->of_node;
160 if (!pdata && tps65910->
dev->of_node)
161 pdata = tps65910_parse_dt_for_gpio(&pdev->
dev, tps65910,
168 for (i = 0; i < tps65910_gpio->
gpio_chip.ngpio; ++
i) {
172 ret = tps65910_reg_set_bits(tps65910,
176 "GPIO Sleep setting failed with err %d\n", ret);
182 dev_err(&pdev->
dev,
"Could not register gpiochip, %d\n", ret);
186 platform_set_drvdata(pdev, tps65910_gpio);
193 struct tps65910_gpio *tps65910_gpio = platform_get_drvdata(pdev);
199 .driver.name =
"tps65910-gpio",
201 .probe = tps65910_gpio_probe,
205 static int __init tps65910_gpio_init(
void)
211 static void __exit tps65910_gpio_exit(
void)