Module Name:    src
Committed By:   jakllsch
Date:           Fri Mar  3 16:52:08 UTC 2017

Modified Files:
        src/sys/dev/marvell: mvsdio.c

Log Message:
Add check during mvsdio_attach that CMD line is in idle state.

If the CMD line is not in idle state, the interrupt handler routine will
misbehave causing an endless interrupt handler loop.  This would prevent
the the kernel from getting to mountroot.

On my Pogoplug POGO-V4-A3-01, this was caused by U-Boot routing com1's TX
and RX signals to the SD card slot's CMD and DAT[0] lines respectively.

We should probably grow Marvell SoC MPP (pinmux) configuration frobs.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/marvell/mvsdio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/marvell/mvsdio.c
diff -u src/sys/dev/marvell/mvsdio.c:1.5 src/sys/dev/marvell/mvsdio.c:1.6
--- src/sys/dev/marvell/mvsdio.c:1.5	Sat Mar 15 13:33:48 2014
+++ src/sys/dev/marvell/mvsdio.c	Fri Mar  3 16:52:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvsdio.c,v 1.5 2014/03/15 13:33:48 kiyohara Exp $	*/
+/*	$NetBSD: mvsdio.c,v 1.6 2017/03/03 16:52:08 jakllsch Exp $	*/
 /*
  * Copyright (c) 2010 KIYOHARA Takashi
  * All rights reserved.
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsdio.c,v 1.5 2014/03/15 13:33:48 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsdio.c,v 1.6 2017/03/03 16:52:08 jakllsch Exp $");
 
 #include "opt_mvsdio.h"
 
@@ -157,6 +157,7 @@ mvsdio_attach(device_t parent, device_t 
 	struct marvell_attach_args *mva = aux;
 	struct sdmmcbus_attach_args saa;
 	uint32_t nis, eis;
+	uint32_t hps;
 
 	aprint_naive("\n");
 	aprint_normal(": Marvell Secure Digital Input/Output Interface\n");
@@ -227,6 +228,13 @@ mvsdio_attach(device_t parent, device_t 
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVSDIO_EISE, eis);
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVSDIO_EISIE, eis);
 
+	hps = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVSDIO_HPS16LSB);
+	if ((hps & HPS16LSB_CMDLEVEL) == 0) {
+		aprint_error_dev(sc->sc_dev,
+		    "CMD line not idle, HPS 0x%x (bad MPP config?)\n", hps);
+		return;
+	}
+
         /*
 	 * Attach the generic SD/MMC bus driver.  (The bus driver must
 	 * not invoke any chipset functions before it is attached.)

Reply via email to