Hi,
With the code below in da850-board-evm.c, I can turn on my LED connected to
the gpio.
#define DA850_LED0_GPIO GPIO_TO_PIN(8, 14)
status = gpio_request(DA850_LED0_GPIO, "led0gpio");
if (status < 0) {
return status;
}
gpio_direction_output(DA850_LED0_GPIO, 0);
gpio_set_value(DA850_LED0_GPIO, 0);
If I comment this code in the kernel initialization and I try what you
proposed, I do not get the same result. (142 comes from 16*8+14)
# echo 142 > /sys/class/gpio/export
# ls /sys/class/gpio
export gpio142 gpiochip128 gpiochip64 unexport gpiochip0 gpiochip32
gpiochip96
# cat /sys/class/gpio/gpio142/value
1
# echo 1 > /sys/class/gpio/gpio142/direction
# echo 0 > /sys/class/gpio/gpio142/value
# cat /sys/class/gpio/gpio142/value
1
The output is always to 1, in fact the gpio is not in output, it is still in
tri-state. CONFIG_GPIO_SYSFS is enabled.
Do you have any idea?
Thanks.
Regards,
Nicolas
On Wed, Jun 30, 2010 at 3:28 AM, Christophe Aeschlimann <
[email protected]> wrote:
> Hi,
>
>
> On 30.06.2010 04:09, Jon Povey wrote:
>
>> Nicolas Luna wrote:
>>
>>> Hi,
>>>
>>> I wonder what would be the easiest way to control GPIO in userspace.
>>> I read the documentation gpio.txt but I'm not sure what I should use
>>> (Control interfaces?, GPIO controllers?) and how to implement it.
>>>
>>> Is there more explication about int gpio_export_link(struct device
>>> *dev, const char *name, unsigned gpio) because I think it could be
>>> the key.
>>>
>>> Will I need to write my own module and communicate with it?.
>>>
>>
>> You don't need to write a module. You can access GPIOs from a shell
>> script:
>>
>
> To be able to do so you must configure your kernel with the following
> option enabled :
>
> CONFIG_GPIO_SYSFS
>
>
> echo $GPIO_NUMBER> /sys/class/gpio/export
>>
>> creates a directory /sys/class/gpio/gpio$GPIO_NUMBER, e.g. 8.
>> (That will fail if something else like a driver has requested that gpio
>> already).
>>
>> cat /sys/class/gpio/gpio8/value
>>
>> gets the value 0/1
>>
>> echo 1> /sys/class/gpio/gpio8/direction
>>
>> sets it to output (iirc)
>>
>> echo 1> /sys/class/gpio/gpio8/value
>>
>> now sets the output value.
>>
>> echo 8> /sys/class/gpio/unexport
>>
>> to release it when you are finished.
>>
>> gpio_export_link() is for when you claim a gpio for use in the kernel but
>> also want to export one of the above kind of sysfs entries.
>>
>> --
>> Jon Povey
>> [email protected]
>>
>> Racelogic is a limited company registered in England. Registered number
>> 2743719 .
>> Registered Office Unit 10, Swan Business Centre, Osier Way, Buckingham,
>> Bucks, MK18 1TB .
>>
>> The information contained in this electronic mail transmission is intended
>> by Racelogic Ltd for the use of the named individual or entity to which it
>> is directed and may contain information that is confidential or privileged.
>> If you have received this electronic mail transmission in error, please
>> delete it from your system without copying or forwarding it, and notify the
>> sender of the error by reply email so that the sender's address records can
>> be corrected. The views expressed by the sender of this communication do not
>> necessarily represent those of Racelogic Ltd. Please note that Racelogic
>> reserves the right to monitor e-mail communications passing through its
>> network
>>
>>
>>
> Regards,
>
>
> --
> Christophe Aeschlimann
>
> Embedded Software Engineer
>
> Advanced Communications Networks S.A.
>
> Rue du Puits-Godet 8a
> 2000 Neuchātel, Switzerland
>
> Tél. +41 32 724 74 31
>
> [email protected]
>
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source