phy-mv-usb.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
  4. */
  5. #ifndef __MV_USB_OTG_CONTROLLER__
  6. #define __MV_USB_OTG_CONTROLLER__
  7. #include <linux/types.h>
  8. /* Command Register Bit Masks */
  9. #define USBCMD_RUN_STOP (0x00000001)
  10. #define USBCMD_CTRL_RESET (0x00000002)
  11. /* otgsc Register Bit Masks */
  12. #define OTGSC_CTRL_VUSB_DISCHARGE 0x00000001
  13. #define OTGSC_CTRL_VUSB_CHARGE 0x00000002
  14. #define OTGSC_CTRL_OTG_TERM 0x00000008
  15. #define OTGSC_CTRL_DATA_PULSING 0x00000010
  16. #define OTGSC_STS_USB_ID 0x00000100
  17. #define OTGSC_STS_A_VBUS_VALID 0x00000200
  18. #define OTGSC_STS_A_SESSION_VALID 0x00000400
  19. #define OTGSC_STS_B_SESSION_VALID 0x00000800
  20. #define OTGSC_STS_B_SESSION_END 0x00001000
  21. #define OTGSC_STS_1MS_TOGGLE 0x00002000
  22. #define OTGSC_STS_DATA_PULSING 0x00004000
  23. #define OTGSC_INTSTS_USB_ID 0x00010000
  24. #define OTGSC_INTSTS_A_VBUS_VALID 0x00020000
  25. #define OTGSC_INTSTS_A_SESSION_VALID 0x00040000
  26. #define OTGSC_INTSTS_B_SESSION_VALID 0x00080000
  27. #define OTGSC_INTSTS_B_SESSION_END 0x00100000
  28. #define OTGSC_INTSTS_1MS 0x00200000
  29. #define OTGSC_INTSTS_DATA_PULSING 0x00400000
  30. #define OTGSC_INTR_USB_ID 0x01000000
  31. #define OTGSC_INTR_A_VBUS_VALID 0x02000000
  32. #define OTGSC_INTR_A_SESSION_VALID 0x04000000
  33. #define OTGSC_INTR_B_SESSION_VALID 0x08000000
  34. #define OTGSC_INTR_B_SESSION_END 0x10000000
  35. #define OTGSC_INTR_1MS_TIMER 0x20000000
  36. #define OTGSC_INTR_DATA_PULSING 0x40000000
  37. #define CAPLENGTH_MASK (0xff)
  38. /* Timer's interval, unit 10ms */
  39. #define T_A_WAIT_VRISE 100
  40. #define T_A_WAIT_BCON 2000
  41. #define T_A_AIDL_BDIS 100
  42. #define T_A_BIDL_ADIS 20
  43. #define T_B_ASE0_BRST 400
  44. #define T_B_SE0_SRP 300
  45. #define T_B_SRP_FAIL 2000
  46. #define T_B_DATA_PLS 10
  47. #define T_B_SRP_INIT 100
  48. #define T_A_SRP_RSPNS 10
  49. #define T_A_DRV_RSM 5
  50. enum otg_function {
  51. OTG_B_DEVICE = 0,
  52. OTG_A_DEVICE
  53. };
  54. enum mv_otg_timer {
  55. A_WAIT_BCON_TIMER = 0,
  56. OTG_TIMER_NUM
  57. };
  58. /* PXA OTG state machine */
  59. struct mv_otg_ctrl {
  60. /* internal variables */
  61. u8 a_set_b_hnp_en; /* A-Device set b_hnp_en */
  62. u8 b_srp_done;
  63. u8 b_hnp_en;
  64. /* OTG inputs */
  65. u8 a_bus_drop;
  66. u8 a_bus_req;
  67. u8 a_clr_err;
  68. u8 a_bus_resume;
  69. u8 a_bus_suspend;
  70. u8 a_conn;
  71. u8 a_sess_vld;
  72. u8 a_srp_det;
  73. u8 a_vbus_vld;
  74. u8 b_bus_req; /* B-Device Require Bus */
  75. u8 b_bus_resume;
  76. u8 b_bus_suspend;
  77. u8 b_conn;
  78. u8 b_se0_srp;
  79. u8 b_sess_end;
  80. u8 b_sess_vld;
  81. u8 id;
  82. u8 a_suspend_req;
  83. /*Timer event */
  84. u8 a_aidl_bdis_timeout;
  85. u8 b_ase0_brst_timeout;
  86. u8 a_bidl_adis_timeout;
  87. u8 a_wait_bcon_timeout;
  88. struct timer_list timer[OTG_TIMER_NUM];
  89. };
  90. #define VUSBHS_MAX_PORTS 8
  91. struct mv_otg_regs {
  92. u32 usbcmd; /* Command register */
  93. u32 usbsts; /* Status register */
  94. u32 usbintr; /* Interrupt enable */
  95. u32 frindex; /* Frame index */
  96. u32 reserved1[1];
  97. u32 deviceaddr; /* Device Address */
  98. u32 eplistaddr; /* Endpoint List Address */
  99. u32 ttctrl; /* HOST TT status and control */
  100. u32 burstsize; /* Programmable Burst Size */
  101. u32 txfilltuning; /* Host Transmit Pre-Buffer Packet Tuning */
  102. u32 reserved[4];
  103. u32 epnak; /* Endpoint NAK */
  104. u32 epnaken; /* Endpoint NAK Enable */
  105. u32 configflag; /* Configured Flag register */
  106. u32 portsc[VUSBHS_MAX_PORTS]; /* Port Status/Control x, x = 1..8 */
  107. u32 otgsc;
  108. u32 usbmode; /* USB Host/Device mode */
  109. u32 epsetupstat; /* Endpoint Setup Status */
  110. u32 epprime; /* Endpoint Initialize */
  111. u32 epflush; /* Endpoint De-initialize */
  112. u32 epstatus; /* Endpoint Status */
  113. u32 epcomplete; /* Endpoint Interrupt On Complete */
  114. u32 epctrlx[16]; /* Endpoint Control, where x = 0.. 15 */
  115. u32 mcr; /* Mux Control */
  116. u32 isr; /* Interrupt Status */
  117. u32 ier; /* Interrupt Enable */
  118. };
  119. struct mv_otg {
  120. struct usb_phy phy;
  121. struct mv_otg_ctrl otg_ctrl;
  122. /* base address */
  123. void __iomem *phy_regs;
  124. void __iomem *cap_regs;
  125. struct mv_otg_regs __iomem *op_regs;
  126. struct platform_device *pdev;
  127. int irq;
  128. u32 irq_status;
  129. u32 irq_en;
  130. struct delayed_work work;
  131. struct workqueue_struct *qwork;
  132. spinlock_t wq_lock;
  133. struct mv_usb_platform_data *pdata;
  134. unsigned int active;
  135. unsigned int clock_gating;
  136. struct clk *clk;
  137. };
  138. #endif