From mboxrd@z Thu Jan 1 00:00:00 1970 From: maitysanchayan@gmail.com (maitysanchayan at gmail.com) Date: Tue, 5 May 2015 18:59:04 +0530 Subject: Appropriate method of io remapping a single memory location? In-Reply-To: References: <20150505101847.GB7024@Sanchayan-Arch.toradex.int> Message-ID: <20150505132904.GC7024@Sanchayan-Arch.toradex.int> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hello Carlo, On 15-05-05 14:25:25, Carlo Caione wrote: > On Tue, May 5, 2015 at 12:18 PM, wrote: > > Hello, > > > > I am adding a small piece of code to expose SoC specific information > > while following the below information, for a Cortex A5 platform. > > > > https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-soc > > > > For the SoC device attribute revision, I need to access a location 0x80 > > for reading the ROM revision information. I am kinda stuck at trying to > > find the appropriate way to read this location. > > > > The devm_ioremap* functions take a device pointer which I can manage but > > they also need a struct resource argument and devm_ioremap requries a > > resource_size_t as well. Having only a specific location to read, > > without having any struct resource what would be the appropriate way to > > get this information. > > If the register / memory location is only used for that specific > purpose then using something like reg = <0x00000080 0x4> in the DT > node is perfectly fine. But if the register is part of a larger device > you can use a syscon device to represent that. 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. 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? Perhaps the side effect would be the stale mapping lying aroung even once the .init section is reclaimed? > > -- > Carlo Caione Thanks & Regards, Sanchayan Maity.