muic_notifier.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * include/linux/muic/common/muic_notifier.h
  3. *
  4. * header file supporting MUIC notifier call chain information
  5. *
  6. * Copyright (C) 2010 Samsung Electronics
  7. * Seung-Jin Hahn <[email protected]>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #ifndef __MUIC_NOTIFIER_H__
  25. #define __MUIC_NOTIFIER_H__
  26. #include <linux/muic/common/muic.h>
  27. #if IS_ENABLED(CONFIG_PDIC_NOTIFIER)
  28. #include <linux/usb/typec/common/pdic_notifier.h>
  29. #endif
  30. /* MUIC notifier call chain command */
  31. typedef enum {
  32. MUIC_NOTIFY_CMD_DETACH = 0,
  33. MUIC_NOTIFY_CMD_ATTACH,
  34. MUIC_NOTIFY_CMD_LOGICALLY_DETACH,
  35. MUIC_NOTIFY_CMD_LOGICALLY_ATTACH,
  36. MUIC_PDIC_NOTIFY_CMD_ATTACH,
  37. MUIC_PDIC_NOTIFY_CMD_DETACH,
  38. PDIC_MUIC_NOTIFY_CMD_JIG_ATTACH,
  39. PDIC_MUIC_NOTIFY_CMD_JIG_DETACH,
  40. } muic_notifier_cmd_t;
  41. /* MUIC notifier call sequence,
  42. * largest priority number device will be called first. */
  43. typedef enum {
  44. MUIC_NOTIFY_DEV_DOCK = 0,
  45. MUIC_NOTIFY_DEV_MHL,
  46. MUIC_NOTIFY_DEV_USB,
  47. MUIC_NOTIFY_DEV_TSP,
  48. MUIC_NOTIFY_DEV_CHARGER,
  49. MUIC_NOTIFY_DEV_PDIC,
  50. MUIC_NOTIFY_DEV_CPUIDLE,
  51. MUIC_NOTIFY_DEV_CPUFREQ,
  52. #if IS_ENABLED(CONFIG_USB_TYPEC_MANAGER_NOTIFIER)
  53. MUIC_NOTIFY_DEV_MANAGER,
  54. #endif
  55. MUIC_NOTIFY_DEV_CABLE_DATA,
  56. } muic_notifier_device_t;
  57. struct muic_notifier_struct {
  58. muic_attached_dev_t attached_dev;
  59. muic_notifier_cmd_t cmd;
  60. #if IS_ENABLED(CONFIG_PDIC_NOTIFIER)
  61. PD_NOTI_ATTACH_TYPEDEF cxt;
  62. #if IS_ENABLED(CONFIG_MUIC_POGO)
  63. PD_NOTI_ATTACH_TYPEDEF pogo_cxt;
  64. #endif /* CONFIG_MUIC_POGO */
  65. #endif
  66. struct blocking_notifier_head notifier_call_chain;
  67. };
  68. #define MUIC_NOTIFIER_BLOCK(name) \
  69. struct notifier_block (name)
  70. /* muic notifier init/notify function
  71. * this function is for JUST MUIC device driver.
  72. * DON'T use function anywhrer else!!
  73. */
  74. extern struct device *switch_device;
  75. extern void muic_notifier_attach_attached_dev(muic_attached_dev_t new_dev);
  76. extern void muic_notifier_detach_attached_dev(muic_attached_dev_t cur_dev);
  77. extern void muic_pdic_notifier_attach_attached_dev(muic_attached_dev_t new_dev);
  78. extern void muic_pdic_notifier_detach_attached_dev(muic_attached_dev_t new_dev);
  79. extern void muic_notifier_logically_attach_attached_dev(muic_attached_dev_t new_dev);
  80. extern void muic_notifier_logically_detach_attached_dev(muic_attached_dev_t cur_dev);
  81. #if IS_ENABLED(CONFIG_VIRTUAL_MUIC)
  82. extern void vt_muic_notifier_attach_attached_dev(muic_attached_dev_t new_dev);
  83. extern void vt_muic_notifier_detach_attached_dev(muic_attached_dev_t cur_dev);
  84. #endif
  85. #if IS_ENABLED(CONFIG_PDIC_SLSI_NON_MCU)
  86. extern int muic_pdic_notifier_register(struct notifier_block *nb,
  87. notifier_fn_t notifier, muic_notifier_device_t listener);
  88. extern int muic_pdic_notifier_unregister(struct notifier_block *nb);
  89. #endif
  90. /* muic notifier register/unregister API
  91. * for used any where want to receive muic attached device attach/detach. */
  92. extern int muic_notifier_register(struct notifier_block *nb,
  93. notifier_fn_t notifier, muic_notifier_device_t listener);
  94. extern int muic_notifier_unregister(struct notifier_block *nb);
  95. /* Choose a proper noti. interface for a test */
  96. extern void muic_notifier_set_new_noti(bool flag);
  97. #if IS_ENABLED(CONFIG_MUIC_POGO)
  98. extern void muic_pogo_notifier_attach_attached_dev(muic_attached_dev_t new_dev);
  99. extern void muic_pogo_notifier_detach_attached_dev(muic_attached_dev_t cur_dev);
  100. #endif /* CONFIG_MUIC_POGO */
  101. #endif /* __MUIC_NOTIFIER_H__ */