fxhci_debug.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: fxhci_debug.c
  15. * Date: 2022-02-11 13:33:12
  16. * LastEditTime: 2022-02-18 09:12:15
  17. * Description:  This files is for implementation of XHCI debug utilities
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. * 1.0 Zhugengyu 2022/2/7 init commit
  23. */
  24. #include <inttypes.h>
  25. #include "fdebug.h"
  26. #include "fxhci_private.h"
  27. #define FUSB_DEBUG_TAG "FXHCI_DEBUG"
  28. #define FUSB_ERROR(format, ...) FT_DEBUG_PRINT_E(FUSB_DEBUG_TAG, format, ##__VA_ARGS__)
  29. #define FUSB_WARN(format, ...) FT_DEBUG_PRINT_W(FUSB_DEBUG_TAG, format, ##__VA_ARGS__)
  30. #define FUSB_INFO(format, ...) FT_DEBUG_PRINT_I(FUSB_DEBUG_TAG, format, ##__VA_ARGS__)
  31. #define FUSB_DEBUG(format, ...) FT_DEBUG_PRINT_D(FUSB_DEBUG_TAG, format, ##__VA_ARGS__)
  32. void FXhciDumpSlotCtx(const FXhciSlotCtx *const sc)
  33. {
  34. FUSB_INFO("Slot Context (@%p): ", sc);
  35. FUSB_INFO(" FIELD1\t0x%08x ", sc->f1);
  36. FUSB_INFO(" FIELD2\t0x%08x ", sc->f2);
  37. FUSB_INFO(" FIELD3\t0x%08x ", sc->f3);
  38. FUSB_INFO(" FIELD4\t0x%08x ", sc->f4);
  39. FXHCI_SC_DUMP(FUSB_INFO, ROUTE, sc);
  40. FXHCI_SC_DUMP(FUSB_INFO, SPEED1, sc);
  41. FXHCI_SC_DUMP(FUSB_INFO, MTT, sc);
  42. FXHCI_SC_DUMP(FUSB_INFO, HUB, sc);
  43. FXHCI_SC_DUMP(FUSB_INFO, CTXENT, sc);
  44. FXHCI_SC_DUMP(FUSB_INFO, RHPORT, sc);
  45. FXHCI_SC_DUMP(FUSB_INFO, NPORTS, sc);
  46. FXHCI_SC_DUMP(FUSB_INFO, TTID, sc);
  47. FXHCI_SC_DUMP(FUSB_INFO, TTPORT, sc);
  48. FXHCI_SC_DUMP(FUSB_INFO, TTT, sc);
  49. FXHCI_SC_DUMP(FUSB_INFO, UADDR, sc);
  50. FXHCI_SC_DUMP(FUSB_INFO, STATE, sc);
  51. }
  52. void FXhciDumpEpCtx(const FXhciEpCtx *const ec)
  53. {
  54. FUSB_INFO("Endpoint Context (@%p): ", ec);
  55. FUSB_INFO(" FIELD1\t0x%08x ", ec->f1);
  56. FUSB_INFO(" FIELD2\t0x%08x ", ec->f2);
  57. FUSB_INFO(" TRDQ_L\t0x%08x ", ec->tr_dq_low);
  58. FUSB_INFO(" TRDQ_H\t0x%08x ", ec->tr_dq_high);
  59. FUSB_INFO(" FIELD5\t0x%08x ", ec->f5);
  60. FXHCI_EC_DUMP(FUSB_INFO, STATE, ec);
  61. FXHCI_EC_DUMP(FUSB_INFO, INTVAL, ec);
  62. FXHCI_EC_DUMP(FUSB_INFO, CERR, ec);
  63. FXHCI_EC_DUMP(FUSB_INFO, TYPE, ec);
  64. FXHCI_EC_DUMP(FUSB_INFO, MBS, ec);
  65. FXHCI_EC_DUMP(FUSB_INFO, MPS, ec);
  66. FXHCI_EC_DUMP(FUSB_INFO, DCS, ec);
  67. FXHCI_EC_DUMP(FUSB_INFO, AVRTRB, ec);
  68. FXHCI_EC_DUMP(FUSB_INFO, MXESIT, ec);
  69. }
  70. void FXhciDumpDevCtx(const FXhciDevCtx *const dc, const u32 ctx_mask)
  71. {
  72. unsigned int i;
  73. if (ctx_mask & 1)
  74. FXhciDumpSlotCtx(dc->slot);
  75. for (i = 1; i <= FXHCI_SC_GET(CTXENT, dc->slot); ++i)
  76. {
  77. if (ctx_mask & (1 << i))
  78. FXhciDumpEpCtx(dc->ep[i]);
  79. }
  80. }
  81. void FXhciDumpInputCtx(const FXhciInputCtx *const ic)
  82. {
  83. FUSB_INFO("Input Control add: 0x%08x ", *ic->add);
  84. FUSB_INFO("Input Control drop: 0x%08x ", *ic->drop);
  85. FXhciDumpDevCtx(&ic->dev, *ic->add);
  86. }
  87. void FXhciDumpTransferTrb(const FXhciTrb *const cur)
  88. {
  89. FUSB_INFO("Transfer TRB (@%p): ", cur);
  90. FUSB_INFO(" PTR_L\t0x%08x ", cur->ptr_low);
  91. FUSB_INFO(" PTR_H\t0x%08x ", cur->ptr_high);
  92. FUSB_INFO(" STATUS\t0x%08x ", cur->status);
  93. FUSB_INFO(" CNTRL\t0x%08x ", cur->control);
  94. FXHCI_TRB_DUMP(FUSB_INFO, TL, cur);
  95. FXHCI_TRB_DUMP(FUSB_INFO, TDS, cur);
  96. FXHCI_TRB_DUMP(FUSB_INFO, C, cur);
  97. FXHCI_TRB_DUMP(FUSB_INFO, ISP, cur);
  98. FXHCI_TRB_DUMP(FUSB_INFO, CH, cur);
  99. FXHCI_TRB_DUMP(FUSB_INFO, IOC, cur);
  100. FXHCI_TRB_DUMP(FUSB_INFO, IDT, cur);
  101. FXHCI_TRB_DUMP(FUSB_INFO, TT, cur);
  102. FXHCI_TRB_DUMP(FUSB_INFO, DIR, cur);
  103. }
  104. static const FXhciTrb *FXhciNextTrb(const FXhciTrb *const cur)
  105. {
  106. if (FXHCI_TRB_GET(TT, cur) == FXHCI_TRB_LINK)
  107. return (!cur->ptr_low) ? NULL : (void *)(uintptr)(cur->ptr_low);
  108. else
  109. return cur + 1;
  110. }
  111. void FXhciDumpTransferTrbs(const FXhciTrb *const first, const FXhciTrb *const last)
  112. {
  113. const FXhciTrb *cur;
  114. for (cur = first; cur; cur = FXhciNextTrb(cur))
  115. {
  116. FXhciDumpTransferTrb(cur);
  117. if (cur == last)
  118. break;
  119. }
  120. }