soc/software/litesdcard: use new send register to send command and remove CSR8_CMD_FIX.

This commit is contained in:
Florent Kermarrec 2020-05-29 20:15:02 +02:00
parent efcba14b1b
commit b1ec092e88
2 changed files with 21 additions and 26 deletions

View File

@ -1274,7 +1274,7 @@ class LiteXSoC(SoC):
else: else:
self.submodules.sdclk = SDClockerS7(sys_clk_freq=self.sys_clk_freq) self.submodules.sdclk = SDClockerS7(sys_clk_freq=self.sys_clk_freq)
self.submodules.sdphy = SDPHY(sdcard_pads, self.platform.device) self.submodules.sdphy = SDPHY(sdcard_pads, self.platform.device)
self.submodules.sdcore = SDCore(self.sdphy, csr_data_width=self.csr_data_width) self.submodules.sdcore = SDCore(self.sdphy)
self.submodules.sdtimer = Timer() self.submodules.sdtimer = Timer()
self.add_csr("sdclk") self.add_csr("sdclk")
self.add_csr("sdphy") self.add_csr("sdphy")

View File

@ -280,11 +280,6 @@ int sdcard_wait_response(void) {
} }
/* commands */ /* commands */
#if CONFIG_CSR_DATA_WIDTH == 8
#define CSR8_CMD_FIX sdcore_issue_cmd_write(1)
#else
#define CSR8_CMD_FIX
#endif
void sdcard_go_idle(void) { void sdcard_go_idle(void) {
#ifdef SDCARD_DEBUG #ifdef SDCARD_DEBUG
@ -292,7 +287,7 @@ void sdcard_go_idle(void) {
#endif #endif
sdcore_argument_write(0x00000000); sdcore_argument_write(0x00000000);
sdcore_command_write((0 << 8) | SDCARD_CTRL_RESPONSE_NONE); sdcore_command_write((0 << 8) | SDCARD_CTRL_RESPONSE_NONE);
CSR8_CMD_FIX; sdcore_send_write(1);
} }
int sdcard_send_ext_csd(void) { int sdcard_send_ext_csd(void) {
@ -303,7 +298,7 @@ int sdcard_send_ext_csd(void) {
#endif #endif
sdcore_argument_write(arg); sdcore_argument_write(arg);
sdcore_command_write((8 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((8 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -313,7 +308,7 @@ int sdcard_app_cmd(int rca) {
#endif #endif
sdcore_argument_write(rca << 16); sdcore_argument_write(rca << 16);
sdcore_command_write((55 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((55 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -329,7 +324,7 @@ int sdcard_app_send_op_cond(int hcs, int s18r) {
#endif #endif
sdcore_argument_write(arg); sdcore_argument_write(arg);
sdcore_command_write((41 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((41 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -339,7 +334,7 @@ int sdcard_all_send_cid(void) {
#endif #endif
sdcore_argument_write(0x00000000); sdcore_argument_write(0x00000000);
sdcore_command_write((2 << 8) | SDCARD_CTRL_RESPONSE_LONG); sdcore_command_write((2 << 8) | SDCARD_CTRL_RESPONSE_LONG);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -349,7 +344,7 @@ int sdcard_set_relative_address(void) {
#endif #endif
sdcore_argument_write(0x00000000); sdcore_argument_write(0x00000000);
sdcore_command_write((3 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((3 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -359,7 +354,7 @@ int sdcard_send_cid(unsigned int rca) {
#endif #endif
sdcore_argument_write(rca << 16); sdcore_argument_write(rca << 16);
sdcore_command_write((10 << 8) | SDCARD_CTRL_RESPONSE_LONG); sdcore_command_write((10 << 8) | SDCARD_CTRL_RESPONSE_LONG);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -369,7 +364,7 @@ int sdcard_send_csd(unsigned int rca) {
#endif #endif
sdcore_argument_write(rca << 16); sdcore_argument_write(rca << 16);
sdcore_command_write((9 << 8) | SDCARD_CTRL_RESPONSE_LONG); sdcore_command_write((9 << 8) | SDCARD_CTRL_RESPONSE_LONG);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -379,7 +374,7 @@ int sdcard_select_card(unsigned int rca) {
#endif #endif
sdcore_argument_write(rca << 16); sdcore_argument_write(rca << 16);
sdcore_command_write((7 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((7 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -389,7 +384,7 @@ int sdcard_app_set_bus_width(void) {
#endif #endif
sdcore_argument_write(0x00000002); sdcore_argument_write(0x00000002);
sdcore_command_write((6 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((6 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -408,7 +403,7 @@ int sdcard_switch(unsigned int mode, unsigned int group, unsigned int value, uns
sdcore_blockcount_write(1); sdcore_blockcount_write(1);
sdcore_command_write((6 << 8) | SDCARD_CTRL_RESPONSE_SHORT | sdcore_command_write((6 << 8) | SDCARD_CTRL_RESPONSE_SHORT |
(SDCARD_CTRL_DATA_TRANSFER_READ << 5)); (SDCARD_CTRL_DATA_TRANSFER_READ << 5));
CSR8_CMD_FIX; sdcore_send_write(1);
sdcard_wait_response(); sdcard_wait_response();
return sdcard_wait_data_done(); return sdcard_wait_data_done();
} }
@ -422,7 +417,7 @@ int sdcard_app_send_scr(void) {
sdcore_blockcount_write(1); sdcore_blockcount_write(1);
sdcore_command_write((51 << 8) | SDCARD_CTRL_RESPONSE_SHORT | sdcore_command_write((51 << 8) | SDCARD_CTRL_RESPONSE_SHORT |
(SDCARD_CTRL_DATA_TRANSFER_READ << 5)); (SDCARD_CTRL_DATA_TRANSFER_READ << 5));
CSR8_CMD_FIX; sdcore_send_write(1);
sdcard_wait_response(); sdcard_wait_response();
return sdcard_wait_data_done(); return sdcard_wait_data_done();
} }
@ -434,7 +429,7 @@ int sdcard_app_set_blocklen(unsigned int blocklen) {
#endif #endif
sdcore_argument_write(blocklen); sdcore_argument_write(blocklen);
sdcore_command_write((16 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((16 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -449,7 +444,7 @@ int sdcard_write_single_block(unsigned int blockaddr) {
sdcore_blockcount_write(1); sdcore_blockcount_write(1);
sdcore_command_write((24 << 8) | SDCARD_CTRL_RESPONSE_SHORT | sdcore_command_write((24 << 8) | SDCARD_CTRL_RESPONSE_SHORT |
(SDCARD_CTRL_DATA_TRANSFER_WRITE << 5)); (SDCARD_CTRL_DATA_TRANSFER_WRITE << 5));
CSR8_CMD_FIX; sdcore_send_write(1);
cmd_response = sdcard_wait_response(); cmd_response = sdcard_wait_response();
} }
return cmd_response; return cmd_response;
@ -466,7 +461,7 @@ int sdcard_write_multiple_block(unsigned int blockaddr, unsigned int blockcnt) {
sdcore_blockcount_write(blockcnt); sdcore_blockcount_write(blockcnt);
sdcore_command_write((25 << 8) | SDCARD_CTRL_RESPONSE_SHORT | sdcore_command_write((25 << 8) | SDCARD_CTRL_RESPONSE_SHORT |
(SDCARD_CTRL_DATA_TRANSFER_WRITE << 5)); (SDCARD_CTRL_DATA_TRANSFER_WRITE << 5));
CSR8_CMD_FIX; sdcore_send_write(1);
cmd_response = sdcard_wait_response(); cmd_response = sdcard_wait_response();
} }
return cmd_response; return cmd_response;
@ -483,7 +478,7 @@ int cmd_response = -1;
sdcore_blockcount_write(1); sdcore_blockcount_write(1);
sdcore_command_write((17 << 8) | SDCARD_CTRL_RESPONSE_SHORT | sdcore_command_write((17 << 8) | SDCARD_CTRL_RESPONSE_SHORT |
(SDCARD_CTRL_DATA_TRANSFER_READ << 5)); (SDCARD_CTRL_DATA_TRANSFER_READ << 5));
CSR8_CMD_FIX; sdcore_send_write(1);
cmd_response = sdcard_wait_response(); cmd_response = sdcard_wait_response();
} }
return sdcard_wait_data_done(); return sdcard_wait_data_done();
@ -500,7 +495,7 @@ int cmd_response = -1;
sdcore_blockcount_write(blockcnt); sdcore_blockcount_write(blockcnt);
sdcore_command_write((18 << 8) | SDCARD_CTRL_RESPONSE_SHORT | sdcore_command_write((18 << 8) | SDCARD_CTRL_RESPONSE_SHORT |
(SDCARD_CTRL_DATA_TRANSFER_READ << 5)); (SDCARD_CTRL_DATA_TRANSFER_READ << 5));
CSR8_CMD_FIX; sdcore_send_write(1);
cmd_response = sdcard_wait_response(); cmd_response = sdcard_wait_response();
} }
return cmd_response; return cmd_response;
@ -512,7 +507,7 @@ int sdcard_stop_transmission(void) {
#endif #endif
sdcore_argument_write(0x0000000); sdcore_argument_write(0x0000000);
sdcore_command_write((12 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((12 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -522,7 +517,7 @@ int sdcard_send_status(unsigned int rca) {
#endif #endif
sdcore_argument_write(rca << 16); sdcore_argument_write(rca << 16);
sdcore_command_write((13 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((13 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }
@ -532,7 +527,7 @@ int sdcard_set_block_count(unsigned int blockcnt) {
#endif #endif
sdcore_argument_write(blockcnt); sdcore_argument_write(blockcnt);
sdcore_command_write((23 << 8) | SDCARD_CTRL_RESPONSE_SHORT); sdcore_command_write((23 << 8) | SDCARD_CTRL_RESPONSE_SHORT);
CSR8_CMD_FIX; sdcore_send_write(1);
return sdcard_wait_response(); return sdcard_wait_response();
} }