> Date: Thu, 26 Apr 2018 10:35:45 +0300
> From: Artturi Alm <[email protected]>
>
> Hi,
>
> wrote simple gpio indicator sensor driver, and spotted this.
>
> decided to keep the /* XXX */ for tech@, so this should be 'safe'
> for anyone not using gpioctl(8) no matter what :)
>
> i don't really see any risk, only w/o one might need to do this
> w/ext resistors.
>
> comments?
Can you please actually describe what the intention of your patches is
in normal English, preferably with proper punctation and without silly
abbreviations. One of the reason your diffs get ignored is because it
simply takes too much effort to figure out what you actually mean.
Thanks,
Mark
> diff --git sys/dev/fdt/sxipio.c sys/dev/fdt/sxipio.c
> index fe231d6bfd7..46f1212dee9 100644
> --- sys/dev/fdt/sxipio.c
> +++ sys/dev/fdt/sxipio.c
> @@ -356,6 +356,11 @@ sxipio_config_pin(void *cookie, uint32_t *cells, int
> config)
> mux = (config & GPIO_CONFIG_OUTPUT) ? 1 : 0;
> off = (pin & 0x7) << 2;
> SXICMS4(sc, SXIPIO_CFG(port, pin), 0x7 << off, mux << off);
> + if (config & GPIO_CONFIG_PULLUP)
> + SXICMS4(sc, SXIPIO_PUL(port, pin), 0x3 << off, 1 << off);
> + else if (config & GPIO_CONFIG_PULLDOWN)
> + SXICMS4(sc, SXIPIO_PUL(port, pin), 0x3 << off, 2 << off);
> + /* XXX should else _PUL 0 << off expl. here? */
> }
>
> int
> @@ -446,15 +451,18 @@ sxipio_pin_ctl(void *cookie, int pin, int flags)
> {
> struct sxipio_gpio *gpio = cookie;
> uint32_t cells[3];
> + int config;
>
> cells[0] = gpio->port;
> cells[1] = pin;
> cells[2] = 0;
>
> - if (ISSET(flags, GPIO_PIN_OUTPUT))
> - sxipio_config_pin(gpio->sc, cells, GPIO_CONFIG_OUTPUT);
> - else
> - sxipio_config_pin(gpio->sc, cells, 0);
> + config = ISSET(flags, GPIO_PIN_OUTPUT) ? GPIO_CONFIG_OUTPUT : 0;
> + if (ISSET(flags, GPIO_PIN_PULLUP))
> + config |= GPIO_CONFIG_PULLDOWN;
> + else if (ISSET(flags, GPIO_PIN_PULLDOWN))
> + config |= GPIO_CONFIG_PULLDOWN;
> + sxipio_config_pin(gpio->sc, cells, config);
> }
>
> void
> @@ -503,7 +511,8 @@ sxipio_attach_gpio(struct device *parent)
> state = (reg >> pin) & 1;
>
> sc->sc_gpio_pins[port][pin].pin_caps =
> - GPIO_PIN_INPUT | GPIO_PIN_OUTPUT;
> + GPIO_PIN_INPUT | GPIO_PIN_OUTPUT |
> + GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN;
> 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;
> diff --git sys/dev/ofw/ofw_gpio.h sys/dev/ofw/ofw_gpio.h
> index 52b2fe08453..0917ace3b67 100644
> --- sys/dev/ofw/ofw_gpio.h
> +++ sys/dev/ofw/ofw_gpio.h
> @@ -37,6 +37,8 @@ void gpio_controller_register(struct gpio_controller
> *);
>
> #define GPIO_CONFIG_INPUT 0x0000
> #define GPIO_CONFIG_OUTPUT 0x0001
> +#define GPIO_CONFIG_PULLUP 0x0002
> +#define GPIO_CONFIG_PULLDOWN 0x0004
> void gpio_controller_config_pin(uint32_t *, int);
>
> int gpio_controller_get_pin(uint32_t *);
>