Re: [PATCH v2 1/2] nvmem: add driver for JZ4780 efuse

From: Rob Herring
Date: Wed Jan 17 2018 - 20:59:56 EST


On Wed, Jan 17, 2018 at 11:31 AM, PrasannaKumar Muralidharan
<prasannatsmkumar@xxxxxxxxx> wrote:
> Hi Rob,
>
> On 11 January 2018 at 20:38, Rob Herring <robh@xxxxxxxxxx> wrote:
>> On Sat, Jan 6, 2018 at 6:43 AM, PrasannaKumar Muralidharan
>> <prasannatsmkumar@xxxxxxxxx> wrote:
>>> Hi Rob,
>>>
>>> On 4 January 2018 at 01:32, Rob Herring <robh@xxxxxxxxxx> wrote:
>>>> On Thu, Dec 28, 2017 at 10:29:52PM +0100, Mathieu Malaterre wrote:
>>>>> From: PrasannaKumar Muralidharan <prasannatsmkumar@xxxxxxxxx>

[...]

>>>>> + nemc: nemc@13410000 {
>>>>> + compatible = "ingenic,jz4780-nemc";
>>>>> + reg = <0x13410000 0x10000>;
>>>>> + #address-cells = <2>;
>>>>> + #size-cells = <1>;
>>>>> + ranges = <1 0 0x1b000000 0x1000000
>>>>> + 2 0 0x1a000000 0x1000000
>>>>> + 3 0 0x19000000 0x1000000
>>>>> + 4 0 0x18000000 0x1000000
>>>>> + 5 0 0x17000000 0x1000000
>>>>> + 6 0 0x16000000 0x1000000>;
>>>>> +
>>>>> + clocks = <&cgu JZ4780_CLK_NEMC>;
>>>>> +
>>>>> + status = "disabled";
>>>>> + };
>>>>>
>>>>> - clocks = <&cgu JZ4780_CLK_NEMC>;
>>>>> + efuse: efuse@134100d0 {
>>>>> + compatible = "ingenic,jz4780-efuse";
>>>>> + reg = <0x134100d0 0xff>;
>>>>
>>>> You are creating an overlapping region here with nemc above. Don't do
>>>> that.
>>>
>>> Should "reg = <0x13410000 0x10000>;" be used instead?
>>
>> No, that still overlaps with nemc. What's in registers 0x00-0xcf and
>> 0x1d0-0xffff? Either get rid of this node altogether and make the
>> driver for nemc also instantiate the efuse driver (DT is not the only
>> way to instantiate drivers), or create sub-nodes under nemc for each
>> distinct h/w block in the 13410000-13420000 address space.
>
> My idea was not to change nemc driver.
>
> By "create sub-nodes under nemc" do you mean something like below?

Yes.

> nemc: nemc@13410000 {
> compatible = "ingenic,jz4780-nemc";
> reg = <0x13410000 0x10000>;
> <...>
> status = "disabled";

Though having disabled here is strange. We'd normally ignore all the
child nodes.

>
> efuse: efuse@134101d0 {
> compatible = "ingenic,jz4780-efuse";
> reg = <0x134100d0 0xff>;
> }
> }
>
> Will this instantiate efuse driver? I do not know how to do that with
> sub-node. I will explore more on this.

The nemc driver just needs to call of_platform_default_populate.

>> Or a third option is make nemc reg:
>>
>> reg = <0x13410000 0xd0>, <0x134101d0 0xfe30>;
>>
>> But I suspect that is wrong and you probably have some other function in there.
>>
>> Rob
>
> If the efuse block were to use a different base register address (that
> does not overlap with nemc register range) in future SoC how the node
> should be? Using nemc to instantiate efuse won't be the best choice if
> that happens.

Then you will have a different compatible for nemc (because it is
different) and then the driver should skip the above step.

Rob