#define SPC_V30 0x0c
#define SPC_V33 0x0e
+// SDHCI software reset flags
+#define SRF_ALL 0x01
+#define SRF_CMD 0x02
+#define SRF_DATA 0x04
+
// SDHCI result flags
#define SR_OCR_CCS (1<<30)
#define SR_OCR_NOTBUSY (1<<31)
}
}
+// Send an sdhci reset
+static int
+sdcard_reset(struct sdhci_s *regs, int flags)
+{
+ writeb(®s->software_reset, flags);
+ u32 end = timer_calc(SDHCI_PIO_TIMEOUT);
+ while (readb(®s->software_reset))
+ if (timer_check(end)) {
+ warn_timeout();
+ return -1;
+ }
+ return 0;
+}
+
// Send a command to the card.
static int
sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
dprintf(3, "sdhci@%p ver=%x cap=%x %x\n", regs
, readw(®s->controller_version)
, readl(®s->cap_lo), readl(®s->cap_hi));
+ sdcard_reset(regs, SRF_ALL);
writew(®s->irq_signal, 0);
writew(®s->irq_enable, 0xffff);
writew(®s->error_signal, 0);