aboutsummaryrefslogtreecommitdiffstats
path: root/src/hw/sdcard.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-08-04 09:48:30 -0400
committerKevin O'Connor <kevin@koconnor.net>2015-08-04 09:48:30 -0400
commit86efbb6572a268123eb00067cb7b1526cebf92c4 (patch)
tree61881cbf269f4b8bf7bb12f3dcab848c48418069 /src/hw/sdcard.c
parent67bb455db4c756d8c35b9d59e0e690a3e3fbae95 (diff)
downloadseabios-86efbb6572a268123eb00067cb7b1526cebf92c4.tar.gz
sdcard: Make sure controller support 3.3V before enabling it
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/hw/sdcard.c')
-rw-r--r--src/hw/sdcard.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/hw/sdcard.c b/src/hw/sdcard.c
index aa27f841..58171c50 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) : 0;
@@ -312,7 +321,8 @@ sdcard_controller_setup(void *data)
writew(&regs->irq_signal, 0);
writew(&regs->irq_enable, 0xffff);
writew(&regs->error_signal, 0);
- writeb(&regs->power_control, 0x0f);
+ writeb(&regs->power_control, 0);
+ writeb(&regs->power_control, SPC_V33 | SPC_POWER_ON);
int ret = sdcard_set_frequency(regs, 400);
if (ret)
return;