interface.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Greybus Interface Block code
  4. *
  5. * Copyright 2014 Google Inc.
  6. * Copyright 2014 Linaro Ltd.
  7. */
  8. #ifndef __INTERFACE_H
  9. #define __INTERFACE_H
  10. #include <linux/types.h>
  11. #include <linux/device.h>
  12. enum gb_interface_type {
  13. GB_INTERFACE_TYPE_INVALID = 0,
  14. GB_INTERFACE_TYPE_UNKNOWN,
  15. GB_INTERFACE_TYPE_DUMMY,
  16. GB_INTERFACE_TYPE_UNIPRO,
  17. GB_INTERFACE_TYPE_GREYBUS,
  18. };
  19. #define GB_INTERFACE_QUIRK_NO_CPORT_FEATURES BIT(0)
  20. #define GB_INTERFACE_QUIRK_NO_INIT_STATUS BIT(1)
  21. #define GB_INTERFACE_QUIRK_NO_GMP_IDS BIT(2)
  22. #define GB_INTERFACE_QUIRK_FORCED_DISABLE BIT(3)
  23. #define GB_INTERFACE_QUIRK_LEGACY_MODE_SWITCH BIT(4)
  24. #define GB_INTERFACE_QUIRK_NO_BUNDLE_ACTIVATE BIT(5)
  25. #define GB_INTERFACE_QUIRK_NO_PM BIT(6)
  26. struct gb_interface {
  27. struct device dev;
  28. struct gb_control *control;
  29. struct list_head bundles;
  30. struct list_head module_node;
  31. struct list_head manifest_descs;
  32. u8 interface_id; /* Physical location within the Endo */
  33. u8 device_id;
  34. u8 features; /* Feature flags set in the manifest */
  35. enum gb_interface_type type;
  36. u32 ddbl1_manufacturer_id;
  37. u32 ddbl1_product_id;
  38. u32 vendor_id;
  39. u32 product_id;
  40. u64 serial_number;
  41. struct gb_host_device *hd;
  42. struct gb_module *module;
  43. unsigned long quirks;
  44. struct mutex mutex;
  45. bool disconnected;
  46. bool ejected;
  47. bool removed;
  48. bool active;
  49. bool enabled;
  50. bool mode_switch;
  51. bool dme_read;
  52. struct work_struct mode_switch_work;
  53. struct completion mode_switch_completion;
  54. };
  55. #define to_gb_interface(d) container_of(d, struct gb_interface, dev)
  56. struct gb_interface *gb_interface_create(struct gb_module *module,
  57. u8 interface_id);
  58. int gb_interface_activate(struct gb_interface *intf);
  59. void gb_interface_deactivate(struct gb_interface *intf);
  60. int gb_interface_enable(struct gb_interface *intf);
  61. void gb_interface_disable(struct gb_interface *intf);
  62. int gb_interface_add(struct gb_interface *intf);
  63. void gb_interface_del(struct gb_interface *intf);
  64. void gb_interface_put(struct gb_interface *intf);
  65. void gb_interface_mailbox_event(struct gb_interface *intf, u16 result,
  66. u32 mailbox);
  67. int gb_interface_request_mode_switch(struct gb_interface *intf);
  68. #endif /* __INTERFACE_H */