blob: 3095d22e68d8dc34c02dfbf5a504e1ec95740a59 [file] [log] [blame]
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +01001/*
2 * Copyright (C) 2005-2006 Atmel Corporation
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22#ifndef __CPU_AT32AP_ATMEL_MCI_H__
23#define __CPU_AT32AP_ATMEL_MCI_H__
24
Reinhard Meyer1592ef82010-08-13 10:31:06 +020025#ifndef __ASSEMBLY__
26
27/*
28 * Structure for struct SoC access.
29 * Names starting with '_' are fillers.
30 */
31typedef struct atmel_mci {
32 /* reg Offset */
33 u32 cr; /* 0x00 */
34 u32 mr; /* 0x04 */
35 u32 dtor; /* 0x08 */
36 u32 sdcr; /* 0x0c */
37 u32 argr; /* 0x10 */
38 u32 cmdr; /* 0x14 */
elen.songc310fc82011-07-12 00:17:07 +000039 u32 blkr; /* 0x18 */
Reinhard Meyer1592ef82010-08-13 10:31:06 +020040 u32 _1c; /* 0x1c */
41 u32 rspr; /* 0x20 */
42 u32 rspr1; /* 0x24 */
43 u32 rspr2; /* 0x28 */
44 u32 rspr3; /* 0x2c */
45 u32 rdr; /* 0x30 */
46 u32 tdr; /* 0x34 */
47 u32 _38; /* 0x38 */
48 u32 _3c; /* 0x3c */
49 u32 sr; /* 0x40 */
50 u32 ier; /* 0x44 */
51 u32 idr; /* 0x48 */
52 u32 imr; /* 0x4c */
53} atmel_mci_t;
54
55#endif /* __ASSEMBLY__ */
56
57/*
58 * NOTICE: Use of registers offsets is depreciated.
59 * These defines will be removed once the old driver
60 * is taken out of commision.
61 *
62 * Atmel MultiMedia Card Interface (MCI) registers
63 */
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +010064#define MMCI_CR 0x0000
65#define MMCI_MR 0x0004
66#define MMCI_DTOR 0x0008
67#define MMCI_SDCR 0x000c
68#define MMCI_ARGR 0x0010
69#define MMCI_CMDR 0x0014
elen.songc310fc82011-07-12 00:17:07 +000070#define MMCI_BLKR 0x0018
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +010071#define MMCI_RSPR 0x0020
72#define MMCI_RSPR1 0x0024
73#define MMCI_RSPR2 0x0028
74#define MMCI_RSPR3 0x002c
75#define MMCI_RDR 0x0030
76#define MMCI_TDR 0x0034
77#define MMCI_SR 0x0040
78#define MMCI_IER 0x0044
79#define MMCI_IDR 0x0048
80#define MMCI_IMR 0x004c
81
82/* Bitfields in CR */
83#define MMCI_MCIEN_OFFSET 0
84#define MMCI_MCIEN_SIZE 1
85#define MMCI_MCIDIS_OFFSET 1
86#define MMCI_MCIDIS_SIZE 1
87#define MMCI_PWSEN_OFFSET 2
88#define MMCI_PWSEN_SIZE 1
89#define MMCI_PWSDIS_OFFSET 3
90#define MMCI_PWSDIS_SIZE 1
91#define MMCI_SWRST_OFFSET 7
92#define MMCI_SWRST_SIZE 1
93
94/* Bitfields in MR */
95#define MMCI_CLKDIV_OFFSET 0
96#define MMCI_CLKDIV_SIZE 8
97#define MMCI_PWSDIV_OFFSET 8
98#define MMCI_PWSDIV_SIZE 3
Haavard Skinnemoenf0d12462007-06-27 13:34:26 +020099#define MMCI_RDPROOF_OFFSET 11
100#define MMCI_RDPROOF_SIZE 1
101#define MMCI_WRPROOF_OFFSET 12
102#define MMCI_WRPROOF_SIZE 1
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +0100103#define MMCI_PDCPADV_OFFSET 14
104#define MMCI_PDCPADV_SIZE 1
105#define MMCI_PDCMODE_OFFSET 15
106#define MMCI_PDCMODE_SIZE 1
107#define MMCI_BLKLEN_OFFSET 16
108#define MMCI_BLKLEN_SIZE 16
109
110/* Bitfields in DTOR */
111#define MMCI_DTOCYC_OFFSET 0
112#define MMCI_DTOCYC_SIZE 4
113#define MMCI_DTOMUL_OFFSET 4
114#define MMCI_DTOMUL_SIZE 3
115
116/* Bitfields in SDCR */
117#define MMCI_SCDSEL_OFFSET 0
118#define MMCI_SCDSEL_SIZE 4
119#define MMCI_SCDBUS_OFFSET 7
120#define MMCI_SCDBUS_SIZE 1
121
122/* Bitfields in ARGR */
123#define MMCI_ARG_OFFSET 0
124#define MMCI_ARG_SIZE 32
125
126/* Bitfields in CMDR */
127#define MMCI_CMDNB_OFFSET 0
128#define MMCI_CMDNB_SIZE 6
129#define MMCI_RSPTYP_OFFSET 6
130#define MMCI_RSPTYP_SIZE 2
131#define MMCI_SPCMD_OFFSET 8
132#define MMCI_SPCMD_SIZE 3
133#define MMCI_OPDCMD_OFFSET 11
134#define MMCI_OPDCMD_SIZE 1
135#define MMCI_MAXLAT_OFFSET 12
136#define MMCI_MAXLAT_SIZE 1
137#define MMCI_TRCMD_OFFSET 16
138#define MMCI_TRCMD_SIZE 2
139#define MMCI_TRDIR_OFFSET 18
140#define MMCI_TRDIR_SIZE 1
141#define MMCI_TRTYP_OFFSET 19
142#define MMCI_TRTYP_SIZE 2
143
elen.songc310fc82011-07-12 00:17:07 +0000144/* Bitfields in BLKR */
145#define MMCI_BCNT_OFFSET 0
146#define MMCI_BCNT_SIZE 16
147#define MMCI_BLKLEN_OFFSET 16
148#define MMCI_BLKLEN_SIZE 16
149
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +0100150/* Bitfields in RSPRx */
151#define MMCI_RSP_OFFSET 0
152#define MMCI_RSP_SIZE 32
153
154/* Bitfields in SR/IER/IDR/IMR */
155#define MMCI_CMDRDY_OFFSET 0
156#define MMCI_CMDRDY_SIZE 1
157#define MMCI_RXRDY_OFFSET 1
158#define MMCI_RXRDY_SIZE 1
159#define MMCI_TXRDY_OFFSET 2
160#define MMCI_TXRDY_SIZE 1
161#define MMCI_BLKE_OFFSET 3
162#define MMCI_BLKE_SIZE 1
163#define MMCI_DTIP_OFFSET 4
164#define MMCI_DTIP_SIZE 1
165#define MMCI_NOTBUSY_OFFSET 5
166#define MMCI_NOTBUSY_SIZE 1
167#define MMCI_ENDRX_OFFSET 6
168#define MMCI_ENDRX_SIZE 1
169#define MMCI_ENDTX_OFFSET 7
170#define MMCI_ENDTX_SIZE 1
171#define MMCI_RXBUFF_OFFSET 14
172#define MMCI_RXBUFF_SIZE 1
173#define MMCI_TXBUFE_OFFSET 15
174#define MMCI_TXBUFE_SIZE 1
175#define MMCI_RINDE_OFFSET 16
176#define MMCI_RINDE_SIZE 1
177#define MMCI_RDIRE_OFFSET 17
178#define MMCI_RDIRE_SIZE 1
179#define MMCI_RCRCE_OFFSET 18
180#define MMCI_RCRCE_SIZE 1
181#define MMCI_RENDE_OFFSET 19
182#define MMCI_RENDE_SIZE 1
183#define MMCI_RTOE_OFFSET 20
184#define MMCI_RTOE_SIZE 1
185#define MMCI_DCRCE_OFFSET 21
186#define MMCI_DCRCE_SIZE 1
187#define MMCI_DTOE_OFFSET 22
188#define MMCI_DTOE_SIZE 1
189#define MMCI_OVRE_OFFSET 30
190#define MMCI_OVRE_SIZE 1
191#define MMCI_UNRE_OFFSET 31
192#define MMCI_UNRE_SIZE 1
193
194/* Constants for DTOMUL */
195#define MMCI_DTOMUL_1_CYCLE 0
196#define MMCI_DTOMUL_16_CYCLES 1
197#define MMCI_DTOMUL_128_CYCLES 2
198#define MMCI_DTOMUL_256_CYCLES 3
199#define MMCI_DTOMUL_1024_CYCLES 4
200#define MMCI_DTOMUL_4096_CYCLES 5
201#define MMCI_DTOMUL_65536_CYCLES 6
202#define MMCI_DTOMUL_1048576_CYCLES 7
203
204/* Constants for RSPTYP */
205#define MMCI_RSPTYP_NO_RESP 0
206#define MMCI_RSPTYP_48_BIT_RESP 1
207#define MMCI_RSPTYP_136_BIT_RESP 2
208
209/* Constants for SPCMD */
210#define MMCI_SPCMD_NO_SPEC_CMD 0
211#define MMCI_SPCMD_INIT_CMD 1
212#define MMCI_SPCMD_SYNC_CMD 2
213#define MMCI_SPCMD_INT_CMD 4
214#define MMCI_SPCMD_INT_RESP 5
215
216/* Constants for TRCMD */
217#define MMCI_TRCMD_NO_TRANS 0
218#define MMCI_TRCMD_START_TRANS 1
219#define MMCI_TRCMD_STOP_TRANS 2
220
221/* Constants for TRTYP */
222#define MMCI_TRTYP_BLOCK 0
223#define MMCI_TRTYP_MULTI_BLOCK 1
224#define MMCI_TRTYP_STREAM 2
225
226/* Bit manipulation macros */
227#define MMCI_BIT(name) \
228 (1 << MMCI_##name##_OFFSET)
229#define MMCI_BF(name,value) \
230 (((value) & ((1 << MMCI_##name##_SIZE) - 1)) \
231 << MMCI_##name##_OFFSET)
232#define MMCI_BFEXT(name,value) \
233 (((value) >> MMCI_##name##_OFFSET)\
234 & ((1 << MMCI_##name##_SIZE) - 1))
235#define MMCI_BFINS(name,value,old) \
236 (((old) & ~(((1 << MMCI_##name##_SIZE) - 1) \
237 << MMCI_##name##_OFFSET)) \
238 | MMCI_BF(name,value))
239
Reinhard Meyer1592ef82010-08-13 10:31:06 +0200240/*
241 * NOTICE: Use of registers offsets is depreciated.
242 * These defines will be removed once the old driver
243 * is taken out of commision.
244 *
245 * Register access macros
246 */
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +0100247#define mmci_readl(reg) \
Andreas Bießmannf4278b72010-11-04 23:15:31 +0000248 readl((void *)ATMEL_BASE_MMCI + MMCI_##reg)
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +0100249#define mmci_writel(reg,value) \
Andreas Bießmannf4278b72010-11-04 23:15:31 +0000250 writel((value), (void *)ATMEL_BASE_MMCI + MMCI_##reg)
Haavard Skinnemoenfc26c972006-01-20 10:03:53 +0100251
252#endif /* __CPU_AT32AP_ATMEL_MCI_H__ */