Re: gpio(4) support for APU2

2021-06-30 Thread Chris Cappuccio
Chris Narkiewicz [he...@ezaquarii.com] wrote:
> On Wed, Jan 29, 2020 at 10:47:28PM +0800, Nathanael Rensen wrote:
> > The diff below adds gpio(4) support to wbsio(4) for Nuvoton NCT5104D
> > (pcengines APU2).
> 
> I'm resurrecting this thread. I was looking for GPIO support for APU2
> board and found this patch in archives.
> 
> Any chance of taking it in?
> 

This is not the first patch to support gpio on wbsio, it's at least
the third, but arguably the best :)

Mark Kettenis said:

"But as before this diff does nothing to make sure it is actually
safe to touch these gpio pins.  Other machines might have the same
chip but use the pins internally to switch power to on-board
components."

A simple way to do this could be some kind of description file
specific to the board. Kind of like an FDT, but just for GPIO pins. 
GPIO Descriptor Tree?

So, when you are using an APU1/APU2, copy apu.gpiodt to /etc/gpiodt
and the kernel will load it on boot like a firmware image to decide
what pins you get access to from userland. Or maybe gpioctl would
load allowed pin use settings in rc.securelevel ?

Is this a sane way to go? If so, what attributes would be needed for
each pin? Something like user, locked, kernel?

apu.gpiodt:

gpio0@wbsio {
hwproduct = "APU";
pin0 = "locked";
pin1 = "locked";
pin2 = "locked";
pin3 = "user";
pin4 = "user";
pin5 = "user";
pin6 = "user";
pin7 = "user";
pin8 = "user";
pin9 = "user";
pin10 = "user";
pin11 = "user";
pin12 = "user";
pin13 = "user";
pin14 = "user";
pin15 = "user";
};

Chris



Re: gpio(4) support for APU2

2021-06-29 Thread Raimo Niskanen
On Tue, Jun 29, 2021 at 04:22:47AM +0100, Chris Narkiewicz wrote:
> On Wed, Jan 29, 2020 at 10:47:28PM +0800, Nathanael Rensen wrote:
> > The diff below adds gpio(4) support to wbsio(4) for Nuvoton NCT5104D
> > (pcengines APU2).
> 
> I'm resurrecting this thread. I was looking for GPIO support for APU2
> board and found this patch in archives.

I solved the problem of controlling the LEDs in the APU2 using
a daemon started from /etc/securelevel and then writing 1-char
commands to it over a FIFO.

I also created a pull request of that solution for PCEngines'
apu_gpio_lib, as a code example, but they have not managed
to prioritize it:

https://github.com/pcengines/apu_gpio_lib/pull/4

/ Raimo Niskanen



