82 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Apple Onboard Audio GPIO definitions4 *5 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>6 */7 8#ifndef __AOA_GPIO_H9#define __AOA_GPIO_H10#include <linux/workqueue.h>11#include <linux/mutex.h>12 13typedef void (*notify_func_t)(void *data);14 15enum notify_type {16 AOA_NOTIFY_HEADPHONE,17 AOA_NOTIFY_LINE_IN,18 AOA_NOTIFY_LINE_OUT,19};20 21struct gpio_runtime;22struct gpio_methods {23 /* for initialisation/de-initialisation of the GPIO layer */24 void (*init)(struct gpio_runtime *rt);25 void (*exit)(struct gpio_runtime *rt);26 27 /* turn off headphone, speakers, lineout */28 void (*all_amps_off)(struct gpio_runtime *rt);29 /* turn headphone, speakers, lineout back to previous setting */30 void (*all_amps_restore)(struct gpio_runtime *rt);31 32 void (*set_headphone)(struct gpio_runtime *rt, int on);33 void (*set_speakers)(struct gpio_runtime *rt, int on);34 void (*set_lineout)(struct gpio_runtime *rt, int on);35 void (*set_master)(struct gpio_runtime *rt, int on);36 37 int (*get_headphone)(struct gpio_runtime *rt);38 int (*get_speakers)(struct gpio_runtime *rt);39 int (*get_lineout)(struct gpio_runtime *rt);40 int (*get_master)(struct gpio_runtime *rt);41 42 void (*set_hw_reset)(struct gpio_runtime *rt, int on);43 44 /* use this to be notified of any events. The notification45 * function is passed the data, and is called in process46 * context by the use of schedule_work.47 * The interface for it is that setting a function to NULL48 * removes it, and they return 0 if the operation succeeded,49 * and -EBUSY if the notification is already assigned by50 * someone else. */51 int (*set_notify)(struct gpio_runtime *rt,52 enum notify_type type,53 notify_func_t notify,54 void *data);55 /* returns 0 if not plugged in, 1 if plugged in56 * or a negative error code */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 /* to be assigned by fabric */71 struct device_node *node;72 /* since everyone needs this pointer anyway... */73 struct gpio_methods *methods;74 /* to be used by the gpio implementation */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 /* __AOA_GPIO_H */82