|
| 1 | +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) |
| 2 | +%YAML 1.2 |
| 3 | +--- |
| 4 | +$id: http://devicetree.org/schemas/pci/sophgo,sg2042-pcie-host.yaml# |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# |
| 6 | + |
| 7 | +title: Sophgo SG2042 PCIe Host (Cadence PCIe Wrapper) |
| 8 | + |
| 9 | +description: |
| 10 | + Sophgo SG2042 PCIe host controller is based on the Cadence PCIe core. |
| 11 | + |
| 12 | +maintainers: |
| 13 | + |
| 14 | + |
| 15 | +properties: |
| 16 | + compatible: |
| 17 | + const: sophgo,sg2042-pcie-host |
| 18 | + |
| 19 | + reg: |
| 20 | + maxItems: 2 |
| 21 | + |
| 22 | + reg-names: |
| 23 | + items: |
| 24 | + - const: reg |
| 25 | + - const: cfg |
| 26 | + |
| 27 | + vendor-id: |
| 28 | + const: 0x1f1c |
| 29 | + |
| 30 | + device-id: |
| 31 | + const: 0x2042 |
| 32 | + |
| 33 | + msi: |
| 34 | + type: object |
| 35 | + $ref: /schemas/interrupt-controller/msi-controller.yaml# |
| 36 | + unevaluatedProperties: false |
| 37 | + |
| 38 | + properties: |
| 39 | + compatible: |
| 40 | + items: |
| 41 | + - const: sophgo,sg2042-pcie-msi |
| 42 | + |
| 43 | + interrupts: |
| 44 | + maxItems: 1 |
| 45 | + |
| 46 | + interrupt-names: |
| 47 | + const: msi |
| 48 | + |
| 49 | + msi-parent: true |
| 50 | + |
| 51 | + sophgo,link-id: |
| 52 | + $ref: /schemas/types.yaml#/definitions/uint32 |
| 53 | + description: | |
| 54 | + SG2042 uses Cadence IP, every IP is composed of 2 cores (called link0 |
| 55 | + & link1 as Cadence's term). Each core corresponds to a host bridge, |
| 56 | + and each host bridge has only one root port. Their configuration |
| 57 | + registers are completely independent. SG2042 integrates two Cadence IPs, |
| 58 | + so there can actually be up to four host bridges. "sophgo,link-id" is |
| 59 | + used to identify which core/link the PCIe host bridge node corresponds to. |
| 60 | +
|
| 61 | + The Cadence IP has two modes of operation, selected by a strap pin. |
| 62 | +
|
| 63 | + In the single-link mode, the Cadence PCIe core instance associated |
| 64 | + with Link0 is connected to all the lanes and the Cadence PCIe core |
| 65 | + instance associated with Link1 is inactive. |
| 66 | +
|
| 67 | + In the dual-link mode, the Cadence PCIe core instance associated |
| 68 | + with Link0 is connected to the lower half of the lanes and the |
| 69 | + Cadence PCIe core instance associated with Link1 is connected to |
| 70 | + the upper half of the lanes. |
| 71 | +
|
| 72 | + SG2042 contains 2 Cadence IPs and configures the Cores as below: |
| 73 | +
|
| 74 | + +-- Core (Link0) <---> pcie_rc0 +-----------------+ |
| 75 | + | | | |
| 76 | + Cadence IP 1 --+ | cdns_pcie0_ctrl | |
| 77 | + | | | |
| 78 | + +-- Core (Link1) <---> disabled +-----------------+ |
| 79 | +
|
| 80 | + +-- Core (Link0) <---> pcie_rc1 +-----------------+ |
| 81 | + | | | |
| 82 | + Cadence IP 2 --+ | cdns_pcie1_ctrl | |
| 83 | + | | | |
| 84 | + +-- Core (Link1) <---> pcie_rc2 +-----------------+ |
| 85 | +
|
| 86 | + pcie_rcX is PCIe node ("sophgo,sg2042-pcie-host") defined in DTS. |
| 87 | +
|
| 88 | + Sophgo defines some new register files to add support for their MSI |
| 89 | + controller inside PCIe. These new register files are defined in DTS as |
| 90 | + syscon node ("sophgo,sg2042-pcie-ctrl"), i.e. "cdns_pcie0_ctrl" / |
| 91 | + "cdns_pcie1_ctrl". cdns_pcieX_ctrl contains some registers shared by |
| 92 | + pcie_rcX, even two RC (Link)s may share different bits of the same |
| 93 | + register. For example, cdns_pcie1_ctrl contains registers shared by |
| 94 | + link0 & link1 for Cadence IP 2. |
| 95 | +
|
| 96 | + "sophgo,link-id" is defined to distinguish the two RC's in one Cadence IP, |
| 97 | + so we can know what registers (bits) we should use. |
| 98 | +
|
| 99 | + sophgo,syscon-pcie-ctrl: |
| 100 | + $ref: /schemas/types.yaml#/definitions/phandle |
| 101 | + description: |
| 102 | + Phandle to the PCIe System Controller DT node. It's required to |
| 103 | + access some MSI operation registers shared by PCIe RCs. |
| 104 | + |
| 105 | +allOf: |
| 106 | + - $ref: cdns-pcie-host.yaml# |
| 107 | + |
| 108 | +required: |
| 109 | + - compatible |
| 110 | + - reg |
| 111 | + - reg-names |
| 112 | + - vendor-id |
| 113 | + - device-id |
| 114 | + - sophgo,link-id |
| 115 | + - sophgo,syscon-pcie-ctrl |
| 116 | + |
| 117 | +unevaluatedProperties: false |
| 118 | + |
| 119 | +examples: |
| 120 | + - | |
| 121 | + #include <dt-bindings/interrupt-controller/irq.h> |
| 122 | +
|
| 123 | + pcie@62000000 { |
| 124 | + compatible = "sophgo,sg2042-pcie-host"; |
| 125 | + device_type = "pci"; |
| 126 | + reg = <0x62000000 0x00800000>, |
| 127 | + <0x48000000 0x00001000>; |
| 128 | + reg-names = "reg", "cfg"; |
| 129 | + #address-cells = <3>; |
| 130 | + #size-cells = <2>; |
| 131 | + ranges = <0x81000000 0 0x00000000 0xde000000 0 0x00010000>, |
| 132 | + <0x82000000 0 0xd0400000 0xd0400000 0 0x0d000000>; |
| 133 | + bus-range = <0x00 0xff>; |
| 134 | + vendor-id = <0x1f1c>; |
| 135 | + device-id = <0x2042>; |
| 136 | + cdns,no-bar-match-nbits = <48>; |
| 137 | + sophgo,link-id = <0>; |
| 138 | + sophgo,syscon-pcie-ctrl = <&cdns_pcie1_ctrl>; |
| 139 | + msi-parent = <&msi_pcie>; |
| 140 | + msi_pcie: msi { |
| 141 | + compatible = "sophgo,sg2042-pcie-msi"; |
| 142 | + msi-controller; |
| 143 | + interrupt-parent = <&intc>; |
| 144 | + interrupts = <123 IRQ_TYPE_LEVEL_HIGH>; |
| 145 | + interrupt-names = "msi"; |
| 146 | + }; |
| 147 | + }; |
0 commit comments