xref: /openbmc/u-boot/include/fsl_dspi.h (revision a8919371108f0e7428345d1da7791810b5c783f9)
1*a8919371SHaikun.Wang@freescale.com /*
2*a8919371SHaikun.Wang@freescale.com  * Freescale DSPI Module Defines
3*a8919371SHaikun.Wang@freescale.com  *
4*a8919371SHaikun.Wang@freescale.com  * Copyright (C) 2004-2007, 2015 Freescale Semiconductor, Inc.
5*a8919371SHaikun.Wang@freescale.com  * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
6*a8919371SHaikun.Wang@freescale.com  * Chao Fu (B44548@freesacle.com)
7*a8919371SHaikun.Wang@freescale.com  * Haikun Wang (B53464@freescale.com)
8*a8919371SHaikun.Wang@freescale.com  *
9*a8919371SHaikun.Wang@freescale.com  * SPDX-License-Identifier:	GPL-2.0+
10*a8919371SHaikun.Wang@freescale.com  */
11*a8919371SHaikun.Wang@freescale.com 
12*a8919371SHaikun.Wang@freescale.com #ifndef _FSL_DSPI_H_
13*a8919371SHaikun.Wang@freescale.com #define _FSL_DSPI_H_
14*a8919371SHaikun.Wang@freescale.com 
15*a8919371SHaikun.Wang@freescale.com /* DMA Serial Peripheral Interface (DSPI) */
16*a8919371SHaikun.Wang@freescale.com struct dspi {
17*a8919371SHaikun.Wang@freescale.com 	u32 mcr;	/* 0x00 */
18*a8919371SHaikun.Wang@freescale.com 	u32 resv0;	/* 0x04 */
19*a8919371SHaikun.Wang@freescale.com 	u32 tcr;	/* 0x08 */
20*a8919371SHaikun.Wang@freescale.com 	u32 ctar[8];	/* 0x0C - 0x28 */
21*a8919371SHaikun.Wang@freescale.com 	u32 sr;		/* 0x2C */
22*a8919371SHaikun.Wang@freescale.com 	u32 irsr;	/* 0x30 */
23*a8919371SHaikun.Wang@freescale.com 	u32 tfr;	/* 0x34 - PUSHR */
24*a8919371SHaikun.Wang@freescale.com 	u32 rfr;	/* 0x38 - POPR */
25*a8919371SHaikun.Wang@freescale.com #ifdef CONFIG_MCF547x_8x
26*a8919371SHaikun.Wang@freescale.com 	u32 tfdr[4];	/* 0x3C */
27*a8919371SHaikun.Wang@freescale.com 	u8 resv2[0x30];	/* 0x40 */
28*a8919371SHaikun.Wang@freescale.com 	u32 rfdr[4];	/* 0x7C */
29*a8919371SHaikun.Wang@freescale.com #else
30*a8919371SHaikun.Wang@freescale.com 	u32 tfdr[16];	/* 0x3C */
31*a8919371SHaikun.Wang@freescale.com 	u32 rfdr[16];	/* 0x7C */
32*a8919371SHaikun.Wang@freescale.com #endif
33*a8919371SHaikun.Wang@freescale.com };
34*a8919371SHaikun.Wang@freescale.com 
35*a8919371SHaikun.Wang@freescale.com /* Module configuration */
36*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_MSTR			0x80000000
37*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSCK			0x40000000
38*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_DCONF(x)		(((x) & 0x03) << 28)
39*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_FRZ			0x08000000
40*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_MTFE			0x04000000
41*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_PCSSE			0x02000000
42*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_ROOE			0x01000000
43*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_PCSIS(x)		(1 << (16 + (x)))
44*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_PCSIS_MASK		(0xff << 16)
45*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS7			0x00800000
46*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS6			0x00400000
47*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS5			0x00200000
48*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS4			0x00100000
49*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS3			0x00080000
50*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS2			0x00040000
51*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS1			0x00020000
52*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CSIS0			0x00010000
53*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_DOZE			0x00008000
54*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_MDIS			0x00004000
55*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_DTXF			0x00002000
56*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_DRXF			0x00001000
57*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CTXF			0x00000800
58*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_CRXF			0x00000400
59*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_SMPL_PT(x)		(((x) & 0x03) << 8)
60*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_FCPCS			0x00000001
61*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_PES			0x00000001
62*a8919371SHaikun.Wang@freescale.com #define DSPI_MCR_HALT			0x00000001
63*a8919371SHaikun.Wang@freescale.com 
64*a8919371SHaikun.Wang@freescale.com /* Transfer count */
65*a8919371SHaikun.Wang@freescale.com #define DSPI_TCR_SPI_TCNT(x)		(((x) & 0x0000FFFF) << 16)
66*a8919371SHaikun.Wang@freescale.com 
67*a8919371SHaikun.Wang@freescale.com /* Clock and transfer attributes */
68*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR(x)			(0x0c + (x * 4))
69*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_DBR			0x80000000
70*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_TRSZ(x)		(((x) & 0x0F) << 27)
71*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_CPOL			0x04000000
72*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_CPHA			0x02000000
73*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_LSBFE			0x01000000
74*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PCSSCK(x)		(((x) & 0x03) << 22)
75*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PCSSCK_7CLK		0x00A00000
76*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PCSSCK_5CLK		0x00800000
77*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PCSSCK_3CLK		0x00400000
78*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PCSSCK_1CLK		0x00000000
79*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PASC(x)		(((x) & 0x03) << 20)
80*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PASC_7CLK		0x00300000
81*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PASC_5CLK		0x00200000
82*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PASC_3CLK		0x00100000
83*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PASC_1CLK		0x00000000
84*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PDT(x)		(((x) & 0x03) << 18)
85*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PDT_7CLK		0x000A0000
86*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PDT_5CLK		0x00080000
87*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PDT_3CLK		0x00040000
88*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PDT_1CLK		0x00000000
89*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PBR(x)		(((x) & 0x03) << 16)
90*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PBR_7CLK		0x00030000
91*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PBR_5CLK		0x00020000
92*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PBR_3CLK		0x00010000
93*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_PBR_1CLK		0x00000000
94*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_CSSCK(x)		(((x) & 0x0F) << 12)
95*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_ASC(x)		(((x) & 0x0F) << 8)
96*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_DT(x)			(((x) & 0x0F) << 4)
97*a8919371SHaikun.Wang@freescale.com #define DSPI_CTAR_BR(x)			((x) & 0x0F)
98*a8919371SHaikun.Wang@freescale.com 
99*a8919371SHaikun.Wang@freescale.com /* Status */
100*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_TCF			0x80000000
101*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_TXRXS			0x40000000
102*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_EOQF			0x10000000
103*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_TFUF			0x08000000
104*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_TFFF			0x02000000
105*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_RFOF			0x00080000
106*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_RFDF			0x00020000
107*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_TXCTR(x)		(((x) & 0x0000F000) >> 12)
108*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_TXPTR(x)		(((x) & 0x00000F00) >> 8)
109*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_RXCTR(x)		(((x) & 0x000000F0) >> 4)
110*a8919371SHaikun.Wang@freescale.com #define DSPI_SR_RXPTR(x)		((x) & 0x0000000F)
111*a8919371SHaikun.Wang@freescale.com 
112*a8919371SHaikun.Wang@freescale.com /* DMA/interrupt request selct and enable */
113*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_TCFE			0x80000000
114*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_EOQFE			0x10000000
115*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_TFUFE			0x08000000
116*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_TFFFE			0x02000000
117*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_TFFFS			0x01000000
118*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_RFOFE			0x00080000
119*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_RFDFE			0x00020000
120*a8919371SHaikun.Wang@freescale.com #define DSPI_IRSR_RFDFS			0x00010000
121*a8919371SHaikun.Wang@freescale.com 
122*a8919371SHaikun.Wang@freescale.com /* Transfer control - 32-bit access */
123*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_PCS(x)			(((1 << x) & 0x0000003f) << 16)
124*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CONT			0x80000000
125*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CTAS(x)		(((x) & 0x07) << 28)
126*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_EOQ			0x08000000
127*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CTCNT			0x04000000
128*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS7			0x00800000
129*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS6			0x00400000
130*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS5			0x00200000
131*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS4			0x00100000
132*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS3			0x00080000
133*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS2			0x00040000
134*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS1			0x00020000
135*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_CS0			0x00010000
136*a8919371SHaikun.Wang@freescale.com 
137*a8919371SHaikun.Wang@freescale.com /* Transfer Fifo */
138*a8919371SHaikun.Wang@freescale.com #define DSPI_TFR_TXDATA(x)		((x) & 0x0000FFFF)
139*a8919371SHaikun.Wang@freescale.com 
140*a8919371SHaikun.Wang@freescale.com /* Bit definitions and macros for DRFR */
141*a8919371SHaikun.Wang@freescale.com #define DSPI_RFR_RXDATA(x)		((x) & 0x0000FFFF)
142*a8919371SHaikun.Wang@freescale.com 
143*a8919371SHaikun.Wang@freescale.com /* Bit definitions and macros for DTFDR group */
144*a8919371SHaikun.Wang@freescale.com #define DSPI_TFDR_TXDATA(x)		((x) & 0x0000FFFF)
145*a8919371SHaikun.Wang@freescale.com #define DSPI_TFDR_TXCMD(x)		(((x) & 0x0000FFFF) << 16)
146*a8919371SHaikun.Wang@freescale.com 
147*a8919371SHaikun.Wang@freescale.com /* Bit definitions and macros for DRFDR group */
148*a8919371SHaikun.Wang@freescale.com #define DSPI_RFDR_RXDATA(x)		((x) & 0x0000FFFF)
149*a8919371SHaikun.Wang@freescale.com 
150*a8919371SHaikun.Wang@freescale.com #endif				/* _FSL_DSPI_H_ */
151