bcm2835_gpio_direction_output not setting up GPIO value
Stephen Warren
swarren at wwwdotorg.org
Tue Dec 1 19:46:19 PST 2015
On 11/15/2015 04:48 AM, Stefan Wahren wrote:
> Hi Martin,
>
> Am 07.04.2015 um 04:38 schrieb Stephen Warren:
>> On 04/06/2015 03:10 AM, Martin Sperl wrote:
>>> Is there any reason why bcm2835_gpio_direction_output is
>>> not setting up the value of GPIO as requested?
>>>
>>> static int bcm2835_gpio_direction_output(struct gpio_chip *chip,
>>> unsigned offset, int value)
>>> {
>>> return pinctrl_gpio_direction_output(chip->base + offset);
>>> }
>>> Some oversight?
>>>
>>> Maybe it should look like this (untested)?
>>>
>>> static int bcm2835_gpio_direction_output(struct gpio_chip *chip,
>>> unsigned offset, int value)
>>> {
>>> int err = pinctrl_gpio_direction_output(chip->base + offset);
>>> if (!err)
>>> bcm2835_gpio_set(chip, offset, value);
>>> return err;
>>> }
>>
>> That sounds reasonable. I'm not sure why I didn't code it like that
>> before.
>>
>> One change though: The output value should be set before changing the
>> direction. That way, the pin won't become an output and drive some stale
>> value (whatever is in the output register) before the desired output
>> value is written, thus potentially causing a glitch on the pin.
>
> i want to submit a implementation of the get_direction callback and want
> fix this old issue too.
>
> Any objections about it?
>
> Do you want to be added as suggested-by?
That sounds fine.
More information about the linux-rpi-kernel
mailing list