From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 10/17] mfd mc13892: support reading the revision
Date: Mon, 11 Oct 2010 13:28:18 +0200 [thread overview]
Message-ID: <1286796505-16049-11-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1286796505-16049-1-git-send-email-s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mfd/mc13892.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
include/mfd/mc13892.h | 22 ++++++++++++++++-
2 files changed, 83 insertions(+), 1 deletions(-)
diff --git a/drivers/mfd/mc13892.c b/drivers/mfd/mc13892.c
index 2f415fc..08a439b 100644
--- a/drivers/mfd/mc13892.c
+++ b/drivers/mfd/mc13892.c
@@ -25,6 +25,7 @@
#include <xfuncs.h>
#include <errno.h>
#include <spi/spi.h>
+#include <malloc.h>
#include <i2c/i2c.h>
#include <mfd/mc13892.h>
@@ -210,8 +211,63 @@ static struct file_operations mc_fops = {
.write = mc_write,
};
+struct mc13892_rev {
+ u16 rev_id;
+ enum mc13892_revision rev;
+ char *revstr;
+};
+
+static struct mc13892_rev mc13892_revisions[] = {
+ { 0x01, MC13892_REVISION_1_0, "1.0" },
+ { 0x09, MC13892_REVISION_1_1, "1.1" },
+ { 0x0a, MC13892_REVISION_1_2, "1.2" },
+ { 0x10, MC13892_REVISION_2_0, "2.0" },
+ { 0x11, MC13892_REVISION_2_1, "2.1" },
+ { 0x18, MC13892_REVISION_3_0, "3.0" },
+ { 0x19, MC13892_REVISION_3_1, "3.1" },
+ { 0x1a, MC13892_REVISION_3_2, "3.2" },
+ { 0x02, MC13892_REVISION_3_2a, "3.2a" },
+ { 0x1b, MC13892_REVISION_3_3, "3.3" },
+ { 0x1d, MC13892_REVISION_3_5, "3.5" },
+};
+
+static int mc13893_query_revision(struct mc13892 *mc13892)
+{
+ unsigned int rev_id;
+ char *revstr;
+ int rev, i;
+
+ mc13892_reg_read(mc13892, 7, &rev_id);
+
+ for (i = 0; i < ARRAY_SIZE(mc13892_revisions); i++)
+ if ((rev_id & 0x1f) == mc13892_revisions[i].rev_id)
+ break;
+
+ if (i == ARRAY_SIZE(mc13892_revisions))
+ return -EINVAL;
+
+ rev = mc13892_revisions[i].rev;
+ revstr = mc13892_revisions[i].revstr;
+
+ if (rev == MC13892_REVISION_2_0) {
+ if ((rev_id >> 9) & 0x3) {
+ rev = MC13892_REVISION_2_0a;
+ revstr = "2.0a";
+ }
+ }
+
+ dev_info(mc_dev->cdev.dev, "PMIC ID: 0x%08x [Rev: %s]\n",
+ rev_id, revstr);
+
+ mc13892->revision = rev;
+
+ return rev;
+}
+
static int mc_probe(struct device_d *dev, enum mc13892_mode mode)
{
+ int rev;
+
if (mc_dev)
return -EBUSY;
@@ -230,6 +286,12 @@ static int mc_probe(struct device_d *dev, enum mc13892_mode mode)
mc_dev->cdev.dev = dev;
mc_dev->cdev.ops = &mc_fops;
+ rev = mc13893_query_revision(mc_dev);
+ if (rev < 0) {
+ free(mc_dev);
+ return -EINVAL;
+ }
+
devfs_create(&mc_dev->cdev);
return 0;
diff --git a/include/mfd/mc13892.h b/include/mfd/mc13892.h
index 11ae878..78a42e9 100644
--- a/include/mfd/mc13892.h
+++ b/include/mfd/mc13892.h
@@ -79,6 +79,21 @@ enum mc13892_reg {
MC13892_REG_TEST4 = 0x3f,
};
+enum mc13892_revision {
+ MC13892_REVISION_1_0,
+ MC13892_REVISION_1_1,
+ MC13892_REVISION_1_2,
+ MC13892_REVISION_2_0,
+ MC13892_REVISION_2_0a,
+ MC13892_REVISION_2_1,
+ MC13892_REVISION_3_0,
+ MC13892_REVISION_3_1,
+ MC13892_REVISION_3_2,
+ MC13892_REVISION_3_2a,
+ MC13892_REVISION_3_3,
+ MC13892_REVISION_3_5,
+};
+
enum mc13892_mode {
MC13892_MODE_I2C,
MC13892_MODE_SPI,
@@ -89,7 +104,7 @@ struct mc13892 {
struct i2c_client *client;
struct spi_device *spi;
enum mc13892_mode mode;
-
+ enum mc13892_revision revision;
};
extern struct mc13892 *mc13892_get(void);
@@ -98,4 +113,9 @@ extern int mc13892_reg_read(struct mc13892 *mc13892, enum mc13892_reg reg, u32 *
extern int mc13892_reg_write(struct mc13892 *mc13892, enum mc13892_reg reg, u32 val);
extern int mc13892_set_bits(struct mc13892 *mc13892, enum mc13892_reg reg, u32 mask, u32 val);
+static inline enum mc13892_revision mc13892_get_revision(struct mc13892 *mc13892)
+{
+ return mc13892->revision;
+}
+
#endif /* __ASM_ARCH_MC13892_H */
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2010-10-11 11:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-11 11:28 Patches for -next Sascha Hauer
2010-10-11 11:28 ` [PATCH 01/17] i.MX27: Add support for SDHC pins Sascha Hauer
2010-10-11 11:28 ` [PATCH 02/17] mci: Add i.MX esdhc support Sascha Hauer
2010-10-11 11:28 ` [PATCH 03/17] mci: print error code on failure Sascha Hauer
2010-10-11 11:28 ` [PATCH 04/17] spi i.MX: add spi version namespace to register defines Sascha Hauer
2010-10-11 11:28 ` [PATCH 05/17] spi i.MX: redirect functions to version specific functions Sascha Hauer
2010-10-11 11:28 ` [PATCH 06/17] spi i.MX: Add i.MX51 support Sascha Hauer
2010-10-11 11:28 ` [PATCH 07/17] Move mfd drivers to drivers/mfd Sascha Hauer
2010-10-11 11:28 ` [PATCH 08/17] move include files for mfd drivers to include/mfd Sascha Hauer
2010-10-11 11:28 ` [PATCH 09/17] mfd mc13892: Add spi support Sascha Hauer
2010-10-11 11:28 ` Sascha Hauer [this message]
2010-10-11 11:28 ` [PATCH 11/17] mci: handle SD cards < 2.0 correctly Sascha Hauer
2010-10-11 12:48 ` Juergen Beisert
2010-10-11 13:07 ` Belisko Marek
2010-10-11 13:47 ` Juergen Beisert
2010-10-11 12:53 ` Juergen Beisert
2010-10-11 11:28 ` [PATCH 12/17] mci: align write buffer if necessary Sascha Hauer
2010-10-11 11:28 ` [PATCH 13/17] defaultenv: handle disk partitions Sascha Hauer
2010-10-11 12:26 ` Juergen Beisert
2010-10-11 12:50 ` Sascha Hauer
2010-10-11 12:59 ` Juergen Beisert
2010-10-11 13:54 ` Sascha Hauer
2010-10-11 14:22 ` Juergen Beisert
2010-10-12 6:51 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 11:28 ` [PATCH 14/17] imx_serial: Add mx51 support Sascha Hauer
2010-10-11 11:28 ` [PATCH 15/17] ARM mmu: Call __mmu_cache_flush instead of hardcoded v4/v5 only function Sascha Hauer
2010-10-11 11:28 ` [PATCH 16/17] ARM i.MX: Add basic i.MX51 support Sascha Hauer
2010-10-11 11:28 ` [PATCH 17/17] ARM i.MX51: Add babbage board support 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=1286796505-16049-11-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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