spear-pcie-gadget.txt 3.9 KB

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