Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | ======================================= |
| 4 | Configuring PCI Endpoint Using CONFIGFS |
| 5 | ======================================= |
| 6 | |
| 7 | :Author: Kishon Vijay Abraham I <kishon@ti.com> |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 8 | |
| 9 | The PCI Endpoint Core exposes configfs entry (pci_ep) to configure the |
| 10 | PCI endpoint function and to bind the endpoint function |
| 11 | with the endpoint controller. (For introducing other mechanisms to |
| 12 | configure the PCI Endpoint Function refer to [1]). |
| 13 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 14 | Mounting configfs |
| 15 | ================= |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 16 | |
| 17 | The PCI Endpoint Core layer creates pci_ep directory in the mounted configfs |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 18 | directory. configfs can be mounted using the following command:: |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 19 | |
| 20 | mount -t configfs none /sys/kernel/config |
| 21 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 22 | Directory Structure |
| 23 | =================== |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 24 | |
| 25 | The pci_ep configfs has two directories at its root: controllers and |
| 26 | functions. Every EPC device present in the system will have an entry in |
| 27 | the *controllers* directory and and every EPF driver present in the system |
| 28 | will have an entry in the *functions* directory. |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 29 | :: |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 30 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 31 | /sys/kernel/config/pci_ep/ |
| 32 | .. controllers/ |
| 33 | .. functions/ |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 34 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 35 | Creating EPF Device |
| 36 | =================== |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 37 | |
| 38 | Every registered EPF driver will be listed in controllers directory. The |
| 39 | entries corresponding to EPF driver will be created by the EPF core. |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 40 | :: |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 41 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 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>/ |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 49 | |
| 50 | In order to create a <EPF device> of the type probed by <EPF Driver>, the |
| 51 | user has to create a directory inside <EPF DriverN>. |
| 52 | |
| 53 | Every <EPF device> directory consists of the following entries that can be |
| 54 | used to configure the standard configuration header of the endpoint function. |
| 55 | (These entries are created by the framework when any new <EPF Device> is |
| 56 | created) |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 57 | :: |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 58 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 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 |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 71 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 72 | EPC Device |
| 73 | ========== |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 74 | |
| 75 | Every registered EPC device will be listed in controllers directory. The |
| 76 | entries corresponding to EPC device will be created by the EPC core. |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 77 | :: |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 78 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 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 |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 88 | |
| 89 | The <EPC Device> directory will have a list of symbolic links to |
| 90 | <EPF Device>. These symbolic links should be created by the user to |
| 91 | represent the functions present in the endpoint device. |
| 92 | |
| 93 | The <EPC Device> directory will also have a *start* field. Once |
| 94 | "1" is written to this field, the endpoint device will be ready to |
| 95 | establish the link with the host. This is usually done after |
| 96 | all the EPF devices are created and linked with the EPC device. |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 97 | :: |
Kishon Vijay Abraham I | bea37d3 | 2017-03-27 15:15:00 +0530 | [diff] [blame] | 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 | |
Changbin Du | d4518e4 | 2019-05-14 22:47:32 +0800 | [diff] [blame] | 118 | [1] :doc:`pci-endpoint` |