altmode-glink.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __ALTMODE_H__
  6. #define __ALTMODE_H__
  7. #include <linux/types.h>
  8. /**
  9. * struct altmode_client_data
  10. * Uniquely define altmode client while registering with altmode framework.
  11. *
  12. * @svid: Unique ID for Type-C Altmode client devices
  13. * @name: Short descriptive name to identify client
  14. * @priv: Pointer to client driver's internal top level structure
  15. * @callback: Callback function to receive PMIC GLINK message data
  16. */
  17. struct altmode_client_data {
  18. u16 svid;
  19. const char *name;
  20. void *priv;
  21. int (*callback)(void *priv, void *data, size_t len);
  22. };
  23. struct altmode_client;
  24. enum altmode_send_msg_type {
  25. ALTMODE_PAN_EN = 0x10,
  26. ALTMODE_PAN_ACK,
  27. };
  28. struct altmode_pan_ack_msg {
  29. u32 cmd_type;
  30. u8 port_index;
  31. };
  32. #if IS_ENABLED(CONFIG_QTI_ALTMODE_GLINK)
  33. struct device;
  34. int altmode_register_notifier(struct device *client_dev, void (*cb)(void *),
  35. void *priv);
  36. int altmode_deregister_notifier(struct device *client_dev, void *priv);
  37. struct altmode_client *altmode_register_client(struct device *dev,
  38. const struct altmode_client_data *client_data);
  39. int altmode_deregister_client(struct altmode_client *client);
  40. int altmode_send_data(struct altmode_client *client, void *data, size_t len);
  41. #else
  42. static inline int altmode_register_notifier(struct device *client_dev,
  43. void (*cb)(void *), void *priv)
  44. {
  45. return -ENODEV;
  46. }
  47. static inline int altmode_deregister_notifier(struct device *client_dev,
  48. void *priv)
  49. {
  50. return -ENODEV;
  51. }
  52. static inline struct altmode_client *altmode_register_client(struct device *dev,
  53. const struct altmode_client_data *client_data)
  54. {
  55. return ERR_PTR(-ENODEV);
  56. }
  57. static inline int altmode_deregister_client(struct altmode_client *client)
  58. {
  59. return -ENODEV;
  60. }
  61. static inline int altmode_send_data(struct altmode_client *client, void *data,
  62. size_t len)
  63. {
  64. return -ENODEV;
  65. }
  66. #endif
  67. #endif