Skip to content

Commit 6cdebf6

Browse files
committed
Merge tag 'spi-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi updates from Mark Brown: "This release sees some exciting changes from David Lechner which implements some optimisations that have been talked about for a long time which allows client drivers to pre-prepare SPI messages for repeated or low latency use. This lets us move work out of latency sensitive paths and avoid repeating work for frequently performed operations. As well as being useful in itself this will also be used in future to allow controllers to directly trigger SPI operations (eg, from interrupts). Otherwise this release has mostly been focused on cleanups, plus a couple of new devices: - Support for pre-optimising messages - A big set of updates from Uwe Kleine-König moving drivers to use APIs with more modern terminology for controllers - Major overhaul of the s3c64xx driver - Support for Google GS101 and Samsung Exynos850" * tag 'spi-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (122 commits) spi: Introduce SPI_INVALID_CS and is_valid_cs() spi: Fix types of the last chip select storage variables spi: Consistently use BIT for cs_index_mask spi: Exctract spi_dev_check_cs() helper spi: Exctract spi_set_all_cs_unused() helper spi: s3c64xx: switch exynos850 to new port config data spi: s3c64xx: switch gs101 to new port config data spi: s3c64xx: deprecate fifo_lvl_mask, rx_lvl_offset and port_id spi: s3c64xx: get rid of the OF alias ID dependency spi: s3c64xx: introduce s3c64xx_spi_set_port_id() spi: s3c64xx: let the SPI core determine the bus number spi: s3c64xx: allow FIFO depth to be determined from the compatible spi: s3c64xx: retrieve the FIFO depth from the device tree spi: s3c64xx: determine the fifo depth only once spi: s3c64xx: allow full FIFO masks spi: s3c64xx: define a magic value spi: dt-bindings: introduce FIFO depth properties spi: axi-spi-engine: use struct_size() macro spi: axi-spi-engine: use __counted_by() attribute spi: axi-spi-engine: remove p from struct spi_engine_message_state ...
2 parents 21ac5a9 + be84be4 commit 6cdebf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1569
-802
lines changed

Documentation/devicetree/bindings/spi/atmel,at91rm9200-spi.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ properties:
2222
- const: atmel,at91rm9200-spi
2323
- items:
2424
- const: microchip,sam9x7-spi
25-
- const: microchip,sam9x60-spi
2625
- const: atmel,at91rm9200-spi
2726

2827
reg:

Documentation/devicetree/bindings/spi/samsung,spi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ properties:
1717
compatible:
1818
oneOf:
1919
- enum:
20+
- google,gs101-spi
2021
- samsung,s3c2443-spi # for S3C2443, S3C2416 and S3C2450
2122
- samsung,s3c6410-spi
2223
- samsung,s5pv210-spi # for S5PV210 and S5PC110
2324
- samsung,exynos4210-spi
2425
- samsung,exynos5433-spi
26+
- samsung,exynos850-spi
2527
- samsung,exynosautov9-spi
2628
- tesla,fsd-spi
2729
- const: samsung,exynos7-spi
@@ -74,8 +76,6 @@ required:
7476
- compatible
7577
- clocks
7678
- clock-names
77-
- dmas
78-
- dma-names
7979
- interrupts
8080
- reg
8181

Documentation/devicetree/bindings/spi/spi-controller.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ properties:
6969
Should be generally avoided and be replaced by
7070
spi-cs-high + ACTIVE_HIGH.
7171
72+
fifo-depth:
73+
$ref: /schemas/types.yaml#/definitions/uint32
74+
description:
75+
Size of the RX and TX data FIFOs in bytes.
76+
77+
rx-fifo-depth:
78+
$ref: /schemas/types.yaml#/definitions/uint32
79+
description:
80+
Size of the RX data FIFO in bytes.
81+
82+
tx-fifo-depth:
83+
$ref: /schemas/types.yaml#/definitions/uint32
84+
description:
85+
Size of the TX data FIFO in bytes.
86+
7287
num-cs:
7388
$ref: /schemas/types.yaml#/definitions/uint32
7489
description:
@@ -116,6 +131,10 @@ patternProperties:
116131
- compatible
117132
- reg
118133

