hd.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Greybus Host Device
  4. *
  5. * Copyright 2014-2015 Google Inc.
  6. * Copyright 2014-2015 Linaro Ltd.
  7. */
  8. #ifndef __HD_H
  9. #define __HD_H
  10. #include <linux/types.h>
  11. #include <linux/device.h>
  12. struct gb_host_device;
  13. struct gb_message;
  14. struct gb_hd_driver {
  15. size_t hd_priv_size;
  16. int (*cport_allocate)(struct gb_host_device *hd, int cport_id,
  17. unsigned long flags);
  18. void (*cport_release)(struct gb_host_device *hd, u16 cport_id);
  19. int (*cport_enable)(struct gb_host_device *hd, u16 cport_id,
  20. unsigned long flags);
  21. int (*cport_disable)(struct gb_host_device *hd, u16 cport_id);
  22. int (*cport_connected)(struct gb_host_device *hd, u16 cport_id);
  23. int (*cport_flush)(struct gb_host_device *hd, u16 cport_id);
  24. int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id,
  25. u8 phase, unsigned int timeout);
  26. int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id,
  27. size_t peer_space, unsigned int timeout);
  28. int (*cport_clear)(struct gb_host_device *hd, u16 cport_id);
  29. int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id,
  30. struct gb_message *message, gfp_t gfp_mask);
  31. void (*message_cancel)(struct gb_message *message);
  32. int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
  33. int (*latency_tag_disable)(struct gb_host_device *hd, u16 cport_id);
  34. int (*output)(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
  35. bool async);
  36. };
  37. struct gb_host_device {
  38. struct device dev;
  39. int bus_id;
  40. const struct gb_hd_driver *driver;
  41. struct list_head modules;
  42. struct list_head connections;
  43. struct ida cport_id_map;
  44. /* Number of CPorts supported by the UniPro IP */
  45. size_t num_cports;
  46. /* Host device buffer constraints */
  47. size_t buffer_size_max;
  48. struct gb_svc *svc;
  49. /* Private data for the host driver */
  50. unsigned long hd_priv[] __aligned(sizeof(s64));
  51. };
  52. #define to_gb_host_device(d) container_of(d, struct gb_host_device, dev)
  53. int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id);
  54. void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id);
  55. int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,
  56. unsigned long flags);
  57. void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id);
  58. struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
  59. struct device *parent,
  60. size_t buffer_size_max,
  61. size_t num_cports);
  62. int gb_hd_add(struct gb_host_device *hd);
  63. void gb_hd_del(struct gb_host_device *hd);
  64. void gb_hd_shutdown(struct gb_host_device *hd);
  65. void gb_hd_put(struct gb_host_device *hd);
  66. int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
  67. bool in_irq);
  68. int gb_hd_init(void);
  69. void gb_hd_exit(void);
  70. #endif /* __HD_H */