<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Oct 28, 2017 at 10:26 AM, Kevin O'Connor <span dir="ltr"><<a href="mailto:kevin@koconnor.net" target="_blank">kevin@koconnor.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Okay. One more thing to try is a slightly different voltage range.<br>
<br>
-Kevin<br>
<br>
<br>
--- a/src/hw/sdcard.c<br>
+++ b/src/hw/sdcard.c<br>
@@ -123,6 +123,17 @@ struct sdhci_s {<br>
<span class=""> #define SRF_DATA 0x04<br>
<br>
// SDHCI result flags<br>
</span>+#define SR_OCR_VDD_165_195 (1<<7)<br>
+#define SR_OCR_VDD_27_28 (1<<15)<br>
+#define SR_OCR_VDD_28_29 (1<<16)<br>
+#define SR_OCR_VDD_29_30 (1<<17)<br>
+#define SR_OCR_VDD_30_31 (1<<18)<br>
+#define SR_OCR_VDD_31_32 (1<<19)<br>
+#define SR_OCR_VDD_32_33 (1<<20)<br>
+#define SR_OCR_VDD_33_34 (1<<21)<br>
+#define SR_OCR_VDD_34_35 (1<<22)<br>
+#define SR_OCR_VDD_35_36 (1<<23)<br>
<span class="">+#define SR_OCR_S18R (1<<24)<br>
#define SR_OCR_CCS (1<<30)<br>
#define SR_OCR_NOTBUSY (1<<31)<br>
<br>
</span>@@ -181,7 +192,7 @@ static int<br>
<span class=""> sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)<br>
{<br>
u32 state = readl(®s->present_state);<br>
- dprintf(9, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);<br>
+ dprintf(1, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);<br>
if ((state & SP_CMD_INHIBIT)<br>
|| ((cmd & 0x03) == 0x03 && state & SP_DAT_INHIBIT)) {<br>
dprintf(1, "sdcard_pio not ready %x\n", state);<br>
</span>@@ -203,7 +214,7 @@ sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)<br>
<span class=""> writew(®s->irq_status, SI_CMD_COMPLETE);<br>
// Read response<br>
memcpy(param, regs->response, sizeof(regs->response));<br>
- dprintf(9, "sdcard cmd %x response %x %x %x %x\n"<br>
+ dprintf(1, "sdcard cmd %x response %x %x %x %x\n"<br>
, cmd, param[0], param[1], param[2], param[3]);<br>
return 0;<br>
}<br>
</span>@@ -302,13 +313,13 @@ sdcard_set_power(struct sdhci_s *regs)<br>
u32 cap = readl(®s->cap_lo);<br>
u32 volt, vbits;<br>
if (cap & SD_CAPLO_V33) {<br>
- volt = 1<<20;<br>
+ volt = SR_OCR_VDD_32_33 | SR_OCR_VDD_33_34;<br>
vbits = SPC_V33;<br>
} else if (cap & SD_CAPLO_V30) {<br>
- volt = 1<<18;<br>
+ volt = SR_OCR_VDD_29_30 | SR_OCR_VDD_30_31;<br>
vbits = SPC_V30;<br>
} else if (cap & SD_CAPLO_V18) {<br>
- volt = 1<<7;<br>
+ volt = SR_OCR_VDD_165_195;<br>
vbits = SPC_V18;<br>
} else {<br>
dprintf(1, "SD controller unsupported volt range (%x)\n", cap);<br>
@@ -399,11 +410,11 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)<br>
if (ret)<br>
return ret;<br>
// Let card know SDHC/SDXC is supported and confirm voltage<br>
- u32 hcs = 0, vrange = (volt >= (1<<15) ? 0x100 : 0x200) | 0xaa;<br>
+ u32 hcs = 0, vrange = (volt >= SR_OCR_VDD_27_28 ? 0x100 : 0x200) | 0xaa;<br>
<span class=""> param[0] = vrange;<br>
ret = sdcard_pio(regs, SC_SEND_IF_COND, param);<br>
if (!ret && param[0] == vrange)<br>
- hcs = (1<<30);<br>
</span>+ hcs = SR_OCR_CCS | (1<<28);<br>
<span class=""> // Verify SD card (instead of MMC or SDIO)<br>
param[0] = 0x00;<br>
ret = sdcard_pio_app(regs, SC_APP_SEND_OP_COND, param);<br>
</span>@@ -414,8 +425,12 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)<br>
if (ret)<br>
return ret;<br>
drive->card_type |= SF_MMC;<br>
<span class="">- hcs = (1<<30);<br>
</span>+ hcs = SR_OCR_CCS;<br>
}<br>
+ // XXX<br>
+ if (volt == (SR_OCR_VDD_32_33 | SR_OCR_VDD_33_34)<br>
+ && hcs && readl(®s->cap_lo) & SD_CAPLO_V18)<br>
<span class="">+ hcs |= SR_OCR_S18R;<br>
// Init card<br>
u32 end = timer_calc(SDHCI_POWERUP_<wbr>TIMEOUT);<br>
for (;;) {<br>
</span>@@ -434,6 +449,10 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)<br>
<div class="HOEnZb"><div class="h5"> }<br>
msleep(5); // Avoid flooding log when debugging<br>
}<br>
+ if (param[0] & SR_OCR_S18R) {<br>
+ dprintf(1, "Card requests 1.8 volt\n");<br>
+ return -1;<br>
+ }<br>
drive->card_type |= (param[0] & SR_OCR_CCS) ? SF_HIGHCAPACITY : 0;<br>
// Select card (get cid, set rca, get csd, select card)<br>
param[0] = 0x00;<br>
</div></div></blockquote></div><br></div><div class="gmail_extra">no luck, log attached</div></div>