Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/rockchip Fix reading through /dev/gpio and use ...



details:   https://anonhg.NetBSD.org/src/rev/2c51eb49bc4d
branches:  trunk
changeset: 323473:2c51eb49bc4d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jun 16 12:49:46 2018 +0000

description:
Fix reading through /dev/gpio and use the same style for writing registers in both fdt and /dev/gpio cases

diffstat:

 sys/arch/arm/rockchip/rk_gpio.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 5ccdc8a45945 -r 2c51eb49bc4d sys/arch/arm/rockchip/rk_gpio.c
--- a/sys/arch/arm/rockchip/rk_gpio.c   Sat Jun 16 10:42:41 2018 +0000
+++ b/sys/arch/arm/rockchip/rk_gpio.c   Sat Jun 16 12:49:46 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_gpio.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $ */
+/* $NetBSD: rk_gpio.c,v 1.2 2018/06/16 12:49:46 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk_gpio.c,v 1.1 2018/06/16 00:19:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_gpio.c,v 1.2 2018/06/16 12:49:46 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -190,8 +190,10 @@
 
        mutex_enter(&sc->sc_lock);
        data = RD4(sc, GPIO_SWPORTA_DR_REG);
-       data &= ~data_mask;
-       data |= __SHIFTIN(val, data_mask);
+       if (val)
+               data |= data_mask;
+       else
+               data &= ~data_mask;
        WR4(sc, GPIO_SWPORTA_DR_REG, data);
        mutex_exit(&sc->sc_lock);
 }
@@ -215,7 +217,7 @@
        const uint32_t data_mask = __BIT(pin);
 
        /* No lock required for reads */
-       data = RD4(sc, GPIO_SWPORTA_DR_REG);
+       data = RD4(sc, GPIO_EXT_PORTA_REG);
        val = __SHIFTOUT(data, data_mask);
 
        return val;



Home | Main Index | Thread Index | Old Index