From: Bo Shen <voice.shen@atmel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] gpio: atmel: add gpio common API support
Date: Thu, 22 Aug 2013 11:21:23 +0800 [thread overview]
Message-ID: <521583B3.7070404@atmel.com> (raw)
In-Reply-To: <5214D951.5030101@gmail.com>
Hi Andreas,
On 8/21/2013 23:14, Andreas Bie?mann wrote:
> On 08/13/2013 08:38 AM, Bo Shen wrote:
>> add gpio common API support for gpio command
>>
>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>> ---
>> drivers/gpio/at91_gpio.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 43 insertions(+)
>>
>> diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
>> index 15f396f..3de0844 100644
>> --- a/drivers/gpio/at91_gpio.c
>> +++ b/drivers/gpio/at91_gpio.c
>> @@ -363,3 +363,46 @@ int at91_get_pio_value(unsigned port, unsigned pin)
>>
>> return pdsr != 0;
>> }
>> +
>> +/* Common GPIO API */
>> +
>> +#define at91_gpio_to_port(gpio) (gpio / 32)
>> +#define at91_gpio_to_pin(gpio) (gpio % 32)
>> +
>> +int gpio_request(unsigned gpio, const char *label)
>> +{
>> + return 0;
>> +}
>> +
>> +int gpio_free(unsigned gpio)
>> +{
>> + return 0;
>> +}
>> +
>> +int gpio_direction_input(unsigned gpio)
>> +{
>> + at91_set_pio_input(at91_gpio_to_port(gpio),
>> + at91_gpio_to_pin(gpio), 0);
>> + return 0;
>> +}
>> +
>> +int gpio_direction_output(unsigned gpio, int value)
>> +{
>> + at91_set_pio_output(at91_gpio_to_port(gpio),
>> + at91_gpio_to_pin(gpio), value);
>> + return 0;
>> +}
>> +
>> +int gpio_get_value(unsigned gpio)
>> +{
>> + return (int) at91_get_pio_value(at91_gpio_to_port(gpio),
>> + at91_gpio_to_pin(gpio));
>
> why cast to int here?
Actually no need, as the at91_get_pio_value() return value is int.
I will remove the cast in next version.
>> +}
>> +
>> +int gpio_set_value(unsigned gpio, int value)
>> +{
>> + at91_set_pio_value(at91_gpio_to_port(gpio),
>> + at91_gpio_to_pin(gpio), value);
>> +
>> + return 0;
>> +}
>>
>
> Great, I love this. But wasn't there some define for generic GPIO?
I am not fully get your meaning, what you mean "define for generic
GPIO"? define gpio pin number (?)
> Shouldn't we encapsulate this API into this other define?
You mean, not in this file or anything else?
> Best regards
>
> Andreas Bie?mann
>
Best Regards,
Bo Shen
next prev parent reply other threads:[~2013-08-22 3:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 6:38 [U-Boot] [PATCH 0/4] gpio: atmel: fix code to use pointer for pio port Bo Shen
2013-08-13 6:38 ` [U-Boot] [PATCH 1/4] " Bo Shen
2013-08-21 15:08 ` Andreas Bießmann
2013-08-22 3:15 ` Bo Shen
2013-08-22 6:26 ` Andreas Bießmann
2013-08-22 7:03 ` Bo Shen
2013-08-22 7:24 ` [U-Boot] [PATCH v2] " Bo Shen
2013-08-22 15:01 ` [U-Boot] [U-Boot,v2] " Andreas Bießmann
2013-08-13 6:38 ` [U-Boot] [PATCH 2/4] gpio: atmel: remove the at91_pio definition Bo Shen
2013-08-21 15:10 ` Andreas Bießmann
2013-08-13 6:38 ` [U-Boot] [PATCH 3/4] gpio: atmel: add gpio common API support Bo Shen
2013-08-21 15:14 ` Andreas Bießmann
2013-08-22 3:21 ` Bo Shen [this message]
2013-08-22 6:34 ` Andreas Bießmann
2013-08-22 7:06 ` Bo Shen
2013-08-22 15:01 ` [U-Boot] [U-Boot,3/4] " Andreas Bießmann
2013-08-13 6:38 ` [U-Boot] [PATCH 4/4] gpio: atmel: add copyright and remove error header info Bo Shen
2013-08-21 15:17 ` Andreas Bießmann
2013-08-21 17:20 ` Jens Scharsig
2013-08-21 17:20 ` Jens Scharsig
2013-08-22 15:01 ` [U-Boot] [U-Boot,4/4] " Andreas Bießmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=521583B3.7070404@atmel.com \
--to=voice.shen@atmel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.