From 88647590380fc477860d6eed02cabf08b6295aef Mon Sep 17 00:00:00 2001 From: gonzo Date: Sat, 1 Aug 2015 23:10:36 +0000 Subject: [PATCH] Set output pin initial value based on pin's pinmux pullup/pulldown setup 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c index 8e28adc07944..a5f4176f6c1c 100644 --- a/sys/arm/ti/ti_gpio.c +++ b/sys/arm/ti/ti_gpio.c @@ -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); }