summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/sd.h40
-rw-r--r--firmware/target/arm/ata-sd-pp.c50
2 files changed, 42 insertions, 48 deletions
diff --git a/firmware/export/sd.h b/firmware/export/sd.h
index 11923fdc92..c3949af466 100644
--- a/firmware/export/sd.h
+++ b/firmware/export/sd.h
@@ -48,4 +48,44 @@ bool sd_present(IF_MV_NONVOID(int drive));
48 48
49long sd_last_disk_activity(void); 49long sd_last_disk_activity(void);
50 50
51/* SD States */
52#define IDLE 0
53#define READY 1
54#define IDENT 2
55#define STBY 3
56#define TRAN 4
57#define DATA 5
58#define RCV 6
59#define PRG 7
60#define DIS 8
61
62/* SD Commands */
63#define GO_IDLE_STATE 0
64#define ALL_SEND_CID 2
65#define SEND_RELATIVE_ADDR 3
66#define SET_DSR 4
67#define SWITCH_FUNC 6
68#define SELECT_CARD 7
69#define DESELECT_CARD 7
70#define SEND_IF_COND 8
71#define SEND_CSD 9
72#define SEND_CID 10
73#define STOP_TRANSMISSION 12
74#define SEND_STATUS 13
75#define GO_INACTIVE_STATE 15
76#define SET_BLOCKLEN 16
77#define READ_SINGLE_BLOCK 17
78#define READ_MULTIPLE_BLOCK 18
79#define SEND_NUM_WR_BLOCKS 22
80#define WRITE_BLOCK 24
81#define WRITE_MULTIPLE_BLOCK 25
82#define ERASE_WR_BLK_START 32
83#define ERASE_WR_BLK_END 33
84#define ERASE 38
85#define APP_CMD 55
86
87/* Application Specific commands */
88#define SET_BUS_WIDTH 6
89#define SD_APP_OP_COND 41
90
51#endif 91#endif
diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c
index 95e41e302b..af8c20d534 100644
--- a/firmware/target/arm/ata-sd-pp.c
+++ b/firmware/target/arm/ata-sd-pp.c
@@ -18,6 +18,7 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "config.h" /* for HAVE_MULTIVOLUME */
21#include "fat.h" 22#include "fat.h"
22#include "hotswap.h" 23#include "hotswap.h"
23#include "ata-sd-target.h" 24#include "ata-sd-target.h"
@@ -64,44 +65,8 @@
64#define CMD_ERROR_2 0x2 /* SD did not respond to command (either it doesn't 65#define CMD_ERROR_2 0x2 /* SD did not respond to command (either it doesn't
65 understand the command or is not inserted) */ 66 understand the command or is not inserted) */
66 67
67/* SD States */
68#define IDLE 0
69#define READY 1
70#define IDENT 2
71#define STBY 3
72#define TRAN 4
73#define DATA 5
74#define RCV 6
75#define PRG 7
76#define DIS 8
77
78#define FIFO_LEN 16 /* FIFO is 16 words deep */ 68#define FIFO_LEN 16 /* FIFO is 16 words deep */
79 69
80/* SD Commands */
81#define GO_IDLE_STATE 0
82#define ALL_SEND_CID 2
83#define SEND_RELATIVE_ADDR 3
84#define SET_DSR 4
85#define SWITCH_FUNC 6
86#define SELECT_CARD 7
87#define DESELECT_CARD 7
88#define SEND_IF_COND 8
89#define SEND_CSD 9
90#define SEND_CID 10
91#define STOP_TRANSMISSION 12
92#define SEND_STATUS 13
93#define GO_INACTIVE_STATE 15
94#define SET_BLOCKLEN 16
95#define READ_SINGLE_BLOCK 17
96#define READ_MULTIPLE_BLOCK 18
97#define SEND_NUM_WR_BLOCKS 22
98#define WRITE_BLOCK 24
99#define WRITE_MULTIPLE_BLOCK 25
100#define ERASE_WR_BLK_START 32
101#define ERASE_WR_BLK_END 33
102#define ERASE 38
103#define APP_CMD 55
104
105#define EC_OK 0 70#define EC_OK 0
106#define EC_FAILED 1 71#define EC_FAILED 1
107#define EC_NOCARD 2 72#define EC_NOCARD 2
@@ -124,17 +89,6 @@
124#define EC_COMMAND 19 89#define EC_COMMAND 19
125#define NUM_EC 20 90#define NUM_EC 20
126 91
127/* Application Specific commands */
128#define SET_BUS_WIDTH 6
129#define SD_APP_OP_COND 41
130
131/** global, exported variables **/
132#ifdef HAVE_MULTIVOLUME
133#define NUM_DRIVES 2
134#else
135#define NUM_DRIVES 1
136#endif
137
138/* for compatibility */ 92/* for compatibility */
139static long last_disk_activity = -1; 93static long last_disk_activity = -1;
140 94
@@ -153,7 +107,7 @@ struct sd_card_status
153 int retry_max; 107 int retry_max;
154}; 108};
155 109
156static struct sd_card_status sd_status[NUM_DRIVES] = 110static struct sd_card_status sd_status[NUM_VOLUMES] =
157{ 111{
158 { 0, 1 }, 112 { 0, 1 },
159#ifdef HAVE_MULTIVOLUME 113#ifdef HAVE_MULTIVOLUME