On Thu, Jul 26, 2018 at 2:01 AM Tomer Maimon <tmaimon77@xxxxxxxxx> wrote:
> I initialize bgpio as follow:
>
>Â Â Â Â Â Â Â Â Â Â Â Â Âret = bgpio_init(&pctrl->gpio_bank[id].gc, (...)
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pctrl->dev, 4,
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pctrl->gpio_bank[id].base +
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NPCM7XX_GP_N_DIN,
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pctrl->gpio_bank[id].base +
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NPCM7XX_GP_N_DOUT,
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL,
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL,
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pctrl->gpio_bank[id].base +
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NPCM7XX_GP_N_IEM,
>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â BGPIOF_READ_OUTPUT_REG_SET);
> The problem occur when reading the GPIO value from bgpio_get_set function,
> because the directions value are inverse it reading the wrong I/O registers
>
> For direction out it reading dat register (instead of set register)
>
> For direction in it calling set register (instead of dat register)
Hm I don't quite get it... sorry. Maybe if you show your fix and what
you expect to happen I can understand better?
Do you mean that because you write the inverse value to
IEM this happens, and the BGPIO code assumes that
you always write 1 to set a line as input and 0 to set it
as output?
I would say if this causes the problem we should just add
a new BGPIOF_INVERTED_REG_DIR with comment in
include/linux/gpio/driver.h and make the necessary fix to
respect this flag in the gpio-mmio.c core so it works right.
If you do this as a separate patch I would be grateful :)
Yours,
Linus Walleij