Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/sunxi wait at most one second for controller to...



details:   https://anonhg.NetBSD.org/src/rev/10dd0cd2d5c0
branches:  trunk
changeset: 829454:10dd0cd2d5c0
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Thu Feb 01 14:50:36 2018 +0000

description:
wait at most one second for controller to complete reset

diffstat:

 sys/arch/arm/sunxi/sun6i_spi.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 8b2a94087523 -r 10dd0cd2d5c0 sys/arch/arm/sunxi/sun6i_spi.c
--- a/sys/arch/arm/sunxi/sun6i_spi.c    Thu Feb 01 12:09:19 2018 +0000
+++ b/sys/arch/arm/sunxi/sun6i_spi.c    Thu Feb 01 14:50:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sun6i_spi.c,v 1.1 2018/01/31 16:24:11 jakllsch Exp $   */
+/*     $NetBSD: sun6i_spi.c,v 1.2 2018/02/01 14:50:36 jakllsch Exp $   */
 
 /*
  * Copyright (c) 2018 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.1 2018/01/31 16:24:11 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_spi.c,v 1.2 2018/02/01 14:50:36 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -169,8 +169,17 @@
 
        gcr = SPI_GCR_SRST;
        bus_space_write_4(sc->sc_iot, sc->sc_ioh, SPI_GCR, gcr);
-       do {
-       } while ((bus_space_read_4(sc->sc_iot, sc->sc_ioh, SPI_GCR) & SPI_GCR_SRST) != 0);
+       for (u_int i = 0; ; i++) {
+               if (i >= 1000000) {
+                       aprint_error_dev(self, "reset timeout\n");
+                       return;
+               }
+               gcr = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SPI_GCR);
+               if ((gcr & SPI_GCR_SRST) == 0)
+                       break;
+               else
+                       DELAY(1);
+       }
        gcr = SPI_GCR_TP_EN | SPI_GCR_MODE | SPI_GCR_EN;
        bus_space_write_4(sc->sc_iot, sc->sc_ioh, SPI_GCR, gcr);
 



Home | Main Index | Thread Index | Old Index