lkml.org 
[lkml]   [2017]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] rtc: omap: Support scratch registers
On 08/11/2017 at 13:36:15 +0530, Keerthy wrote:
>
>
> On Wednesday 08 November 2017 12:46 PM, Alexandre Belloni wrote:
> > On 08/11/2017 at 12:38:05 +0530, Keerthy wrote:
> >>
> >>
> >> On Wednesday 08 November 2017 11:57 AM, Alexandre Belloni wrote:
> >>> Hi,
> >>>
> >>> On 08/11/2017 at 11:30:45 +0530, Keerthy wrote:
> >>>>>>> +static int omap_rtc_scratch_read(void *priv, unsigned int offset, void *_val,
> >>>>>>> + size_t bytes)
> >>>>>>> +{
> >>>>>>> + struct omap_rtc *rtc = priv;
> >>>>>>> + u32 *val = _val;
> >>>>>>> + int i;
> >>>>>>> +
> >>>>>>> + for (i = 0; i < bytes / 4; i++)
> >>>>>>> + val[i] = rtc_readl(rtc,
> >>>>>>> + OMAP_RTC_SCRATCH0_REG + offset + (i * 4));
> >>>>
> >>>> Can the offset be the Scratch register number instead of bytes offset?
> >>>> More intuitive to me.
> >>>>
> >>>> So that one can request using offset as 0, 1, 2 instead of 0, 4, 8?
> >>>>
> >>>
> >>> Well, the offset is coming from the nvmem core, itself getting it from
> >>> the Linux file API (and it is in bytes). However, you have the guarantee
> >>> that it will be aligned on a word, see:
> >>> http://elixir.free-electrons.com/linux/latest/source/drivers/nvmem/core.c#L88
> >>
> >> Okay Alexandre. Thanks for clarifying. Looks good to me.
> >> I have tested on AM437X-GP-EVM.
> >>
> >
> > If needed, you can define nvmem cells (and I guess that is what you
> > want):
> > http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/nvmem/nvmem.txt
>
> With this patch we cannot still use nvmem_device_write and
> nvmem_device_read as the nvmem_device is still not registered.
>
> How can a driver write to scratch pad registers? Should we be calling
> nvmem_register in the probe?

It is not needed, it is registered by rtc_nvmem_register().

nvmem_device_read/write are working because that is what I'm using to
implement the old sysfs ABI with rtc_nvram_read/write.

--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

\
 
 \ /
  Last update: 2017-11-08 21:10    [W:0.042 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site