From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751042AbdKHIfm (ORCPT ); Wed, 8 Nov 2017 03:35:42 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:36340 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbdKHIfl (ORCPT ); Wed, 8 Nov 2017 03:35:41 -0500 Date: Wed, 8 Nov 2017 09:35:33 +0100 From: Alexandre Belloni To: Keerthy Cc: Sekhar Nori , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Linux OMAP List Subject: Re: [PATCH] rtc: omap: Support scratch registers Message-ID: <20171108083533.5ibx43biwk7exlnc@piout.net> References: <600fd106-9f79-0f5a-a2fd-e6b067785c17@ti.com> <4741d4c7-d6f7-ecdb-1eed-1293175f38d9@ti.com> <9a383f74-e049-885b-4705-93968f4c75d4@ti.com> <20171108062738.cml7qaek324rvc4e@piout.net> <775d3cfc-95ca-1dff-d146-64efbdd71e1f@ti.com> <20171108071612.65wrw7mhoip55lia@piout.net> <898f67e7-5d65-9067-f40d-0d80462324d5@ti.com> <20171108082145.kpd3c45x5skce5wd@piout.net> <79f52c27-1c6a-c4ec-9635-d05eec635661@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/11/2017 at 14:02:31 +0530, Keerthy wrote: > > > On Wednesday 08 November 2017 02:01 PM, Keerthy wrote: > > > > > > On Wednesday 08 November 2017 01:51 PM, Alexandre Belloni wrote: > >> 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(). > > > > Let me go through the chain: > > > > rtc_register_device -> __rtc_register_device --> rtc_nvmem_register -> > > rtc_nvram_register > > > > I am seeing that for rtc-omap driver there is rtc_register_device call > > I mean there NO rtc_register_device call. > > > and i see that rtc_nvmem_register is not getting called. > > > > Should we add rtc_register_device in probe of rtc-omap? > > Do you also have that patch: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git/commit/?h=rtc-next&id=57072758623fa4f3019bce65e2b00f24af8dfdd7 ? > >> > >> 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