Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Explicitly configure pin pull-down/up settings for ...



details:   https://anonhg.NetBSD.org/src/rev/48dedb8e60b0
branches:  trunk
changeset: 825788:48dedb8e60b0
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jul 30 17:32:59 2017 +0000

description:
Explicitly configure pin pull-down/up settings for SDIO.

diffstat:

 sys/arch/arm/broadcom/bcm2835_gpio_subr.c |  21 +++++++++++++++++++--
 sys/arch/arm/broadcom/bcm2835_gpio_subr.h |   3 ++-
 sys/arch/evbarm/rpi/rpi_machdep.c         |   7 +++++--
 3 files changed, 26 insertions(+), 5 deletions(-)

diffs (83 lines):

diff -r 8fc3c4c16190 -r 48dedb8e60b0 sys/arch/arm/broadcom/bcm2835_gpio_subr.c
--- a/sys/arch/arm/broadcom/bcm2835_gpio_subr.c Sun Jul 30 17:01:27 2017 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_gpio_subr.c Sun Jul 30 17:32:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_gpio_subr.c,v 1.4 2016/02/02 13:55:50 skrll Exp $      */
+/*     $NetBSD: bcm2835_gpio_subr.c,v 1.5 2017/07/30 17:32:59 jmcneill Exp $   */
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio_subr.c,v 1.4 2016/02/02 13:55:50 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio_subr.c,v 1.5 2017/07/30 17:32:59 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -84,3 +84,20 @@
 
        return ((v >> shift) & mask);
 }
+
+void
+bcm2835gpio_function_setpull(u_int pin, u_int pud)
+{
+       const paddr_t iop = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_GPIO_BASE);
+       const bus_space_tag_t iot = &bcm2835_bs_tag;
+       const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(iop);
+       const u_int mask = 1 << (pin % BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
+       const u_int regid = (pin / BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
+
+       bus_space_write_4(iot, ioh, BCM2835_GPIO_GPPUD, pud);
+       delay(1);
+       bus_space_write_4(iot, ioh, BCM2835_GPIO_GPPUDCLK(regid), mask);
+       delay(1);
+       bus_space_write_4(iot, ioh, BCM2835_GPIO_GPPUD, 0);
+       bus_space_write_4(iot, ioh, BCM2835_GPIO_GPPUDCLK(regid), 0);
+}
diff -r 8fc3c4c16190 -r 48dedb8e60b0 sys/arch/arm/broadcom/bcm2835_gpio_subr.h
--- a/sys/arch/arm/broadcom/bcm2835_gpio_subr.h Sun Jul 30 17:01:27 2017 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_gpio_subr.h Sun Jul 30 17:32:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_gpio_subr.h,v 1.2 2014/04/22 18:51:35 kardel Exp $     */
+/*     $NetBSD: bcm2835_gpio_subr.h,v 1.3 2017/07/30 17:32:59 jmcneill Exp $   */
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -33,5 +33,6 @@
 
 void  bcm2835gpio_function_select(u_int, u_int);
 u_int bcm2835gpio_function_read(u_int);
+void  bcm2835gpio_function_setpull(u_int, u_int);
 
 #endif /* _BROADCOM_BCM2835_GPIOVAR_H_ */
diff -r 8fc3c4c16190 -r 48dedb8e60b0 sys/arch/evbarm/rpi/rpi_machdep.c
--- a/sys/arch/evbarm/rpi/rpi_machdep.c Sun Jul 30 17:01:27 2017 +0000
+++ b/sys/arch/evbarm/rpi/rpi_machdep.c Sun Jul 30 17:32:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpi_machdep.c,v 1.73 2017/07/30 16:54:36 jmcneill Exp $        */
+/*     $NetBSD: rpi_machdep.c,v 1.74 2017/07/30 17:32:59 jmcneill Exp $        */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.73 2017/07/30 16:54:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.74 2017/07/30 17:32:59 jmcneill Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_bcm283x.h"
@@ -492,6 +492,9 @@
        for (int pin = 34; pin <= 39; pin++) {
                /* Enable SDHCI on SDIO */
                bcm2835gpio_function_select(pin, BCM2835_GPIO_ALT3);
+               bcm2835gpio_function_setpull(pin,
+                   pin == 34 ? BCM2835_GPIO_GPPUD_PULLOFF :
+                   BCM2835_GPIO_GPPUD_PULLUP);
        }
 #endif
 }



Home | Main Index | Thread Index | Old Index