Appropriate method of io remapping a single memory location?

Carlo Caione carlo at caione.org
Wed May 6 03:03:32 EDT 2015


On Tue, May 5, 2015 at 3:29 PM,  <maitysanchayan at gmail.com> wrote:
> Thanks for the reply. Hmm... I did not think of a DT entry as it is a
> single location and not part of any particular peripheral. Not even
> mentioned in the memory map.

That's why I suggested to use a syscon device.

> I tried grepping for ioremap functions instead of devm ones and saw one
> instance and I wrote mine like this
>
>         rom_rev = ioremap(ROM_REVISION_REGISTER, SZ_1);
>         if (rom_rev)
>                 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%08x",
>                                                 readl(rom_rev));
>
> Is something like this valid? Or use of devm_* functions is
> recommeneded? Since this ioremap is gonna be called from a function
> which is bound to the .init_machine entry of DT_MACHINE_START any harm
> in doing this ioremap directly or the DT method would be recommended?

I guess that DT is always recommended. I would use something like
of_find_compatible_node() + of_iomap() on the syscon device for that
(after of_platform_populate()).
Probably you could use also directly the physical location or a
iotable but it is definitely uglier IMO.

-- 
Carlo Caione



More information about the Kernelnewbies mailing list