1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef __DRIVERS_MMC_ATMEL_MCI_H__
17#define __DRIVERS_MMC_ATMEL_MCI_H__
18
19
20#define ATMCI_CR 0x0000
21# define ATMCI_CR_MCIEN ( 1 << 0)
22# define ATMCI_CR_MCIDIS ( 1 << 1)
23# define ATMCI_CR_PWSEN ( 1 << 2)
24# define ATMCI_CR_PWSDIS ( 1 << 3)
25# define ATMCI_CR_SWRST ( 1 << 7)
26#define ATMCI_MR 0x0004
27# define ATMCI_MR_CLKDIV(x) ((x) << 0)
28# define ATMCI_MR_PWSDIV(x) ((x) << 8)
29# define ATMCI_MR_RDPROOF ( 1 << 11)
30# define ATMCI_MR_WRPROOF ( 1 << 12)
31# define ATMCI_MR_PDCFBYTE ( 1 << 13)
32# define ATMCI_MR_PDCPADV ( 1 << 14)
33# define ATMCI_MR_PDCMODE ( 1 << 15)
34# define ATMCI_MR_CLKODD(x) ((x) << 16)
35#define ATMCI_DTOR 0x0008
36# define ATMCI_DTOCYC(x) ((x) << 0)
37# define ATMCI_DTOMUL(x) ((x) << 4)
38#define ATMCI_SDCR 0x000c
39# define ATMCI_SDCSEL_SLOT_A ( 0 << 0)
40# define ATMCI_SDCSEL_SLOT_B ( 1 << 0)
41# define ATMCI_SDCSEL_MASK ( 3 << 0)
42# define ATMCI_SDCBUS_1BIT ( 0 << 6)
43# define ATMCI_SDCBUS_4BIT ( 2 << 6)
44# define ATMCI_SDCBUS_8BIT ( 3 << 6)
45# define ATMCI_SDCBUS_MASK ( 3 << 6)
46#define ATMCI_ARGR 0x0010
47#define ATMCI_CMDR 0x0014
48# define ATMCI_CMDR_CMDNB(x) ((x) << 0)
49# define ATMCI_CMDR_RSPTYP_NONE ( 0 << 6)
50# define ATMCI_CMDR_RSPTYP_48BIT ( 1 << 6)
51# define ATMCI_CMDR_RSPTYP_136BIT ( 2 << 6)
52# define ATMCI_CMDR_SPCMD_INIT ( 1 << 8)
53# define ATMCI_CMDR_SPCMD_SYNC ( 2 << 8)
54# define ATMCI_CMDR_SPCMD_INT ( 4 << 8)
55# define ATMCI_CMDR_SPCMD_INTRESP ( 5 << 8)
56# define ATMCI_CMDR_OPDCMD ( 1 << 11)
57# define ATMCI_CMDR_MAXLAT_5CYC ( 0 << 12)
58# define ATMCI_CMDR_MAXLAT_64CYC ( 1 << 12)
59# define ATMCI_CMDR_START_XFER ( 1 << 16)
60# define ATMCI_CMDR_STOP_XFER ( 2 << 16)
61# define ATMCI_CMDR_TRDIR_WRITE ( 0 << 18)
62# define ATMCI_CMDR_TRDIR_READ ( 1 << 18)
63# define ATMCI_CMDR_BLOCK ( 0 << 19)
64# define ATMCI_CMDR_MULTI_BLOCK ( 1 << 19)
65# define ATMCI_CMDR_STREAM ( 2 << 19)
66# define ATMCI_CMDR_SDIO_BYTE ( 4 << 19)
67# define ATMCI_CMDR_SDIO_BLOCK ( 5 << 19)
68# define ATMCI_CMDR_SDIO_SUSPEND ( 1 << 24)
69# define ATMCI_CMDR_SDIO_RESUME ( 2 << 24)
70#define ATMCI_BLKR 0x0018
71# define ATMCI_BCNT(x) ((x) << 0)
72# define ATMCI_BLKLEN(x) ((x) << 16)
73#define ATMCI_CSTOR 0x001c
74# define ATMCI_CSTOCYC(x) ((x) << 0)
75# define ATMCI_CSTOMUL(x) ((x) << 4)
76#define ATMCI_RSPR 0x0020
77#define ATMCI_RSPR1 0x0024
78#define ATMCI_RSPR2 0x0028
79#define ATMCI_RSPR3 0x002c
80#define ATMCI_RDR 0x0030
81#define ATMCI_TDR 0x0034
82#define ATMCI_SR 0x0040
83#define ATMCI_IER 0x0044
84#define ATMCI_IDR 0x0048
85#define ATMCI_IMR 0x004c
86# define ATMCI_CMDRDY ( 1 << 0)
87# define ATMCI_RXRDY ( 1 << 1)
88# define ATMCI_TXRDY ( 1 << 2)
89# define ATMCI_BLKE ( 1 << 3)
90# define ATMCI_DTIP ( 1 << 4)
91# define ATMCI_NOTBUSY ( 1 << 5)
92# define ATMCI_ENDRX ( 1 << 6)
93# define ATMCI_ENDTX ( 1 << 7)
94# define ATMCI_SDIOIRQA ( 1 << 8)
95# define ATMCI_SDIOIRQB ( 1 << 9)
96# define ATMCI_SDIOWAIT ( 1 << 12)
97# define ATMCI_CSRCV ( 1 << 13)
98# define ATMCI_RXBUFF ( 1 << 14)
99# define ATMCI_TXBUFE ( 1 << 15)
100# define ATMCI_RINDE ( 1 << 16)
101# define ATMCI_RDIRE ( 1 << 17)
102# define ATMCI_RCRCE ( 1 << 18)
103# define ATMCI_RENDE ( 1 << 19)
104# define ATMCI_RTOE ( 1 << 20)
105# define ATMCI_DCRCE ( 1 << 21)
106# define ATMCI_DTOE ( 1 << 22)
107# define ATMCI_CSTOE ( 1 << 23)
108# define ATMCI_BLKOVRE ( 1 << 24)
109# define ATMCI_DMADONE ( 1 << 25)
110# define ATMCI_FIFOEMPTY ( 1 << 26)
111# define ATMCI_XFRDONE ( 1 << 27)
112# define ATMCI_ACKRCV ( 1 << 28)
113# define ATMCI_ACKRCVE ( 1 << 29)
114# define ATMCI_OVRE ( 1 << 30)
115# define ATMCI_UNRE ( 1 << 31)
116#define ATMCI_DMA 0x0050
117# define ATMCI_DMA_OFFSET(x) ((x) << 0)
118# define ATMCI_DMA_CHKSIZE(x) ((x) << 4)
119# define ATMCI_DMAEN ( 1 << 8)
120#define ATMCI_CFG 0x0054
121# define ATMCI_CFG_FIFOMODE_1DATA ( 1 << 0)
122# define ATMCI_CFG_FERRCTRL_COR ( 1 << 4)
123# define ATMCI_CFG_HSMODE ( 1 << 8)
124# define ATMCI_CFG_LSYNC ( 1 << 12)
125#define ATMCI_WPMR 0x00e4
126# define ATMCI_WP_EN ( 1 << 0)
127# define ATMCI_WP_KEY (0x4d4349 << 8)
128#define ATMCI_WPSR 0x00e8
129# define ATMCI_GET_WP_VS(x) ((x) & 0x0f)
130# define ATMCI_GET_WP_VSRC(x) (((x) >> 8) & 0xffff)
131#define ATMCI_VERSION 0x00FC
132#define ATMCI_FIFO_APERTURE 0x0200
133
134
135#define ATMCI_REGS_SIZE 0x100
136
137
138#define atmci_readl(port,reg) \
139 __raw_readl((port)->regs + reg)
140#define atmci_writel(port,reg,value) \
141 __raw_writel((value), (port)->regs + reg)
142
143
144#ifdef CONFIG_AVR32
145# define ATMCI_PDC_CONNECTED 0
146#else
147# define ATMCI_PDC_CONNECTED 1
148#endif
149
150
151
152
153
154
155
156static inline unsigned int atmci_convert_chksize(unsigned int maxburst)
157{
158 if (maxburst > 1)
159 return fls(maxburst) - 2;
160 else
161 return 0;
162}
163
164#endif
165