15 #include <linux/kernel.h>
16 #include <linux/slab.h>
17 #include <linux/module.h>
44 switch (wm8994->
type) {
62 static int wm8994_gpio_direction_in(
struct gpio_chip *chip,
unsigned offset)
64 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
65 struct wm8994 *wm8994 = wm8994_gpio->
wm8994;
71 static int wm8994_gpio_get(
struct gpio_chip *chip,
unsigned offset)
73 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
74 struct wm8994 *wm8994 = wm8994_gpio->
wm8994;
87 static int wm8994_gpio_direction_out(
struct gpio_chip *chip,
88 unsigned offset,
int value)
90 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
91 struct wm8994 *wm8994 = wm8994_gpio->
wm8994;
100 static void wm8994_gpio_set(
struct gpio_chip *chip,
unsigned offset,
int value)
102 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
103 struct wm8994 *wm8994 = wm8994_gpio->
wm8994;
111 static int wm8994_gpio_to_irq(
struct gpio_chip *chip,
unsigned offset)
113 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
114 struct wm8994 *wm8994 = wm8994_gpio->
wm8994;
120 #ifdef CONFIG_DEBUG_FS
121 static const char *wm8994_gpio_fn(
u16 fn)
125 return "pin-specific";
133 return "Temperature";
135 return "MICBIAS1 detect";
137 return "MICBIAS1 short";
139 return "MICBIAS2 detect";
141 return "MICBIAS2 short";
151 return "DRC1 activity";
153 return "DRC2 activity";
155 return "DRC3 activity";
157 return "Write sequencer";
163 return "Thermal warning";
167 return "FLL1 output";
169 return "FLL1 output";
177 struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
178 struct wm8994 *wm8994 = wm8994_gpio->
wm8994;
181 for (i = 0; i < chip->ngpio; i++) {
182 int gpio = i + chip->base;
193 label =
"Unrequested";
195 seq_printf(s,
" gpio-%-3d (%-20.20s) ", gpio, label);
200 "GPIO control %d read failed: %d\n",
232 #define wm8994_gpio_dbg_show NULL
235 static struct gpio_chip template_chip = {
238 .request = wm8994_gpio_request,
239 .direction_input = wm8994_gpio_direction_in,
240 .get = wm8994_gpio_get,
241 .direction_output = wm8994_gpio_direction_out,
242 .set = wm8994_gpio_set,
243 .to_irq = wm8994_gpio_to_irq,
252 struct wm8994_gpio *wm8994_gpio;
257 if (wm8994_gpio ==
NULL)
271 dev_err(&pdev->
dev,
"Could not register gpiochip, %d\n",
276 platform_set_drvdata(pdev, wm8994_gpio);
286 struct wm8994_gpio *wm8994_gpio = platform_get_drvdata(pdev);
292 .driver.name =
"wm8994-gpio",
294 .probe = wm8994_gpio_probe,
298 static int __init wm8994_gpio_init(
void)
304 static void __exit wm8994_gpio_exit(
void)