chipidea.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Platform data for the chipidea USB dual role controller
  4. */
  5. #ifndef __LINUX_USB_CHIPIDEA_H
  6. #define __LINUX_USB_CHIPIDEA_H
  7. #include <linux/extcon.h>
  8. #include <linux/usb/otg.h>
  9. struct ci_hdrc;
  10. /**
  11. * struct ci_hdrc_cable - structure for external connector cable state tracking
  12. * @connected: true if cable is connected, false otherwise
  13. * @changed: set to true when extcon event happen
  14. * @enabled: set to true if we've enabled the vbus or id interrupt
  15. * @edev: device which generate events
  16. * @ci: driver state of the chipidea device
  17. * @nb: hold event notification callback
  18. * @conn: used for notification registration
  19. */
  20. struct ci_hdrc_cable {
  21. bool connected;
  22. bool changed;
  23. bool enabled;
  24. struct extcon_dev *edev;
  25. struct ci_hdrc *ci;
  26. struct notifier_block nb;
  27. };
  28. struct ci_hdrc_platform_data {
  29. const char *name;
  30. /* offset of the capability registers */
  31. uintptr_t capoffset;
  32. unsigned power_budget;
  33. struct phy *phy;
  34. /* old usb_phy interface */
  35. struct usb_phy *usb_phy;
  36. enum usb_phy_interface phy_mode;
  37. unsigned long flags;
  38. #define CI_HDRC_REGS_SHARED BIT(0)
  39. #define CI_HDRC_DISABLE_DEVICE_STREAMING BIT(1)
  40. #define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2)
  41. #define CI_HDRC_DISABLE_HOST_STREAMING BIT(3)
  42. #define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING | \
  43. CI_HDRC_DISABLE_HOST_STREAMING)
  44. /*
  45. * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
  46. * but otg is not supported (no register otgsc).
  47. */
  48. #define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4)
  49. #define CI_HDRC_IMX28_WRITE_FIX BIT(5)
  50. #define CI_HDRC_FORCE_FULLSPEED BIT(6)
  51. #define CI_HDRC_TURN_VBUS_EARLY_ON BIT(7)
  52. #define CI_HDRC_SET_NON_ZERO_TTHA BIT(8)
  53. #define CI_HDRC_OVERRIDE_AHB_BURST BIT(9)
  54. #define CI_HDRC_OVERRIDE_TX_BURST BIT(10)
  55. #define CI_HDRC_OVERRIDE_RX_BURST BIT(11)
  56. #define CI_HDRC_OVERRIDE_PHY_CONTROL BIT(12) /* Glue layer manages phy */
  57. #define CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13)
  58. #define CI_HDRC_IMX_IS_HSIC BIT(14)
  59. #define CI_HDRC_PMQOS BIT(15)
  60. #define CI_HDRC_PHY_VBUS_CONTROL BIT(16)
  61. #define CI_HDRC_HAS_PORTSC_PEC_MISSED BIT(17)
  62. enum usb_dr_mode dr_mode;
  63. #define CI_HDRC_CONTROLLER_RESET_EVENT 0
  64. #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
  65. #define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2
  66. #define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3
  67. #define CI_HDRC_CONTROLLER_VBUS_EVENT 4
  68. int (*notify_event) (struct ci_hdrc *ci, unsigned event);
  69. struct regulator *reg_vbus;
  70. struct usb_otg_caps ci_otg_caps;
  71. bool tpl_support;
  72. /* interrupt threshold setting */
  73. u32 itc_setting;
  74. u32 ahb_burst_config;
  75. u32 tx_burst_size;
  76. u32 rx_burst_size;
  77. /* VBUS and ID signal state tracking, using extcon framework */
  78. struct ci_hdrc_cable vbus_extcon;
  79. struct ci_hdrc_cable id_extcon;
  80. u32 phy_clkgate_delay_us;
  81. /* pins */
  82. struct pinctrl *pctl;
  83. struct pinctrl_state *pins_default;
  84. struct pinctrl_state *pins_host;
  85. struct pinctrl_state *pins_device;
  86. /* platform-specific hooks */
  87. int (*hub_control)(struct ci_hdrc *ci, u16 typeReq, u16 wValue,
  88. u16 wIndex, char *buf, u16 wLength,
  89. bool *done, unsigned long *flags);
  90. void (*enter_lpm)(struct ci_hdrc *ci, bool enable);
  91. };
  92. /* Default offset of capability registers */
  93. #define DEF_CAPOFFSET 0x100
  94. /* Add ci hdrc device */
  95. struct platform_device *ci_hdrc_add_device(struct device *dev,
  96. struct resource *res, int nres,
  97. struct ci_hdrc_platform_data *platdata);
  98. /* Remove ci hdrc device */
  99. void ci_hdrc_remove_device(struct platform_device *pdev);
  100. /* Get current available role */
  101. enum usb_dr_mode ci_hdrc_query_available_role(struct platform_device *pdev);
  102. #endif