2 * linux/drivers/mmc/jz_mmc.h
4 * Author: Vladimir Shebordaev, Igor Oblakov
5 * Copyright: MontaVista Software Inc.
7 * $Id: jz_mmc.h,v 1.3 2007-06-15 08:04:20 jlwei Exp $
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.
13 #ifndef __MMC_JZMMC_H__
14 #define __MMC_JZMMC_H__
16 #include "mmc_protocol.h"
18 #define MMC_DEBUG_LEVEL 0 /* Enable Debug: 0 - no debug */
20 #define MMC_BLOCK_SIZE 512 /* MMC/SD Block Size */
22 #define ID_TO_RCA(x) ((x)+1)
24 #define MMC_OCR_ARG 0x00ff8000 /* Argument of OCR */
29 MMC_ERROR_OUT_OF_RANGE
,
33 MMC_ERROR_ERASE_PARAM
,
34 MMC_ERROR_WP_VIOLATION
,
35 MMC_ERROR_CARD_IS_LOCKED
,
36 MMC_ERROR_LOCK_UNLOCK_FAILED
,
38 MMC_ERROR_ILLEGAL_COMMAND
,
39 MMC_ERROR_CARD_ECC_FAILED
,
44 MMC_ERROR_CID_CSD_OVERWRITE
,
45 MMC_ERROR_STATE_MISMATCH
,
46 MMC_ERROR_HEADER_MISMATCH
,
49 MMC_ERROR_DRIVER_FAILURE
,
52 /* the information structure of MMC/SD Card */
53 typedef struct MMC_INFO
55 int id
; /* Card index */
56 int sd
; /* MMC or SD card */
58 u32 scr
; /* SCR 63:32*/
59 int flags
; /* Ejected, inserted */
60 enum card_state state
; /* empty, ident, ready, whatever */
62 /* Card specific information */
73 int index
; /* Slot index - used for CS lines */
74 int cmd
; /* Command to send */
75 u32 arg
; /* Argument to send */
76 enum mmc_rsp_t rtype
; /* Response type expected */
78 /* Data transfer (these may be modified at the low level) */
79 u16 nob
; /* Number of blocks to transfer*/
80 u16 block_len
; /* Block length */
81 u8
*buffer
; /* Data buffer */
82 u32 cnt
; /* Data length, for PIO */
85 u8 response
[18]; /* Buffer to store response - CRC is optional */
86 enum mmc_result_t result
;
89 char * mmc_result_to_string(int);
90 int mmc_unpack_csd(struct mmc_request
*request
, struct mmc_csd
*csd
);
91 int mmc_unpack_r1(struct mmc_request
*request
, struct mmc_response_r1
*r1
, enum card_state state
);
92 int mmc_unpack_r6(struct mmc_request
*request
, struct mmc_response_r1
*r1
, enum card_state state
, int *rca
);
93 int mmc_unpack_scr(struct mmc_request
*request
, struct mmc_response_r1
*r1
, enum card_state state
, u32
*scr
);
94 int mmc_unpack_cid(struct mmc_request
*request
, struct mmc_cid
*cid
);
95 int mmc_unpack_r3(struct mmc_request
*request
, struct mmc_response_r3
*r3
);
97 void mmc_send_cmd(struct mmc_request
*request
, int cmd
, u32 arg
,
98 u16 nob
, u16 block_len
, enum mmc_rsp_t rtype
, u8
*buffer
);
99 u32
mmc_tran_speed(u8 ts
);
100 void jz_mmc_set_clock(int sd
, u32 rate
);
101 void jz_mmc_hardware_init(void);
103 static inline void mmc_simple_cmd(struct mmc_request
*request
, int cmd
, u32 arg
, enum mmc_rsp_t rtype
)
105 mmc_send_cmd( request
, cmd
, arg
, 0, 0, rtype
, 0);
108 int mmc_legacy_init(int verbose
);
109 int mmc_read(ulong src
, uchar
*dst
, int size
);
110 int mmc_write(uchar
*src
, ulong dst
, int size
);
111 int mmc2info(ulong addr
);
113 #endif /* __MMC_JZMMC_H__ */