Source-Changes-HG archive

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

[src/netbsd-8]: src Pull up following revision(s) (requested by yamaguchi in ...



details:   https://anonhg.NetBSD.org/src/rev/66f537d51aba
branches:  netbsd-8
changeset: 434649:66f537d51aba
user:      snj <snj%NetBSD.org@localhost>
date:      Mon Feb 19 18:50:35 2018 +0000

description:
Pull up following revision(s) (requested by yamaguchi in ticket #558):
        share/man/man4/wbsio.4: 1.7-1.8
        sys/dev/isa/files.isa: 1.168-1.169
        sys/dev/isa/wbsio.c: 1.16-1.21
        sys/dev/isa/wbsioreg.h: 1.6-1.7
Add wbsio(4) GPIO driver. Implemeted by s-yamaguchi@IIJ, reviewed by msaitoh@n.o.
I just commit by proxy.
--
Fix NCT6779 gpio pin configuration. Implemeted by s-yamaguchi@IIJ, reviewed by msaitoh@n.o.
I just commit by proxy.
--
Add Watchdog timer implementation to wbsio(4). Implemeted by s-yamaguchi@IIJ, reviewed by msaitoh@n.o.
I just commit by proxy.
--
Add an option to enable GPIO function of wbsio. Implemeted by s-yamaguchi@IIJ, reviewed by msaitoh@n.o.
I just commit by proxy.
--
Improve the error log message to use product name. Implemeted by s-yamaguchi@IIJ, reviewed by msaitoh@n.o.
I just commit by proxy.
--
Update the manual of wbsio(4). Implemeted by s-yamaguchi@IIJ, reviewed by msaitoh@n.o.
I just commit by proxy.
--
New sentence, new line. Fix xref. Sort SEE ALSO.
--
PR/52887: HITOSHI Osada: wbsio needs sysmon_wdog.
--
Now that watchdog support has been added, make sure that a modular driver
requires the sysmon_wdog module.

diffstat:

 share/man/man4/wbsio.4 |   18 +-
 sys/dev/isa/files.isa  |    4 +-
 sys/dev/isa/wbsio.c    |  625 +++++++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/isa/wbsioreg.h |  116 +++++++++-
 4 files changed, 742 insertions(+), 21 deletions(-)

diffs (truncated from 973 to 300 lines):

diff -r 2d83606b80ca -r 66f537d51aba share/man/man4/wbsio.4
--- a/share/man/man4/wbsio.4    Mon Feb 19 18:39:43 2018 +0000
+++ b/share/man/man4/wbsio.4    Mon Feb 19 18:50:35 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: wbsio.4,v 1.3.18.1 2017/11/22 14:56:30 martin Exp $
+.\"    $NetBSD: wbsio.4,v 1.3.18.2 2018/02/19 18:50:35 snj Exp $
 .\"    $OpenBSD: wbsio.4,v 1.2 2008/02/17 16:48:47 jmc Exp $
 .\"
 .\" Copyright (c) 2008 Mark Kettenis <kettenis%openbsd.org@localhost>
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd July 12, 2017
+.Dd December 12, 2017
 .Dt WBSIO 4
 .Os
 .Sh NAME
@@ -25,17 +25,25 @@
 .Cd "wbsio* at isa? port 0x2e"
 .Cd "wbsio* at isa? port 0x4e"
 .Cd "lm* at wbsio?"
+.Cd "gpio* at gpiobus?"
+.Pp
+.Cd "options WBSIO_GPIO"
 .Sh DESCRIPTION
 The
 .Nm
-driver provides support for the Winbond (was spun off as Nuvoton) LPC Super I/O
-ICs.
-Only the hardware monitoring function is currently supported.
+driver provides support for the Winbond (was spun off as Nuvoton)
+LPC Super I/O ICs.
+The hardware monitoring function and GPIO are currently supported.
 .Pp
 Support for the hardware monitor function is provided through the
 .Xr lm 4
 driver.
+The GPIO function supports 64 pins for NCT6795D.
+Access to the pins provided by the
+.Xr gpio 4
+interface.
 .Sh SEE ALSO
+.Xr gpio 4 ,
 .Xr intro 4 ,
 .Xr isa 4 ,
 .Xr lm 4
diff -r 2d83606b80ca -r 66f537d51aba sys/dev/isa/files.isa
--- a/sys/dev/isa/files.isa     Mon Feb 19 18:39:43 2018 +0000
+++ b/sys/dev/isa/files.isa     Mon Feb 19 18:50:35 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.isa,v 1.167 2016/12/09 04:32:39 christos Exp $
+#      $NetBSD: files.isa,v 1.167.8.1 2018/02/19 18:50:35 snj Exp $
 #
 # Config file and device description for machine-independent ISA code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -454,7 +454,7 @@
 file   dev/isa/smsc.c                  smsc                    needs-flag
 
 # Winbond LPC Super I/O
-device wbsio {}
+device wbsio { }: gpiobus, sysmon_wdog
 attach wbsio at isa
 file   dev/isa/wbsio.c                 wbsio
 
diff -r 2d83606b80ca -r 66f537d51aba sys/dev/isa/wbsio.c
--- a/sys/dev/isa/wbsio.c       Mon Feb 19 18:39:43 2018 +0000
+++ b/sys/dev/isa/wbsio.c       Mon Feb 19 18:50:35 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wbsio.c,v 1.10.10.1 2017/11/22 14:56:30 martin Exp $   */
+/*     $NetBSD: wbsio.c,v 1.10.10.2 2018/02/19 18:50:35 snj Exp $      */
 /*     $OpenBSD: wbsio.c,v 1.10 2015/03/14 03:38:47 jsg Exp $  */
 /*
  * Copyright (c) 2008 Mark Kettenis <kettenis%openbsd.org@localhost>
@@ -20,27 +20,55 @@
  * Winbond LPC Super I/O driver.
  */
 
+#include <sys/cdefs.h>
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/systm.h>
+#include <sys/mutex.h>
+#include <sys/gpio.h>
 
 #include <sys/bus.h>
 
 #include <dev/isa/isareg.h>
 #include <dev/isa/isavar.h>
 #include <dev/isa/wbsioreg.h>
+#include <dev/sysmon/sysmonvar.h>
+
+/* Don't use gpio for now in the module */
+#if !defined(_MODULE) && defined(WBSIO_GPIO)
+#include "gpio.h"
+#endif
+
+#if NGPIO > 0
+#include <dev/gpio/gpiovar.h>
+#endif
 
 struct wbsio_softc {
        device_t        sc_dev;
        device_t        sc_lm_dev;
+#if NGPIO > 0
+       device_t        sc_gpio_dev;
+#endif
 
        bus_space_tag_t         sc_iot;
        bus_space_handle_t      sc_ioh;
+       kmutex_t                sc_conf_lock;
 
        struct isa_attach_args  sc_ia;
        struct isa_io           sc_io;
+
+#if NGPIO > 0
+       bus_space_handle_t      sc_gpio_ioh;
+       kmutex_t                sc_gpio_lock;
+       struct gpio_chipset_tag sc_gpio_gc;
+       struct gpio_pin         sc_gpio_pins[WBSIO_GPIO_NPINS];
+       bool                    sc_gpio_rt;
+#endif
+
+       struct sysmon_wdog      sc_smw;
+       bool                    sc_smw_valid;
 };
 
 static const struct wbsio_product {
@@ -79,22 +107,47 @@
 static void    wbsio_childdet(device_t, device_t);
 static int     wbsio_print(void *, const char *);
 static int     wbsio_search(device_t, cfdata_t, const int *, void *);
+static bool    wbsio_suspend(device_t, const pmf_qual_t *);
+#if NGPIO > 0
+static int     wbsio_gpio_search(device_t, cfdata_t, const int *, void *);
+static int     wbsio_gpio_rt_init(struct wbsio_softc *);
+static int     wbsio_gpio_rt_read(struct wbsio_softc *, int, int);
+static void    wbsio_gpio_rt_write(struct wbsio_softc *, int, int, int);
+static int     wbsio_gpio_rt_pin_read(void *, int);
+static void    wbsio_gpio_rt_pin_write(void *, int, int);
+static void    wbsio_gpio_rt_pin_ctl(void *, int, int);
+static void    wbsio_gpio_enable_nct6779d(device_t);
+static void    wbsio_gpio_pinconfig_nct6779d(device_t);
+#endif
+static void    wbsio_wdog_attach(device_t);
+static int     wbsio_wdog_detach(device_t);
+static int     wbsio_wdog_setmode(struct sysmon_wdog *);
+static int     wbsio_wdog_tickle(struct sysmon_wdog *);
+static void    wbsio_wdog_setcounter(struct wbsio_softc *, uint8_t);
+static void    wbsio_wdog_clear_timeout(struct wbsio_softc *);
 
 CFATTACH_DECL2_NEW(wbsio, sizeof(struct wbsio_softc),
     wbsio_match, wbsio_attach, wbsio_detach, NULL,
     wbsio_rescan, wbsio_childdet);
 
 static __inline void
-wbsio_conf_enable(bus_space_tag_t iot, bus_space_handle_t ioh)
+wbsio_conf_enable(kmutex_t *lock, bus_space_tag_t iot, bus_space_handle_t ioh)
 {
+       if (lock)
+               mutex_enter(lock);
+
        bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC);
        bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC);
 }
 
 static __inline void
-wbsio_conf_disable(bus_space_tag_t iot, bus_space_handle_t ioh)
+wbsio_conf_disable(kmutex_t *lock, bus_space_tag_t iot, bus_space_handle_t ioh)
 {
+
        bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_DS_MAGIC);
+
+       if (lock)
+               mutex_exit(lock);
 }
 
 static __inline uint8_t