134+
dependencies:
135+
rx-fifo-depth: [ tx-fifo-depth ]
136+
tx-fifo-depth: [ rx-fifo-depth ]
137+
119138
allOf:
120139
- if:
121140
not:
@@ -129,6 +148,14 @@ allOf:
129148
properties:
130149
"#address-cells":
131150
const: 0
151+
- not:
152+
required:
153+
- fifo-depth
154+
- rx-fifo-depth
155+
- not:
156+
required:
157+
- fifo-depth
158+
- tx-fifo-depth
132159

133160
additionalProperties: true
134161

Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ properties:
2222
- enum:
2323
- fsl,imx8ulp-spi
2424
- fsl,imx93-spi
25+
- fsl,imx95-spi
2526
- const: fsl,imx7ulp-spi
2627
reg:
2728
maxItems: 1

Documentation/devicetree/bindings/spi/spi-nxp-fspi.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ allOf:
1515

1616
properties:
1717
compatible:
18-
enum:
19-
- nxp,imx8dxl-fspi
20-
- nxp,imx8mm-fspi
21-
- nxp,imx8mp-fspi
22-
- nxp,imx8qxp-fspi
23-
- nxp,lx2160a-fspi
18+
oneOf:
19+
- enum:
20+
- nxp,imx8dxl-fspi
21+
- nxp,imx8mm-fspi
22+
- nxp,imx8mp-fspi
23+
- nxp,imx8qxp-fspi
24+
- nxp,lx2160a-fspi
25+
- items:
26+
- enum:
27+
- nxp,imx93-fspi
28+
- nxp,imx95-fspi
29+
- const: nxp,imx8mm-fspi
2430

2531
reg:
2632
items:

Documentation/driver-api/driver-model/devres.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ SLAVE DMA ENGINE
463463
SPI
464464
devm_spi_alloc_master()
465465
devm_spi_alloc_slave()
466-
devm_spi_register_master()
466+
devm_spi_register_controller()
467467

468468
WATCHDOG
469469
devm_watchdog_register_device()

Documentation/spi/spi-summary.rst

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ What is SPI?
99
The "Serial Peripheral Interface" (SPI) is a synchronous four wire serial
1010
link used to connect microcontrollers to sensors, memory, and peripherals.
1111
It's a simple "de facto" standard, not complicated enough to acquire a
12-
standardization body. SPI uses a master/slave configuration.
12+
standardization body. SPI uses a host/target configuration.
1313

1414
The three signal wires hold a clock (SCK, often on the order of 10 MHz),
1515
and parallel data lines with "Master Out, Slave In" (MOSI) or "Master In,
@@ -19,14 +19,14 @@ commonly used. Each clock cycle shifts data out and data in; the clock
1919
doesn't cycle except when there is a data bit to shift. Not all data bits
2020
are used though; not every protocol uses those full duplex capabilities.
2121

22-
SPI masters use a fourth "chip select" line to activate a given SPI slave
22+
SPI hosts use a fourth "chip select" line to activate a given SPI target
2323
device, so those three signal wires may be connected to several chips
24-
in parallel. All SPI slaves support chipselects; they are usually active
25-
low signals, labeled nCSx for slave 'x' (e.g. nCS0). Some devices have
26-
other signals, often including an interrupt to the master.
24+
in parallel. All SPI targets support chipselects; they are usually active
25+
low signals, labeled nCSx for target 'x' (e.g. nCS0). Some devices have
26+
other signals, often including an interrupt to the host.
2727

2828
Unlike serial busses like USB or SMBus, even low level protocols for
29-
SPI slave functions are usually not interoperable between vendors
29+
SPI target functions are usually not interoperable between vendors
3030
(except for commodities like SPI memory chips).
3131

3232
- SPI may be used for request/response style device protocols, as with
@@ -43,10 +43,10 @@ SPI slave functions are usually not interoperable between vendors
4343

4444
- Sometimes SPI is used to daisy-chain devices, like shift registers.
4545

