devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <dev@lynxeye.de>
To: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@ti.com>,
	U-Boot Mailing List <u-boot@lists.denx.de>,
	Jerry Van Baren <vanbaren@cideas.com>,
	Sean Paul <seanpaul@chromium.org>,
	Devicetree Discuss <devicetree-discuss@lists.ozlabs.org>
Subject: Re: [PATCH 09/14] fdt: Add polarity-aware gpio functions to fdtdec
Date: Fri, 26 Oct 2012 09:17:22 +0200	[thread overview]
Message-ID: <1351235842.20572.10.camel@tellur> (raw)
In-Reply-To: <1351218671-15228-10-git-send-email-sjg@chromium.org>

Am Donnerstag, den 25.10.2012, 19:31 -0700 schrieb Simon Glass:
> From: Sean Paul <seanpaul@chromium.org>
> 
> Add get and set gpio functions to fdtdec that take into account the
> polarity field in fdtdec_gpio_state.flags.
> 
In another thread Stephen Warren and I came to the conclusion that we
most likely should remove this polarity flag from the GPIO bindings.

Currently it is only for the USB VBUS GPIO which should move over to
regulators once they land in U-Boot. Do you have any other applications
for this flag, so we might reconsider removing it?

> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>  include/fdtdec.h |   16 ++++++++++++++++
>  lib/fdtdec.c     |   20 ++++++++++++++++++++
>  2 files changed, 36 insertions(+), 0 deletions(-)
> 
> diff --git a/include/fdtdec.h b/include/fdtdec.h
> index 12f73a7..17daa99 100644
> --- a/include/fdtdec.h
> +++ b/include/fdtdec.h
> @@ -90,6 +90,22 @@ struct fdt_gpio_state {
>  #define fdt_gpio_isvalid(x) ((x)->gpio != FDT_GPIO_NONE)
>  
>  /**
> + * Read the GPIO taking into account the polarity of the pin.
> + *
> + * @param gpio		pointer to the decoded gpio
> + * @return value of the gpio if successful, < 0 if unsuccessful
> + */
> +int fdtdec_get_gpio(struct fdt_gpio_state *gpio);
> +
> +/**
> + * Write the GPIO taking into account the polarity of the pin.
> + *
> + * @param gpio		pointer to the decoded gpio
> + * @return 0 if successful
> + */
> +int fdtdec_set_gpio(struct fdt_gpio_state *gpio, int val);
> +
> +/**
>   * Find the next numbered alias for a peripheral. This is used to enumerate
>   * all the peripherals of a certain type.
>   *
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index 6c417d2..91ba558 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -487,6 +487,26 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
>  	return err == 1 ? 0 : err;
>  }
>  
> +int fdtdec_get_gpio(struct fdt_gpio_state *gpio)
> +{
> +	int val;
> +
> +	if (!fdt_gpio_isvalid(gpio))
> +		return -1;
> +
> +	val = gpio_get_value(gpio->gpio);
> +	return gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
> +}
> +
> +int fdtdec_set_gpio(struct fdt_gpio_state *gpio, int val)
> +{
> +	if (!fdt_gpio_isvalid(gpio))
> +		return -1;
> +
> +	val = gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
> +	return gpio_set_value(gpio->gpio, val);
> +}
> +
>  int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
>  {
>  	/*

  reply	other threads:[~2012-10-26  7:17 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26  2:30 [PATCH 0/14] fdt: Add various device tree utilities and features Simon Glass
     [not found] ` <1351218671-15228-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-10-26  2:30   ` [PATCH 01/14] fdt: Add function to get config int from device tree Simon Glass
2012-10-26  2:30   ` [PATCH 02/14] fdt: Add function to get a config string " Simon Glass
2012-10-26  2:31   ` [PATCH 03/14] fdt: Add fdtdec_decode_region() to decode memory region Simon Glass
2012-10-26  2:31   ` [PATCH 04/14] fdt: Add function for decoding multiple gpios globally available Simon Glass
2012-10-26  2:31   ` [PATCH 05/14] fdt: Export fdtdec_find_alias_node() function Simon Glass
     [not found]     ` <1351218671-15228-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-10-26  4:24       ` David Gibson
2012-10-31 23:50         ` Simon Glass
2012-10-26  2:31   ` [PATCH 06/14] fdt: Export fdtdec_lookup() and fix the name Simon Glass
2012-10-26  2:31   ` [PATCH 07/14] fdt: Add function to read boolean property Simon Glass
2012-10-26  2:31   ` [PATCH 08/14] fdt: Add fdtdec_get_uint64 to decode a 64-bit value from a property Simon Glass
2012-10-26  2:31   ` [PATCH 09/14] fdt: Add polarity-aware gpio functions to fdtdec Simon Glass
2012-10-26  7:17     ` Lucas Stach [this message]
2012-10-31 23:59       ` Simon Glass
2012-11-01  4:50         ` Stephen Warren
2012-11-15 23:31           ` Simon Glass
2012-11-15 23:46             ` Stephen Warren
2012-11-16  0:01               ` Simon Glass
2012-10-26  2:31   ` [PATCH 11/14] fdt: Tell the FDT library where the device tree is Simon Glass
2012-10-26  2:31   ` [PATCH 12/14] fdt: Allow device tree to specify secure booting Simon Glass
2012-10-26  2:31 ` [PATCH 10/14] fdt: Load boot command from device tree Simon Glass
2012-10-26  2:31 ` [PATCH 13/14] fdt: Add option to default to most compatible conf in a fit image Simon Glass
2012-10-26  2:31 ` [PATCH 14/14] fdt: Set kernaddr if fdt indicates a kernel is present Simon Glass
     [not found]   ` <1351218671-15228-15-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-11-28 14:30     ` [U-Boot] " Dennis Lan (dlan)
2012-11-18  1:35 ` [PATCH 0/14] fdt: Add various device tree utilities and features Jerry Van Baren
2012-11-19 17:08   ` Simon Glass

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=1351235842.20572.10.camel@tellur \
    --to=dev@lynxeye.de \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=seanpaul@chromium.org \
    --cc=sjg@chromium.org \
    --cc=trini@ti.com \
    --cc=u-boot@lists.denx.de \
    --cc=vanbaren@cideas.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).