Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Apple Onboard Audio GPIO definitions
0004  *
0005  * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
0006  */
0007 
0008 #ifndef __AOA_GPIO_H
0009 #define __AOA_GPIO_H
0010 #include <linux/workqueue.h>
0011 #include <linux/mutex.h>
0012 #include <asm/prom.h>
0013 
0014 typedef void (*notify_func_t)(void *data);
0015 
0016 enum notify_type {
0017     AOA_NOTIFY_HEADPHONE,
0018     AOA_NOTIFY_LINE_IN,
0019     AOA_NOTIFY_LINE_OUT,
0020 };
0021 
0022 struct gpio_runtime;
0023 struct gpio_methods {
0024     /* for initialisation/de-initialisation of the GPIO layer */
0025     void (*init)(struct gpio_runtime *rt);
0026     void (*exit)(struct gpio_runtime *rt);
0027 
0028     /* turn off headphone, speakers, lineout */
0029     void (*all_amps_off)(struct gpio_runtime *rt);
0030     /* turn headphone, speakers, lineout back to previous setting */
0031     void (*all_amps_restore)(struct gpio_runtime *rt);
0032 
0033     void (*set_headphone)(struct gpio_runtime *rt, int on);
0034     void (*set_speakers)(struct gpio_runtime *rt, int on);
0035     void (*set_lineout)(struct gpio_runtime *rt, int on);
0036     void (*set_master)(struct gpio_runtime *rt, int on);
0037 
0038     int (*get_headphone)(struct gpio_runtime *rt);
0039     int (*get_speakers)(struct gpio_runtime *rt);
0040     int (*get_lineout)(struct gpio_runtime *rt);
0041     int (*get_master)(struct gpio_runtime *rt);
0042 
0043     void (*set_hw_reset)(struct gpio_runtime *rt, int on);
0044 
0045     /* use this to be notified of any events. The notification
0046      * function is passed the data, and is called in process
0047      * context by the use of schedule_work.
0048      * The interface for it is that setting a function to NULL
0049      * removes it, and they return 0 if the operation succeeded,
0050      * and -EBUSY if the notification is already assigned by
0051      * someone else. */
0052     int (*set_notify)(struct gpio_runtime *rt,
0053               enum notify_type type,
0054               notify_func_t notify,
0055               void *data);
0056     /* returns 0 if not plugged in, 1 if plugged in
0057      * or a negative error code */
0058     int (*get_detect)(struct gpio_runtime *rt,
0059               enum notify_type type);
0060 };
0061 
0062 struct gpio_notification {
0063     struct delayed_work work;
0064     notify_func_t notify;
0065     void *data;
0066     void *gpio_private;
0067     struct mutex mutex;
0068 };
0069 
0070 struct gpio_runtime {
0071     /* to be assigned by fabric */
0072     struct device_node *node;
0073     /* since everyone needs this pointer anyway... */
0074     struct gpio_methods *methods;
0075     /* to be used by the gpio implementation */
0076     int implementation_private;
0077     struct gpio_notification headphone_notify;
0078     struct gpio_notification line_in_notify;
0079     struct gpio_notification line_out_notify;
0080 };
0081 
0082 #endif /* __AOA_GPIO_H */