15 #include <linux/kernel.h>
16 #include <linux/slab.h>
17 #include <linux/module.h>
52 static int wm831x_gpio_get(
struct gpio_chip *chip,
unsigned offset)
54 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
55 struct wm831x *wm831x = wm831x_gpio->
wm831x;
62 if (ret & 1 << offset)
68 static void wm831x_gpio_set(
struct gpio_chip *chip,
unsigned offset,
int value)
70 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
71 struct wm831x *wm831x = wm831x_gpio->
wm831x;
77 static int wm831x_gpio_direction_out(
struct gpio_chip *chip,
78 unsigned offset,
int value)
80 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
81 struct wm831x *wm831x = wm831x_gpio->
wm831x;
95 wm831x_gpio_set(chip, offset, value);
100 static int wm831x_gpio_to_irq(
struct gpio_chip *chip,
unsigned offset)
102 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
103 struct wm831x *wm831x = wm831x_gpio->
wm831x;
109 static int wm831x_gpio_set_debounce(
struct gpio_chip *chip,
unsigned offset,
112 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
113 struct wm831x *wm831x = wm831x_gpio->
wm831x;
130 if (debounce >= 32 && debounce <= 64)
132 else if (debounce >= 4000 && debounce <= 8000)
140 #ifdef CONFIG_DEBUG_FS
143 struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
144 struct wm831x *wm831x = wm831x_gpio->
wm831x;
147 for (i = 0; i < chip->ngpio; i++) {
148 int gpio = i + chip->base;
159 label =
"Unrequested";
161 seq_printf(s,
" gpio-%-3d (%-20.20s) ", gpio, label);
166 "GPIO control %d read failed: %d\n",
183 pull =
"INVALID PULL";
191 powerdomain =
"VPMIC";
193 powerdomain =
"DBVDD";
198 if (reg & WM831X_GPN_PWR_DOM)
199 powerdomain =
"SYSVDD";
201 powerdomain =
"DBVDD";
205 powerdomain =
"TPVDD";
215 tristated = !tristated;
220 wm831x_gpio_get(chip, i) ?
"high" :
"low",
225 tristated ?
" tristated" :
"",
230 #define wm831x_gpio_dbg_show NULL
233 static struct gpio_chip template_chip = {
236 .direction_input = wm831x_gpio_direction_in,
237 .get = wm831x_gpio_get,
238 .direction_output = wm831x_gpio_direction_out,
239 .set = wm831x_gpio_set,
240 .to_irq = wm831x_gpio_to_irq,
241 .set_debounce = wm831x_gpio_set_debounce,
250 struct wm831x_gpio *wm831x_gpio;
255 if (wm831x_gpio ==
NULL)
269 dev_err(&pdev->
dev,
"Could not register gpiochip, %d\n", ret);
273 platform_set_drvdata(pdev, wm831x_gpio);
280 struct wm831x_gpio *wm831x_gpio = platform_get_drvdata(pdev);
286 .driver.name =
"wm831x-gpio",
288 .probe = wm831x_gpio_probe,
292 static int __init wm831x_gpio_init(
void)
298 static void __exit wm831x_gpio_exit(
void)