intel-ish-client-if.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Intel ISH client Interface definitions
  4. *
  5. * Copyright (c) 2019, Intel Corporation.
  6. */
  7. #ifndef _INTEL_ISH_CLIENT_IF_H_
  8. #define _INTEL_ISH_CLIENT_IF_H_
  9. struct ishtp_cl_device;
  10. struct ishtp_device;
  11. struct ishtp_cl;
  12. struct ishtp_fw_client;
  13. /* Client state */
  14. enum cl_state {
  15. ISHTP_CL_INITIALIZING = 0,
  16. ISHTP_CL_CONNECTING,
  17. ISHTP_CL_CONNECTED,
  18. ISHTP_CL_DISCONNECTING,
  19. ISHTP_CL_DISCONNECTED
  20. };
  21. /**
  22. * struct ishtp_cl_device - ISHTP device handle
  23. * @driver: driver instance on a bus
  24. * @name: Name of the device for probe
  25. * @probe: driver callback for device probe
  26. * @remove: driver callback on device removal
  27. *
  28. * Client drivers defines to get probed/removed for ISHTP client device.
  29. */
  30. struct ishtp_cl_driver {
  31. struct device_driver driver;
  32. const char *name;
  33. const guid_t *guid;
  34. int (*probe)(struct ishtp_cl_device *dev);
  35. int (*remove)(struct ishtp_cl_device *dev);
  36. int (*reset)(struct ishtp_cl_device *dev);
  37. const struct dev_pm_ops *pm;
  38. };
  39. /**
  40. * struct ishtp_msg_data - ISHTP message data struct
  41. * @size: Size of data in the *data
  42. * @data: Pointer to data
  43. */
  44. struct ishtp_msg_data {
  45. uint32_t size;
  46. unsigned char *data;
  47. };
  48. /*
  49. * struct ishtp_cl_rb - request block structure
  50. * @list: Link to list members
  51. * @cl: ISHTP client instance
  52. * @buffer: message header
  53. * @buf_idx: Index into buffer
  54. * @read_time: unused at this time
  55. */
  56. struct ishtp_cl_rb {
  57. struct list_head list;
  58. struct ishtp_cl *cl;
  59. struct ishtp_msg_data buffer;
  60. unsigned long buf_idx;
  61. unsigned long read_time;
  62. };
  63. int ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
  64. struct module *owner);
  65. void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
  66. int ishtp_register_event_cb(struct ishtp_cl_device *device,
  67. void (*read_cb)(struct ishtp_cl_device *));
  68. /* Get the device * from ishtp device instance */
  69. struct device *ishtp_device(struct ishtp_cl_device *cl_device);
  70. /* Trace interface for clients */
  71. void *ishtp_trace_callback(struct ishtp_cl_device *cl_device);
  72. /* Get device pointer of PCI device for DMA acces */
  73. struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device);
  74. struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device);
  75. void ishtp_cl_free(struct ishtp_cl *cl);
  76. int ishtp_cl_link(struct ishtp_cl *cl);
  77. void ishtp_cl_unlink(struct ishtp_cl *cl);
  78. int ishtp_cl_disconnect(struct ishtp_cl *cl);
  79. int ishtp_cl_connect(struct ishtp_cl *cl);
  80. int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length);
  81. int ishtp_cl_flush_queues(struct ishtp_cl *cl);
  82. int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb);
  83. bool ishtp_cl_tx_empty(struct ishtp_cl *cl);
  84. struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl);
  85. void *ishtp_get_client_data(struct ishtp_cl *cl);
  86. void ishtp_set_client_data(struct ishtp_cl *cl, void *data);
  87. struct ishtp_device *ishtp_get_ishtp_device(struct ishtp_cl *cl);
  88. void ishtp_set_tx_ring_size(struct ishtp_cl *cl, int size);
  89. void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size);
  90. void ishtp_set_connection_state(struct ishtp_cl *cl, int state);
  91. void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id);
  92. void ishtp_put_device(struct ishtp_cl_device *cl_dev);
  93. void ishtp_get_device(struct ishtp_cl_device *cl_dev);
  94. void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data);
  95. void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device);
  96. struct ishtp_cl_device *ishtp_dev_to_cl_device(struct device *dev);
  97. int ishtp_register_event_cb(struct ishtp_cl_device *device,
  98. void (*read_cb)(struct ishtp_cl_device *));
  99. struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
  100. const guid_t *uuid);
  101. int ishtp_get_fw_client_id(struct ishtp_fw_client *fw_client);
  102. int ish_hw_reset(struct ishtp_device *dev);
  103. #endif /* _INTEL_ISH_CLIENT_IF_H_ */