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

This commit is contained in:
jmcneill 2017-07-30 17:32:59 +00:00
parent 38b77cbb72
commit f49f56161d
3 changed files with 26 additions and 5 deletions

View File

@ -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 @@ bcm2835gpio_function_read(u_int pin)
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);
}

View File

@ -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_ */

View File

@ -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 @@ rpi_pinctrl(void)
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
}