spear-pcie-gadget.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ========================
  3. Spear PCIe Gadget Driver
  4. ========================
  5. Author
  6. ======
  7. Pratyush Anand (pratyush.anand@gmail.com)
  8. Location
  9. ========
  10. driver/misc/spear13xx_pcie_gadget.c
  11. Supported Chip:
  12. ===============
  13. SPEAr1300
  14. SPEAr1310
  15. Menuconfig option:
  16. ==================
  17. Device Drivers
  18. Misc devices
  19. PCIe gadget support for SPEAr13XX platform
  20. purpose
  21. =======
  22. This driver has several nodes which can be read/written by configfs interface.
  23. Its main purpose is to configure selected dual mode PCIe controller as device
  24. and then program its various registers to configure it as a particular device
  25. type. This driver can be used to show spear's PCIe device capability.
  26. Description of different nodes:
  27. ===============================
  28. read behavior of nodes:
  29. -----------------------
  30. =============== ==============================================================
  31. link gives ltssm status.
  32. int_type type of supported interrupt
  33. no_of_msi zero if MSI is not enabled by host. A positive value is the
  34. number of MSI vector granted.
  35. vendor_id returns programmed vendor id (hex)
  36. device_id returns programmed device id(hex)
  37. bar0_size: returns size of bar0 in hex.
  38. bar0_address returns address of bar0 mapped area in hex.
  39. bar0_rw_offset returns offset of bar0 for which bar0_data will return value.
  40. bar0_data returns data at bar0_rw_offset.
  41. =============== ==============================================================
  42. write behavior of nodes:
  43. ------------------------
  44. =============== ================================================================
  45. link write UP to enable ltsmm DOWN to disable
  46. int_type write interrupt type to be configured and (int_type could be
  47. INTA, MSI or NO_INT). Select MSI only when you have programmed
  48. no_of_msi node.
  49. no_of_msi number of MSI vector needed.
  50. inta write 1 to assert INTA and 0 to de-assert.
  51. send_msi write MSI vector to be sent.
  52. vendor_id write vendor id(hex) to be programmed.
  53. device_id write device id(hex) to be programmed.
  54. bar0_size write size of bar0 in hex. default bar0 size is 1000 (hex)
  55. bytes.
  56. bar0_address write address of bar0 mapped area in hex. (default mapping of
  57. bar0 is SYSRAM1(E0800000). Always program bar size before bar
  58. address. Kernel might modify bar size and address for alignment,
  59. so read back bar size and address after writing to cross check.
  60. bar0_rw_offset write offset of bar0 for which bar0_data will write value.
  61. bar0_data write data to be written at bar0_rw_offset.
  62. =============== ================================================================
  63. Node programming example
  64. ========================
  65. Program all PCIe registers in such a way that when this device is connected
  66. to the PCIe host, then host sees this device as 1MB RAM.
  67. ::
  68. #mount -t configfs none /Config
  69. For nth PCIe Device Controller::
  70. # cd /config/pcie_gadget.n/
  71. Now you have all the nodes in this directory.
  72. program vendor id as 0x104a::
  73. # echo 104A >> vendor_id
  74. program device id as 0xCD80::
  75. # echo CD80 >> device_id
  76. program BAR0 size as 1MB::
  77. # echo 100000 >> bar0_size
  78. check for programmed bar0 size::
  79. # cat bar0_size
  80. Program BAR0 Address as DDR (0x2100000). This is the physical address of
  81. memory, which is to be made visible to PCIe host. Similarly any other peripheral
  82. can also be made visible to PCIe host. E.g., if you program base address of UART
  83. as BAR0 address then when this device will be connected to a host, it will be
  84. visible as UART.
  85. ::
  86. # echo 2100000 >> bar0_address
  87. program interrupt type : INTA::
  88. # echo INTA >> int_type
  89. go for link up now::
  90. # echo UP >> link
  91. It will have to be insured that, once link up is done on gadget, then only host
  92. is initialized and start to search PCIe devices on its port.
  93. ::
  94. /*wait till link is up*/
  95. # cat link
  96. Wait till it returns UP.
  97. To assert INTA::
  98. # echo 1 >> inta
  99. To de-assert INTA::
  100. # echo 0 >> inta
  101. if MSI is to be used as interrupt, program no of msi vector needed (say4)::
  102. # echo 4 >> no_of_msi
  103. select MSI as interrupt type::
  104. # echo MSI >> int_type
  105. go for link up now::
  106. # echo UP >> link
  107. wait till link is up::
  108. # cat link
  109. An application can repetitively read this node till link is found UP. It can
  110. sleep between two read.
  111. wait till msi is enabled::
  112. # cat no_of_msi
  113. Should return 4 (number of requested MSI vector)
  114. to send msi vector 2::
  115. # echo 2 >> send_msi
  116. # cd -