@@ -155,11 +208,11 @@
        iot = ia->ia_iot;
        if (bus_space_map(iot, ia->ia_io[0].ir_addr, WBSIO_IOSIZE, 0, &ioh))
                return 0;
-       wbsio_conf_enable(iot, ioh);
+       wbsio_conf_enable(NULL, iot, ioh);
        id = wbsio_conf_read(iot, ioh, WBSIO_ID);
        rev = wbsio_conf_read(iot, ioh, WBSIO_REV);
        aprint_debug("wbsio_probe: id 0x%02x, rev 0x%02x\n", id, rev);
-       wbsio_conf_disable(iot, ioh);
+       wbsio_conf_disable(NULL, iot, ioh);
        bus_space_unmap(iot, ioh, WBSIO_IOSIZE);
 
        if ((product = wbsio_lookup(id, rev)) == NULL)
@@ -195,8 +248,10 @@
                return;
        }
 
+       mutex_init(&sc->sc_conf_lock, MUTEX_DEFAULT, IPL_NONE);
+
        /* Enter configuration mode */
-       wbsio_conf_enable(sc->sc_iot, sc->sc_ioh);
+       wbsio_conf_enable(&sc->sc_conf_lock, sc->sc_iot, sc->sc_ioh);
 
        /* Read device ID */
        id = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_ID);