> 
> Any chance of taking it in?
> 
> Patch below:
> 
> > It is based on Matt Dainty's diff posted to this list
> > in November 2018:
> > 
> >   https://marc.info/?l=openbsd-tech=154134941027009=2
> > 
> > A key difference from Matt Dainty's original diff is the use of
> > config_search() rather than config_found() to avoid problems with
> > the lm78 driver mentioned in his post.
> > 
> > Nathanael
> > 
> > Index: sys/dev/isa/wbsioreg.h
> > ===
> > RCS file: /cvs/src/sys/dev/isa/wbsioreg.h,v
> > retrieving revision 1.5
> > diff -u -p -r1.5 wbsioreg.h
> > --- sys/dev/isa/wbsioreg.h  17 Dec 2019 01:34:59 -  1.5
> > +++ sys/dev/isa/wbsioreg.h  29 Jan 2020 14:30:28 -
> > @@ -30,8 +30,15 @@
> >  
> >  /* Configuration Space Registers */
> >  #define WBSIO_LDN  0x07/* Logical Device Number */
> > +#define WBSIO_MF   0x1c/* Multi Function Selection */
> > +#define WBSIO_MF_UARTD (1 << 2)
> > +#define WBSIO_MF_UARTC (1 << 3)
> > +#define WBSIO_MF_GP67  (1 << 4)
> >  #define WBSIO_ID   0x20/* Device ID */
> >  #define WBSIO_REV  0x21/* Device Revision */
> > +#define WBSIO_CR27 0x27/* Global Option */
> > +#define WBSIO_SF   0x2f/* Strapping Function */
> > +#define WBSIO_LDN_EN   0x30/* Logical Device Enable */
> >  
> >  #define WBSIO_ID_W83627HF  0x52
> >  #define WBSIO_ID_W83627THF 0x82
> > @@ -52,8 +59,38 @@
> >  #define WBSIO_ID_NCT6795D  0xd3
> >  
> >  /* Logical Device Number (LDN) Assignments */
> > +#define WBSIO_LDN_GPIO10x07
> > +#define WBSIO_LDN_WDT  0x08
> > +#define WBSIO_LDN_GPIO20x09/* Not used */
> >  #define WBSIO_LDN_HM   0x0b
> > +#define WBSIO_LDN_GPIO30x0f
> >  
> >  /* Hardware Monitor Control Registers (LDN B) */
> >  #define WBSIO_HM_ADDR_MSB  0x60/* Address [15:8] */
> >  #define WBSIO_HM_ADDR_LSB  0x61/* Address [7:0] */
> > +
> > +/* GPIO Control Registers (LDN 7) */
> > +/* GPIOn registers are offset by n*4 bytes */
> > +#define WBSIO_GPIO_IO  0xe0/* GPIO Direction */
> > +#define WBSIO_GPIO_DATA0xe1/* GPIO Data */
> > +#define WBSIO_GPIO_INVERT  0xe2/* GPIO Invert */
> > +#define WBSIO_GPIO_STATUS  0xe3/* GPIO Status */
> > +#define WBSIO_GPIO0_EN (1 << 0)
> > +#define WBSIO_GPIO1_EN (1 << 1)
> > +#define WBSIO_GPIO6_EN (1 << 6)
> > +#define WBSIO_GPIO0_NPINS  8
> > +#define WBSIO_GPIO1_NPINS  8
> > +#define WBSIO_GPIO6_NPINS  1
> > +#define WBSIO_GPIO_NPINS   (WBSIO_GPIO0_NPINS + WBSIO_GPIO1_NPINS + \
> > +WBSIO_GPIO6_NPINS)
> > +
> > +/* WDT Control Registers (LDN 8) */
> > +#define WBSIO_WDT_ENABLE   0x30
> > +#define WBSIO_WDT_CONTROL  0xf0
> > +#define WBSIO_WDT_COUNTER  0xf1
> > +#define WBSIO_WDT_MINUTE   (1 << 3)
> > +#define WBSIO_WDT_FAST (1 << 4)
> > +
> > +/* GPIO Control Registers (LDN F) */
> > +/* GPIOn register is offset by n bytes */
> > +#define WBSIO_GPIO_PP_OD   0xe0/* GPIO Push-Pull/Open Drain */
> > Index: sys/dev/isa/wbsio.c
> > ===
> > RCS file: /cvs/src/sys/dev/isa/wbsio.c,v
> > retrieving revision 1.11
> > diff -u -p -r1.11 wbsio.c
> > --- sys/dev/isa/wbsio.c 17 Dec 2019 01:34:59 -  1.11
> > +++ sys/dev/isa/wbsio.c 29 Jan 2020 14:30:28 -
> > @@ -23,11 +23,13 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  
> >  #include 
> >  
> >  #include 
> >  #include 
> > +#include 
> >  
> >  #ifdef WBSIO_DEBUG
> >  #define DPRINTF(x) printf x
> > @@ -40,12 +42,22 @@ struct wbsio_softc {
> >  
> > bus_space_tag_t sc_iot;
> > bus_space_handle_t  sc_ioh;
> > +
> > +   struct gpio_chipset_tag sc_gpio_gc;
> > +   gpio_pin_t  sc_gpio_pins[WBSIO_GPIO_NPINS];
> >  };
> >  
> >  intwbsio_probe(struct device *, void *, void *);
> >  void   wbsio_attach(struct device *, struct device *, void *);
> > +intwbsio_search_cb(struct device *, void *, void *);
> >  intwbsio_print(void *, const char *);
> >  
> > +int

