Skip to content

Commit 8ea39d9

Browse files
committed
spi: add multi-lane support
Merge series from David Lechner <dlechner@baylibre.com>: This series is adding support for SPI controllers and peripherals that have multiple SPI data lanes (data lanes being independent sets of SDI/SDO lines, each with their own serializer/deserializer). This series covers this specific use case: +--------------+ +---------+ | SPI | | SPI | | Controller | | ADC | | | | | | CS0 |--->| CS | | SCLK |--->| SCLK | | SDO |--->| SDI | | SDI0 |<---| SDOA | | SDI1 |<---| SDOB | | SDI2 |<---| SDOC | | SDI3 |<---| SDOD | +--------------+ +--------+ The ADC is a simultaneous sampling ADC that can convert 4 samples at the same time. It has 4 data output lines (SDOA-D) that each contain the data of one of the 4 channels. So it requires a SPI controller with 4 separate deserializers in order to receive all of the information at the same time. This should also work for the use case in [1] as well. (Some of the patches in this series were already submitted there). In that case the SPI controller is used kind of like it is two separate SPI controllers, each with its own chip select, clock, and data lines. [1]: https://lore.kernel.org/linux-spi/20250616220054.3968946-1-sean.anderson@linux.dev/ The DT bindings are a fairly straight-forward mapping of which pins on the peripheral are connected to which pins on the controller. The SPI core code parses this and makes the information available to drivers. When a peripheral driver sees that multiple data lanes are wired up, it can chose to use them when sending messages. The SPI message API is a bit higher-level than just specifying the number of data lines for a SPI transfer though. I did some research on other SPI controllers that have this feature. They tend to be the kind meant for connecting to two flash memory chips at the same time but can be used more generically as well. They generally have the option to either use one lane at a time (Sean's use case), or can mirror the same data on multiple lanes (no users of this yet) or can perform striping of a single data FIFO/DMA stream to/from the two lanes (our use case). For now, the API assumes that if you want to do mirror/striping, then you want to use all available data lanes. Otherwise, it just uses the first data lane for "normal" SPI transfers.
2 parents da0a672 + 0ec5ed7 commit 8ea39d9

14 files changed

Lines changed: 641 additions & 27 deletions

Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ properties:
3434
spi-cpol: true
3535

3636
spi-rx-bus-width:
37-
minimum: 0
38-
maximum: 1
37+
items:
38+
minimum: 0
39+
maximum: 1
3940

4041
dc-gpios:
4142
maxItems: 1

Documentation/devicetree/bindings/iio/adc/adi,ad4030.yaml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ properties:
3737
maximum: 102040816
3838

3939
spi-rx-bus-width:
40-
enum: [1, 2, 4]
40+
maxItems: 2
41+
# all lanes must have the same width
42+
oneOf:
43+
- contains:
44+
const: 1
45+
- contains:
46+
const: 2
47+
- contains:
48+
const: 4
4149

4250
vdd-5v-supply: true
4351
vdd-1v8-supply: true
@@ -88,6 +96,18 @@ oneOf:
8896

8997
unevaluatedProperties: false
9098

99+
allOf:
100+
- if:
101+
properties:
102+
compatible:
103+
enum:
104+
- adi,ad4030-24
105+
- adi,ad4032-24
106+
then:
107+
properties:
108+
spi-rx-bus-width:
109+
maxItems: 1
110+
91111
examples:
92112
- |
93113
#include <dt-bindings/gpio/gpio.h>
@@ -108,3 +128,23 @@ examples:
108128
reset-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
109129
};
110130
};
131+
- |
132+
#include <dt-bindings/gpio/gpio.h>
133+
134+
spi {
135+
#address-cells = <1>;
136+
#size-cells = <0>;
137+
138+
adc@0 {
139+
compatible = "adi,ad4630-24";
140+
reg = <0>;
141+
spi-max-frequency = <80000000>;
142+
spi-rx-bus-width = <4>, <4>;
143+
vdd-5v-supply = <&supply_5V>;
144+
vdd-1v8-supply = <&supply_1_8V>;
145+
vio-supply = <&supply_1_8V>;
146+
ref-supply = <&supply_5V>;
147+
cnv-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
148+
reset-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
149+
};
150+
};

Documentation/devicetree/bindings/iio/adc/adi,ad4695.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ properties:
3838
spi-cpha: true
3939

4040
spi-rx-bus-width:
41-
minimum: 1
42-
maximum: 4
41+
items:
42+
minimum: 1
43+
maximum: 4
4344

4445
avdd-supply:
4546
description: Analog power supply.

Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ required:
7070

7171
unevaluatedProperties: false
7272

