[PATCH 4/4] spi: m25p80: detect non-jedec chips by using DT compatible
Lucas Stach
l.stach at pengutronix.de
Thu Feb 6 10:37:10 EST 2014
Signed-off-by: Lucas Stach <l.stach at 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
More information about the barebox
mailing list