aoa-gpio.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Apple Onboard Audio GPIO definitions
  4. *
  5. * Copyright 2006 Johannes Berg <[email protected]>
  6. */
  7. #ifndef __AOA_GPIO_H
  8. #define __AOA_GPIO_H
  9. #include <linux/workqueue.h>
  10. #include <linux/mutex.h>
  11. #include <asm/prom.h>
  12. typedef void (*notify_func_t)(void *data);
  13. enum notify_type {
  14. AOA_NOTIFY_HEADPHONE,
  15. AOA_NOTIFY_LINE_IN,
  16. AOA_NOTIFY_LINE_OUT,
  17. };
  18. struct gpio_runtime;
  19. struct gpio_methods {
  20. /* for initialisation/de-initialisation of the GPIO layer */
  21. void (*init)(struct gpio_runtime *rt);
  22. void (*exit)(struct gpio_runtime *rt);
  23. /* turn off headphone, speakers, lineout */
  24. void (*all_amps_off)(struct gpio_runtime *rt);
  25. /* turn headphone, speakers, lineout back to previous setting */
  26. void (*all_amps_restore)(struct gpio_runtime *rt);
  27. void (*set_headphone)(struct gpio_runtime *rt, int on);
  28. void (*set_speakers)(struct gpio_runtime *rt, int on);
  29. void (*set_lineout)(struct gpio_runtime *rt, int on);
  30. void (*set_master)(struct gpio_runtime *rt, int on);
  31. int (*get_headphone)(struct gpio_runtime *rt);
  32. int (*get_speakers)(struct gpio_runtime *rt);
  33. int (*get_lineout)(struct gpio_runtime *rt);
  34. int (*get_master)(struct gpio_runtime *rt);
  35. void (*set_hw_reset)(struct gpio_runtime *rt, int on);
  36. /* use this to be notified of any events. The notification
  37. * function is passed the data, and is called in process
  38. * context by the use of schedule_work.
  39. * The interface for it is that setting a function to NULL
  40. * removes it, and they return 0 if the operation succeeded,
  41. * and -EBUSY if the notification is already assigned by
  42. * someone else. */
  43. int (*set_notify)(struct gpio_runtime *rt,
  44. enum notify_type type,
  45. notify_func_t notify,
  46. void *data);
  47. /* returns 0 if not plugged in, 1 if plugged in
  48. * or a negative error code */
  49. int (*get_detect)(struct gpio_runtime *rt,
  50. enum notify_type type);
  51. };
  52. struct gpio_notification {
  53. struct delayed_work work;
  54. notify_func_t notify;
  55. void *data;
  56. void *gpio_private;
  57. struct mutex mutex;
  58. };
  59. struct gpio_runtime {
  60. /* to be assigned by fabric */
  61. struct device_node *node;
  62. /* since everyone needs this pointer anyway... */
  63. struct gpio_methods *methods;
  64. /* to be used by the gpio implementation */
  65. int implementation_private;
  66. struct gpio_notification headphone_notify;
  67. struct gpio_notification line_in_notify;
  68. struct gpio_notification line_out_notify;
  69. };
  70. #endif /* __AOA_GPIO_H */