blob: 9440d80b500b583ee243f85d1843c8eed4f09436 [file] [log] [blame]
wdenk71f95112003-06-15 22:40:42 +00001/*
wdenk8bde7f72003-06-27 21:31:46 +00002 * linux/drivers/mmc/mmc_pxa.h
wdenk71f95112003-06-15 22:40:42 +00003 *
wdenk8bde7f72003-06-27 21:31:46 +00004 * Author: Vladimir Shebordaev, Igor Oblakov
wdenk71f95112003-06-15 22:40:42 +00005 * Copyright: MontaVista Software Inc.
6 *
7 * $Id: mmc_pxa.h,v 0.3.1.6 2002/09/25 19:25:48 ted Exp ted $
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#ifndef __MMC_PXA_P_H__
14#define __MMC_PXA_P_H__
15
16/* PXA-250 MMC controller registers */
17
18/* MMC_STRPCL */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020019#define MMC_STRPCL_STOP_CLK (0x0001UL)
wdenk71f95112003-06-15 22:40:42 +000020#define MMC_STRPCL_START_CLK (0x0002UL)
21
22/* MMC_STAT */
23#define MMC_STAT_END_CMD_RES (0x0001UL << 13)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020024#define MMC_STAT_PRG_DONE (0x0001UL << 12)
25#define MMC_STAT_DATA_TRAN_DONE (0x0001UL << 11)
26#define MMC_STAT_CLK_EN (0x0001UL << 8)
27#define MMC_STAT_RECV_FIFO_FULL (0x0001UL << 7)
28#define MMC_STAT_XMIT_FIFO_EMPTY (0x0001UL << 6)
29#define MMC_STAT_RES_CRC_ERROR (0x0001UL << 5)
wdenk71f95112003-06-15 22:40:42 +000030#define MMC_STAT_SPI_READ_ERROR_TOKEN (0x0001UL << 4)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020031#define MMC_STAT_CRC_READ_ERROR (0x0001UL << 3)
32#define MMC_STAT_CRC_WRITE_ERROR (0x0001UL << 2)
33#define MMC_STAT_TIME_OUT_RESPONSE (0x0001UL << 1)
34#define MMC_STAT_READ_TIME_OUT (0x0001UL)
wdenk71f95112003-06-15 22:40:42 +000035
36#define MMC_STAT_ERRORS (MMC_STAT_RES_CRC_ERROR|MMC_STAT_SPI_READ_ERROR_TOKEN\
37 |MMC_STAT_CRC_READ_ERROR|MMC_STAT_TIME_OUT_RESPONSE\
38 |MMC_STAT_READ_TIME_OUT|MMC_STAT_CRC_WRITE_ERROR)
39
40/* MMC_CLKRT */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020041#define MMC_CLKRT_20MHZ (0x0000UL)
42#define MMC_CLKRT_10MHZ (0x0001UL)
43#define MMC_CLKRT_5MHZ (0x0002UL)
wdenk71f95112003-06-15 22:40:42 +000044#define MMC_CLKRT_2_5MHZ (0x0003UL)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020045#define MMC_CLKRT_1_25MHZ (0x0004UL)
46#define MMC_CLKRT_0_625MHZ (0x0005UL)
47#define MMC_CLKRT_0_3125MHZ (0x0006UL)
wdenk71f95112003-06-15 22:40:42 +000048
49/* MMC_SPI */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020050#define MMC_SPI_DISABLE (0x00UL)
51#define MMC_SPI_EN (0x01UL)
52#define MMC_SPI_CS_EN (0x01UL << 2)
53#define MMC_SPI_CS_ADDRESS (0x01UL << 3)
54#define MMC_SPI_CRC_ON (0x01UL << 1)
wdenk71f95112003-06-15 22:40:42 +000055
56/* MMC_CMDAT */
stefano babicc95219f2007-11-20 10:40:24 +010057#define MMC_CMDAT_SD_4DAT (0x0001UL << 8)
wdenk71f95112003-06-15 22:40:42 +000058#define MMC_CMDAT_MMC_DMA_EN (0x0001UL << 7)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020059#define MMC_CMDAT_INIT (0x0001UL << 6)
60#define MMC_CMDAT_BUSY (0x0001UL << 5)
61#define MMC_CMDAT_BCR (0x0003UL << 5)
wdenk71f95112003-06-15 22:40:42 +000062#define MMC_CMDAT_STREAM (0x0001UL << 4)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020063#define MMC_CMDAT_BLOCK (0x0000UL << 4)
64#define MMC_CMDAT_WRITE (0x0001UL << 3)
65#define MMC_CMDAT_READ (0x0000UL << 3)
66#define MMC_CMDAT_DATA_EN (0x0001UL << 2)
67#define MMC_CMDAT_R0 (0)
68#define MMC_CMDAT_R1 (0x0001UL)
69#define MMC_CMDAT_R2 (0x0002UL)
70#define MMC_CMDAT_R3 (0x0003UL)
wdenk71f95112003-06-15 22:40:42 +000071
72/* MMC_RESTO */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020073#define MMC_RES_TO_MAX (0x007fUL) /* [6:0] */
wdenk71f95112003-06-15 22:40:42 +000074
75/* MMC_RDTO */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020076#define MMC_READ_TO_MAX (0x0ffffUL) /* [15:0] */
wdenk71f95112003-06-15 22:40:42 +000077
78/* MMC_BLKLEN */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020079#define MMC_BLK_LEN_MAX (0x03ffUL) /* [9:0] */
wdenk71f95112003-06-15 22:40:42 +000080
81/* MMC_PRTBUF */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020082#define MMC_PRTBUF_BUF_PART_FULL (0x01UL)
wdenk71f95112003-06-15 22:40:42 +000083#define MMC_PRTBUF_BUF_FULL (0x00UL )
84
85/* MMC_I_MASK */
86#define MMC_I_MASK_TXFIFO_WR_REQ (0x01UL << 6)
87#define MMC_I_MASK_RXFIFO_RD_REQ (0x01UL << 5)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020088#define MMC_I_MASK_CLK_IS_OFF (0x01UL << 4)
89#define MMC_I_MASK_STOP_CMD (0x01UL << 3)
90#define MMC_I_MASK_END_CMD_RES (0x01UL << 2)
91#define MMC_I_MASK_PRG_DONE (0x01UL << 1)
wdenk71f95112003-06-15 22:40:42 +000092#define MMC_I_MASK_DATA_TRAN_DONE (0x01UL)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020093#define MMC_I_MASK_ALL (0x07fUL)
wdenk71f95112003-06-15 22:40:42 +000094
95
96/* MMC_I_REG */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020097#define MMC_I_REG_TXFIFO_WR_REQ (0x01UL << 6)
98#define MMC_I_REG_RXFIFO_RD_REQ (0x01UL << 5)
wdenk71f95112003-06-15 22:40:42 +000099#define MMC_I_REG_CLK_IS_OFF (0x01UL << 4)
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200100#define MMC_I_REG_STOP_CMD (0x01UL << 3)
101#define MMC_I_REG_END_CMD_RES (0x01UL << 2)
102#define MMC_I_REG_PRG_DONE (0x01UL << 1)
103#define MMC_I_REG_DATA_TRAN_DONE (0x01UL)
104#define MMC_I_REG_ALL (0x007fUL)
wdenk71f95112003-06-15 22:40:42 +0000105
106/* MMC_CMD */
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200107#define MMC_CMD_INDEX_MAX (0x006fUL) /* [5:0] */
wdenk71f95112003-06-15 22:40:42 +0000108#define CMD(x) (x)
109
110#define MMC_DEFAULT_RCA 1
111
112#define MMC_BLOCK_SIZE 512
113#define MMC_CMD_RESET 0
114#define MMC_CMD_SEND_OP_COND 1
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200115#define MMC_CMD_ALL_SEND_CID 2
wdenk71f95112003-06-15 22:40:42 +0000116#define MMC_CMD_SET_RCA 3
stefano babicc95219f2007-11-20 10:40:24 +0100117#define MMC_CMD_SELECT_CARD 7
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200118#define MMC_CMD_SEND_CSD 9
119#define MMC_CMD_SEND_CID 10
wdenk71f95112003-06-15 22:40:42 +0000120#define MMC_CMD_SEND_STATUS 13
121#define MMC_CMD_SET_BLOCKLEN 16
122#define MMC_CMD_READ_BLOCK 17
123#define MMC_CMD_RD_BLK_MULTI 18
124#define MMC_CMD_WRITE_BLOCK 24
stefano babicc95219f2007-11-20 10:40:24 +0100125#define MMC_CMD_APP_CMD 55
126
127#define SD_CMD_APP_SET_BUS_WIDTH 6
128#define SD_CMD_APP_OP_COND 41
wdenk71f95112003-06-15 22:40:42 +0000129
130#define MMC_MAX_BLOCK_SIZE 512
131
132#define MMC_R1_IDLE_STATE 0x01
133#define MMC_R1_ERASE_STATE 0x02
134#define MMC_R1_ILLEGAL_CMD 0x04
135#define MMC_R1_COM_CRC_ERR 0x08
136#define MMC_R1_ERASE_SEQ_ERR 0x01
137#define MMC_R1_ADDR_ERR 0x02
138#define MMC_R1_PARAM_ERR 0x04
139
140#define MMC_R1B_WP_ERASE_SKIP 0x0002
141#define MMC_R1B_ERR 0x0004
142#define MMC_R1B_CC_ERR 0x0008
143#define MMC_R1B_CARD_ECC_ERR 0x0010
144#define MMC_R1B_WP_VIOLATION 0x0020
145#define MMC_R1B_ERASE_PARAM 0x0040
146#define MMC_R1B_OOR 0x0080
147#define MMC_R1B_IDLE_STATE 0x0100
148#define MMC_R1B_ERASE_RESET 0x0200
149#define MMC_R1B_ILLEGAL_CMD 0x0400
150#define MMC_R1B_COM_CRC_ERR 0x0800
151#define MMC_R1B_ERASE_SEQ_ERR 0x1000
152#define MMC_R1B_ADDR_ERR 0x2000
153#define MMC_R1B_PARAM_ERR 0x4000
154
155typedef struct mmc_cid
156{
157/* FIXME: BYTE_ORDER */
158 uchar year:4,
159 month:4;
160 uchar sn[3];
161 uchar fwrev:4,
162 hwrev:4;
163 uchar name[6];
164 uchar id[3];
165} mmc_cid_t;
166
167typedef struct mmc_csd
168{
stefano babicc95219f2007-11-20 10:40:24 +0100169 uint8_t csd_structure:2,
170 spec_ver:4,
171 rsvd1:2;
172 uint8_t taac;
173 uint8_t nsac;
174 uint8_t tran_speed;
175 uint16_t ccc:12,
176 read_bl_len:4;
177 uint64_t read_bl_partial:1,
178 write_blk_misalign:1,
179 read_blk_misalign:1,
180 dsr_imp:1,
181 rsvd2:2,
182 c_size:12,
183 vdd_r_curr_min:3,
184 vdd_r_curr_max:3,
185 vdd_w_curr_min:3,
186 vdd_w_curr_max:3,
187 c_size_mult:3,
188 erase_blk_en:1,
189 sector_size:7,
190 wp_grp_size:7,
191 wp_grp_enable:1,
192 default_ecc:2,
193 r2w_factor:3,
194 write_bl_len:4,
195 write_bl_partial:1,
196 rsvd3:4,
197 content_prot_app:1;
198 uint8_t file_format_grp:1,
199 copy:1,
200 perm_write_protect:1,
201 tmp_write_protect:1,
202 file_format:2,
203 ecc:2;
wdenk71f95112003-06-15 22:40:42 +0000204} mmc_csd_t;
205
wdenk71f95112003-06-15 22:40:42 +0000206#endif /* __MMC_PXA_P_H__ */