Re: [PATCH v2 1/3] usb: phy: generic: migrate to gpio_desc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 28, 2015 at 4:44 PM, Felipe Balbi <balbi@xxxxxx> wrote:
> On Wed, Jan 28, 2015 at 01:40:59PM -0200, Fabio Estevam wrote:
>> On Wed, Jan 28, 2015 at 12:04 PM, Felipe Balbi <balbi@xxxxxx> wrote:
>>
>> > I don't want to change direction all the time, some controllers might
>> > not be glitch free, but I agree that direction has to be set. It looks
>> > like we're missing a gpiod_direction_output() call from probe() so that
>> > this gpiod_set_value() works fine.
>>
>> We could do like that:
>>
>> nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
>>
>> and it works.
>>
>> However, the initial value can't be set to 0 always as it depends if
>> the pin is active low or high.
>>
>> I tried to do like this:
>>
>>         nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset");
>>         if (gpiod_is_active_low(nop->gpiod_reset))
>>             gpiod_direction_output(nop->gpiod_reset, GPIOD_OUT_LOW);
>>         else
>>             gpiod_direction_output(nop->gpiod_reset, GPIOD_OUT_HIGH);
>
> won't the descriptor itself handle that for us ? Linus ?

The descriptor table contains polarity information like this:
Documentation/gpio/board.txt
(same GPIO_ACTIVE_LOW/HIGH can be passed for device tree and
I guess also ACPI)

So you should only need to drive the output high, and the core will
invert it if needed.

So in this case I'd go back and check where the GPIOs are described
and make sure it is properly indicated which polarity it has.

If you're anyway doing manual control like this, you have to use
gpiod_direction_output_raw() to avoid the inversion in the core.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux