Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/hw/sdcard.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/hw/sdcard.c b/src/hw/sdcard.c index 57f44b0..d4dea6a 100644 --- a/src/hw/sdcard.c +++ b/src/hw/sdcard.c @@ -84,6 +84,7 @@ struct sdhci_s { #define ST_MULTIPLE (1<<5)
// SDHCI capabilities flags +#define SD_CAPLO_V33 (1<<24) #define SD_CAPLO_BASECLOCK_SHIFT 8 #define SD_CAPLO_BASECLOCK_MASK 0x3f
@@ -93,6 +94,10 @@ struct sdhci_s { #define SCC_CLOCK_ENABLE (1<<2) #define SCC_SDCLK_SHIFT 8
+// SDHCI power control flags +#define SPC_POWER_ON (1<<0) +#define SPC_V33 0x0e + // SDHCI result flags #define SR_OCR_CCS (1<<30)
@@ -274,6 +279,10 @@ sdcard_set_frequency(struct sdhci_s *regs, u32 khz) dprintf(1, "Unknown base frequency for SD controller\n"); return -1; } + if (!(cap & SD_CAPLO_V33)) { + dprintf(1, "SD controller does not support 3.3V power\n"); + return -1; + } // Set new frequency u32 divisor = DIV_ROUND_UP(base_freq * 1000, khz); divisor = divisor >= 1 ? 1 << (__ffs(divisor-1)+1) : 0; @@ -315,7 +324,8 @@ sdcard_controller_setup(void *data) int ret = sdcard_set_frequency(regs, 400); if (ret) return; - writeb(®s->power_control, 0x0f); + writeb(®s->power_control, 0); + writeb(®s->power_control, SPC_V33 | SPC_POWER_ON);
// Initialize card int card_type = sdcard_card_setup(regs);