@@ -3,24 +3,24 @@ PXA2xx SPI on SSP driver HOWTO
3
3
==============================
4
4
5
5
This 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
7
7
(see Documentation/spi/spi-summary.rst). The driver has the following features
8
8
9
9
- Support for any PXA2xx and compatible SSP.
10
10
- SSP PIO and SSP DMA data transfers.
11
11
- External and Internal (SSPFRM) chip selects.
12
- - Per slave device (chip) configuration.
12
+ - Per peripheral device (chip) configuration.
13
13
- Full suspend, freeze, resume support.
14
14
15
15
The driver is built around a &struct spi_message FIFO serviced by kernel
16
16
thread. The kernel thread, spi_pump_messages(), drives message FIFO and
17
17
is responsible for queuing SPI transactions and setting up and launching
18
18
the DMA or interrupt driven transfers.
19
19
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
24
24
is passed to the driver via a table found in include/linux/spi/pxa2xx_spi.h::
25
25
26
26
struct pxa2xx_spi_controller {
@@ -30,7 +30,7 @@ is passed to the driver via a table found in include/linux/spi/pxa2xx_spi.h::
30
30
};
31
31
32
32
The "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 .
34
34
35
35
The "pxa2xx_spi_controller.enable_dma" field informs the driver that SSP DMA should
36
36
be 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".
40
40
For the new platforms the description of the controller and peripheral devices
41
41
comes from Device Tree or ACPI.
42
42
43
- NSSP MASTER SAMPLE
44
- ------------------
43
+ NSSP HOST SAMPLE
44
+ ----------------
45
45
Below is a sample configuration using the PXA255 NSSP for a legacy platform::
46
46
47
47
static struct resource pxa_spi_nssp_resources[] = {
@@ -57,7 +57,7 @@ Below is a sample configuration using the PXA255 NSSP for a legacy platform::
57
57
},
58
58
};
59
59
60
- static struct pxa2xx_spi_controller pxa_nssp_master_info = {
60
+ static struct pxa2xx_spi_controller pxa_nssp_controller_info = {
61
61
.num_chipselect = 1, /* Matches the number of chips attached to NSSP */
62
62
.enable_dma = 1, /* Enables NSSP DMA */
63
63
};
@@ -68,7 +68,7 @@ Below is a sample configuration using the PXA255 NSSP for a legacy platform::
68
68
.resource = pxa_spi_nssp_resources,
69
69
.num_resources = ARRAY_SIZE(pxa_spi_nssp_resources),
70
70
.dev = {
71
- .platform_data = &pxa_nssp_master_info , /* Passed to driver */
71
+ .platform_data = &pxa_nssp_controller_info , /* Passed to driver */
72
72
},
73
73
};
74
74
@@ -81,17 +81,17 @@ Below is a sample configuration using the PXA255 NSSP for a legacy platform::
81
81
(void)platform_add_device(devices, ARRAY_SIZE(devices));
82
82
}
83
83
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
87
87
arch/.../mach-*/board- *.c using the "spi_board_info" structure found in
88
88
"linux/spi/spi.h". See "Documentation/spi/spi-summary.rst" for additional
89
89
information.
90
90
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
92
92
information 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
95
95
device. All fields are optional.
96
96
97
97
::
@@ -123,7 +123,7 @@ dma_burst_size == 0.
123
123
The "pxa2xx_spi_chip.timeout" fields is used to efficiently handle
124
124
trailing bytes in the SSP receiver FIFO. The correct value for this field is
125
125
dependent 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
127
127
timeouts and must busy-wait any trailing bytes.
128
128
129
129
NOTE: 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
132
132
to accommodate these chips.
133
133
134
134
135
- NSSP SLAVE SAMPLE
136
- -----------------
135
+ NSSP PERIPHERAL SAMPLE
136
+ ----------------------
137
137
For a legacy platform or in some other cases, the pxa2xx_spi_chip structure
138
138
is passed to the pxa2xx_spi driver in the "spi_board_info.controller_data"
139
139
field. Below is a sample configuration using the PXA255 NSSP.
@@ -161,16 +161,16 @@ field. Below is a sample configuration using the PXA255 NSSP.
161
161
.bus_num = 2, /* Framework bus number */
162
162
.chip_select = 0, /* Framework chip select */
163
163
.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 */
166
166
},
167
167
{
168
168
.modalias = "cs8405a", /* Name of spi_driver for this device */
169
169
.max_speed_hz = 3686400, /* Run SSP as fast a possible */
170
170
.bus_num = 2, /* Framework bus number */
171
171
.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 */
174
174
},
175
175
};
176
176
@@ -193,17 +193,14 @@ mode supports both coherent and stream based DMA mappings.
193
193
The following logic is used to determine the type of I/O to be used on
194
194
a per "spi_transfer" basis::
195
195
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
198
199
199
- if spi_message.len > 8191 then
200
200
print "rate limited" warning
201
201
use PIO transfers
202
202
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
207
204
use streaming DMA mode
208
205
209
206
otherwise
0 commit comments