> From: "Stephen Graf" <s_g...@telus.net>
> Date: Tue, 10 Oct 2017 23:09:07 -0700
> 
> Hi Mark,
> 
> Have you had any time to look further at the sxipio driver changes required
> for H3 devices?  As you noted in an earlier email, the H3 device initializes
> the configuration registers to all 1s, in contrast to the A10 devices where
> the registers are set to 0.  Thus the A10 pins are set to input (0) while
> the H3 pins are set to a new status called disabled (7) in the
> documentation.
> 
> To make my system work I have simply added a line:
> if(mux == 7) mux = 0;
> 
> to the  sxipio_attach_gpio function:
> 
>                 /* Get pin configuration. */
>                 reg = SXIREAD4(sc, SXIPIO_CFG(port, pin));
>                 off = (pin & 0x7) << 2;
>                 mux = (reg >> off) & 0x7;
> 
> if(mux == 7) mux = 0;
> 
> Could you formalize and bless this change?

Sorry, I've been too busy to deal with this until now.

Here is the diff I had in my tree to solve the issue.  Does this one
work for you?

Thanks,

Mark


Index: dev/fdt/sxipio.c
===================================================================
RCS file: /cvs/src/sys/dev/fdt/sxipio.c,v
retrieving revision 1.4
diff -u -p -r1.4 sxipio.c
--- dev/fdt/sxipio.c    30 Aug 2017 16:21:29 -0000      1.4
+++ dev/fdt/sxipio.c    12 Nov 2017 17:56:20 -0000
@@ -89,6 +89,7 @@ struct sxipio_softc {
 
 #define SXIPIO_GPIO_IN         0
 #define SXIPIO_GPIO_OUT                1
+#define SXIPIO_DISABLED                7
 
 int    sxipio_match(struct device *, void *, void *);
 void   sxipio_attach(struct device *, struct device *, void *);
@@ -446,7 +447,7 @@ sxipio_attach_gpio(struct device *parent
        uint32_t reg;
        int port, pin;
        int off, mux;
-       int state;
+       int state, flags;
        int i;
 
        for (i = 0; i < sc->sc_npins; i++) {
@@ -464,17 +465,28 @@ sxipio_attach_gpio(struct device *parent
                mux = (reg >> off) & 0x7;
 
                /* Skip pins that have been assigned other functions. */
-               if (mux != SXIPIO_GPIO_IN && mux != SXIPIO_GPIO_OUT)
+               if (mux != SXIPIO_GPIO_IN && mux != SXIPIO_GPIO_OUT &&
+                   mux != SXIPIO_DISABLED)
                        continue;
 
+               switch (mux) {
+               case SXIPIO_GPIO_IN:
+                       flags = GPIO_PIN_SET | GPIO_PIN_INPUT;
+                       break;
+               case SXIPIO_GPIO_OUT:
+                       flags = GPIO_PIN_SET | GPIO_PIN_OUTPUT;
+                       break;
+               default:
+                       flags = GPIO_PIN_SET;
+               }
+
                /* Get pin state. */
                reg = SXIREAD4(sc, SXIPIO_DAT(port));
                state = (reg >> pin) & 1;
 
                sc->sc_gpio_pins[port][pin].pin_caps =
                    GPIO_PIN_INPUT | GPIO_PIN_OUTPUT;
-               sc->sc_gpio_pins[port][pin].pin_flags =
-                   GPIO_PIN_SET | (mux ? GPIO_PIN_OUTPUT : GPIO_PIN_INPUT);
+               sc->sc_gpio_pins[port][pin].pin_flags = flags;
                sc->sc_gpio_pins[port][pin].pin_state = state;
                sc->sc_gpio_pins[port][pin].pin_num = pin;
        }

Reply via email to