aoa-gpio.h 2.4 KB

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