Re: [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API

Boris Brezillon
2018-08-21T09:56:39Z

On Tue, 21 Aug 2018 10:50:07 +0100
Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:

> On 20/08/18 19:20, Boris Brezillon wrote:
> > On Mon, 20 Aug 2018 11:43:34 +0100
> > Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:
> >
> >>
> >> Overall am still not able to clear visualize on how MTD bindings with
> >> nvmem cells would look in both partition and un-partition usecases?
> >> An example DT would be nice here!!
> >
> > Something along those lines:
> >
> This looks good to me.
> > mtdnode {
> > nvmem-cells {
> > #address-cells = <1>;
> > #size-cells = <1>;
> >
> > cell@0 {
> > reg = <0x0 0x14>;
> > };
> > };
> >
> > partitions {
> > compatible = "fixed-partitions";
> > #address-cells = <1>;
> > #size-cells = <1>;
> >
> > partition@0 {
> > reg = <0x0 0x20000>;
> >
> > nvmem-cells {
> > #address-cells = <1>;
> > #size-cells = <1>;
> >
> > cell@0 {
> > reg = <0x0 0x10>;
> > };
> > };
> > };
> > };
> > }; >
>
> Just curious...Is there a reason why we can't do it like this?:
> Is this because of issue of #address-cells and #size-cells Or mtd
> bindings always prefer subnodes?
>
> mtdnode {
> reg = <0x0123000 0x40000>;
> #address-cells = <1>;
> #size-cells = <1>;
> cell@0 {
> compatible = "nvmem-cell";
> reg = <0x0 0x14>;
> };
>
> partitions {
> compatible = "fixed-partitions";
> #address-cells = <1>;
> #size-cells = <1>;
>
> partition@0 {
> reg = <0x0 0x20000>;
> cell@0 {
> compatible = "nvmem-cell";
> reg = <0x0 0x10>;
> };
> };
> };
> };

It's because partitions were initially directly defined under the mtd
node, so, if you have an old DT you might have something like:

mtdnode {
reg = <0x0123000 0x40000>;
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
reg = <0x0 0x20000>;
...
};
...
};

If we use such a DT with this patch applied, the NVMEM framework will
consider MTD partitions as nvmem cells, which is not what we want.