bcm2835_gpio_direction_output not setting up GPIO value

Stefan Wahren info at lategoodbye.de
Sun Nov 15 03:48:24 PST 2015


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?

Best regards
Stefan

>
> _______________________________________________
> linux-rpi-kernel mailing list
> linux-rpi-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel
>




More information about the linux-rpi-kernel mailing list