@@ -204,7 +259,7 @@
        rev = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_REV);
 
        /* Escape from configuration mode */
-       wbsio_conf_disable(sc->sc_iot, sc->sc_ioh);
+       wbsio_conf_disable(&sc->sc_conf_lock, sc->sc_iot, sc->sc_ioh);
 
        if ((product = wbsio_lookup(id, rev)) == NULL) {
                aprint_error_dev(self, "Unknown device. Failed to attach\n");
@@ -226,9 +281,17 @@
        } else
                aprint_normal("0x%02x\n", rev);
 
-       if (!pmf_device_register(self, NULL, NULL))
+       if (!pmf_device_register(self, wbsio_suspend, NULL))
                aprint_error_dev(self, "couldn't establish power handler\n");
+
+       wbsio_wdog_attach(self);
+
        wbsio_rescan(self, "wbsio", NULL);
+
+#if NGPIO > 0
+
+       wbsio_rescan(self, "gpiobus", NULL);
+#endif
 }
 
 int
@@ -237,10 +300,26 @@
        struct wbsio_softc *sc = device_private(self);
        int rc;
 
+       if ((rc = wbsio_wdog_detach(self)) != 0)
+               return rc;
+
        if ((rc = config_detach_children(self, flags)) != 0)
                return rc;
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, WBSIO_IOSIZE);
        pmf_device_deregister(self);
+
+#if NGPIO > 0
+       if (sc->sc_gpio_dev) {
+               bus_space_unmap(sc->sc_iot, sc->sc_gpio_ioh,
+                   WBSIO_GPIO_IOSIZE);
+       }
+
+       if (sc->sc_gpio_rt) {
+               mutex_destroy(&sc->sc_gpio_lock);
+       }
+#endif
+
+       mutex_destroy(&sc->sc_conf_lock);
        return 0;
 }
 
@@ -248,6 +327,13 @@
 wbsio_rescan(device_t self, const char *ifattr, const int *locators)
 {
 
+#if NGPIO > 0
+       if (ifattr_match(ifattr, "gpiobus")) {
+               config_search_loc(wbsio_gpio_search, self,
+                   ifattr, locators, NULL);
+               return 0;
+       }
+#endif
        config_search_loc(wbsio_search, self, ifattr, locators, NULL);
 
        return 0;
@@ -272,7 +358,7 @@
        uint8_t reg0, reg1, rev;
 
        /* Enter configuration mode */
-       wbsio_conf_enable(sc->sc_iot, sc->sc_ioh);
+       wbsio_conf_enable(&sc->sc_conf_lock, sc->sc_iot, sc->sc_ioh);
 
        /* Select HM logical device */
        wbsio_conf_write(sc->sc_iot, sc->sc_ioh, WBSIO_LDN, WBSIO_LDN_HM);
@@ -287,7 +373,7 @@
        reg1 = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_HM_ADDR_MSB);
 
        /* Escape from configuration mode */
-       wbsio_conf_disable(sc->sc_iot, sc->sc_ioh);
+       wbsio_conf_disable(&sc->sc_conf_lock, sc->sc_iot, sc->sc_ioh);
 
        iobase = (reg1 << 8) | (reg0 & ~0x7);
 
@@ -295,12 +381,12 @@
                return -1;
 
        /* Enter configuration mode */
-       wbsio_conf_enable(sc->sc_iot, sc->sc_ioh);
+       wbsio_conf_enable(&sc->sc_conf_lock, sc->sc_iot, sc->sc_ioh);
        /* Read device ID and revision */



Home | Main Index | Thread Index | Old Index