1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * SPI driver for rockchip
5 * (C) Copyright 2015 Google, Inc
7 * (C) Copyright 2008-2013 Rockchip Electronics
8 * Peter, Software Engineering, <superpeter.cai@gmail.com>.
32 u32 dmardlr; /* 0x44 */
34 u32 txdr[0x100]; /* 0x400 */
35 u32 rxdr[0x100]; /* 0x800 */
40 DFS_SHIFT = 0, /* Data Frame Size */
47 CFS_SHIFT = 2, /* Control Frame Size */
50 SCPH_SHIFT = 6, /* Serial Clock Phase */
52 SCPH_TOGMID = 0, /* SCLK toggles in middle of first data bit */
53 SCPH_TOGSTA, /* SCLK toggles at start of first data bit */
55 SCOL_SHIFT = 7, /* Serial Clock Polarity */
57 SCOL_LOW = 0, /* Inactive state of serial clock is low */
58 SCOL_HIGH, /* Inactive state of serial clock is high */
60 CSM_SHIFT = 8, /* Chip Select Mode */
62 CSM_KEEP = 0, /* ss_n stays low after each frame */
63 CSM_HALF, /* ss_n high for half sclk_out cycles */
64 CSM_ONE, /* ss_n high for one sclk_out cycle */
67 SSN_DELAY_SHIFT = 10, /* SSN to Sclk_out delay */
69 SSN_DELAY_HALF = 0, /* 1/2 sclk_out cycle */
70 SSN_DELAY_ONE = 1, /* 1 sclk_out cycle */
72 SEM_SHIFT = 11, /* Serial Endian Mode */
74 SEM_LITTLE = 0, /* little endian */
75 SEM_BIG, /* big endian */
77 FBM_SHIFT = 12, /* First Bit Mode */
79 FBM_MSB = 0, /* first bit is MSB */
80 FBM_LSB, /* first bit in LSB */
82 HALF_WORD_TX_SHIFT = 13, /* Byte and Halfword Transform */
84 HALF_WORD_ON = 0, /* apb 16bit write/read, spi 8bit write/read */
85 HALF_WORD_OFF, /* apb 8bit write/read, spi 8bit write/read */
87 RXDSD_SHIFT = 14, /* Rxd Sample Delay, in cycles */
90 FRF_SHIFT = 16, /* Frame Format */
92 FRF_SPI = 0, /* Motorola SPI */
93 FRF_SSP, /* Texas Instruments SSP*/
94 FRF_MICROWIRE, /* National Semiconductors Microwire */
97 TMOD_SHIFT = 18, /* Transfer Mode */
99 TMOD_TR = 0, /* xmit & recv */
100 TMOD_TO, /* xmit only */
101 TMOD_RO, /* recv only */
104 OMOD_SHIFT = 20, /* Operation Mode */
106 OMOD_MASTER = 0, /* Master Mode */
107 OMOD_SLAVE, /* Slave Mode */
120 #define ROCKCHIP_SPI_TIMEOUT_MS 1000
123 * We limit the maximum bitrate to 50MBit/s (50MHz) due to an assumed
124 * hardware limitation... the Linux kernel source has the following
126 * "sclk_out: spi master internal logic in rk3x can support 50Mhz"
128 #define ROCKCHIP_SPI_MAX_RATE 50000000
130 #endif /* __RK_SPI_H */