Skip to content

Commit 81e00c7

Browse files
author
Tomasz Bursztyka
committed
dts/bindings: Add a dedicated frame format property on SPI device
Most of the time SPI devices use TI's frame format. But some may use Motorola's. This is already taken care of in the SPI API and now it will be possible to select the right format from DTS. Like: ... frame-format = <SPI_FRAME_FORMAT_MOTOROLA>; ... This is only meant to be used for devices supporting both formats (so the format is not hard-coded in the driver) and selected by hardware configuration or else. Which, in such case, it will need to use DT_INST_PROP(<instance number>, frame-format) macro call to retrieve the property value. Others can fully ignore it. Signed-off-by: Tomasz Bursztyka <[email protected]>
1 parent 3a8e048 commit 81e00c7

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

dts/bindings/spi/spi-device.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@ properties:
2929
enum:
3030
- 0
3131
- 2048
32+
frame-format:
33+
type: int
34+
default: 0
35+
required: false
36+
description: |
37+
Motorola or TI frame format. By default it's always Motorola's,
38+
thus 0 as this is, by far, the most common format.
39+
Use the macros not the actual enum value, here is the concordance
40+
list (see dt-bindings/spi/spi.h)
41+
0 SPI_FRAME_FORMAT_MOTOROLA
42+
32768 SPI_FRAME_FORMAT_TI
43+
enum:
44+
- 0
45+
- 32768

include/drivers/spi.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,6 @@ extern "C" {
117117
#define SPI_CS_ACTIVE_HIGH BIT(14)
118118
/** @} */
119119

120-
/**
121-
* @name SPI Frame Format
122-
* @{
123-
*
124-
* 2 frame formats are exposed: Motorola and TI.
125-
* The main difference is the behavior of the CS line. In Motorala it stays
126-
* active the whole transfer. In TI, it's active only one serial clock period
127-
* prior to actually make the transfer, it is thus inactive during the transfer,
128-
* which ends when the clocks ends as well.
129-
* By default, as it is the most commonly used, the Motorola frame format
130-
* will prevail.
131-
*/
132-
#define SPI_FRAME_FORMAT_MOTOROLA (0U << 15)
133-
#define SPI_FRAME_FORMAT_TI (1U << 15)
134-
/** @} */
135-
136120
/**
137121
* @name SPI MISO lines (if @kconfig{CONFIG_SPI_EXTENDED_MODES} is enabled)
138122
* @{

include/dt-bindings/spi/spi.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@
2424
#define SPI_HALF_DUPLEX (1U << 11)
2525
/** @} */
2626

27+
/**
28+
* @name SPI Frame Format
29+
* @{
30+
*
31+
* 2 frame formats are exposed: Motorola and TI.
32+
* The main difference is the behavior of the CS line. In Motorala it stays
33+
* active the whole transfer. In TI, it's active only one serial clock period
34+
* prior to actually make the transfer, it is thus inactive during the transfer,
35+
* which ends when the clocks ends as well.
36+
* By default, as it is the most commonly used, the Motorola frame format
37+
* will prevail.
38+
*/
39+
#define SPI_FRAME_FORMAT_MOTOROLA (0U << 15)
40+
#define SPI_FRAME_FORMAT_TI (1U << 15)
41+
/** @} */
42+
2743
/**
2844
* @}
2945
*/

0 commit comments

Comments
 (0)