]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Set output pin initial value based on pin's pinmux pullup/pulldown setup
authorgonzo <gonzo@FreeBSD.org>
Sat, 1 Aug 2015 23:10:36 +0000 (23:10 +0000)
committergonzo <gonzo@FreeBSD.org>
Sat, 1 Aug 2015 23:10:36 +0000 (23:10 +0000)
Some of FDT blobs for AM335x-based devices use pinmux pullup/pulldown
flag to setup initial GPIO ouputp value, e.g. 4DCAPE-43 sets LCD DATAEN
signal this way. It works for Linux because Linux driver does not enforce
pin direction until after it's requested by consumer. So input with pullup
flag set acts as output with GPIO_HIGH value

Reviewed by: loos

sys/arm/ti/ti_gpio.c

index 8e28adc07944a1f1bada4d3557d015a89dc1f456..a5f4176f6c1c34f8f73b695b697a76a4c479514f 100644 (file)
@@ -573,7 +573,7 @@ ti_gpio_bank_init(device_t dev)
 {
        int pin;
        struct ti_gpio_softc *sc;
-       uint32_t flags, reg_oe, rev;
+       uint32_t flags, reg_oe, reg_set, rev;
        clk_ident_t clk;
 
        sc = device_get_softc(dev);
@@ -607,12 +607,18 @@ ti_gpio_bank_init(device_t dev)
 
        /* Init OE register based on pads configuration. */
        reg_oe = 0xffffffff;
+       reg_set = 0;
        for (pin = 0; pin < PINS_PER_BANK; pin++) {
                TI_GPIO_GET_FLAGS(dev, pin, &flags);
-               if (flags & GPIO_PIN_OUTPUT)
+               if (flags & GPIO_PIN_OUTPUT) {
                        reg_oe &= ~(1UL << pin);
+                       if (flags & GPIO_PIN_PULLUP)
+                               reg_set |= (1UL << pin);
+               }
        }
        ti_gpio_write_4(sc, TI_GPIO_OE, reg_oe);
+       if (reg_set)
+               ti_gpio_write_4(sc, TI_GPIO_SETDATAOUT, reg_set);
 
        return (0);
 }