From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/1] Animeo IP: use gpiolib ip to detect the hw version
Date: Sat, 26 Jan 2013 01:08:54 +0100 [thread overview]
Message-ID: <1359158934-9369-1-git-send-email-plagnioj@jcrosoft.com> (raw)
if err assume
SubCo
SDN
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
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
next reply other threads:[~2013-01-26 0:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-26 0:08 Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-01-27 11:19 ` Sascha Hauer
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=1359158934-9369-1-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/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