OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [include/] [sdc.h] - Blame information for rev 607

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 389 tac2
#ifndef _SDC_H
2
#define _SDC_H
3
#include "board.h"
4
#include "typedefs.h"
5
 
6
#include "spr-defs.h"
7
#include "support.h"
8
//#include <stdlib.h>
9
 
10
 
11
#define REG32(add) *((volatile unsigned long *)(add))
12
#define DBGA(stuff...)  //      printf("SDC_HAL:" stuff)
13
/* Memory card sector size */
14
#define SECTOR_SIZE 512
15
 
16
#define SECTOR_TO_BLOCK(a) (a << 9)
17
 
18
//SD_CONTROLLER Register
19
#define WORD_0 0x00
20
#define WORD_1 0x40
21
#define WORD_2 0x80
22
#define WORD_3 0xC0
23
 
24
 
25
#define SD_ARG 0x00
26
#define SD_COMMAND 0x04 
27
#define SD_STATUS 0x08
28
#define SD_RESP1 0x0c
29
 
30
#define SD_CTRL 0x1c
31
#define SD_BLOCK 0x20
32
#define SD_POWER 0x24
33
#define SD_SOFTWARE_RST 0x28
34
#define SD_TIMEOUT 0x2c
35
#define SD_NORMAL_INT_STATUS 0x30
36
#define SD_ERROR_INT_STATUS 0x34
37
#define SD_NORMAL_INT_STATUS_ENABLE 0x38
38
#define SD_ERROR_INT_STATUS_ENABLE 0x3c
39
#define SD_NOMAL_INT_SIGNAL_ENABLE  0x40
40
#define SD_ERROR_INT_SIGNAL_ENABLE  0x44
41
#define SD_CAPABILITY  0x48
42
#define SD_CLOCK_D  0x4c
43
#define BD_STATUS 0x50
44
#define BD_ISR 0x54
45
#define BD_RX 0x60
46
#define BD_TX 0x80
47
 
48
#define CLK_CARD 25000000
49
#define CLK_CPU 25000000
50
#define CMD_TIMEOUT_MS ((CLK_CPU/CLK_CARD) * 512)
51
#define MAX_POL 1000
52
#define SD_REG(REG)  REG32(SDC_CONTROLLER_BASE+REG) 
53
 
54
 
55
//Commands
56
#define CMD0 0x000 // software reset
57
#define CMD2 0x200
58
#define CMD3 0x300
59
#define CMD7 0x700
60
#define CMD8  0x800
61
#define CMD9  0x900  // ask card to send card speficic data (CSD)
62
#define CMD16  0x1000   // sets the block length used by the memory card
63
#define CMD17  0x1100 // read single block
64
 
65
#define ACMD41 0x2900
66
#define ACMD6 0x600
67
#define CMD55 0x3700
68
 
69
//CMD ARG
70
//CMD8
71
#define VHS  0x100 //2.7-3.6V
72
#define CHECK_PATTERN 0xAA
73
//ACMD41
74
#define BUSY 0x80000000
75
#define HCS 0x40000000
76
#define VOLTAGE_MASK 0xFFFFFF
77
 
78
//CMD7
79
#define READY_FOR_DATA 0x100
80
#define CARD_STATUS_STB  0x600
81
 
82
//Command setting
83
#define CICE 0x10
84
#define CRCE 0x08
85
#define RSP_48 0x2
86
#define RSP_146 0x1
87
 
88
//Status Mask
89
//Normal interupt status
90
#define CMD_COMPLETE 0x1
91
#define EI 0x8000
92
 
93
//Error interupt status
94
#define CMD_TIMEOUT 0x1
95
#define CCRC 0x1
96
#define CIE  0x8
97
 
98
#define CID_MID_MASK 0x7F8000
99
#define CID_OID_MASK 0x7FFF             
100
#define CID_B1 0x7F800000
101
#define CID_B2 0x7F8000
102
#define CID_B3 0x7F80
103
#define CID_B4 0x7F
104
 
105
#define RCA_RCA_MASK 0xFFFF0000
106
 
107
#define WRITE_OP  1
108
#define READ_OP  0
109
 
110
 
111
typedef struct {
112
        unsigned long int pad:18;
113
        unsigned  int cmdi:6;
114
        unsigned  int cmdt:2;
115
        unsigned  int dps:1;
116
        unsigned  int cice:1;
117
        unsigned  int crce:1;
118
        unsigned  int  rsvd:1;
119
        unsigned  int rts:2;
120
}sd_controller_csr ;
121
 
122
 
123
 
124
typedef struct {
125
        char mid:8;
126
        short oid:16;
127
        unsigned char pnm[5];
128
        char  prv:8;
129
        int psn:32;
130
        char rsv:4;
131
        short mdt:12;
132
}sd_card_cid;
133
 
134
typedef struct {
135
}sd_card_csd;
136
 
137
typedef struct  {
138
        int rca;
139
        int Voltage_window;
140
        char HCS_s;
141
    char Active;
142
        char phys_spec_2_0;
143
         int  cid_reg;
144
        sd_card_csd * csd_reg;
145
 
146
}sd_card ;
147
 
148
extern volatile sd_card dev;
149
 
150
unsigned char sd_wait_rsp(void);
151
int setup_bd_transfer(boolean direction, int block_addr, volatile unsigned char *buff);
152
void reset_card(void);
153
int finnish_bd_transfer(void);
154
int sd_setup_transfer (sd_card sd_card_0);
155
int setBLockLength(void);
156
 
157
int memCardInit(void);
158
 
159
#endif // _SDC_H
160
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.