blob: 6065b0344e23ce888a2ce5eea1015c35165e0c66 [file] [log] [blame]
Johannes Bergf3d94782006-06-21 15:42:43 +02001/*
2 * Apple Onboard Audio GPIO definitions
3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * GPL v2, can be found in COPYING.
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 /* for initialisation/de-initialisation of the GPIO layer */
26 void (*init)(struct gpio_runtime *rt);
27 void (*exit)(struct gpio_runtime *rt);
28
29 /* turn off headphone, speakers, lineout */
30 void (*all_amps_off)(struct gpio_runtime *rt);
31 /* turn headphone, speakers, lineout back to previous setting */
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);
Johannes Berg5f17e792009-01-15 18:22:31 +010037 void (*set_master)(struct gpio_runtime *rt, int on);
Johannes Bergf3d94782006-06-21 15:42:43 +020038
39 int (*get_headphone)(struct gpio_runtime *rt);
40 int (*get_speakers)(struct gpio_runtime *rt);
41 int (*get_lineout)(struct gpio_runtime *rt);
Johannes Berg5f17e792009-01-15 18:22:31 +010042 int (*get_master)(struct gpio_runtime *rt);
Johannes Bergf3d94782006-06-21 15:42:43 +020043
44 void (*set_hw_reset)(struct gpio_runtime *rt, int on);
45
46 /* use this to be notified of any events. The notification
47 * function is passed the data, and is called in process
48 * context by the use of schedule_work.
49 * The interface for it is that setting a function to NULL
50 * removes it, and they return 0 if the operation succeeded,
51 * and -EBUSY if the notification is already assigned by
52 * someone else. */
53 int (*set_notify)(struct gpio_runtime *rt,
54 enum notify_type type,
55 notify_func_t notify,
56 void *data);
57 /* returns 0 if not plugged in, 1 if plugged in
58 * or a negative error code */
59 int (*get_detect)(struct gpio_runtime *rt,
60 enum notify_type type);
61};
62
63struct gpio_notification {
David Howellsc4028952006-11-22 14:57:56 +000064 struct delayed_work work;
Johannes Bergf3d94782006-06-21 15:42:43 +020065 notify_func_t notify;
66 void *data;
67 void *gpio_private;
Johannes Bergf3d94782006-06-21 15:42:43 +020068 struct mutex mutex;
69};
70
71struct gpio_runtime {
72 /* to be assigned by fabric */
73 struct device_node *node;
74 /* since everyone needs this pointer anyway... */
75 struct gpio_methods *methods;
76 /* to be used by the gpio implementation */
77 int implementation_private;
78 struct gpio_notification headphone_notify;
79 struct gpio_notification line_in_notify;
80 struct gpio_notification line_out_notify;
81};
82
83#endif /* __AOA_GPIO_H */