* [PATCH] driver: mtd: update struct map_info's swap as per map requirement.
@ 2017-05-04 7:20 Prabhakar Kushwaha
2017-05-15 8:48 ` Boris Brezillon
0 siblings, 1 reply; 4+ messages in thread
From: Prabhakar Kushwaha @ 2017-05-04 7:20 UTC (permalink / raw)
To: linux-mtd; +Cc: dedekind1, oss, Prabhakar Kushwaha
It is not necessary for all device's maps to be CFI_HOST_ENDIAN. Maps device
can be Bigendian or little endian.
Currently it is being taken care using CONFIG_MTD_CFI_LE_BYTE_SWAP or
CONFIG_MTD_CFI_BE_BYTE_SWAP i.e. compile time.
Now update struct map_info's swap field based on device characteristics
defined in device tree.
Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
---
drivers/mtd/maps/physmap_of.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 14e8909..f39607d 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -20,6 +20,7 @@
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/concat.h>
+#include <linux/mtd/cfi_endian.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
@@ -243,6 +244,9 @@ static int of_flash_probe(struct platform_device *dev)
info->list[i].map.bankwidth = be32_to_cpup(width);
info->list[i].map.device_node = dp;
+ if (of_property_read_bool(dp->parent, "big-endian"))
+ info->list[i].map.swap = CFI_BIG_ENDIAN;
+
err = of_flash_probe_gemini(dev, dp, &info->list[i].map);
if (err)
return err;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] driver: mtd: update struct map_info's swap as per map requirement.
2017-05-04 7:20 [PATCH] driver: mtd: update struct map_info's swap as per map requirement Prabhakar Kushwaha
@ 2017-05-15 8:48 ` Boris Brezillon
2017-05-15 17:28 ` Scott Wood
0 siblings, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2017-05-15 8:48 UTC (permalink / raw)
To: Prabhakar Kushwaha; +Cc: linux-mtd, oss, dedekind1
Hi Prabhakar,
On Thu, 4 May 2017 12:50:37 +0530
Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> wrote:
> It is not necessary for all device's maps to be CFI_HOST_ENDIAN. Maps device
> can be Bigendian or little endian.
>
> Currently it is being taken care using CONFIG_MTD_CFI_LE_BYTE_SWAP or
> CONFIG_MTD_CFI_BE_BYTE_SWAP i.e. compile time.
>
> Now update struct map_info's swap field based on device characteristics
> defined in device tree.
You should update Documentation/devicetree/bindings/mtd/mtd-physmap.txt
and Cc DT maintainers.
>
> Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
> ---
> drivers/mtd/maps/physmap_of.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
> index 14e8909..f39607d 100644
> --- a/drivers/mtd/maps/physmap_of.c
> +++ b/drivers/mtd/maps/physmap_of.c
> @@ -20,6 +20,7 @@
> #include <linux/mtd/map.h>
> #include <linux/mtd/partitions.h>
> #include <linux/mtd/concat.h>
> +#include <linux/mtd/cfi_endian.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/of_platform.h>
> @@ -243,6 +244,9 @@ static int of_flash_probe(struct platform_device *dev)
> info->list[i].map.bankwidth = be32_to_cpup(width);
> info->list[i].map.device_node = dp;
>
> + if (of_property_read_bool(dp->parent, "big-endian"))
> + info->list[i].map.swap = CFI_BIG_ENDIAN;
> +
Shouldn't we have
else if (of_property_read_bool(dp->parent,
"little-endian"))
info->list[i].map.swap = CFI_LITTE_ENDIAN;
else if (of_property_read_bool(dp->parent,
"host-endian"))
info->list[i].map.swap = CFI_HOST_ENDIAN;
Otherwise, you'll fallback to CFI_DEFAULT_ENDIAN (determined with the
CONFIG_MTD_CFI_BE/LE_BYTE_SWAP config options) if the endianness is
not big-endian, which is probably not what you want.
You can even make this property a string property:
if (!of_property_read_string(dp->parent,
"cfi-endianness",
&endianness)) {
if (!strcmp("big", endianness))
info->list[i].map.swap = CFI_BIG_ENDIAN;
else if (!strcmp("little", endianness))
info->list[i].map.swap = CFI_LITTLE_ENDIAN;
else if (!strcmp("host", endianness))
info->list[i].map.swap = CFI_HOST_ENDIAN;
}
> err = of_flash_probe_gemini(dev, dp, &info->list[i].map);
> if (err)
> return err;
Regards,
Boris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver: mtd: update struct map_info's swap as per map requirement.
2017-05-15 8:48 ` Boris Brezillon
@ 2017-05-15 17:28 ` Scott Wood
2017-05-15 19:01 ` Boris Brezillon
0 siblings, 1 reply; 4+ messages in thread
From: Scott Wood @ 2017-05-15 17:28 UTC (permalink / raw)
To: Boris Brezillon, Prabhakar Kushwaha; +Cc: linux-mtd, dedekind1
On Mon, 2017-05-15 at 10:48 +0200, Boris Brezillon wrote:
>
> You can even make this property a string property:
>
> if (!of_property_read_string(dp->parent,
> "cfi-endianness",
> &endianness)) {
> if (!strcmp("big", endianness))
> info->list[i].map.swap = CFI_BIG_ENDIAN;
> else if (!strcmp("little", endianness))
> info->list[i].map.swap = CFI_LITTLE_ENDIAN;
> else if (!strcmp("host", endianness))
> info->list[i].map.swap = CFI_HOST_ENDIAN;
> }
Boolean endianness properties are the standard elsewhere -- why should CFI be
different?
See Documentation/devicetree/bindings/common-properties.txt
-Scott
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver: mtd: update struct map_info's swap as per map requirement.
2017-05-15 17:28 ` Scott Wood
@ 2017-05-15 19:01 ` Boris Brezillon
0 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2017-05-15 19:01 UTC (permalink / raw)
To: Scott Wood; +Cc: Prabhakar Kushwaha, linux-mtd, dedekind1
On Mon, 15 May 2017 12:28:33 -0500
Scott Wood <oss@buserror.net> wrote:
> On Mon, 2017-05-15 at 10:48 +0200, Boris Brezillon wrote:
> >
> > You can even make this property a string property:
> >
> > if (!of_property_read_string(dp->parent,
> > "cfi-endianness",
> > &endianness)) {
> > if (!strcmp("big", endianness))
> > info->list[i].map.swap = CFI_BIG_ENDIAN;
> > else if (!strcmp("little", endianness))
> > info->list[i].map.swap = CFI_LITTLE_ENDIAN;
> > else if (!strcmp("host", endianness))
> > info->list[i].map.swap = CFI_HOST_ENDIAN;
> > }
>
> Boolean endianness properties are the standard elsewhere -- why should CFI be
> different?
>
> See Documentation/devicetree/bindings/common-properties.txt
Forget this suggestion, I didn't know xxx-endian were standard props. My
first comment still applies though.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-15 19:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-04 7:20 [PATCH] driver: mtd: update struct map_info's swap as per map requirement Prabhakar Kushwaha
2017-05-15 8:48 ` Boris Brezillon
2017-05-15 17:28 ` Scott Wood
2017-05-15 19:01 ` Boris Brezillon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.