1
2
3
4
5
6
7
8
9#ifndef __AOA_GPIO_H
10#define __AOA_GPIO_H
11#include <linux/workqueue.h>
12#include <linux/mutex.h>
13#include <asm/prom.h>
14
15typedef void (*notify_func_t)(void *data);
16
17enum notify_type {
18 AOA_NOTIFY_HEADPHONE,
19 AOA_NOTIFY_LINE_IN,
20 AOA_NOTIFY_LINE_OUT,
21};
22
23struct gpio_runtime;
24struct gpio_methods {
25
26 void (*init)(struct gpio_runtime *rt);
27 void (*exit)(struct gpio_runtime *rt);
28
29
30 void (*all_amps_off)(struct gpio_runtime *rt);
31
32 void (*all_amps_restore)(struct gpio_runtime *rt);
33
34 void (*set_headphone)(struct gpio_runtime *rt, int on);
35 void (*set_speakers)(struct gpio_runtime *rt, int on);
36 void (*set_lineout)(struct gpio_runtime *rt, int on);
37
38 int (*get_headphone)(struct gpio_runtime *rt);
39 int (*get_speakers)(struct gpio_runtime *rt);
40 int (*get_lineout)(struct gpio_runtime *rt);
41
42 void (*set_hw_reset)(struct gpio_runtime *rt, int on);
43
44
45
46
47
48
49
50
51 int (*set_notify)(struct gpio_runtime *rt,
52 enum notify_type type,
53 notify_func_t notify,
54 void *data);
55
56
57 int (*get_detect)(struct gpio_runtime *rt,
58 enum notify_type type);
59};
60
61struct gpio_notification {
62 struct delayed_work work;
63 notify_func_t notify;
64 void *data;
65 void *gpio_private;
66 struct mutex mutex;
67};
68
69struct gpio_runtime {
70
71 struct device_node *node;
72
73 struct gpio_methods *methods;
74
75 int implementation_private;
76 struct gpio_notification headphone_notify;
77 struct gpio_notification line_in_notify;
78 struct gpio_notification line_out_notify;
79};
80
81#endif
82