73+
patternProperties:
74+
"^.*@[0-9a-f]+":
75+
type: object
76+
77+
properties:
78+
spi-rx-bus-width:
79+
maxItems: 8
80+
items:
81+
enum: [0, 1]
82+
83+
spi-tx-bus-width:
84+
maxItems: 8
85+
items:
86+
enum: [0, 1]
87+
7388
examples:
7489
- |
7590
spi@44a00000 {

Documentation/devicetree/bindings/spi/allwinner,sun4i-a10-spi.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ patternProperties:
5555
maximum: 4
5656

5757
spi-rx-bus-width:
58-
const: 1
58+
items:
59+
- const: 1
5960

6061
spi-tx-bus-width:
61-
const: 1
62+
items:
63+
- const: 1
6264

6365
required:
6466
- compatible

Documentation/devicetree/bindings/spi/allwinner,sun6i-a31-spi.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ patternProperties:
8181
maximum: 4
8282

8383
spi-rx-bus-width:
84-
const: 1
84+
items:
85+
- const: 1
8586

8687
spi-tx-bus-width:
87-
const: 1
88+
items:
89+
- const: 1
8890

8991
required:
9092
- compatible

Documentation/devicetree/bindings/spi/andestech,ae350-spi.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ patternProperties:
4545

4646
properties:
4747
spi-rx-bus-width:
48-
enum: [1, 4]
48+
items:
49+
- enum: [1, 4]
4950

5051
spi-tx-bus-width:
51-
enum: [1, 4]
52+
items:
53+
- enum: [1, 4]
5254

5355
allOf:
5456
- $ref: spi-controller.yaml#

Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ patternProperties:
5454

5555
properties:
5656
spi-rx-bus-width:
57-
enum: [1, 2, 4]
57+
items:
58+
- enum: [1, 2, 4]
5859

5960
spi-tx-bus-width:
60-
enum: [1, 2, 4]
61+
items:
62+
- enum: [1, 2, 4]
6163

6264
required:
6365
- compatible

Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,23 @@ properties:
6464
description:
6565
Bus width to the SPI bus used for read transfers.
6666
If 0 is provided, then no RX will be possible on this device.
67-
$ref: /schemas/types.yaml#/definitions/uint32
68-
enum: [0, 1, 2, 4, 8]
69-
default: 1
67+
68+
Some SPI peripherals and controllers may have multiple data lanes for
69+
receiving two or more words at the same time. If this is the case, each
70+
index in the array represents the lane on both the SPI peripheral and
71+
controller. Additional mapping properties may be needed if a lane is
72+
skipped on either side.
73+
$ref: /schemas/types.yaml#/definitions/uint32-array
74+
items:
75+
enum: [0, 1, 2, 4, 8]
76+
default: [1]
77+
78+
spi-rx-lane-map:
79+
description: Mapping of peripheral SDO lanes to controller SDI lanes.
80+
Each index in the array represents a peripheral SDO lane, and the value
81+
at that index represents the corresponding controller SDI lane.
82+
$ref: /schemas/types.yaml#/definitions/uint32-array
83+
default: [0, 1, 2, 3, 4, 5, 6, 7]
7084

7185
spi-rx-delay-us:
7286
description:
@@ -81,9 +95,23 @@ properties:
8195
description:
8296
Bus width to the SPI bus used for write transfers.
8397
If 0 is provided, then no TX will be possible on this device.
84-
$ref: /schemas/types.yaml#/definitions/uint32
85-
enum: [0, 1, 2, 4, 8]
86-
default: 1
98+
99+
Some SPI peripherals and controllers may have multiple data lanes for
100+
transmitting two or more words at the same time. If this is the case, each
101+
index in the array represents the lane on both the SPI peripheral and
102+
controller. Additional mapping properties may be needed if a lane is
103+
skipped on either side.
104+
$ref: /schemas/types.yaml#/definitions/uint32-array
105+
items:
106+
enum: [0, 1, 2, 4, 8]
107+
default: [1]
108+
109+
spi-tx-lane-map:
110+
description: Mapping of peripheral SDI lanes to controller SDO lanes.
111+
Each index in the array represents a peripheral SDI lane, and the value
112+
at that index represents the corresponding controller SDO lane.
113+
$ref: /schemas/types.yaml#/definitions/uint32-array
114+
default: [0, 1, 2, 3, 4, 5, 6, 7]
87115

88116
spi-tx-delay-us:
89117
description:

Documentation/spi/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Serial Peripheral Interface (SPI)
99

1010
spi-summary
1111
spidev
12+
multiple-data-lanes
1213
butterfly
1314
spi-lm70llp
1415
spi-sc18is602

0 commit comments

Comments
 (0)