1
0

bus.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * ISHTP bus definitions
  3. *
  4. * Copyright (c) 2014-2016, Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. #ifndef _LINUX_ISHTP_CL_BUS_H
  16. #define _LINUX_ISHTP_CL_BUS_H
  17. #include <linux/device.h>
  18. #include <linux/mod_devicetable.h>
  19. struct ishtp_cl;
  20. struct ishtp_cl_device;
  21. struct ishtp_device;
  22. struct ishtp_msg_hdr;
  23. /**
  24. * struct ishtp_cl_device - ISHTP device handle
  25. * @dev: device pointer
  26. * @ishtp_dev: pointer to ishtp device structure to primarily to access
  27. * hw device operation callbacks and properties
  28. * @fw_client: fw_client pointer to get fw information like protocol name
  29. * max message length etc.
  30. * @device_link: Link to next client in the list on a bus
  31. * @event_work: Used to schedule rx event for client
  32. * @driver_data: Storage driver private data
  33. * @reference_count: Used for get/put device
  34. * @event_cb: Callback to driver to send events
  35. *
  36. * An ishtp_cl_device pointer is returned from ishtp_add_device()
  37. * and links ISHTP bus clients to their actual host client pointer.
  38. * Drivers for ISHTP devices will get an ishtp_cl_device pointer
  39. * when being probed and shall use it for doing bus I/O.
  40. */
  41. struct ishtp_cl_device {
  42. struct device dev;
  43. struct ishtp_device *ishtp_dev;
  44. struct ishtp_fw_client *fw_client;
  45. struct list_head device_link;
  46. struct work_struct event_work;
  47. void *driver_data;
  48. int reference_count;
  49. void (*event_cb)(struct ishtp_cl_device *device);
  50. };
  51. /**
  52. * struct ishtp_cl_device - ISHTP device handle
  53. * @driver: driver instance on a bus
  54. * @name: Name of the device for probe
  55. * @probe: driver callback for device probe
  56. * @remove: driver callback on device removal
  57. *
  58. * Client drivers defines to get probed/removed for ISHTP client device.
  59. */
  60. struct ishtp_cl_driver {
  61. struct device_driver driver;
  62. const char *name;
  63. int (*probe)(struct ishtp_cl_device *dev);
  64. int (*remove)(struct ishtp_cl_device *dev);
  65. int (*reset)(struct ishtp_cl_device *dev);
  66. const struct dev_pm_ops *pm;
  67. };
  68. int ishtp_bus_new_client(struct ishtp_device *dev);
  69. void ishtp_remove_all_clients(struct ishtp_device *dev);
  70. int ishtp_cl_device_bind(struct ishtp_cl *cl);
  71. void ishtp_cl_bus_rx_event(struct ishtp_cl_device *device);
  72. /* Write a multi-fragment message */
  73. int ishtp_send_msg(struct ishtp_device *dev,
  74. struct ishtp_msg_hdr *hdr, void *msg,
  75. void (*ipc_send_compl)(void *),
  76. void *ipc_send_compl_prm);
  77. /* Write a single-fragment message */
  78. int ishtp_write_message(struct ishtp_device *dev,
  79. struct ishtp_msg_hdr *hdr,
  80. unsigned char *buf);
  81. /* Use DMA to send/receive messages */
  82. int ishtp_use_dma_transfer(void);
  83. /* Exported functions */
  84. void ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,
  85. bool warm_reset);
  86. void ishtp_recv(struct ishtp_device *dev);
  87. void ishtp_reset_handler(struct ishtp_device *dev);
  88. void ishtp_reset_compl_handler(struct ishtp_device *dev);
  89. void ishtp_put_device(struct ishtp_cl_device *);
  90. void ishtp_get_device(struct ishtp_cl_device *);
  91. int __ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
  92. struct module *owner);
  93. #define ishtp_cl_driver_register(driver) \
  94. __ishtp_cl_driver_register(driver, THIS_MODULE)
  95. void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
  96. int ishtp_register_event_cb(struct ishtp_cl_device *device,
  97. void (*read_cb)(struct ishtp_cl_device *));
  98. int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const uuid_le *cuuid);
  99. #endif /* _LINUX_ISHTP_CL_BUS_H */