glink_interface.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef GLINKINTERFACE_H
  7. #define GLINKINTERFACE_H
  8. #include <linux/delay.h>
  9. #include <linux/device.h>
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/mutex.h>
  14. #include <linux/of.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/sched.h>
  17. #include <linux/slab.h>
  18. #include <linux/wait.h>
  19. #include <linux/rpmsg.h>
  20. #define TOUCH_GLINK_INTENT_SIZE 0x0c
  21. #define TOUCH_MSG_SIZE 0x08
  22. #define TIMEOUT_MS 2000
  23. struct glink_touch_priv {
  24. void *handle;
  25. struct mutex glink_mutex;
  26. struct mutex touch_state_mutex;
  27. void *lhndl;
  28. char rx_buf[TOUCH_GLINK_INTENT_SIZE];
  29. bool glink_touch_cmplt;
  30. wait_queue_head_t link_state_wait;
  31. bool msm_touch_rpmsg;
  32. };
  33. static void *glink_touch_drv;
  34. enum touch_slate_cmds {
  35. TOUCH_ENTER_PREPARE = 0x1100,
  36. TOUCH_ENTER,
  37. TOUCH_EXIT_PREPARE,
  38. TOUCH_EXIT
  39. };
  40. struct glink_touch_dev {
  41. struct rpmsg_endpoint *channel;
  42. struct device *dev;
  43. bool chnl_state;
  44. void *message;
  45. size_t message_length;
  46. };
  47. struct touch_channel_ops {
  48. void (*glink_channel_state)(bool state);
  49. void (*rx_msg)(void *data, int len);
  50. };
  51. void glink_touch_channel_init(void (*fn1)(bool), void (*fn2)(void *, int));
  52. #if IS_ENABLED(CONFIG_MSM_SLATERSB_RPMSG)
  53. int glink_touch_tx_msg(void *msg, size_t len);
  54. #else
  55. static inline int glink_touch_tx_msg(void *msg, size_t len)
  56. {
  57. return -EIO;
  58. }
  59. #endif
  60. #endif