@@ -3,24 +3,24 @@ PXA2xx SPI on SSP driver HOWTO
33==============================
44
55This a mini HOWTO on the pxa2xx_spi driver. The driver turns a PXA2xx
6- synchronous serial port into an SPI master controller
6+ synchronous serial port into an SPI host controller
77(see Documentation/spi/spi-summary.rst). The driver has the following features
88
99- Support for any PXA2xx and compatible SSP.
1010- SSP PIO and SSP DMA data transfers.
1111- External and Internal (SSPFRM) chip selects.
12- - Per slave device (chip) configuration.
12+ - Per peripheral device (chip) configuration.
1313- Full suspend, freeze, resume support.
1414
1515The driver is built around a &struct spi_message FIFO serviced by kernel
1616thread. The kernel thread, spi_pump_messages(), drives message FIFO and
1717is responsible for queuing SPI transactions and setting up and launching
1818the DMA or interrupt driven transfers.
1919
20- Declaring PXA2xx Master Controllers
21- -----------------------------------
22- Typically, for a legacy platform, an SPI master is defined in the
23- arch/.../mach-*/board- *.c as a "platform device". The master configuration
20+ Declaring PXA2xx host controllers
21+ ---------------------------------
22+ Typically, for a legacy platform, an SPI host controller is defined in the
23+ arch/.../mach-*/board- *.c as a "platform device". The host controller configuration
2424is passed to the driver via a table found in include/linux/spi/pxa2xx_spi.h::
2525
2626 struct pxa2xx_spi_controller {
@@ -30,7 +30,7 @@ is passed to the driver via a table found in include/linux/spi/pxa2xx_spi.h::
3030 };
3131
3232The "pxa2xx_spi_controller.num_chipselect" field is used to determine the number of
33- slave device (chips) attached to this SPI master .
33+ peripheral devices (chips) attached to this SPI host controller .
3434
3535The "pxa2xx_spi_controller.enable_dma" field informs the driver that SSP DMA should
3636be used. This caused the driver to acquire two DMA channels: Rx channel and
@@ -40,8 +40,8 @@ See the "PXA2xx Developer Manual" section "DMA Controller".
4040For the new platforms the description of the controller and peripheral devices
4141comes from Device Tree or ACPI.
4242
43- NSSP MASTER SAMPLE
44- ------------------
43+ NSSP HOST SAMPLE
44+ ----------------
4545Below is a sample configuration using the PXA255 NSSP for a legacy platform::
4646
4747 static struct resource pxa_spi_nssp_resources[] = {
@@ -57,7 +57,7 @@ Below is a sample configuration using the PXA255 NSSP for a legacy platform::
5757 },
5858 };
5959
60- static struct pxa2xx_spi_controller pxa_nssp_master_info = {
60+ static struct pxa2xx_spi_controller pxa_nssp_controller_info = {
6161 .num_chipselect = 1, /* Matches the number of chips attached to NSSP */
6262 .enable_dma = 1, /* Enables NSSP DMA */
6363 };
@@ -68,7 +68,7 @@ Below is a sample configuration using the PXA255 NSSP for a legacy platform::
6868 .resource = pxa_spi_nssp_resources,
6969 .num_resources = ARRAY_SIZE(pxa_spi_nssp_resources),
7070 .dev = {
71- .platform_data = &pxa_nssp_master_info , /* Passed to driver */
71+ .platform_data = &pxa_nssp_controller_info , /* Passed to driver */
7272 },
7373 };
7474
@@ -81,17 +81,17 @@ Below is a sample configuration using the PXA255 NSSP for a legacy platform::
8181 (void)platform_add_device(devices, ARRAY_SIZE(devices));
8282 }
8383
84- Declaring Slave Devices
85- -----------------------
86- Typically, for a legacy platform, each SPI slave (chip) is defined in the
84+ Declaring peripheral devices
85+ ----------------------------
86+ Typically, for a legacy platform, each SPI peripheral device (chip) is defined in the
8787arch/.../mach-*/board- *.c using the "spi_board_info" structure found in
8888"linux/spi/spi.h". See "Documentation/spi/spi-summary.rst" for additional
8989information.
9090
91- Each slave device attached to the PXA must provide slave specific configuration
91+ Each peripheral device (chip) attached to the PXA2xx must provide specific chip configuration
9292information via the structure "pxa2xx_spi_chip" found in
93- "include/linux/spi/pxa2xx_spi.h". The pxa2xx_spi master controller driver
94- will uses the configuration whenever the driver communicates with the slave
93+ "include/linux/spi/pxa2xx_spi.h". The PXA2xx host controller driver will use
94+ the configuration whenever the driver communicates with the peripheral
9595device. All fields are optional.
9696
9797::
@@ -123,7 +123,7 @@ dma_burst_size == 0.
123123The "pxa2xx_spi_chip.timeout" fields is used to efficiently handle
124124trailing bytes in the SSP receiver FIFO. The correct value for this field is
125125dependent on the SPI bus speed ("spi_board_info.max_speed_hz") and the specific
126- slave device. Please note that the PXA2xx SSP 1 does not support trailing byte
126+ peripheral device. Please note that the PXA2xx SSP 1 does not support trailing byte
127127timeouts and must busy-wait any trailing bytes.
128128
129129NOTE: the SPI driver cannot control the chip select if SSPFRM is used, so the
@@ -132,8 +132,8 @@ asserted around the complete message. Use SSPFRM as a GPIO (through a descriptor
132132to accommodate these chips.
133133
134134
135- NSSP SLAVE SAMPLE
136- -----------------
135+ NSSP PERIPHERAL SAMPLE
136+ ----------------------
137137For a legacy platform or in some other cases, the pxa2xx_spi_chip structure
138138is passed to the pxa2xx_spi driver in the "spi_board_info.controller_data"
139139field. Below is a sample configuration using the PXA255 NSSP.
@@ -161,16 +161,16 @@ field. Below is a sample configuration using the PXA255 NSSP.
161161 .bus_num = 2, /* Framework bus number */
162162 .chip_select = 0, /* Framework chip select */
163163 .platform_data = NULL; /* No spi_driver specific config */
164- .controller_data = &cs8415a_chip_info, /* Master chip config */
165- .irq = STREETRACER_APCI_IRQ, /* Slave device interrupt */
164+ .controller_data = &cs8415a_chip_info, /* Host controller config */
165+ .irq = STREETRACER_APCI_IRQ, /* Peripheral device interrupt */
166166 },
167167 {
168168 .modalias = "cs8405a", /* Name of spi_driver for this device */
169169 .max_speed_hz = 3686400, /* Run SSP as fast a possible */
170170 .bus_num = 2, /* Framework bus number */
171171 .chip_select = 1, /* Framework chip select */
172- .controller_data = &cs8405a_chip_info, /* Master chip config */
173- .irq = STREETRACER_APCI_IRQ, /* Slave device interrupt */
172+ .controller_data = &cs8405a_chip_info, /* Host controller config */
173+ .irq = STREETRACER_APCI_IRQ, /* Peripheral device interrupt */
174174 },
175175 };
176176
@@ -193,17 +193,14 @@ mode supports both coherent and stream based DMA mappings.
193193The following logic is used to determine the type of I/O to be used on
194194a per "spi_transfer" basis::
195195
196- if !enable_dma then
197- always use PIO transfers
196+ if spi_message.len > 65536 then
197+ if spi_message.is_dma_mapped or rx_dma_buf != 0 or tx_dma_buf != 0 then
198+ reject premapped transfers
198199
199- if spi_message.len > 8191 then
200200 print "rate limited" warning
201201 use PIO transfers
202202
203- if spi_message.is_dma_mapped and rx_dma_buf != 0 and tx_dma_buf != 0 then
204- use coherent DMA mode
205-
206- if rx_buf and tx_buf are aligned on 8 byte boundary then
203+ if enable_dma and the size is in the range [DMA burst size..65536] then
207204 use streaming DMA mode
208205
209206 otherwise
0 commit comments