mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/1] Animeo IP: use gpiolib ip to detect the hw version
Date: Sun, 27 Jan 2013 12:19:20 +0100	[thread overview]
Message-ID: <20130127111920.GX1906@pengutronix.de> (raw)
In-Reply-To: <1359158934-9369-1-git-send-email-plagnioj@jcrosoft.com>

On Sat, Jan 26, 2013 at 01:08:54AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> if err assume
> SubCo
> SDN
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Applied, thanks

Sascha

> ---
>  arch/arm/boards/animeo_ip/init.c |   50 +++++++++++++++++++++++++++++---------
>  1 file changed, 39 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
> index e5e8694..9063567 100644
> --- a/arch/arm/boards/animeo_ip/init.c
> +++ b/arch/arm/boards/animeo_ip/init.c
> @@ -29,28 +29,56 @@
>  static bool animeo_ip_is_buco;
>  static bool animeo_ip_is_io;
>  
> +static int animeo_ip_get_pio_revision(int gpio, char *name)
> +{
> +	int ret;
> +
> +	ret = gpio_request(gpio, name);
> +	if (ret) {
> +		pr_err("animeo_ip: can not request gpio %d as %s (%d)\n",
> +			gpio, name, ret);
> +		return ret;
> +	}
> +
> +	ret = gpio_direction_input(gpio);
> +
> +	if (ret) {
> +		pr_err("animeo_ip: can configure gpio %d (%s) as input (%d)\n",
> +			gpio, name, ret);
> +		return ret;
> +	}
> +
> +	return gpio_get_value(gpio);
> +}
> +
>  static void animeo_ip_detect_version(void)
>  {
>  	struct device_d *dev = NULL;
>  	char *model, *version;
> +	int val;
>  
> -	at91_set_gpio_input(AT91_PIN_PC20, 0);
> -	at91_set_gpio_input(AT91_PIN_PC21, 0);
> -
> -	animeo_ip_is_buco = !!gpio_get_value(AT91_PIN_PC20);
> -	animeo_ip_is_io = !!gpio_get_value(AT91_PIN_PC21);
> +	animeo_ip_is_io = false;
> +	animeo_ip_is_buco = false;
> +	model = "SubCo";
> +	version = "SDN";
>  
>  	dev = add_generic_device_res("animeo_ip", DEVICE_ID_SINGLE, NULL, 0, NULL);
>  
> -	if (animeo_ip_is_buco)
> -		model = "BuCo";
> -	else
> +	val = animeo_ip_get_pio_revision(AT91_PIN_PC20, "is_buco");
> +	if (val < 0) {
> +		pr_warn("Can not detect model use %s by default\n", model);
> +	} else if (val) {
> +		animeo_ip_is_buco = true;
>  		model = "SubCo";
> +	}
>  
> -	if (animeo_ip_is_io)
> +	val = animeo_ip_get_pio_revision(AT91_PIN_PC21, "is_io");
> +	if (val < 0) {
> +		pr_warn("Can not detect version use %s by default\n", model);
> +	} else if (val) {
> +		animeo_ip_is_io = true;
>  		version = "IO";
> -	else
> -		version = "SDN";
> +	}
>  
>  	dev_add_param_fixed(dev, "model", model);
>  	dev_add_param_fixed(dev, "version", version);
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2013-01-27 11:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-26  0:08 Jean-Christophe PLAGNIOL-VILLARD
2013-01-27 11:19 ` Sascha Hauer [this message]

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=20130127111920.GX1906@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.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