<div dir="ltr">please wait to aplpy this patch...<div><br></div><div>I've found two potential regression in:</div><div><br></div><div><span style="font-size:13px;font-family:arial,sans-serif">- for (type = rom_probe_types; !ltq_mtd->mtd && *type; type++) {</span><br style="font-size:13px;font-family:arial,sans-serif"><span style="font-size:13px;font-family:arial,sans-serif">- ltq_mtd->mtd = do_map_probe(*type, ltq_mtd->map);</span><br style="font-size:13px;font-family:arial,sans-serif"><span style="font-size:13px;font-family:arial,sans-serif">- }</span><br></div><div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">and</span></div><div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">+ if (!ltq_mtd->mtd) {</span><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Regards</span></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 7, 2014 at 1:20 PM, Eddi De Pieri <span dir="ltr"><<a href="mailto:eddi@depieri.net" target="_blank">eddi@depieri.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Maikel Bloemendal <<a href="mailto:openwrt@maikelenyvonne.nl">openwrt@maikelenyvonne.nl</a>><br>
<br>
Signed-off-by: Maikel Bloemendal <<a href="mailto:openwrt@maikelenyvonne.nl">openwrt@maikelenyvonne.nl</a>><br>
Acked-by: Eddi De Pieri <<a href="mailto:eddi@depieri.net">eddi@depieri.net</a>><br>
---<br>
.../0202-owrt-lantiq-multiple-flash.patch | 218 ++++++++++++++++++++<br>
1 file changed, 218 insertions(+)<br>
create mode 100644 target/linux/lantiq/patches-<a href="tel:3.10%2F0202" value="+13100202">3.10/0202</a>-owrt-lantiq-multiple-flash.patch<br>
<br>
diff --git a/target/linux/lantiq/patches-<a href="tel:3.10%2F0202" value="+13100202">3.10/0202</a>-owrt-lantiq-multiple-flash.patch b/target/linux/lantiq/patches-<a href="tel:3.10%2F0202" value="+13100202">3.10/0202</a>-owrt-lantiq-multiple-flash.patch<br>
new file mode 100644<br>
index 0000000..021e6fc<br>
--- /dev/null<br>
+++ b/target/linux/lantiq/patches-3.10/0202-owrt-lantiq-multiple-flash.patch<br>
@@ -0,0 +1,218 @@<br>
+--- "a/drivers/mtd/maps/lantiq-flash.c"<br>
++++ "b/drivers/mtd/maps/lantiq-flash.c"<br>
+@@ -20,6 +20,7 @@<br>
+ #include <linux/mtd/cfi.h><br>
+ #include <linux/platform_device.h><br>
+ #include <linux/mtd/physmap.h><br>
++#include <linux/mtd/concat.h><br>
+ #include <linux/of.h><br>
+<br>
+ #include <lantiq_soc.h><br>
+@@ -39,10 +40,12 @@<br>
+ LTQ_NOR_NORMAL<br>
+ };<br>
+<br>
++#define MAX_RESOURCES 4<br>
++<br>
+ struct ltq_mtd {<br>
+- struct resource *res;<br>
+- struct mtd_info *mtd;<br>
+- struct map_info *map;<br>
++ struct mtd_info *mtd[MAX_RESOURCES];<br>
++ struct mtd_info *cmtd;<br>
++ struct map_info map[MAX_RESOURCES];<br>
+ };<br>
+<br>
+ static const char ltq_map_name[] = "ltq_nor";<br>
+@@ -110,12 +113,39 @@<br>
+ }<br>
+<br>
+ static int<br>
++ltq_mtd_remove(struct platform_device *pdev)<br>
++{<br>
++ struct ltq_mtd *ltq_mtd = platform_get_drvdata(pdev);<br>
++ int i;<br>
++<br>
++ if (ltq_mtd == NULL)<br>
++ return 0;<br>
++<br>
++ if (ltq_mtd->cmtd) {<br>
++ mtd_device_unregister(ltq_mtd->cmtd);<br>
++ if (ltq_mtd->cmtd != ltq_mtd->mtd[0])<br>
++ mtd_concat_destroy(ltq_mtd->cmtd);<br>
++ }<br>
++<br>
++ for (i = 0; i < MAX_RESOURCES; i++) {<br>
++ if (ltq_mtd->mtd[i] != NULL)<br>
++ map_destroy(ltq_mtd->mtd[i]);<br>
++ }<br>
++<br>
++ kfree(ltq_mtd);<br>
++<br>
++ return 0;<br>
++}<br>
++<br>
++static int<br>
+ ltq_mtd_probe(struct platform_device *pdev)<br>
+ {<br>
+ struct mtd_part_parser_data ppdata;<br>
+ struct ltq_mtd *ltq_mtd;<br>
+ struct cfi_private *cfi;<br>
+- int err;<br>
++ int err = 0;<br>
++ int i;<br>
++ int devices_found = 0;<br>
+<br>
+ static const char *rom_probe_types[] = {<br>
+ "cfi_probe", "jedec_probe", NULL<br>
+@@ -131,88 +161,86 @@<br>
+ ltq_mtd = kzalloc(sizeof(struct ltq_mtd), GFP_KERNEL);<br>
+ platform_set_drvdata(pdev, ltq_mtd);<br>
+<br>
+- ltq_mtd->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);<br>
+- if (!ltq_mtd->res) {<br>
+- dev_err(&pdev->dev, "failed to get memory resource\n");<br>
+- err = -ENOENT;<br>
+- goto err_out;<br>
+- }<br>
+-<br>
+- ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL);<br>
+- if (of_find_property(pdev->dev.of_node, "lantiq,noxip", NULL))<br>
+- ltq_mtd->map->phys = NO_XIP;<br>
+- else<br>
+- ltq_mtd->map->phys = ltq_mtd->res->start;<br>
+- ltq_mtd->res->start;<br>
+- ltq_mtd->map->size = resource_size(ltq_mtd->res);<br>
+- ltq_mtd->map->virt = devm_ioremap_resource(&pdev->dev, ltq_mtd->res);<br>
+- if (IS_ERR(ltq_mtd->map->virt)) {<br>
+- err = PTR_ERR(ltq_mtd->map->virt);<br>
+- goto err_out;<br>
+- }<br>
++ for (i = 0; i < pdev->num_resources; i++) {<br>
++ printk(KERN_NOTICE "lantiq nor flash device: %.8llx at %.8llx\n",<br>
++ (unsigned long long)resource_size(&pdev->resource[i]),<br>
++ (unsigned long long)pdev->resource[i].start);<br>
++<br>
++ if (!devm_request_mem_region(&pdev->dev,<br>
++ pdev->resource[i].start,<br>
++ resource_size(&pdev->resource[i]),<br>
++ dev_name(&pdev->dev))) {<br>
++ dev_err(&pdev->dev, "Could not reserve memory region\n");<br>
++ err = -ENOMEM;<br>
++ goto err_out;<br>
++ }<br>
+<br>
+- ltq_mtd->map->name = ltq_map_name;<br>
+- ltq_mtd->map->bankwidth = 2;<br>
+- ltq_mtd->map->read = ltq_read16;<br>
+- ltq_mtd->map->write = ltq_write16;<br>
+- ltq_mtd->map->copy_from = ltq_copy_from;<br>
+- ltq_mtd->map->copy_to = ltq_copy_to;<br>
++ ltq_mtd->map[i].name = ltq_map_name;<br>
++ ltq_mtd->map[i].bankwidth = 2;<br>
++ ltq_mtd->map[i].read = ltq_read16;<br>
++ ltq_mtd->map[i].write = ltq_write16;<br>
++ ltq_mtd->map[i].copy_from = ltq_copy_from;<br>
++ ltq_mtd->map[i].copy_to = ltq_copy_to;<br>
++<br>
++ if (of_find_property(pdev->dev.of_node, "lantiq,noxip", NULL))<br>
++ ltq_mtd->map[i].phys = NO_XIP;<br>
++ else<br>
++ ltq_mtd->map[i].phys = pdev->resource[i].start;<br>
++ ltq_mtd->map[i].size = resource_size(&pdev->resource[i]);<br>
++ ltq_mtd->map[i].virt = devm_ioremap(&pdev->dev, ltq_mtd->map[i].phys,<br>
++ ltq_mtd->map[i].size);<br>
++ if (ltq_mtd->map[i].virt == NULL) {<br>
++ dev_err(&pdev->dev, "Failed to ioremap flash region\n");<br>
++ err = PTR_ERR(ltq_mtd->map[i].virt);<br>
++ goto err_out;<br>
++ }<br>
+<br>
+- ltq_mtd->map->map_priv_1 = LTQ_NOR_PROBING;<br>
++ ltq_mtd->map[i].map_priv_1 = LTQ_NOR_PROBING;<br>
++ ltq_mtd->mtd[i] = do_map_probe("cfi_probe", <q_mtd->map[i]);<br>
++ ltq_mtd->map[i].map_priv_1 = LTQ_NOR_NORMAL;<br>
++<br>
++ if (!ltq_mtd->mtd) {<br>
++ dev_err(&pdev->dev, "probing failed\n");<br>
++ err = -ENXIO;<br>
++ goto err_out;<br>
++ } else {<br>
++ devices_found++;<br>
++ }<br>
+<br>
+- for (type = rom_probe_types; !ltq_mtd->mtd && *type; type++) {<br>
+- ltq_mtd->mtd = do_map_probe(*type, ltq_mtd->map);<br>
+- }<br>
+-<br>
+- ltq_mtd->map->map_priv_1 = LTQ_NOR_NORMAL;<br>
++ ltq_mtd->mtd[i]->owner = THIS_MODULE;<br>
++ ltq_mtd->mtd[i]->dev.parent = &pdev->dev;<br>
+<br>
+- if (!ltq_mtd->mtd) {<br>
+- dev_err(&pdev->dev, "probing failed\n");<br>
+- err = -ENXIO;<br>
+- goto err_free;<br>
++ cfi = ltq_mtd->map[i].fldrv_priv;<br>
++ cfi->addr_unlock1 ^= 1;<br>
++ cfi->addr_unlock2 ^= 1;<br>
++ }<br>
++<br>
++ if (devices_found == 1) {<br>
++ ltq_mtd->cmtd = ltq_mtd->mtd[0];<br>
++ } else if (devices_found > 1) {<br>
++ /*<br>
++ * We detected multiple devices. Concatenate them together.<br>
++ */<br>
++ ltq_mtd->cmtd = mtd_concat_create(ltq_mtd->mtd, devices_found, dev_name(&pdev->dev));<br>
++ if (ltq_mtd->cmtd == NULL)<br>
++ err = -ENXIO;<br>
+ }<br>
+<br>
+- ltq_mtd->mtd->owner = THIS_MODULE;<br>
+-<br>
+- cfi = ltq_mtd->map->fldrv_priv;<br>
+- cfi->addr_unlock1 ^= 1;<br>
+- cfi->addr_unlock2 ^= 1;<br>
+-<br>
+ ppdata.of_node = pdev->dev.of_node;<br>
+- err = mtd_device_parse_register(ltq_mtd->mtd, ltq_probe_types,<br>
++ err = mtd_device_parse_register(ltq_mtd->cmtd, ltq_probe_types,<br>
+ &ppdata, NULL, 0);<br>
+ if (err) {<br>
+ dev_err(&pdev->dev, "failed to add partitions\n");<br>
+- goto err_destroy;<br>
++ goto err_out;<br>
+ }<br>
+<br>
+ return 0;<br>
+<br>
+-err_destroy:<br>
+- map_destroy(ltq_mtd->mtd);<br>
+-err_free:<br>
+- kfree(ltq_mtd->map);<br>
+ err_out:<br>
+- kfree(ltq_mtd);<br>
++ ltq_mtd_remove(pdev);<br>
+ return err;<br>
+ }<br>
+<br>
+-static int<br>
+-ltq_mtd_remove(struct platform_device *pdev)<br>
+-{<br>
+- struct ltq_mtd *ltq_mtd = platform_get_drvdata(pdev);<br>
+-<br>
+- if (ltq_mtd) {<br>
+- if (ltq_mtd->mtd) {<br>
+- mtd_device_unregister(ltq_mtd->mtd);<br>
+- map_destroy(ltq_mtd->mtd);<br>
+- }<br>
+- kfree(ltq_mtd->map);<br>
+- kfree(ltq_mtd);<br>
+- }<br>
+- return 0;<br>
+-}<br>
+-<br>
+ static const struct of_device_id ltq_mtd_match[] = {<br>
+ { .compatible = "lantiq,nor" },<br>
+ {},<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10.4<br>
_______________________________________________<br>
openwrt-devel mailing list<br>
<a href="mailto:openwrt-devel@lists.openwrt.org">openwrt-devel@lists.openwrt.org</a><br>
<a href="https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel" target="_blank">https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel</a><br>
</font></span></blockquote></div><br></div>