From: Lucas Stach <l.stach@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/4] spi: m25p80: detect non-jedec chips by using DT compatible
Date: Thu, 6 Feb 2014 16:37:10 +0100 [thread overview]
Message-ID: <1391701030-18395-4-git-send-email-l.stach@pengutronix.de> (raw)
In-Reply-To: <1391701030-18395-1-git-send-email-l.stach@pengutronix.de>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
drivers/mtd/devices/m25p80.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 2275a232c4f9..8a5ac494831f 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -29,6 +29,9 @@
#include <linux/mtd/cfi.h>
#include <linux/mtd/mtd.h>
+/* driver data flags */
+#define FLAG_PROBE_DT 0x01
+
/* Flash opcodes. */
#define OPCODE_WREN 0x06 /* Write enable */
#define OPCODE_RDSR 0x05 /* Read status register */
@@ -859,6 +862,24 @@ static int m25p_probe(struct device_d *dev)
dev_warn(&spi->dev, "unrecognized id %s\n", data->type);
}
+ /*
+ * Some non-jedec conformant chips can only be recognized by their
+ * DT compatible string.
+ */
+ if (dev->of_id_entry && dev->of_id_entry->data == FLAG_PROBE_DT) {
+ for (i = 0; i < ARRAY_SIZE(m25p_ids) - 1; i++) {
+ if (strcmp(dev->of_id_entry->compatible, m25p_ids[i].name))
+ continue;
+
+ id = &m25p_ids[i];
+ info = (void *)id->driver_data;
+
+ if (!info->jedec_id)
+ do_jdec_probe = 0;
+ break;
+ }
+ }
+
if (do_jdec_probe) {
const struct spi_device_id *jid;
@@ -981,6 +1002,10 @@ static __maybe_unused struct of_device_id m25p80_dt_ids[] = {
{
.compatible = "m25p80",
}, {
+ .compatible = "mr25h10", .data = FLAG_PROBE_DT,
+ }, {
+ .compatible = "mr25h256", .data = FLAG_PROBE_DT,
+ }, {
/* sentinel */
}
};
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-02-06 15:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 15:37 [PATCH 1/4] spi: imx5: allow CSPI to work Lucas Stach
2014-02-06 15:37 ` [PATCH 2/4] spi: imx: correctly set GPIO chip selects on CSPI Lucas Stach
2014-02-06 15:37 ` [PATCH 3/4] spi: m25p80: sync up device list with linux 3.13 Lucas Stach
2014-02-06 15:37 ` Lucas Stach [this message]
2014-02-07 7:23 ` [PATCH 1/4] spi: imx5: allow CSPI to work Sascha Hauer
2014-02-07 9:50 ` Lucas Stach
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=1391701030-18395-4-git-send-email-l.stach@pengutronix.de \
--to=l.stach@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