mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software/liblitesdcard/bios: add sdfreq command to configure SDCard clock frequency.
This commit is contained in:
parent
3897acb9e4
commit
4ac0ed49e1
3 changed files with 35 additions and 1 deletions
|
@ -20,6 +20,34 @@
|
|||
define_command(sdinit, sdcard_init, "Initialize SDCard", LITESDCARD_CMDS);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Command "sdfreq"
|
||||
*
|
||||
* Set SDcard clock frequency
|
||||
*
|
||||
*/
|
||||
#ifdef CSR_SDCORE_BASE
|
||||
static void sdfreq(int nb_params, char **params)
|
||||
{
|
||||
unsigned int freq;
|
||||
char *c;
|
||||
|
||||
if (nb_params < 1) {
|
||||
printf("sdfreq <freq>");
|
||||
return;
|
||||
}
|
||||
|
||||
freq = strtoul(params[0], &c, 0);
|
||||
if (*c != 0) {
|
||||
printf("Incorrect freq");
|
||||
return;
|
||||
}
|
||||
|
||||
sdcard_set_clk_freq(freq);
|
||||
}
|
||||
|
||||
define_command(sdfreq, sdfreq, "Set SDCard clock freq", LITESDCARD_CMDS);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Command "sdread"
|
||||
|
|
|
@ -96,7 +96,7 @@ static uint32_t log2(uint32_t x)
|
|||
return r;
|
||||
}
|
||||
|
||||
static void sdcard_set_clk_freq(uint32_t clk_freq) {
|
||||
void sdcard_set_clk_freq(uint32_t clk_freq) {
|
||||
uint32_t divider;
|
||||
divider = CONFIG_CLOCK_FREQUENCY/clk_freq + 1;
|
||||
divider = (1 << log2(divider));
|
||||
|
|
|
@ -60,6 +60,12 @@ int sdcard_wait_cmd_done(void);
|
|||
int sdcard_wait_data_done(void);
|
||||
int sdcard_wait_response(void);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* SDCard clocker functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
void sdcard_set_clk_freq(uint32_t clk_freq);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* SDCard commands functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue