hd.h 2.9 KB

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