changing circuitry to disable RTC, update initialization to match
[fw/openalt] / fatfs / mmc.h
1 /*************************************************************************
2  *
3  *    Used with ICCARM and AARM.
4  *
5  *    (c) Copyright IAR Systems 2003
6  *
7  *    File name   : mmc.h
8  *    Description : define MMC module
9  *
10  *    History :
11  *    1. Data        : July 1, 2005
12  *       Author      : Stanimir Bonev
13  *       Description : Create
14  *
15  *    $Revision: 1.4 $
16 **************************************************************************/
17
18 #ifndef _MMC_H_
19 #define _MMC_H_
20
21 #include "sysdefs.h"
22 #include "disk.h"
23
24 //
25 //  Hardware depends definitions
26 //
27 #define IdentificationModeClock   400000l
28 #define SystemPeripherialClock    48000000l
29
30 // 
31 //  Time out definition for SD Read Time out ~100msec, Write Time out ~250ms
32 //
33 #define SD_READ_TIME_OUT          7     // [Hz]
34 #define SD_WRITE_TIME_OUT         3     // [HZ]
35
36 //
37 //
38 //
39 #define MMC_OK              0x00
40 #define MMC_IDLE_STATE      0x01
41 #define MMC_ERASE_RST       0x02
42 #define MMC_ILLEGAL_CMD     0x04
43 #define MMC_CRC_ERROR       0x08
44 #define MMC_ERASE_ERROR     0x10
45 #define MMC_ADD_ERROR       0x20
46 #define MMC_PARAM_ERROR     0x40
47
48 #define MMC_DATA_TOKEN      0xfe
49 #define MMC_DATA_ERR_TOKEN  0x1f
50 #define MMC_STOP_TRAN       0xfd
51
52 #define MMC_DLY_1MSEC       1000
53
54 typedef enum
55 {
56   MmcOk = 0, 
57   MmcNoPresent, 
58   MmcNoResponse, 
59   MmcCardError, 
60   MmcDataError,
61   MmcUknowError, 
62   MmmcParameterError, 
63   MmcMiscompare
64
65 mmcState_t;
66
67 typedef enum
68 {
69   CMD0 = 0, // Resets the MultiMediaCard
70   CMD1,     // Activates the card initialization process
71   CMD9,     // Asks the selected card to send its card-specific data (CSD)
72   CMD10,    // Asks the selected card to send its card identification (CID)
73   CMD12,    // Stop transmission on multiple block read
74   CMD13,    // Asks the selected card to send its status register
75   CMD16,    // Selects a block length (in bytes) for all following block commands (read and write)
76   CMD17,    // Reads a block of the size selected by the SET_BLOCKLEN command
77   CMD18,    // Continuously transfers data blocks from card to host until interrupted by a Stop command or the requested number of data blocks transmitted
78   CMD24,    // Writes a block of the size selected by the SET_BLOCKLEN command
79   CMD25,    // Continuously writes blocks of data until a "Stop Tran" token or the requested number of blocks received
80   CMD27,    // Programming of the programmable bits of the CSD
81   CMD28,    // If the card has write protection features, this command sets the write protection bit of the addressed group. The properties of write protection are coded in the card specific data (WP_GRP_SIZE).
82   CMD29,    // If the card has write protection features, this command clears the write protection bit of the addressed group
83   CMD30,    // If the card has write protection features, this command asks the card to send the status of the write protection bits
84   CMD32,    // Sets the address of the first sector of the erase group
85   CMD33,    // Sets the address of the last sector in a continuous range within the selected erase group, or the address of a single sector to be selected for erase
86   CMD34,    // Removes one previously selected sector from the erase selection
87   CMD35,    // Sets the address of the first erase group within a range to be selected for erase
88   CMD36,    // Sets the address of the last erase group within a continuous range to be selected for erase
89   CMD37,    // Removes one previously selected erase group from the erase selection.
90   CMD38,    // Erases all previously selected sectors
91   CMD42,    // Used to set/reset the password or lock/unlock the card. The size of the Data Block is defined by the SET_BLOCK_LEN command
92   CMD55,    // Notifies the card that the next command is an application specific command rather than a standard command.
93   CMD56,    // Used either to transfer a Data Block to the card or to get a Data Block from the card for general purpose/application specific commands. The size of the Data Block is defined with SET_BLOCK_LEN command
94   CMD58,    // Reads the OCR register of a card
95   CMD59,    // Turns the CRC option on or off. A \911\92 in the CRC option bit will turn the option on, a \910\92 will turn it off
96   ACMD41,   // Activates the card\92s initialization process (Only for SD)
97   CMD_END   // End of commands index
98
99 mmcSpiCmdInd_t;
100
101 typedef enum
102 {
103   MmcNoArg = 0,
104   MmcBlockLen,
105   MmcDataAdd, 
106   MmcDummyWord
107
108 mmcAgmType_t;
109
110 typedef enum
111 {
112   MmcR1 = 0,
113   MmcR1b,
114   MmcR2,
115   MmcR3
116
117 mmcRespType_t;
118
119 typedef struct
120 {
121   U8            TxData;
122   mmcAgmType_t  Arg;
123   mmcRespType_t Resp;
124
125 mmcCommads_t;
126
127 #endif