On Fri, Oct 27, 2017 at 7:08 PM, Kevin O'Connor <kevin@koconnor.net> wrote:
Can you try the two patches below?  (Go back to master, apply the
first, gather the log, go back to master, apply the second, gather the
log.)

-Kevin

w/patch 1 only: https://paste.ubuntu.com/25833503/

w/patch 2 only: https://paste.ubuntu.com/25833542/

 


====================== patch 1 =========================

--- a/src/hw/sdcard.c
+++ b/src/hw/sdcard.c
@@ -181,7 +181,7 @@ static int
 sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
 {
     u32 state = readl(&regs->present_state);
-    dprintf(9, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
+    dprintf(1, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
     if ((state & SP_CMD_INHIBIT)
         || ((cmd & 0x03) == 0x03 && state & SP_DAT_INHIBIT)) {
         dprintf(1, "sdcard_pio not ready %x\n", state);
@@ -203,7 +203,7 @@ sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
     writew(&regs->irq_status, SI_CMD_COMPLETE);
     // Read response
     memcpy(param, regs->response, sizeof(regs->response));
-    dprintf(9, "sdcard cmd %x response %x %x %x %x\n"
+    dprintf(1, "sdcard cmd %x response %x %x %x %x\n"
             , cmd, param[0], param[1], param[2], param[3]);
     return 0;
 }
@@ -403,7 +403,7 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)
     param[0] = vrange;
     ret = sdcard_pio(regs, SC_SEND_IF_COND, param);
     if (!ret && param[0] == vrange)
-        hcs = (1<<30);
+        hcs = (1<<30) | (1<<28);
     // Verify SD card (instead of MMC or SDIO)
     param[0] = 0x00;
     ret = sdcard_pio_app(regs, SC_APP_SEND_OP_COND, param);


====================== patch 2 =========================

--- a/src/hw/sdcard.c
+++ b/src/hw/sdcard.c
@@ -123,6 +123,7 @@ struct sdhci_s {
 #define SRF_DATA 0x04

 // SDHCI result flags
+#define SR_OCR_S18R    (1<<24)
 #define SR_OCR_CCS     (1<<30)
 #define SR_OCR_NOTBUSY (1<<31)

@@ -181,7 +182,7 @@ static int
 sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
 {
     u32 state = readl(&regs->present_state);
-    dprintf(9, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
+    dprintf(1, "sdcard_pio cmd %x %x %x\n", cmd, *param, state);
     if ((state & SP_CMD_INHIBIT)
         || ((cmd & 0x03) == 0x03 && state & SP_DAT_INHIBIT)) {
         dprintf(1, "sdcard_pio not ready %x\n", state);
@@ -203,7 +204,7 @@ sdcard_pio(struct sdhci_s *regs, int cmd, u32 *param)
     writew(&regs->irq_status, SI_CMD_COMPLETE);
     // Read response
     memcpy(param, regs->response, sizeof(regs->response));
-    dprintf(9, "sdcard cmd %x response %x %x %x %x\n"
+    dprintf(1, "sdcard cmd %x response %x %x %x %x\n"
             , cmd, param[0], param[1], param[2], param[3]);
     return 0;
 }
@@ -416,6 +417,9 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)
         drive->card_type |= SF_MMC;
         hcs = (1<<30);
     }
+    // XXX
+    if (volt == (1<<20) && hcs && readl(&regs->cap_lo) & SD_CAPLO_V18)
+        hcs |= SR_OCR_S18R;
     // Init card
     u32 end = timer_calc(SDHCI_POWERUP_TIMEOUT);
     for (;;) {
@@ -434,6 +438,10 @@ sdcard_card_setup(struct sddrive_s *drive, int volt, int prio)
         }
         msleep(5); // Avoid flooding log when debugging
     }
+    if (param[0] & SR_OCR_S18R) {
+        dprintf(1, "Card requests 1.8 volt\n");
+        return -1;
+    }
     drive->card_type |= (param[0] & SR_OCR_CCS) ? SF_HIGHCAPACITY : 0;
     // Select card (get cid, set rca, get csd, select card)
     param[0] = 0x00;