Re: sdmmc i/o reset fix

2016-09-11 Thread Mark Kettenis
> Date: Sun, 11 Sep 2016 09:45:59 +0200
> From: Marcus Glocker 
> 
> This gets the sdmmc i/o reset working.
> 
> Now on my allwinner,sun5i-r8 the wifi device also attaches again
> after a reboot (currently just works on cold boot).
> 
> ok?

Had something very similar in one of my trees.  Still detects the
broadcom module on the cubox. So ok kettenis@

> Index: sdmmc_io.c
> ===
> RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_io.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 sdmmc_io.c
> --- sdmmc_io.c12 May 2016 15:26:42 -  1.26
> +++ sdmmc_io.c11 Sep 2016 07:33:36 -
> @@ -113,9 +113,6 @@ sdmmc_io_enable(struct sdmmc_softc *sc)
>   return 1;
>   }
>  
> - /* Reset I/O functions (again). */
> - sdmmc_io_reset(sc);
> -
>   /* Send the new OCR value until all cards are ready. */
>   if (sdmmc_io_send_op_cond(sc, host_ocr, NULL) != 0) {
>   printf("%s: can't send I/O OCR\n", DEVNAME(sc));
> @@ -550,10 +547,13 @@ sdmmc_io_xchg(struct sdmmc_softc *sc, st
>  void
>  sdmmc_io_reset(struct sdmmc_softc *sc)
>  {
> -#if 0 /* XXX command fails */
> - (void)sdmmc_io_write(sc, NULL, SD_IO_REG_CCCR_CTL, CCCR_CTL_RES);
> - sdmmc_delay(10);
> -#endif
> + u_int8_t data = CCCR_CTL_RES;
> +
> + rw_assert_wrlock(&sc->sc_lock);
> +
> + if (sdmmc_io_rw_direct(sc, NULL, SD_IO_CCCR_CTL, (u_char *)&data,
> + SD_ARG_CMD52_WRITE) == 0)
> + sdmmc_delay(10);
>  }
>  
>  /*
> 
> 



sdmmc i/o reset fix

2016-09-11 Thread Marcus Glocker
This gets the sdmmc i/o reset working.

Now on my allwinner,sun5i-r8 the wifi device also attaches again
after a reboot (currently just works on cold boot).

ok?


Index: sdmmc_io.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_io.c,v
retrieving revision 1.26
diff -u -p -r1.26 sdmmc_io.c
--- sdmmc_io.c  12 May 2016 15:26:42 -  1.26
+++ sdmmc_io.c  11 Sep 2016 07:33:36 -
@@ -113,9 +113,6 @@ sdmmc_io_enable(struct sdmmc_softc *sc)
return 1;
}
 
-   /* Reset I/O functions (again). */
-   sdmmc_io_reset(sc);
-
/* Send the new OCR value until all cards are ready. */
if (sdmmc_io_send_op_cond(sc, host_ocr, NULL) != 0) {
printf("%s: can't send I/O OCR\n", DEVNAME(sc));
@@ -550,10 +547,13 @@ sdmmc_io_xchg(struct sdmmc_softc *sc, st
 void
 sdmmc_io_reset(struct sdmmc_softc *sc)
 {
-#if 0 /* XXX command fails */
-   (void)sdmmc_io_write(sc, NULL, SD_IO_REG_CCCR_CTL, CCCR_CTL_RES);
-   sdmmc_delay(10);
-#endif
+   u_int8_t data = CCCR_CTL_RES;
+
+   rw_assert_wrlock(&sc->sc_lock);
+
+   if (sdmmc_io_rw_direct(sc, NULL, SD_IO_CCCR_CTL, (u_char *)&data,
+   SD_ARG_CMD52_WRITE) == 0)
+   sdmmc_delay(10);
 }
 
 /*