Re: gpio(4) support for APU2

2021-06-29 Thread Chris Narkiewicz
On Wed, Jan 29, 2020 at 10:47:28PM +0800, Nathanael Rensen wrote:
> The diff below adds gpio(4) support to wbsio(4) for Nuvoton NCT5104D
> (pcengines APU2).

I'm resurrecting this thread. I was looking for GPIO support for APU2
board and found this patch in archives.

Any chance of taking it in?

Patch below:

> It is based on Matt Dainty's diff posted to this list
> in November 2018:
> 
>   https://marc.info/?l=openbsd-tech=154134941027009=2
> 
> A key difference from Matt Dainty's original diff is the use of
> config_search() rather than config_found() to avoid problems with
> the lm78 driver mentioned in his post.
> 
> Nathanael
> 
> Index: sys/dev/isa/wbsioreg.h
> ===
> RCS file: /cvs/src/sys/dev/isa/wbsioreg.h,v
> retrieving revision 1.5
> diff -u -p -r1.5 wbsioreg.h
> --- sys/dev/isa/wbsioreg.h17 Dec 2019 01:34:59 -  1.5
> +++ sys/dev/isa/wbsioreg.h29 Jan 2020 14:30:28 -
> @@ -30,8 +30,15 @@
>  
>  /* Configuration Space Registers */
>  #define WBSIO_LDN0x07/* Logical Device Number */
> +#define WBSIO_MF 0x1c/* Multi Function Selection */
> +#define WBSIO_MF_UARTD   (1 << 2)
> +#define WBSIO_MF_UARTC   (1 << 3)
> +#define WBSIO_MF_GP67(1 << 4)
>  #define WBSIO_ID 0x20/* Device ID */
>  #define WBSIO_REV0x21/* Device Revision */
> +#define WBSIO_CR27   0x27/* Global Option */
> +#define WBSIO_SF 0x2f/* Strapping Function */
> +#define WBSIO_LDN_EN 0x30/* Logical Device Enable */
>  
>  #define WBSIO_ID_W83627HF0x52
>  #define WBSIO_ID_W83627THF   0x82
> @@ -52,8 +59,38 @@
>  #define WBSIO_ID_NCT6795D0xd3
>  
>  /* Logical Device Number (LDN) Assignments */
> +#define WBSIO_LDN_GPIO1  0x07
> +#define WBSIO_LDN_WDT0x08
> +#define WBSIO_LDN_GPIO2  0x09/* Not used */
>  #define WBSIO_LDN_HM 0x0b
> +#define WBSIO_LDN_GPIO3  0x0f
>  
>  /* Hardware Monitor Control Registers (LDN B) */
>  #define WBSIO_HM_ADDR_MSB0x60/* Address [15:8] */
>  #define WBSIO_HM_ADDR_LSB0x61/* Address [7:0] */
> +
> +/* GPIO Control Registers (LDN 7) */
> +/* GPIOn registers are offset by n*4 bytes */
> +#define WBSIO_GPIO_IO0xe0/* GPIO Direction */
> +#define WBSIO_GPIO_DATA  0xe1/* GPIO Data */
> +#define WBSIO_GPIO_INVERT0xe2/* GPIO Invert */
> +#define WBSIO_GPIO_STATUS0xe3/* GPIO Status */
> +#define WBSIO_GPIO0_EN   (1 << 0)
> +#define WBSIO_GPIO1_EN   (1 << 1)
> +#define WBSIO_GPIO6_EN   (1 << 6)
> +#define WBSIO_GPIO0_NPINS8
> +#define WBSIO_GPIO1_NPINS8
> +#define WBSIO_GPIO6_NPINS1
> +#define WBSIO_GPIO_NPINS (WBSIO_GPIO0_NPINS + WBSIO_GPIO1_NPINS + \
> +  WBSIO_GPIO6_NPINS)
> +
> +/* WDT Control Registers (LDN 8) */
> +#define WBSIO_WDT_ENABLE 0x30
> +#define WBSIO_WDT_CONTROL0xf0
> +#define WBSIO_WDT_COUNTER0xf1
> +#define WBSIO_WDT_MINUTE (1 << 3)
> +#define WBSIO_WDT_FAST   (1 << 4)
> +
> +/* GPIO Control Registers (LDN F) */
> +/* GPIOn register is offset by n bytes */
> +#define WBSIO_GPIO_PP_OD 0xe0/* GPIO Push-Pull/Open Drain */
> Index: sys/dev/isa/wbsio.c
> ===
> RCS file: /cvs/src/sys/dev/isa/wbsio.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 wbsio.c
> --- sys/dev/isa/wbsio.c   17 Dec 2019 01:34:59 -  1.11
> +++ sys/dev/isa/wbsio.c   29 Jan 2020 14:30:28 -
> @@ -23,11 +23,13 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
>  #include 
>  #include 
> +#include 
>  
>  #ifdef WBSIO_DEBUG
>  #define DPRINTF(x) printf x
> @@ -40,12 +42,22 @@ struct wbsio_softc {
>  
>   bus_space_tag_t sc_iot;
>   bus_space_handle_t  sc_ioh;
> +
> + struct gpio_chipset_tag sc_gpio_gc;
> + gpio_pin_t  sc_gpio_pins[WBSIO_GPIO_NPINS];
>  };
>  
>  int  wbsio_probe(struct device *, void *, void *);
>  void wbsio_attach(struct device *, struct device *, void *);
> +int  wbsio_search_cb(struct device *, void *, void *);
>  int  wbsio_print(void *, const char *);
>  
> +int  wbsio_gpio_pin_to_group(struct wbsio_softc *, int);
> +int  wbsio_gpio_pin_read(struct wbsio_softc *, int);
> +int  wbsio_gpio_read(void *, int);
> +void wbsio_gpio_write(void *, int, int);
> +void wbsio_gpio_ctl(void *, int, int);
> +
>  struct cfattach wbsio_ca = {
>   sizeof(struct wbsio_softc),
>   wbsio_probe,
> @@ -56,6 +68,11 @@ struct cfdriver wbsio_cd = {
>   NULL, "wbsio", DV_DULL
>  };
>  
> +struct wbsio_aux {
> + struct isa_attach_args ia;
> + struct gpiobus_attach_args gba;
> +};
> +
>  static __inline void
>  wbsio_conf_enable(bus_space_tag_t iot, bus_space_handle_t ioh)
>  {
> @@ -132,9 +149,10 @@ 

Re: gpio(4) support for APU2

2020-02-10 Thread Theo de Raadt
Mark Kettenis  wrote:

> Nathanael Rensen schreef op 2020-01-29 15:47:
> > The diff below adds gpio(4) support to wbsio(4) for Nuvoton NCT5104D
> > (pcengines APU2). It is based on Matt Dainty's diff posted to this list
> > in November 2018:
> >
> >   https://marc.info/?l=openbsd-tech=154134941027009=2
> >
> > A key difference from Matt Dainty's original diff is the use of
> > config_search() rather than config_found() to avoid problems with
> > the lm78 driver mentioned in his post.
> 
> But as before this diff does nothing to make sure it is actually
> safe to touch these gpio pins.  Other machines might have the same
> chip but use the pins internally to switch power to on-board
> components.

gpio devices, sigh.

It's like wrapping a scarf around your head and crawling under a porch or deck.

You never know what surprises you'll put your hands onto.

spiders and pet poo, maybe some broken glass...



Re: gpio(4) support for APU2

2020-02-10 Thread Mark Kettenis

Nathanael Rensen schreef op 2020-01-29 15:47:

The diff below adds gpio(4) support to wbsio(4) for Nuvoton NCT5104D
(pcengines APU2). It is based on Matt Dainty's diff posted to this list
in November 2018:

  https://marc.info/?l=openbsd-tech=154134941027009=2

A key difference from Matt Dainty's original diff is the use of
config_search() rather than config_found() to avoid problems with
the lm78 driver mentioned in his post.


But as before this diff does nothing to make sure it is actually
safe to touch these gpio pins.  Other machines might have the same
chip but use the pins internally to switch power to on-board
components.


Index: sys/dev/isa/wbsioreg.h
===
RCS file: /cvs/src/sys/dev/isa/wbsioreg.h,v
retrieving revision 1.5
diff -u -p -r1.5 wbsioreg.h
--- sys/dev/isa/wbsioreg.h  17 Dec 2019 01:34:59 -  1.5
+++ sys/dev/isa/wbsioreg.h  29 Jan 2020 14:30:28 -
@@ -30,8 +30,15 @@

 /* Configuration Space Registers */
 #define WBSIO_LDN  0x07/* Logical Device Number */
+#define WBSIO_MF   0x1c/* Multi Function Selection */
+#define WBSIO_MF_UARTD (1 << 2)
+#define WBSIO_MF_UARTC (1 << 3)
+#define WBSIO_MF_GP67  (1 << 4)
 #define WBSIO_ID   0x20/* Device ID */
 #define WBSIO_REV  0x21/* Device Revision */
+#define WBSIO_CR27 0x27/* Global Option */
+#define WBSIO_SF   0x2f/* Strapping Function */
+#define WBSIO_LDN_EN   0x30/* Logical Device Enable */

 #define WBSIO_ID_W83627HF  0x52
 #define WBSIO_ID_W83627THF 0x82
@@ -52,8 +59,38 @@
 #define WBSIO_ID_NCT6795D  0xd3

 /* Logical Device Number (LDN) Assignments */
+#define WBSIO_LDN_GPIO10x07
+#define WBSIO_LDN_WDT  0x08
+#define WBSIO_LDN_GPIO20x09/* Not used */
 #define WBSIO_LDN_HM   0x0b
+#define WBSIO_LDN_GPIO30x0f

 /* Hardware Monitor Control Registers (LDN B) */
 #define WBSIO_HM_ADDR_MSB  0x60/* Address [15:8] */
 #define WBSIO_HM_ADDR_LSB  0x61/* Address [7:0] */
+
+/* GPIO Control Registers (LDN 7) */
+/* GPIOn registers are offset by n*4 bytes */
+#define WBSIO_GPIO_IO  0xe0/* GPIO Direction */
+#define WBSIO_GPIO_DATA0xe1/* GPIO Data */
+#define WBSIO_GPIO_INVERT  0xe2/* GPIO Invert */
+#define WBSIO_GPIO_STATUS  0xe3/* GPIO Status */
+#define WBSIO_GPIO0_EN (1 << 0)
+#define WBSIO_GPIO1_EN (1 << 1)
+#define WBSIO_GPIO6_EN (1 << 6)
+#define WBSIO_GPIO0_NPINS  8
+#define WBSIO_GPIO1_NPINS  8
+#define WBSIO_GPIO6_NPINS  1
+#define WBSIO_GPIO_NPINS   (WBSIO_GPIO0_NPINS + WBSIO_GPIO1_NPINS + \
+WBSIO_GPIO6_NPINS)
+
+/* WDT Control Registers (LDN 8) */
+#define WBSIO_WDT_ENABLE   0x30
+#define WBSIO_WDT_CONTROL  0xf0
+#define WBSIO_WDT_COUNTER  0xf1
+#define WBSIO_WDT_MINUTE   (1 << 3)
+#define WBSIO_WDT_FAST (1 << 4)
+
+/* GPIO Control Registers (LDN F) */
+/* GPIOn register is offset by n bytes */
+#define WBSIO_GPIO_PP_OD   0xe0/* GPIO Push-Pull/Open Drain */
Index: sys/dev/isa/wbsio.c
===
RCS file: /cvs/src/sys/dev/isa/wbsio.c,v
retrieving revision 1.11
diff -u -p -r1.11 wbsio.c
--- sys/dev/isa/wbsio.c 17 Dec 2019 01:34:59 -  1.11
+++ sys/dev/isa/wbsio.c 29 Jan 2020 14:30:28 -
@@ -23,11 +23,13 @@
 #include 
 #include 
 #include 
+#include 

 #include 

 #include 
 #include 
+#include 

 #ifdef WBSIO_DEBUG
 #define DPRINTF(x) printf x
@@ -40,12 +42,22 @@ struct wbsio_softc {

bus_space_tag_t sc_iot;
bus_space_handle_t  sc_ioh;
+
+   struct gpio_chipset_tag sc_gpio_gc;
+   gpio_pin_t  sc_gpio_pins[WBSIO_GPIO_NPINS];
 };

 intwbsio_probe(struct device *, void *, void *);
 void   wbsio_attach(struct device *, struct device *, void *);
+intwbsio_search_cb(struct device *, void *, void *);
 intwbsio_print(void *, const char *);

+intwbsio_gpio_pin_to_group(struct wbsio_softc *, int);
+intwbsio_gpio_pin_read(struct wbsio_softc *, int);
+intwbsio_gpio_read(void *, int);
+void   wbsio_gpio_write(void *, int, int);
+void   wbsio_gpio_ctl(void *, int, int);
+
 struct cfattach wbsio_ca = {
sizeof(struct wbsio_softc),
wbsio_probe,
@@ -56,6 +68,11 @@ struct cfdriver wbsio_cd = {
NULL, "wbsio", DV_DULL
 };

+struct wbsio_aux {
+   struct isa_attach_args ia;
+   struct gpiobus_attach_args gba;
+};
+
 static __inline void
 wbsio_conf_enable(bus_space_tag_t iot, bus_space_handle_t ioh)
 {
@@ -132,9 +149,10 @@ wbsio_attach(struct device *parent, stru
 {
struct wbsio_softc *sc = (void *)self;
struct isa_attach_args *ia = aux;
-   struct isa_attach_args nia;
-   u_int8_t devid, reg, reg0, reg1;
+   

gpio(4) support for APU2

2020-01-29 Thread Nathanael Rensen
The diff below adds gpio(4) support to wbsio(4) for Nuvoton NCT5104D
(pcengines APU2). It is based on Matt Dainty's diff posted to this list
in November 2018:

  https://marc.info/?l=openbsd-tech=154134941027009=2

A key difference from Matt Dainty's original diff is the use of
config_search() rather than config_found() to avoid problems with
the lm78 driver mentioned in his post.

Nathanael

Index: sys/dev/isa/wbsioreg.h
===
RCS file: /cvs/src/sys/dev/isa/wbsioreg.h,v
retrieving revision 1.5
diff -u -p -r1.5 wbsioreg.h
--- sys/dev/isa/wbsioreg.h  17 Dec 2019 01:34:59 -  1.5
+++ sys/dev/isa/wbsioreg.h  29 Jan 2020 14:30:28 -
@@ -30,8 +30,15 @@
 
 /* Configuration Space Registers */
 #define WBSIO_LDN  0x07/* Logical Device Number */
+#define WBSIO_MF   0x1c/* Multi Function Selection */
+#define WBSIO_MF_UARTD (1 << 2)
+#define WBSIO_MF_UARTC (1 << 3)
+#define WBSIO_MF_GP67  (1 << 4)
 #define WBSIO_ID   0x20/* Device ID */
 #define WBSIO_REV  0x21/* Device Revision */
+#define WBSIO_CR27 0x27/* Global Option */
+#define WBSIO_SF   0x2f/* Strapping Function */
+#define WBSIO_LDN_EN   0x30/* Logical Device Enable */
 
 #define WBSIO_ID_W83627HF  0x52
 #define WBSIO_ID_W83627THF 0x82
@@ -52,8 +59,38 @@
 #define WBSIO_ID_NCT6795D  0xd3
 
 /* Logical Device Number (LDN) Assignments */
+#define WBSIO_LDN_GPIO10x07
+#define WBSIO_LDN_WDT  0x08
+#define WBSIO_LDN_GPIO20x09/* Not used */
 #define WBSIO_LDN_HM   0x0b
+#define WBSIO_LDN_GPIO30x0f
 
 /* Hardware Monitor Control Registers (LDN B) */
 #define WBSIO_HM_ADDR_MSB  0x60/* Address [15:8] */
 #define WBSIO_HM_ADDR_LSB  0x61/* Address [7:0] */
+
+/* GPIO Control Registers (LDN 7) */
+/* GPIOn registers are offset by n*4 bytes */
+#define WBSIO_GPIO_IO  0xe0/* GPIO Direction */
+#define WBSIO_GPIO_DATA0xe1/* GPIO Data */
+#define WBSIO_GPIO_INVERT  0xe2/* GPIO Invert */
+#define WBSIO_GPIO_STATUS  0xe3/* GPIO Status */
+#define WBSIO_GPIO0_EN (1 << 0)
+#define WBSIO_GPIO1_EN (1 << 1)
+#define WBSIO_GPIO6_EN (1 << 6)
+#define WBSIO_GPIO0_NPINS  8
+#define WBSIO_GPIO1_NPINS  8
+#define WBSIO_GPIO6_NPINS  1
+#define WBSIO_GPIO_NPINS   (WBSIO_GPIO0_NPINS + WBSIO_GPIO1_NPINS + \
+WBSIO_GPIO6_NPINS)
+
+/* WDT Control Registers (LDN 8) */
+#define WBSIO_WDT_ENABLE   0x30
+#define WBSIO_WDT_CONTROL  0xf0
+#define WBSIO_WDT_COUNTER  0xf1
+#define WBSIO_WDT_MINUTE   (1 << 3)
+#define WBSIO_WDT_FAST (1 << 4)
+
+/* GPIO Control Registers (LDN F) */
+/* GPIOn register is offset by n bytes */
+#define WBSIO_GPIO_PP_OD   0xe0/* GPIO Push-Pull/Open Drain */
Index: sys/dev/isa/wbsio.c
===
RCS file: /cvs/src/sys/dev/isa/wbsio.c,v
retrieving revision 1.11
diff -u -p -r1.11 wbsio.c
--- sys/dev/isa/wbsio.c 17 Dec 2019 01:34:59 -  1.11
+++ sys/dev/isa/wbsio.c 29 Jan 2020 14:30:28 -
@@ -23,11 +23,13 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 #include 
 #include 
+#include 
 
 #ifdef WBSIO_DEBUG
 #define DPRINTF(x) printf x
@@ -40,12 +42,22 @@ struct wbsio_softc {
 
bus_space_tag_t sc_iot;
bus_space_handle_t  sc_ioh;
+
+   struct gpio_chipset_tag sc_gpio_gc;
+   gpio_pin_t  sc_gpio_pins[WBSIO_GPIO_NPINS];
 };
 
 intwbsio_probe(struct device *, void *, void *);
 void   wbsio_attach(struct device *, struct device *, void *);
+intwbsio_search_cb(struct device *, void *, void *);
 intwbsio_print(void *, const char *);
 
+intwbsio_gpio_pin_to_group(struct wbsio_softc *, int);
+intwbsio_gpio_pin_read(struct wbsio_softc *, int);
+intwbsio_gpio_read(void *, int);
+void   wbsio_gpio_write(void *, int, int);
+void   wbsio_gpio_ctl(void *, int, int);
+
 struct cfattach wbsio_ca = {
sizeof(struct wbsio_softc),
wbsio_probe,
@@ -56,6 +68,11 @@ struct cfdriver wbsio_cd = {
NULL, "wbsio", DV_DULL
 };
 
+struct wbsio_aux {
+   struct isa_attach_args ia;
+   struct gpiobus_attach_args gba;
+};
+
 static __inline void
 wbsio_conf_enable(bus_space_tag_t iot, bus_space_handle_t ioh)
 {
@@ -132,9 +149,10 @@ wbsio_attach(struct device *parent, stru
 {
struct wbsio_softc *sc = (void *)self;
struct isa_attach_args *ia = aux;
-   struct isa_attach_args nia;
-   u_int8_t devid, reg, reg0, reg1;
+   struct wbsio_aux wbsio_aux;
+   u_int8_t devid, reg, reg0, reg1, mf;
u_int16_t iobase;
+   int i, npins = 0, group, gpin;
 
/* Map ISA I/O space */
sc->sc_iot = ia->ia_iot;
@@ -219,17 +237,123 @@