46-
In the same way, SPI slaves will only rarely support any kind of automatic
47-
discovery/enumeration protocol. The tree of slave devices accessible from
48-
a given SPI master will normally be set up manually, with configuration
49-
tables.
46+
In the same way, SPI targets will only rarely support any kind of automatic
47+
discovery/enumeration protocol. The tree of target devices accessible from
48+
a given SPI host controller will normally be set up manually, with
49+
configuration tables.
5050

5151
SPI is only one of the names used by such four-wire protocols, and
5252
most controllers have no problem handling "MicroWire" (think of it as
@@ -62,8 +62,8 @@ course they won't handle full duplex transfers. You may find such
6262
chips described as using "three wire" signaling: SCK, data, nCSx.
6363
(That data line is sometimes called MOMI or SISO.)
6464

65-
Microcontrollers often support both master and slave sides of the SPI
66-
protocol. This document (and Linux) supports both the master and slave
65+
Microcontrollers often support both host and target sides of the SPI
66+
protocol. This document (and Linux) supports both the host and target
6767
sides of SPI interactions.
6868

6969

@@ -75,7 +75,7 @@ protocol supported by every MMC or SD memory card. (The older "DataFlash"
7575
cards, predating MMC cards but using the same connectors and card shape,
7676
support only SPI.) Some PC hardware uses SPI flash for BIOS code.
7777

78-
SPI slave chips range from digital/analog converters used for analog
78+
SPI target chips range from digital/analog converters used for analog
7979
sensors and codecs, to memory, to peripherals like USB controllers
8080
or Ethernet adapters; and more.
8181

@@ -118,8 +118,8 @@ starting low (CPOL=0) and data stabilized for sampling during the
118118
trailing clock edge (CPHA=1), that's SPI mode 1.
119119

120120
Note that the clock mode is relevant as soon as the chipselect goes
121-
active. So the master must set the clock to inactive before selecting
122-
a slave, and the slave can tell the chosen polarity by sampling the
121+
active. So the host must set the clock to inactive before selecting
122+
a target, and the target can tell the chosen polarity by sampling the
123123
clock level when its select line goes active. That's why many devices
124124
support for example both modes 0 and 3: they don't care about polarity,
125125
and always clock data in/out on rising clock edges.
@@ -142,13 +142,13 @@ There are two types of SPI driver, here called:
142142

143143
Controller drivers ...
144144
controllers may be built into System-On-Chip
145-
processors, and often support both Master and Slave roles.
145+
processors, and often support both Controller and target roles.
146146
These drivers touch hardware registers and may use DMA.
147147
Or they can be PIO bitbangers, needing just GPIO pins.
148148

149149
Protocol drivers ...
150150
these pass messages through the controller
151-
driver to communicate with a Slave or Master device on the
151+
driver to communicate with a target or Controller device on the
152152
other side of an SPI link.
153153

154154
So for example one protocol driver might talk to the MTD layer to export
@@ -179,22 +179,22 @@ shows up in sysfs in several locations::
179179
/sys/bus/spi/drivers/D ... driver for one or more spi*.* devices
180180

181181
/sys/class/spi_master/spiB ... symlink to a logical node which could hold
182-
class related state for the SPI master controller managing bus "B".
182+
class related state for the SPI host controller managing bus "B".
183183
All spiB.* devices share one physical SPI bus segment, with SCLK,
184184
MOSI, and MISO.
185185

186186
/sys/devices/.../CTLR/slave ... virtual file for (un)registering the
187-
slave device for an SPI slave controller.
188-
Writing the driver name of an SPI slave handler to this file
189-
registers the slave device; writing "(null)" unregisters the slave
187+
target device for an SPI target controller.
188+
Writing the driver name of an SPI target handler to this file
189+
registers the target device; writing "(null)" unregisters the target
190190
device.
191-
Reading from this file shows the name of the slave device ("(null)"
191+
Reading from this file shows the name of the target device ("(null)"
192192
if not registered).
193193

194194
/sys/class/spi_slave/spiB ... symlink to a logical node which could hold
195-
class related state for the SPI slave controller on bus "B". When
195+
class related state for the SPI target controller on bus "B". When
196196
registered, a single spiB.* device is present here, possible sharing
197-
the physical SPI bus segment with other SPI slave devices.
197+
the physical SPI bus segment with other SPI target devices.
198198

199199
At this time, the only class-specific state is the bus number ("B" in "spiB"),
200200
so those /sys/class entries are only useful to quickly identify busses.
@@ -270,10 +270,10 @@ same SOC controller is used. For example, on one board SPI might use
270270
an external clock, where another derives the SPI clock from current
271271
settings of some master clock.
272272

273-
Declare Slave Devices
274-
^^^^^^^^^^^^^^^^^^^^^
273+
Declare target Devices
274+
^^^^^^^^^^^^^^^^^^^^^^
275275

276-
The second kind of information is a list of what SPI slave devices exist
276+
The second kind of information is a list of what SPI target devices exist
277277
on the target board, often with some board-specific data needed for the
278278
driver to work correctly.
279279

@@ -316,7 +316,7 @@ sharing a bus with a device that interprets chipselect "backwards" is
316316
not possible until the infrastructure knows how to deselect it.
317317

318318
Then your board initialization code would register that table with the SPI
319-
infrastructure, so that it's available later when the SPI master controller
319+
infrastructure, so that it's available later when the SPI host controller
320320
driver is registered::
321321

322322
spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
@@ -469,39 +469,39 @@ routines are available to allocate and zero-initialize an spi_message
469469
with several transfers.
470470

471471

472-
How do I write an "SPI Master Controller Driver"?
472+
How do I write an "SPI Controller Driver"?
473473
-------------------------------------------------
474474
An SPI controller will probably be registered on the platform_bus; write
475475
a driver to bind to the device, whichever bus is involved.
476476

477-
The main task of this type of driver is to provide an "spi_master".
478-
Use spi_alloc_master() to allocate the master, and spi_master_get_devdata()
479-
to get the driver-private data allocated for that device.
477+
The main task of this type of driver is to provide an "spi_controller".
478+
Use spi_alloc_host() to allocate the host controller, and
479+
spi_controller_get_devdata() to get the driver-private data allocated for that
480+
device.
480481

481482
::
482483

483-
struct spi_master *master;
484+
struct spi_controller *ctlr;
484485
struct CONTROLLER *c;
485486

486-
master = spi_alloc_master(dev, sizeof *c);
487-
if (!master)
487+
ctlr = spi_alloc_host(dev, sizeof *c);
488+
if (!ctlr)
488489
return -ENODEV;
489490

490-
c = spi_master_get_devdata(master);
491+
c = spi_controller_get_devdata(ctlr);
491492

492-
The driver will initialize the fields of that spi_master, including the
493-
bus number (maybe the same as the platform device ID) and three methods
494-
used to interact with the SPI core and SPI protocol drivers. It will
495-
also initialize its own internal state. (See below about bus numbering
496-
and those methods.)
493+
The driver will initialize the fields of that spi_controller, including the bus
494+
number (maybe the same as the platform device ID) and three methods used to
495+
interact with the SPI core and SPI protocol drivers. It will also initialize
496+
its own internal state. (See below about bus numbering and those methods.)
497497

498-
After you initialize the spi_master, then use spi_register_master() to
498+
After you initialize the spi_controller, then use spi_register_controller() to
499499
publish it to the rest of the system. At that time, device nodes for the
500500
controller and any predeclared spi devices will be made available, and
501501
the driver model core will take care of binding them to drivers.
502502

503-
If you need to remove your SPI controller driver, spi_unregister_master()
504-
will reverse the effect of spi_register_master().
503+
If you need to remove your SPI controller driver, spi_unregister_controller()
504+
will reverse the effect of spi_register_controller().
505505

506506

507507
Bus Numbering
@@ -519,49 +519,49 @@ then be replaced by a dynamically assigned number. You'd then need to treat
519519
this as a non-static configuration (see above).
520520

521521

522-
SPI Master Methods
523-
^^^^^^^^^^^^^^^^^^
522+
SPI Host Controller Methods
523+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
524524

525-
``master->setup(struct spi_device *spi)``
525+
``ctlr->setup(struct spi_device *spi)``
526526
This sets up the device clock rate, SPI mode, and word sizes.
527527
Drivers may change the defaults provided by board_info, and then
528528
call spi_setup(spi) to invoke this routine. It may sleep.
529529

530-
Unless each SPI slave has its own configuration registers, don't
530+
Unless each SPI target has its own configuration registers, don't
531531
change them right away ... otherwise drivers could corrupt I/O
532532
that's in progress for other SPI devices.
533533

534534
.. note::
535535

536536
BUG ALERT: for some reason the first version of
537-
many spi_master drivers seems to get this wrong.
537+
many spi_controller drivers seems to get this wrong.
538538
When you code setup(), ASSUME that the controller
539539
is actively processing transfers for another device.
540540

541-
``master->cleanup(struct spi_device *spi)``
541+
``ctlr->cleanup(struct spi_device *spi)``
542542
Your controller driver may use spi_device.controller_state to hold
543543
state it dynamically associates with that device. If you do that,
544544
be sure to provide the cleanup() method to free that state.
545545

546-
``master->prepare_transfer_hardware(struct spi_master *master)``
546+
``ctlr->prepare_transfer_hardware(struct spi_controller *ctlr)``
547547
This will be called by the queue mechanism to signal to the driver
548548
that a message is coming in soon, so the subsystem requests the
549549
driver to prepare the transfer hardware by issuing this call.
550550
This may sleep.
551551

552-
``master->unprepare_transfer_hardware(struct spi_master *master)``
552+
``ctlr->unprepare_transfer_hardware(struct spi_controller *ctlr)``
553553
This will be called by the queue mechanism to signal to the driver
554554
that there are no more messages pending in the queue and it may
555555
relax the hardware (e.g. by power management calls). This may sleep.
556556

557-
``master->transfer_one_message(struct spi_master *master, struct spi_message *mesg)``
557+
``ctlr->transfer_one_message(struct spi_controller *ctlr, struct spi_message *mesg)``
558558
The subsystem calls the driver to transfer a single message while
559559
queuing transfers that arrive in the meantime. When the driver is
560560
finished with this message, it must call
561561
spi_finalize_current_message() so the subsystem can issue the next
562562
message. This may sleep.
563563

564-
``master->transfer_one(struct spi_master *master, struct spi_device *spi, struct spi_transfer *transfer)``
564+
``ctrl->transfer_one(struct spi_controller *ctlr, struct spi_device *spi, struct spi_transfer *transfer)``
565565
The subsystem calls the driver to transfer a single transfer while
566566
queuing transfers that arrive in the meantime. When the driver is
567567
finished with this transfer, it must call
@@ -576,15 +576,15 @@ SPI Master Methods
576576
* 0: transfer is finished
577577
* 1: transfer is still in progress
578578

579-
``master->set_cs_timing(struct spi_device *spi, u8 setup_clk_cycles, u8 hold_clk_cycles, u8 inactive_clk_cycles)``
580-
This method allows SPI client drivers to request SPI master controller
579+
``ctrl->set_cs_timing(struct spi_device *spi, u8 setup_clk_cycles, u8 hold_clk_cycles, u8 inactive_clk_cycles)``
580+
This method allows SPI client drivers to request SPI host controller
581581
for configuring device specific CS setup, hold and inactive timing
582582
requirements.
583583

584584
Deprecated Methods
585585
^^^^^^^^^^^^^^^^^^
586586

587-
``master->transfer(struct spi_device *spi, struct spi_message *message)``
587+
``ctrl->transfer(struct spi_device *spi, struct spi_message *message)``
588588
This must not sleep. Its responsibility is to arrange that the
589589
transfer happens and its complete() callback is issued. The two
590590
will normally happen later, after other transfers complete, and

0 commit comments

Comments
 (0)