software: Update to new sdcard core name.

This commit is contained in:
Florent Kermarrec 2023-07-20 16:28:51 +02:00
parent 0152e7de8e
commit 6693a723d1
3 changed files with 45 additions and 45 deletions

View File

@ -16,10 +16,10 @@
* Detect SDcard
*
*/
#ifdef CSR_SDPHY_BASE
#ifdef CSR_SDCARD_PHY_BASE
static void sdcard_detect_handler(int nb_params, char **params)
{
uint8_t cd = sdphy_card_detect_read();
uint8_t cd = sdcard_phy_card_detect_read();
printf("SDCard %sinserted.\n", cd ? "not " : "");
}
@ -32,7 +32,7 @@ define_command(sdcard_detect, sdcard_detect_handler, "Detect SDCard", LITESDCARD
* Initialize SDcard
*
*/
#ifdef CSR_SDCORE_BASE
#ifdef CSR_SDCARD_CORE_BASE
static void sdcard_init_handler(int nb_params, char **params)
{
printf("Initialize SDCard... ");
@ -51,7 +51,7 @@ define_command(sdcard_init, sdcard_init_handler, "Initialize SDCard", LITESDCARD
* Set SDcard clock frequency
*
*/
#ifdef CSR_SDCORE_BASE
#ifdef CSR_SDCARD_CORE_BASE
static void sdcard_freq_handler(int nb_params, char **params)
{
unsigned int freq;
@ -79,7 +79,7 @@ define_command(sdcard_freq, sdcard_freq_handler, "Set SDCard clock freq", LITESD
* Perform SDcard block read
*
*/
#ifdef CSR_SDBLOCK2MEM_BASE
#ifdef CSR_SDCARD_BLOCK2MEM_BASE
static void sdcard_read_handler(int nb_params, char **params)
{
unsigned int block;
@ -110,7 +110,7 @@ define_command(sdcard_read, sdcard_read_handler, "Read SDCard block", LITESDCARD
* Perform SDcard block write
*
*/
#ifdef CSR_SDMEM2BLOCK_BASE
#ifdef CSR_SDCARD_MEM2BLOCK_BASE
static void sdcard_write_handler(int nb_params, char **params)
{
int i;

View File

@ -18,7 +18,7 @@
#include <libfatfs/diskio.h>
#include "sdcard.h"
#ifdef CSR_SDCORE_BASE
#ifdef CSR_SDCARD_CORE_BASE
//#define SDCARD_DEBUG
//#define SDCARD_CMD23_SUPPORT /* SET_BLOCK_COUNT */
@ -44,14 +44,14 @@ int sdcard_wait_cmd_done(void) {
printf("cmdevt: wait for event & 0x1\n");
#endif
for (;;) {
event = sdcore_cmd_event_read();
event = sdcard_core_cmd_event_read();
busy_wait_us(10);
if (event & 0x1)
break;
}
#ifdef SDCARD_DEBUG
printf("cmdevt: %08x\n", event);
csr_rd_buf_uint32(CSR_SDCORE_CMD_RESPONSE_ADDR,
csr_rd_buf_uint32(CSR_SDCARD_CORE_CMD_RESPONSE_ADDR,
r, SD_CMD_RESPONSE_SIZE/4);
printf("%08x %08x %08x %08x\n", r[0], r[1], r[2], r[3]);
#endif
@ -68,7 +68,7 @@ int sdcard_wait_data_done(void) {
printf("dataevt: wait for event & 0x1\n");
#endif
for (;;) {
event = sdcore_data_event_read();
event = sdcard_core_data_event_read();
if (event & 0x1)
break;
busy_wait_us(10);
@ -116,7 +116,7 @@ void sdcard_set_clk_freq(unsigned long clk_freq, int show) {
else
printf("%ld KHz\n", clk_freq/1000);
}
sdphy_clocker_divider_write(divider);
sdcard_phy_clocker_divider_write(divider);
}
/*-----------------------------------------------------------------------*/
@ -124,9 +124,9 @@ void sdcard_set_clk_freq(unsigned long clk_freq, int show) {
/*-----------------------------------------------------------------------*/
static inline int sdcard_send_command(uint32_t arg, uint8_t cmd, uint8_t rsp) {
sdcore_cmd_argument_write(arg);
sdcore_cmd_command_write((cmd << 8) | rsp);
sdcore_cmd_send_write(1);
sdcard_core_cmd_argument_write(arg);
sdcard_core_cmd_command_write((cmd << 8) | rsp);
sdcard_core_cmd_send_write(1);
return sdcard_wait_cmd_done();
}
@ -212,8 +212,8 @@ int sdcard_switch(unsigned int mode, unsigned int group, unsigned int value) {
#ifdef SDCARD_DEBUG
printf("CMD6: SWITCH_FUNC\n");
#endif
sdcore_block_length_write(64);
sdcore_block_count_write(1);
sdcard_core_block_length_write(64);
sdcard_core_block_count_write(1);
while (sdcard_send_command(arg, 6,
(SDCARD_CTRL_DATA_TRANSFER_READ << 5) |
SDCARD_CTRL_RESPONSE_SHORT) != SD_OK);
@ -224,8 +224,8 @@ int sdcard_app_send_scr(void) {
#ifdef SDCARD_DEBUG
printf("CMD51: APP_SEND_SCR\n");
#endif
sdcore_block_length_write(8);
sdcore_block_count_write(1);
sdcard_core_block_length_write(8);
sdcard_core_block_count_write(1);
while (sdcard_send_command(0, 51,
(SDCARD_CTRL_DATA_TRANSFER_READ << 5) |
SDCARD_CTRL_RESPONSE_SHORT) != SD_OK);
@ -243,8 +243,8 @@ int sdcard_write_single_block(unsigned int blockaddr) {
#ifdef SDCARD_DEBUG
printf("CMD24: WRITE_SINGLE_BLOCK\n");
#endif
sdcore_block_length_write(512);
sdcore_block_count_write(1);
sdcard_core_block_length_write(512);
sdcard_core_block_count_write(1);
while (sdcard_send_command(blockaddr, 24,
(SDCARD_CTRL_DATA_TRANSFER_WRITE << 5) |
SDCARD_CTRL_RESPONSE_SHORT) != SD_OK);
@ -255,8 +255,8 @@ int sdcard_write_multiple_block(unsigned int blockaddr, unsigned int blockcnt) {
#ifdef SDCARD_DEBUG
printf("CMD25: WRITE_MULTIPLE_BLOCK\n");
#endif
sdcore_block_length_write(512);
sdcore_block_count_write(blockcnt);
sdcard_core_block_length_write(512);
sdcard_core_block_count_write(blockcnt);
while (sdcard_send_command(blockaddr, 25,
(SDCARD_CTRL_DATA_TRANSFER_WRITE << 5) |
SDCARD_CTRL_RESPONSE_SHORT) != SD_OK);
@ -267,8 +267,8 @@ int sdcard_read_single_block(unsigned int blockaddr) {
#ifdef SDCARD_DEBUG
printf("CMD17: READ_SINGLE_BLOCK\n");
#endif
sdcore_block_length_write(512);
sdcore_block_count_write(1);
sdcard_core_block_length_write(512);
sdcard_core_block_count_write(1);
while (sdcard_send_command(blockaddr, 17,
(SDCARD_CTRL_DATA_TRANSFER_READ << 5) |
SDCARD_CTRL_RESPONSE_SHORT) != SD_OK);
@ -279,8 +279,8 @@ int sdcard_read_multiple_block(unsigned int blockaddr, unsigned int blockcnt) {
#ifdef SDCARD_DEBUG
printf("CMD18: READ_MULTIPLE_BLOCK\n");
#endif
sdcore_block_length_write(512);
sdcore_block_count_write(blockcnt);
sdcard_core_block_length_write(512);
sdcard_core_block_count_write(blockcnt);
while (sdcard_send_command(blockaddr, 18,
(SDCARD_CTRL_DATA_TRANSFER_READ << 5) |
SDCARD_CTRL_RESPONSE_SHORT) != SD_OK);
@ -310,7 +310,7 @@ int sdcard_set_block_count(unsigned int blockcnt) {
uint16_t sdcard_decode_rca(void) {
uint32_t r[SD_CMD_RESPONSE_SIZE/4];
csr_rd_buf_uint32(CSR_SDCORE_CMD_RESPONSE_ADDR,
csr_rd_buf_uint32(CSR_SDCARD_CORE_CMD_RESPONSE_ADDR,
r, SD_CMD_RESPONSE_SIZE/4);
return (r[3] >> 16) & 0xffff;
}
@ -318,7 +318,7 @@ uint16_t sdcard_decode_rca(void) {
#ifdef SDCARD_DEBUG
void sdcard_decode_cid(void) {
uint32_t r[SD_CMD_RESPONSE_SIZE/4];
csr_rd_buf_uint32(CSR_SDCORE_CMD_RESPONSE_ADDR,
csr_rd_buf_uint32(CSR_SDCARD_CORE_CMD_RESPONSE_ADDR,
r, SD_CMD_RESPONSE_SIZE/4);
printf(
"CID Register: 0x%08x%08x%08x%08x\n"
@ -351,7 +351,7 @@ void sdcard_decode_cid(void) {
void sdcard_decode_csd(void) {
uint32_t r[SD_CMD_RESPONSE_SIZE/4];
csr_rd_buf_uint32(CSR_SDCORE_CMD_RESPONSE_ADDR,
csr_rd_buf_uint32(CSR_SDCARD_CORE_CMD_RESPONSE_ADDR,
r, SD_CMD_RESPONSE_SIZE/4);
/* FIXME: only support CSR structure version 2.0 */
printf(
@ -385,7 +385,7 @@ int sdcard_init(void) {
for (timeout=1000; timeout>0; timeout--) {
/* Set SDCard in SPI Mode (generate 80 dummy clocks) */
sdphy_init_initialize_write(1);
sdcard_phy_init_initialize_write(1);
busy_wait(1);
/* Set SDCard in Idle state */
@ -408,7 +408,7 @@ int sdcard_init(void) {
for (timeout=1000; timeout>0; timeout--) {
sdcard_app_cmd(0);
if (sdcard_app_send_op_cond(1) == SD_OK) {
csr_rd_buf_uint32(CSR_SDCORE_CMD_RESPONSE_ADDR,
csr_rd_buf_uint32(CSR_SDCARD_CORE_CMD_RESPONSE_ADDR,
r, SD_CMD_RESPONSE_SIZE/4);
if (r[3] & 0x80000000) /* Busy bit, set when init is complete */
@ -472,7 +472,7 @@ int sdcard_init(void) {
return 1;
}
#ifdef CSR_SDBLOCK2MEM_BASE
#ifdef CSR_SDCARD_BLOCK2MEM_BASE
void sdcard_read(uint32_t block, uint32_t count, uint8_t* buf)
{
@ -484,10 +484,10 @@ void sdcard_read(uint32_t block, uint32_t count, uint8_t* buf)
nblocks = 1;
#endif
/* Initialize DMA Writer */
sdblock2mem_dma_enable_write(0);
sdblock2mem_dma_base_write((uint64_t)(uintptr_t) buf);
sdblock2mem_dma_length_write(512*nblocks);
sdblock2mem_dma_enable_write(1);
sdcard_block2mem_dma_enable_write(0);
sdcard_block2mem_dma_base_write((uint64_t)(uintptr_t) buf);
sdcard_block2mem_dma_length_write(512*nblocks);
sdcard_block2mem_dma_enable_write(1);
/* Read Block(s) from SDCard */
#ifdef SDCARD_CMD23_SUPPORT
@ -499,7 +499,7 @@ void sdcard_read(uint32_t block, uint32_t count, uint8_t* buf)
sdcard_read_single_block(block);
/* Wait for DMA Writer to complete */
while ((sdblock2mem_dma_done_read() & 0x1) == 0);
while ((sdcard_block2mem_dma_done_read() & 0x1) == 0);
/* Stop transmission (Only for multiple block reads) */
if (nblocks > 1)
@ -520,7 +520,7 @@ void sdcard_read(uint32_t block, uint32_t count, uint8_t* buf)
#endif
#ifdef CSR_SDMEM2BLOCK_BASE
#ifdef CSR_SDCARD_MEM2BLOCK_BASE
void sdcard_write(uint32_t block, uint32_t count, uint8_t* buf)
{
@ -532,10 +532,10 @@ void sdcard_write(uint32_t block, uint32_t count, uint8_t* buf)
nblocks = 1;
#endif
/* Initialize DMA Reader */
sdmem2block_dma_enable_write(0);
sdmem2block_dma_base_write((uint64_t)(uintptr_t) buf);
sdmem2block_dma_length_write(512*nblocks);
sdmem2block_dma_enable_write(1);
sdcard_mem2block_dma_enable_write(0);
sdcard_mem2block_dma_base_write((uint64_t)(uintptr_t) buf);
sdcard_mem2block_dma_length_write(512*nblocks);
sdcard_mem2block_dma_enable_write(1);
/* Write Block(s) to SDCard */
#ifdef SDCARD_CMD23_SUPPORT
@ -551,7 +551,7 @@ void sdcard_write(uint32_t block, uint32_t count, uint8_t* buf)
sdcard_stop_transmission();
/* Wait for DMA Reader to complete */
while ((sdmem2block_dma_done_read() & 0x1) == 0);
while ((sdcard_mem2block_dma_done_read() & 0x1) == 0);
/* Update Block/Buffer/Count */
block += nblocks;
@ -594,4 +594,4 @@ void fatfs_set_ops_sdcard(void) {
FfDiskOps = &SdCardDiskOps;
}
#endif /* CSR_SDCORE_BASE */
#endif /* CSR_SDCARD_CORE_BASE */

View File

@ -14,7 +14,7 @@ extern "C" {
#define CLKGEN_STATUS_PROGDONE 0x2
#define CLKGEN_STATUS_LOCKED 0x4
#ifdef CSR_SDCORE_BASE
#ifdef CSR_SDCARD_CORE_BASE
#define SD_CMD_RESPONSE_SIZE 16