1.. SPDX-License-Identifier: GPL-2.0
2
3=======================================
4Configuring PCI Endpoint Using CONFIGFS
5=======================================
6
7:Author: Kishon Vijay Abraham I <kishon@ti.com>
8
9The PCI Endpoint Core exposes configfs entry (pci_ep) to configure the
10PCI endpoint function and to bind the endpoint function
11with the endpoint controller. (For introducing other mechanisms to
12configure the PCI Endpoint Function refer to [1]).
13
14Mounting configfs
15=================
16
17The PCI Endpoint Core layer creates pci_ep directory in the mounted configfs
18directory. configfs can be mounted using the following command::
19
20	mount -t configfs none /sys/kernel/config
21
22Directory Structure
23===================
24
25The pci_ep configfs has two directories at its root: controllers and
26functions. Every EPC device present in the system will have an entry in
27the *controllers* directory and every EPF driver present in the system
28will have an entry in the *functions* directory.
29::
30
31	/sys/kernel/config/pci_ep/
32		.. controllers/
33		.. functions/
34
35Creating EPF Device
36===================
37
38Every registered EPF driver will be listed in controllers directory. The
39entries corresponding to EPF driver will be created by the EPF core.
40::
41
42	/sys/kernel/config/pci_ep/functions/
43		.. <EPF Driver1>/
44			... <EPF Device 11>/
45			... <EPF Device 21>/
46		.. <EPF Driver2>/
47			... <EPF Device 12>/
48			... <EPF Device 22>/
49
50In order to create a <EPF device> of the type probed by <EPF Driver>, the
51user has to create a directory inside <EPF DriverN>.
52
53Every <EPF device> directory consists of the following entries that can be
54used to configure the standard configuration header of the endpoint function.
55(These entries are created by the framework when any new <EPF Device> is
56created)
57::
58
59		.. <EPF Driver1>/
60			... <EPF Device 11>/
61				... vendorid
62				... deviceid
63				... revid
64				... progif_code
65				... subclass_code
66				... baseclass_code
67				... cache_line_size
68				... subsys_vendor_id
69				... subsys_id
70				... interrupt_pin
71
72EPC Device
73==========
74
75Every registered EPC device will be listed in controllers directory. The
76entries corresponding to EPC device will be created by the EPC core.
77::
78
79	/sys/kernel/config/pci_ep/controllers/
80		.. <EPC Device1>/
81			... <Symlink EPF Device11>/
82			... <Symlink EPF Device12>/
83			... start
84		.. <EPC Device2>/
85			... <Symlink EPF Device21>/
86			... <Symlink EPF Device22>/
87			... start
88
89The <EPC Device> directory will have a list of symbolic links to
90<EPF Device>. These symbolic links should be created by the user to
91represent the functions present in the endpoint device.
92
93The <EPC Device> directory will also have a *start* field. Once
94"1" is written to this field, the endpoint device will be ready to
95establish the link with the host. This is usually done after
96all the EPF devices are created and linked with the EPC device.
97::
98
99			 | controllers/
100				| <Directory: EPC name>/
101					| <Symbolic Link: Function>
102					| start
103			 | functions/
104				| <Directory: EPF driver>/
105					| <Directory: EPF device>/
106						| vendorid
107						| deviceid
108						| revid
109						| progif_code
110						| subclass_code
111						| baseclass_code
112						| cache_line_size
113						| subsys_vendor_id
114						| subsys_id
115						| interrupt_pin
116						| function
117
118[1] :doc:`pci-endpoint`
119