xref: /openbmc/linux/Documentation/PCI/endpoint/pci-test-function.rst (revision 0898782247ae533d1f4e47a06bc5d4870931b284)
1*bf2c2658SChangbin Du.. SPDX-License-Identifier: GPL-2.0
2*bf2c2658SChangbin Du
3*bf2c2658SChangbin Du=================
4*bf2c2658SChangbin DuPCI Test Function
5*bf2c2658SChangbin Du=================
6*bf2c2658SChangbin Du
7*bf2c2658SChangbin Du:Author: Kishon Vijay Abraham I <kishon@ti.com>
8*bf2c2658SChangbin Du
9*bf2c2658SChangbin DuTraditionally PCI RC has always been validated by using standard
10*bf2c2658SChangbin DuPCI cards like ethernet PCI cards or USB PCI cards or SATA PCI cards.
11*bf2c2658SChangbin DuHowever with the addition of EP-core in linux kernel, it is possible
12*bf2c2658SChangbin Duto configure a PCI controller that can operate in EP mode to work as
13*bf2c2658SChangbin Dua test device.
14*bf2c2658SChangbin Du
15*bf2c2658SChangbin DuThe PCI endpoint test device is a virtual device (defined in software)
16*bf2c2658SChangbin Duused to test the endpoint functionality and serve as a sample driver
17*bf2c2658SChangbin Dufor other PCI endpoint devices (to use the EP framework).
18*bf2c2658SChangbin Du
19*bf2c2658SChangbin DuThe PCI endpoint test device has the following registers:
20*bf2c2658SChangbin Du
21*bf2c2658SChangbin Du	1) PCI_ENDPOINT_TEST_MAGIC
22*bf2c2658SChangbin Du	2) PCI_ENDPOINT_TEST_COMMAND
23*bf2c2658SChangbin Du	3) PCI_ENDPOINT_TEST_STATUS
24*bf2c2658SChangbin Du	4) PCI_ENDPOINT_TEST_SRC_ADDR
25*bf2c2658SChangbin Du	5) PCI_ENDPOINT_TEST_DST_ADDR
26*bf2c2658SChangbin Du	6) PCI_ENDPOINT_TEST_SIZE
27*bf2c2658SChangbin Du	7) PCI_ENDPOINT_TEST_CHECKSUM
28*bf2c2658SChangbin Du	8) PCI_ENDPOINT_TEST_IRQ_TYPE
29*bf2c2658SChangbin Du	9) PCI_ENDPOINT_TEST_IRQ_NUMBER
30*bf2c2658SChangbin Du
31*bf2c2658SChangbin Du* PCI_ENDPOINT_TEST_MAGIC
32*bf2c2658SChangbin Du
33*bf2c2658SChangbin DuThis register will be used to test BAR0. A known pattern will be written
34*bf2c2658SChangbin Duand read back from MAGIC register to verify BAR0.
35*bf2c2658SChangbin Du
36*bf2c2658SChangbin Du* PCI_ENDPOINT_TEST_COMMAND
37*bf2c2658SChangbin Du
38*bf2c2658SChangbin DuThis register will be used by the host driver to indicate the function
39*bf2c2658SChangbin Duthat the endpoint device must perform.
40*bf2c2658SChangbin Du
41*bf2c2658SChangbin Du========	================================================================
42*bf2c2658SChangbin DuBitfield	Description
43*bf2c2658SChangbin Du========	================================================================
44*bf2c2658SChangbin DuBit 0		raise legacy IRQ
45*bf2c2658SChangbin DuBit 1		raise MSI IRQ
46*bf2c2658SChangbin DuBit 2		raise MSI-X IRQ
47*bf2c2658SChangbin DuBit 3		read command (read data from RC buffer)
48*bf2c2658SChangbin DuBit 4		write command (write data to RC buffer)
49*bf2c2658SChangbin DuBit 5		copy command (copy data from one RC buffer to another RC buffer)
50*bf2c2658SChangbin Du========	================================================================
51*bf2c2658SChangbin Du
52*bf2c2658SChangbin Du* PCI_ENDPOINT_TEST_STATUS
53*bf2c2658SChangbin Du
54*bf2c2658SChangbin DuThis register reflects the status of the PCI endpoint device.
55*bf2c2658SChangbin Du
56*bf2c2658SChangbin Du========	==============================
57*bf2c2658SChangbin DuBitfield	Description
58*bf2c2658SChangbin Du========	==============================
59*bf2c2658SChangbin DuBit 0		read success
60*bf2c2658SChangbin DuBit 1		read fail
61*bf2c2658SChangbin DuBit 2		write success
62*bf2c2658SChangbin DuBit 3		write fail
63*bf2c2658SChangbin DuBit 4		copy success
64*bf2c2658SChangbin DuBit 5		copy fail
65*bf2c2658SChangbin DuBit 6		IRQ raised
66*bf2c2658SChangbin DuBit 7		source address is invalid
67*bf2c2658SChangbin DuBit 8		destination address is invalid
68*bf2c2658SChangbin Du========	==============================
69*bf2c2658SChangbin Du
70*bf2c2658SChangbin Du* PCI_ENDPOINT_TEST_SRC_ADDR
71*bf2c2658SChangbin Du
72*bf2c2658SChangbin DuThis register contains the source address (RC buffer address) for the
73*bf2c2658SChangbin DuCOPY/READ command.
74*bf2c2658SChangbin Du
75*bf2c2658SChangbin Du* PCI_ENDPOINT_TEST_DST_ADDR
76*bf2c2658SChangbin Du
77*bf2c2658SChangbin DuThis register contains the destination address (RC buffer address) for
78*bf2c2658SChangbin Duthe COPY/WRITE command.
79*bf2c2658SChangbin Du
80*bf2c2658SChangbin Du* PCI_ENDPOINT_TEST_IRQ_TYPE
81*bf2c2658SChangbin Du
82*bf2c2658SChangbin DuThis register contains the interrupt type (Legacy/MSI) triggered
83*bf2c2658SChangbin Dufor the READ/WRITE/COPY and raise IRQ (Legacy/MSI) commands.
84*bf2c2658SChangbin Du
85*bf2c2658SChangbin DuPossible types:
86*bf2c2658SChangbin Du
87*bf2c2658SChangbin Du======	==
88*bf2c2658SChangbin DuLegacy	0
89*bf2c2658SChangbin DuMSI	1
90*bf2c2658SChangbin DuMSI-X	2
91*bf2c2658SChangbin Du======	==
92*bf2c2658SChangbin Du
93*bf2c2658SChangbin Du* PCI_ENDPOINT_TEST_IRQ_NUMBER
94*bf2c2658SChangbin Du
95*bf2c2658SChangbin DuThis register contains the triggered ID interrupt.
96*bf2c2658SChangbin Du
97*bf2c2658SChangbin DuAdmissible values:
98*bf2c2658SChangbin Du
99*bf2c2658SChangbin Du======	===========
100*bf2c2658SChangbin DuLegacy	0
101*bf2c2658SChangbin DuMSI	[1 .. 32]
102*bf2c2658SChangbin DuMSI-X	[1 .. 2048]
103*bf2c2658SChangbin Du======	===========
104