* [PATCH] Add devicetree support to m25p80 driver
@ 2012-10-21 16:34 Michal Vanka
[not found] ` <5084241A.5050801-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Michal Vanka @ 2012-10-21 16:34 UTC (permalink / raw)
To: mike-UTnDXsALFwNjMdQLN6DIHgC/G2K4zDHf
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
The following patch adds support for devicetree to m25p80 driver.
Note that for jedec chips the chip identification was simplified.
The particular chip is identified by jedec_id only.
Tested on custom Altera Nios2 system.
Signed-off-by: Michal Vanka <mv-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
diff --git a/Documentation/devicetree/bindings/mtd/m25pxx.txt
b/Documentation/devicetree/bindings/mtd/m25pxx.txt
index e69de29..c454a5b 100644
--- a/Documentation/devicetree/bindings/mtd/m25pxx.txt
+++ b/Documentation/devicetree/bindings/mtd/m25pxx.txt
@@ -0,0 +1,39 @@
+* M25PXX Serial Flash
+
+Required properties:
+- compatible : For jedec part should be "generic,m25pxx"
+ For non-jedec part should be one of the following:
+ "catalyst,cat25c11"
+ "catalyst,cat25c03"
+ "catalyst,cat25c09"
+ "catalyst,cat25c17"
+ "catalyst,cat25128"
+ "stmicro,m25p05-nonjedec"
+ "stmicro,m25p10-nonjedec"
+ "stmicro,m25p20-nonjedec"
+ "stmicro,m25p40-nonjedec"
+ "stmicro,m25p80-nonjedec"
+ "stmicro,m25p16-nonjedec"
+ "stmicro,m25p32-nonjedec"
+ "stmicro,m25p64-nonjedec"
+ "stmicro,m25p128-nonjedec"
+
+- spi-max-frequency : Maximum operating frequency for the given chip.
+- reg : Chipselect bit number on gpios chipselect port.
+
+Example: S25FL064K hooked to tinyspi controller:
+
+tiny_spi_2: spi@0x4000 {
+ compatible = "opencores,tiny-spi-1.0", "opencores,tiny-spi-rtlsvn2";
+ reg = < 0x00004000 0x00000020 >;
+ interrupt-parent = < &cpu >;
+ interrupts = < 5 >;
+ clock-frequency = < 100000000 >;
+ baud-width = < 8 >; /* BAUD_WIDTH type NUMBER */
+ gpios = < &spi2_cs 0 0 >;
+ spansion_flash: m25pxx@0 {
+ compatible = "generic,m25pxx";
+ spi-max-frequency = < 20000000 >;
+ reg = <0>;
+ };
+};
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 5d0d68c..1db2c63 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -744,6 +744,29 @@ static const struct spi_device_id m25p_ids[] = {
};
MODULE_DEVICE_TABLE(spi, m25p_ids);
+#ifdef CONFIG_OF
+static const struct of_device_id m25pxx_dt_ids[] = {
+ { .compatible = "generic,m25pxx", },
+ { .compatible = "catalyst,cat25c11", },
+ { .compatible = "catalyst,cat25c03", },
+ { .compatible = "catalyst,cat25c09", },
+ { .compatible = "catalyst,cat25c17", },
+ { .compatible = "catalyst,cat25128", },
+ { .compatible = "stmicro,m25p05-nonjedec", },
+ { .compatible = "stmicro,m25p10-nonjedec", },
+ { .compatible = "stmicro,m25p20-nonjedec", },
+ { .compatible = "stmicro,m25p40-nonjedec", },
+ { .compatible = "stmicro,m25p80-nonjedec", },
+ { .compatible = "stmicro,m25p16-nonjedec", },
+ { .compatible = "stmicro,m25p32-nonjedec", },
+ { .compatible = "stmicro,m25p64-nonjedec", },
+ { .compatible = "stmicro,m25p128-nonjedec", },
+ { /* sentinel */ }
+};
+#else
+#define m25pxx_dt_ids NULL
+#endif
+
static const struct spi_device_id *__devinit jedec_probe(struct
spi_device *spi)
{
int tmp;
@@ -798,7 +821,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
unsigned i;
struct mtd_part_parser_data ppdata;
-#ifdef CONFIG_MTD_OF_PARTS
+#if defined(CONFIG_MTD_OF_PARTS) || defined(CONFIG_OF)
if (!of_device_is_available(spi->dev.of_node))
return -ENODEV;
#endif
@@ -825,27 +848,39 @@ static int __devinit m25p_probe(struct spi_device
*spi)
dev_warn(&spi->dev, "unrecognized id %s\n", data->type);
}
- info = (void *)id->driver_data;
-
- if (info->jedec_id) {
- const struct spi_device_id *jid;
-
- jid = jedec_probe(spi);
- if (IS_ERR(jid)) {
- return PTR_ERR(jid);
- } else if (jid != id) {
- /*
- * JEDEC knows better, so overwrite platform ID. We
- * can't trust partitions any longer, but we'll let
- * mtd apply them anyway, since some partitions may be
- * marked read-only, and we don't want to lose that
- * information, even if it's not 100% accurate.
- */
- dev_warn(&spi->dev, "found %s, expected %s\n",
- jid->name, id->name);
- id = jid;
- info = (void *)jid->driver_data;
+ if (id) {
+ info = (void *)id->driver_data;
+ if (info->jedec_id) {
+ const struct spi_device_id *jid;
+
+ jid = jedec_probe(spi);
+ if (IS_ERR(jid)) {
+ return PTR_ERR(jid);
+ } else if (jid != id) {
+ /*
+ * JEDEC knows better, so overwrite platform ID.
+ * We can't trust partitions any longer, but
+ * we'll let mtd apply them anyway, since some
+ * partitions may be marked read-only,
+ * and we don't want to lose that information,
+ * even if it's not 100% accurate.
+ */
+ dev_warn(&spi->dev, "found %s, expected %s\n",
+ jid->name, id->name);
+ id = jid;
+ info = (void *)jid->driver_data;
+ }
}
+ } else {
+ /*
+ * No id -> we have been most likely configured
+ * by devicetree "generic,m25pxx" record.
+ */
+ id = jedec_probe(spi);
+ if (IS_ERR(id))
+ return PTR_ERR(id);
+
+ info = (void *)id->driver_data;
}
flash = kzalloc(sizeof *flash, GFP_KERNEL);
@@ -968,6 +1003,7 @@ static struct spi_driver m25p80_driver = {
.driver = {
.name = "m25p80",
.owner = THIS_MODULE,
+ .of_match_table = m25pxx_dt_ids,
},
.id_table = m25p_ids,
.probe = m25p_probe,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Add devicetree support to m25p80 driver
[not found] ` <5084241A.5050801-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
@ 2012-11-12 15:32 ` Artem Bityutskiy
2012-11-13 9:56 ` [PATCH resend] " Michal Vanka
1 sibling, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2012-11-12 15:32 UTC (permalink / raw)
To: Michal Vanka
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
mike-UTnDXsALFwNjMdQLN6DIHgC/G2K4zDHf
[-- Attachment #1.1: Type: text/plain, Size: 699 bytes --]
On Sun, 2012-10-21 at 18:34 +0200, Michal Vanka wrote:
> The following patch adds support for devicetree to m25p80 driver.
> Note that for jedec chips the chip identification was simplified.
> The particular chip is identified by jedec_id only.
> Tested on custom Altera Nios2 system.
>
> Signed-off-by: Michal Vanka <mv-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
This patch is wrapped and does not apply. I tried to fix the wrapping,
but it does not apply to the l2-mtd.git tree anyway. The l2 tree is
based on v3.7-rc4. Please, send a cleanly applicable version against the
l2-mtd.git tree:
http://git.infradead.org/users/dedekind/l2-mtd.git
--
Best Regards,
Artem Bityutskiy
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH resend] Add devicetree support to m25p80 driver
[not found] ` <5084241A.5050801-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
2012-11-12 15:32 ` Artem Bityutskiy
@ 2012-11-13 9:56 ` Michal Vanka
[not found] ` <50A2193A.2040100-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Michal Vanka @ 2012-11-13 9:56 UTC (permalink / raw)
To: dedekind1-Re5JQEeQqe8AvxtiuMwx3w,
artem.bityutskiy-VuQAYsv1563Yd54FQh9/CA
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
The following patch adds support for devicetree to m25p80 driver.
Note that for jedec chips the chip identification was simplified.
When configured by devicetree, the particular chip is identified
by jedec_id only.
Tested on custom Altera Nios2 system.
Signed-off-by: Michal Vanka <mv-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
diff --git a/Documentation/devicetree/bindings/mtd/m25pxx.txt
b/Documentation/devicetree/bindings/mtd/m25pxx.txt
index e69de29..c454a5b 100644
--- a/Documentation/devicetree/bindings/mtd/m25pxx.txt
+++ b/Documentation/devicetree/bindings/mtd/m25pxx.txt
@@ -0,0 +1,39 @@
+* M25PXX Serial Flash
+
+Required properties:
+- compatible : For jedec part should be "generic,m25pxx"
+ For non-jedec part should be one of the following:
+ "catalyst,cat25c11"
+ "catalyst,cat25c03"
+ "catalyst,cat25c09"
+ "catalyst,cat25c17"
+ "catalyst,cat25128"
+ "stmicro,m25p05-nonjedec"
+ "stmicro,m25p10-nonjedec"
+ "stmicro,m25p20-nonjedec"
+ "stmicro,m25p40-nonjedec"
+ "stmicro,m25p80-nonjedec"
+ "stmicro,m25p16-nonjedec"
+ "stmicro,m25p32-nonjedec"
+ "stmicro,m25p64-nonjedec"
+ "stmicro,m25p128-nonjedec"
+
+- spi-max-frequency : Maximum operating frequency for the given chip.
+- reg : Chipselect bit number on gpios chipselect port.
+
+Example: S25FL064K hooked to tinyspi controller:
+
+tiny_spi_2: spi@0x4000 {
+ compatible = "opencores,tiny-spi-1.0", "opencores,tiny-spi-rtlsvn2";
+ reg = < 0x00004000 0x00000020 >;
+ interrupt-parent = < &cpu >;
+ interrupts = < 5 >;
+ clock-frequency = < 100000000 >;
+ baud-width = < 8 >; /* BAUD_WIDTH type NUMBER */
+ gpios = < &spi2_cs 0 0 >;
+ spansion_flash: m25pxx@0 {
+ compatible = "generic,m25pxx";
+ spi-max-frequency = < 20000000 >;
+ reg = <0>;
+ };
+};
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 5d0d68c..1db2c63 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -744,6 +744,29 @@ static const struct spi_device_id m25p_ids[] = {
};
MODULE_DEVICE_TABLE(spi, m25p_ids);
+#ifdef CONFIG_OF
+static const struct of_device_id m25pxx_dt_ids[] = {
+ { .compatible = "generic,m25pxx", },
+ { .compatible = "catalyst,cat25c11", },
+ { .compatible = "catalyst,cat25c03", },
+ { .compatible = "catalyst,cat25c09", },
+ { .compatible = "catalyst,cat25c17", },
+ { .compatible = "catalyst,cat25128", },
+ { .compatible = "stmicro,m25p05-nonjedec", },
+ { .compatible = "stmicro,m25p10-nonjedec", },
+ { .compatible = "stmicro,m25p20-nonjedec", },
+ { .compatible = "stmicro,m25p40-nonjedec", },
+ { .compatible = "stmicro,m25p80-nonjedec", },
+ { .compatible = "stmicro,m25p16-nonjedec", },
+ { .compatible = "stmicro,m25p32-nonjedec", },
+ { .compatible = "stmicro,m25p64-nonjedec", },
+ { .compatible = "stmicro,m25p128-nonjedec", },
+ { /* sentinel */ }
+};
+#else
+#define m25pxx_dt_ids NULL
+#endif
+
static const struct spi_device_id *__devinit jedec_probe(struct
spi_device *spi)
{
int tmp;
@@ -798,7 +821,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
unsigned i;
struct mtd_part_parser_data ppdata;
-#ifdef CONFIG_MTD_OF_PARTS
+#if defined(CONFIG_MTD_OF_PARTS) || defined(CONFIG_OF)
if (!of_device_is_available(spi->dev.of_node))
return -ENODEV;
#endif
@@ -825,27 +848,39 @@ static int __devinit m25p_probe(struct spi_device
*spi)
dev_warn(&spi->dev, "unrecognized id %s\n", data->type);
}
- info = (void *)id->driver_data;
-
- if (info->jedec_id) {
- const struct spi_device_id *jid;
-
- jid = jedec_probe(spi);
- if (IS_ERR(jid)) {
- return PTR_ERR(jid);
- } else if (jid != id) {
- /*
- * JEDEC knows better, so overwrite platform ID. We
- * can't trust partitions any longer, but we'll let
- * mtd apply them anyway, since some partitions may be
- * marked read-only, and we don't want to lose that
- * information, even if it's not 100% accurate.
- */
- dev_warn(&spi->dev, "found %s, expected %s\n",
- jid->name, id->name);
- id = jid;
- info = (void *)jid->driver_data;
+ if (id) {
+ info = (void *)id->driver_data;
+ if (info->jedec_id) {
+ const struct spi_device_id *jid;
+
+ jid = jedec_probe(spi);
+ if (IS_ERR(jid)) {
+ return PTR_ERR(jid);
+ } else if (jid != id) {
+ /*
+ * JEDEC knows better, so overwrite platform ID.
+ * We can't trust partitions any longer, but
+ * we'll let mtd apply them anyway, since some
+ * partitions may be marked read-only,
+ * and we don't want to lose that information,
+ * even if it's not 100% accurate.
+ */
+ dev_warn(&spi->dev, "found %s, expected %s\n",
+ jid->name, id->name);
+ id = jid;
+ info = (void *)jid->driver_data;
+ }
}
+ } else {
+ /*
+ * No id -> we have been most likely configured
+ * by devicetree "generic,m25pxx" record.
+ */
+ id = jedec_probe(spi);
+ if (IS_ERR(id))
+ return PTR_ERR(id);
+
+ info = (void *)id->driver_data;
}
flash = kzalloc(sizeof *flash, GFP_KERNEL);
@@ -968,6 +1003,7 @@ static struct spi_driver m25p80_driver = {
.driver = {
.name = "m25p80",
.owner = THIS_MODULE,
+ .of_match_table = m25pxx_dt_ids,
},
.id_table = m25p_ids,
.probe = m25p_probe,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH resend] Add devicetree support to m25p80 driver
[not found] ` <50A2193A.2040100-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
@ 2012-11-13 11:44 ` Artem Bityutskiy
0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2012-11-13 11:44 UTC (permalink / raw)
To: Michal Vanka
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
[-- Attachment #1.1: Type: text/plain, Size: 553 bytes --]
On Tue, 2012-11-13 at 10:56 +0100, Michal Vanka wrote:
> return -ENODEV;
> #endif
> @@ -825,27 +848,39 @@ static int __devinit m25p_probe(struct
> spi_device
> *spi)
> dev_warn(&spi->dev, "unrecognized id %s\n",
> data->type);
Still line-wrapped:
$ git apply --check ~/tmp/mvanka.mbox
fatal: corrupt patch at line 122
Please, make sure it applies to the l2-mtd.git tree. Send it to
yourself, save your own e-mail, and verify with 'git apply --check'.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-13 11:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-21 16:34 [PATCH] Add devicetree support to m25p80 driver Michal Vanka
[not found] ` <5084241A.5050801-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
2012-11-12 15:32 ` Artem Bityutskiy
2012-11-13 9:56 ` [PATCH resend] " Michal Vanka
[not found] ` <50A2193A.2040100-Swe8ldf8qsBeoWH0uzbU5w@public.gmane.org>
2012-11-13 11:44 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).