linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: omap: Support scratch registers
@ 2017-10-31 16:27 Alexandre Belloni
  2017-11-06  6:55 ` Sekhar Nori
  0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Belloni @ 2017-10-31 16:27 UTC (permalink / raw)
  To: linux-rtc; +Cc: Keerthy, linux-kernel, Alexandre Belloni

Register an nvmem device to expose the 3 scratch registers (total of 12
bytes) to both userspace and kernel space.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/rtc/rtc-omap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index d56d937966dc..1d666ac9ef70 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -70,6 +70,10 @@
 #define OMAP_RTC_COMP_MSB_REG		0x50
 #define OMAP_RTC_OSC_REG		0x54
 
+#define OMAP_RTC_SCRATCH0_REG		0x60
+#define OMAP_RTC_SCRATCH1_REG		0x64
+#define OMAP_RTC_SCRATCH2_REG		0x68
+
 #define OMAP_RTC_KICK0_REG		0x6c
 #define OMAP_RTC_KICK1_REG		0x70
 
@@ -667,6 +671,45 @@ static struct pinctrl_desc rtc_pinctrl_desc = {
 	.owner = THIS_MODULE,
 };
 
+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));
+
+	return 0;
+}
+
+static int omap_rtc_scratch_write(void *priv, unsigned int offset, void *_val,
+				  size_t bytes)
+{
+	struct omap_rtc	*rtc = priv;
+	u32 *val = _val;
+	int i;
+
+	rtc->type->unlock(rtc);
+	for (i = 0; i < bytes / 4; i++)
+		rtc_writel(rtc,
+			   OMAP_RTC_SCRATCH0_REG + offset + (i * 4), val[i]);
+	rtc->type->lock(rtc);
+
+	return 0;
+}
+
+static struct nvmem_config omap_rtc_nvmem_config = {
+	.name = "omap_rtc_scratch",
+	.word_size = 4,
+	.stride = 4,
+	.size = OMAP_RTC_KICK0_REG - OMAP_RTC_SCRATCH0_REG,
+	.reg_read = omap_rtc_scratch_read,
+	.reg_write = omap_rtc_scratch_write,
+};
+
 static int omap_rtc_probe(struct platform_device *pdev)
 {
 	struct omap_rtc	*rtc;
@@ -804,6 +847,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	}
 
 	rtc->rtc->ops = &omap_rtc_ops;
+	omap_rtc_nvmem_config.priv = rtc;
+	rtc->rtc->nvmem_config = &omap_rtc_nvmem_config;
 
 	/* handle periodic and alarm irqs */
 	ret = devm_request_irq(&pdev->dev, rtc->irq_timer, rtc_irq, 0,
-- 
2.15.0.rc2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-10-31 16:27 [PATCH] rtc: omap: Support scratch registers Alexandre Belloni
@ 2017-11-06  6:55 ` Sekhar Nori
  2017-11-06  6:59   ` Keerthy
  0 siblings, 1 reply; 14+ messages in thread
From: Sekhar Nori @ 2017-11-06  6:55 UTC (permalink / raw)
  To: Alexandre Belloni, linux-rtc; +Cc: Keerthy, linux-kernel, Linux OMAP List

+ linux omap list

On Tuesday 31 October 2017 09:57 PM, Alexandre Belloni wrote:
> Register an nvmem device to expose the 3 scratch registers (total of 12
> bytes) to both userspace and kernel space.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Looks good to me.

Reviewed-by: Sekhar Nori <nsekhar@ti.com>

Curious on what you are using these registers for.

Thanks,
Sekhar

> ---
>  drivers/rtc/rtc-omap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> index d56d937966dc..1d666ac9ef70 100644
> --- a/drivers/rtc/rtc-omap.c
> +++ b/drivers/rtc/rtc-omap.c
> @@ -70,6 +70,10 @@
>  #define OMAP_RTC_COMP_MSB_REG		0x50
>  #define OMAP_RTC_OSC_REG		0x54
>  
> +#define OMAP_RTC_SCRATCH0_REG		0x60
> +#define OMAP_RTC_SCRATCH1_REG		0x64
> +#define OMAP_RTC_SCRATCH2_REG		0x68
> +
>  #define OMAP_RTC_KICK0_REG		0x6c
>  #define OMAP_RTC_KICK1_REG		0x70
>  
> @@ -667,6 +671,45 @@ static struct pinctrl_desc rtc_pinctrl_desc = {
>  	.owner = THIS_MODULE,
>  };
>  
> +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));
> +
> +	return 0;
> +}
> +
> +static int omap_rtc_scratch_write(void *priv, unsigned int offset, void *_val,
> +				  size_t bytes)
> +{
> +	struct omap_rtc	*rtc = priv;
> +	u32 *val = _val;
> +	int i;
> +
> +	rtc->type->unlock(rtc);
> +	for (i = 0; i < bytes / 4; i++)
> +		rtc_writel(rtc,
> +			   OMAP_RTC_SCRATCH0_REG + offset + (i * 4), val[i]);
> +	rtc->type->lock(rtc);
> +
> +	return 0;
> +}
> +
> +static struct nvmem_config omap_rtc_nvmem_config = {
> +	.name = "omap_rtc_scratch",
> +	.word_size = 4,
> +	.stride = 4,
> +	.size = OMAP_RTC_KICK0_REG - OMAP_RTC_SCRATCH0_REG,
> +	.reg_read = omap_rtc_scratch_read,
> +	.reg_write = omap_rtc_scratch_write,
> +};
> +
>  static int omap_rtc_probe(struct platform_device *pdev)
>  {
>  	struct omap_rtc	*rtc;
> @@ -804,6 +847,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
>  	}
>  
>  	rtc->rtc->ops = &omap_rtc_ops;
> +	omap_rtc_nvmem_config.priv = rtc;
> +	rtc->rtc->nvmem_config = &omap_rtc_nvmem_config;
>  
>  	/* handle periodic and alarm irqs */
>  	ret = devm_request_irq(&pdev->dev, rtc->irq_timer, rtc_irq, 0,
> -- 
> 2.15.0.rc2
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-06  6:55 ` Sekhar Nori
@ 2017-11-06  6:59   ` Keerthy
  2017-11-06  7:02     ` Sekhar Nori
  2017-11-08  6:00     ` Keerthy
  0 siblings, 2 replies; 14+ messages in thread
From: Keerthy @ 2017-11-06  6:59 UTC (permalink / raw)
  To: Sekhar Nori, Alexandre Belloni, linux-rtc; +Cc: linux-kernel, Linux OMAP List



On Monday 06 November 2017 12:25 PM, Sekhar Nori wrote:
> + linux omap list
> 
> On Tuesday 31 October 2017 09:57 PM, Alexandre Belloni wrote:
>> Register an nvmem device to expose the 3 scratch registers (total of 12
>> bytes) to both userspace and kernel space.
>>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> 
> Looks good to me.
> 
> Reviewed-by: Sekhar Nori <nsekhar@ti.com>
> 
> Curious on what you are using these registers for.

This is in response to this:
https://patchwork.kernel.org/patch/9684955/


> 
> Thanks,
> Sekhar
> 
>> ---
>>  drivers/rtc/rtc-omap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 45 insertions(+)
>>
>> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
>> index d56d937966dc..1d666ac9ef70 100644
>> --- a/drivers/rtc/rtc-omap.c
>> +++ b/drivers/rtc/rtc-omap.c
>> @@ -70,6 +70,10 @@
>>  #define OMAP_RTC_COMP_MSB_REG		0x50
>>  #define OMAP_RTC_OSC_REG		0x54
>>  
>> +#define OMAP_RTC_SCRATCH0_REG		0x60
>> +#define OMAP_RTC_SCRATCH1_REG		0x64
>> +#define OMAP_RTC_SCRATCH2_REG		0x68
>> +
>>  #define OMAP_RTC_KICK0_REG		0x6c
>>  #define OMAP_RTC_KICK1_REG		0x70
>>  
>> @@ -667,6 +671,45 @@ static struct pinctrl_desc rtc_pinctrl_desc = {
>>  	.owner = THIS_MODULE,
>>  };
>>  
>> +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));
>> +
>> +	return 0;
>> +}
>> +
>> +static int omap_rtc_scratch_write(void *priv, unsigned int offset, void *_val,
>> +				  size_t bytes)
>> +{
>> +	struct omap_rtc	*rtc = priv;
>> +	u32 *val = _val;
>> +	int i;
>> +
>> +	rtc->type->unlock(rtc);
>> +	for (i = 0; i < bytes / 4; i++)
>> +		rtc_writel(rtc,
>> +			   OMAP_RTC_SCRATCH0_REG + offset + (i * 4), val[i]);
>> +	rtc->type->lock(rtc);
>> +
>> +	return 0;
>> +}
>> +
>> +static struct nvmem_config omap_rtc_nvmem_config = {
>> +	.name = "omap_rtc_scratch",
>> +	.word_size = 4,
>> +	.stride = 4,
>> +	.size = OMAP_RTC_KICK0_REG - OMAP_RTC_SCRATCH0_REG,
>> +	.reg_read = omap_rtc_scratch_read,
>> +	.reg_write = omap_rtc_scratch_write,
>> +};
>> +
>>  static int omap_rtc_probe(struct platform_device *pdev)
>>  {
>>  	struct omap_rtc	*rtc;
>> @@ -804,6 +847,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
>>  	}
>>  
>>  	rtc->rtc->ops = &omap_rtc_ops;
>> +	omap_rtc_nvmem_config.priv = rtc;
>> +	rtc->rtc->nvmem_config = &omap_rtc_nvmem_config;
>>  
>>  	/* handle periodic and alarm irqs */
>>  	ret = devm_request_irq(&pdev->dev, rtc->irq_timer, rtc_irq, 0,
>> -- 
>> 2.15.0.rc2
>>
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-06  6:59   ` Keerthy
@ 2017-11-06  7:02     ` Sekhar Nori
  2017-11-08  6:00     ` Keerthy
  1 sibling, 0 replies; 14+ messages in thread
From: Sekhar Nori @ 2017-11-06  7:02 UTC (permalink / raw)
  To: Keerthy, Alexandre Belloni, linux-rtc; +Cc: linux-kernel, Linux OMAP List

On Monday 06 November 2017 12:29 PM, Keerthy wrote:
> 
> 
> On Monday 06 November 2017 12:25 PM, Sekhar Nori wrote:
>> + linux omap list
>>
>> On Tuesday 31 October 2017 09:57 PM, Alexandre Belloni wrote:
>>> Register an nvmem device to expose the 3 scratch registers (total of 12
>>> bytes) to both userspace and kernel space.
>>>
>>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>>
>> Looks good to me.
>>
>> Reviewed-by: Sekhar Nori <nsekhar@ti.com>
>>
>> Curious on what you are using these registers for.
> 
> This is in response to this:
> https://patchwork.kernel.org/patch/9684955/

Ah, okay. Makes sense then :)

Regards,
Sekhar

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-06  6:59   ` Keerthy
  2017-11-06  7:02     ` Sekhar Nori
@ 2017-11-08  6:00     ` Keerthy
  2017-11-08  6:27       ` Alexandre Belloni
  1 sibling, 1 reply; 14+ messages in thread
From: Keerthy @ 2017-11-08  6:00 UTC (permalink / raw)
  To: Sekhar Nori, Alexandre Belloni, linux-rtc; +Cc: linux-kernel, Linux OMAP List



On Monday 06 November 2017 12:29 PM, Keerthy wrote:
> 
> 
> On Monday 06 November 2017 12:25 PM, Sekhar Nori wrote:
>> + linux omap list
>>
>> On Tuesday 31 October 2017 09:57 PM, Alexandre Belloni wrote:
>>> Register an nvmem device to expose the 3 scratch registers (total of 12
>>> bytes) to both userspace and kernel space.
>>>
>>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>>
>> Looks good to me.
>>
>> Reviewed-by: Sekhar Nori <nsekhar@ti.com>
>>
>> Curious on what you are using these registers for.
> 
> This is in response to this:
> https://patchwork.kernel.org/patch/9684955/

Couple of minor comments below. Apart from that:

Tested-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>

> 
> 
>>
>> Thanks,
>> Sekhar
>>
>>> ---
>>>  drivers/rtc/rtc-omap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 45 insertions(+)
>>>
>>> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
>>> index d56d937966dc..1d666ac9ef70 100644
>>> --- a/drivers/rtc/rtc-omap.c
>>> +++ b/drivers/rtc/rtc-omap.c
>>> @@ -70,6 +70,10 @@
>>>  #define OMAP_RTC_COMP_MSB_REG		0x50
>>>  #define OMAP_RTC_OSC_REG		0x54
>>>  
>>> +#define OMAP_RTC_SCRATCH0_REG		0x60
>>> +#define OMAP_RTC_SCRATCH1_REG		0x64
>>> +#define OMAP_RTC_SCRATCH2_REG		0x68
>>> +
>>>  #define OMAP_RTC_KICK0_REG		0x6c
>>>  #define OMAP_RTC_KICK1_REG		0x70
>>>  
>>> @@ -667,6 +671,45 @@ static struct pinctrl_desc rtc_pinctrl_desc = {
>>>  	.owner = THIS_MODULE,
>>>  };
>>>  
>>> +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?

The above can be:
rtc_readl(rtc, OMAP_RTC_SCRATCH0_REG + (offset + i) * 4), val[i]);


>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +static int omap_rtc_scratch_write(void *priv, unsigned int offset, void *_val,
>>> +				  size_t bytes)
>>> +{
>>> +	struct omap_rtc	*rtc = priv;
>>> +	u32 *val = _val;
>>> +	int i;
>>> +
>>> +	rtc->type->unlock(rtc);
>>> +	for (i = 0; i < bytes / 4; i++)
>>> +		rtc_writel(rtc,
>>> +			   OMAP_RTC_SCRATCH0_REG + offset + (i * 4), val[i]);

The above can be:
rtc_writel(rtc, OMAP_RTC_SCRATCH0_REG + (offset + i) * 4), val[i]);

>>> +	rtc->type->lock(rtc);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +static struct nvmem_config omap_rtc_nvmem_config = {
>>> +	.name = "omap_rtc_scratch",
>>> +	.word_size = 4,
>>> +	.stride = 4,
>>> +	.size = OMAP_RTC_KICK0_REG - OMAP_RTC_SCRATCH0_REG,
>>> +	.reg_read = omap_rtc_scratch_read,
>>> +	.reg_write = omap_rtc_scratch_write,
>>> +};
>>> +
>>>  static int omap_rtc_probe(struct platform_device *pdev)
>>>  {
>>>  	struct omap_rtc	*rtc;
>>> @@ -804,6 +847,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
>>>  	}
>>>  
>>>  	rtc->rtc->ops = &omap_rtc_ops;
>>> +	omap_rtc_nvmem_config.priv = rtc;
>>> +	rtc->rtc->nvmem_config = &omap_rtc_nvmem_config;
>>>  
>>>  	/* handle periodic and alarm irqs */
>>>  	ret = devm_request_irq(&pdev->dev, rtc->irq_timer, rtc_irq, 0,
>>> -- 
>>> 2.15.0.rc2
>>>
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  6:00     ` Keerthy
@ 2017-11-08  6:27       ` Alexandre Belloni
  2017-11-08  7:08         ` Keerthy
  0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Belloni @ 2017-11-08  6:27 UTC (permalink / raw)
  To: Keerthy; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List

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

> The above can be:
> rtc_readl(rtc, OMAP_RTC_SCRATCH0_REG + (offset + i) * 4), val[i]);
> 
> 

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  6:27       ` Alexandre Belloni
@ 2017-11-08  7:08         ` Keerthy
  2017-11-08  7:16           ` Alexandre Belloni
  0 siblings, 1 reply; 14+ messages in thread
From: Keerthy @ 2017-11-08  7:08 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List



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.

Regards,
Keerthy

> 
>> The above can be:
>> rtc_readl(rtc, OMAP_RTC_SCRATCH0_REG + (offset + i) * 4), val[i]);
>>
>>
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  7:08         ` Keerthy
@ 2017-11-08  7:16           ` Alexandre Belloni
  2017-11-08  8:06             ` Keerthy
  0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Belloni @ 2017-11-08  7:16 UTC (permalink / raw)
  To: Keerthy; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List

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


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  7:16           ` Alexandre Belloni
@ 2017-11-08  8:06             ` Keerthy
  2017-11-08  8:21               ` Alexandre Belloni
  0 siblings, 1 reply; 14+ messages in thread
From: Keerthy @ 2017-11-08  8:06 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List



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?

> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  8:06             ` Keerthy
@ 2017-11-08  8:21               ` Alexandre Belloni
  2017-11-08  8:31                 ` Keerthy
  0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Belloni @ 2017-11-08  8:21 UTC (permalink / raw)
  To: Keerthy; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  8:21               ` Alexandre Belloni
@ 2017-11-08  8:31                 ` Keerthy
  2017-11-08  8:32                   ` Keerthy
  0 siblings, 1 reply; 14+ messages in thread
From: Keerthy @ 2017-11-08  8:31 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List



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
and i see that rtc_nvmem_register is not getting called.

Should we add rtc_register_device in probe of rtc-omap?

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  8:31                 ` Keerthy
@ 2017-11-08  8:32                   ` Keerthy
  2017-11-08  8:35                     ` Alexandre Belloni
  0 siblings, 1 reply; 14+ messages in thread
From: Keerthy @ 2017-11-08  8:32 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List



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?
> 
>>
>> nvmem_device_read/write are working because that is what I'm using to
>> implement the old sysfs ABI with rtc_nvram_read/write.
>>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  8:32                   ` Keerthy
@ 2017-11-08  8:35                     ` Alexandre Belloni
  2017-11-08  8:48                       ` Keerthy
  0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Belloni @ 2017-11-08  8:35 UTC (permalink / raw)
  To: Keerthy; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] rtc: omap: Support scratch registers
  2017-11-08  8:35                     ` Alexandre Belloni
@ 2017-11-08  8:48                       ` Keerthy
  0 siblings, 0 replies; 14+ messages in thread
From: Keerthy @ 2017-11-08  8:48 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Sekhar Nori, linux-rtc, linux-kernel, Linux OMAP List



On Wednesday 08 November 2017 02:05 PM, Alexandre Belloni wrote:
> 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
> 
> ?

Ah! Now everything falls in place :-). I did not receive this patch. I
believe i need to add a patch so linux-omap list gets Cc'd whenever
rtc-omap driver is touched.

Thanks a bunch!

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-11-08  8:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 16:27 [PATCH] rtc: omap: Support scratch registers Alexandre Belloni
2017-11-06  6:55 ` Sekhar Nori
2017-11-06  6:59   ` Keerthy
2017-11-06  7:02     ` Sekhar Nori
2017-11-08  6:00     ` Keerthy
2017-11-08  6:27       ` Alexandre Belloni
2017-11-08  7:08         ` Keerthy
2017-11-08  7:16           ` Alexandre Belloni
2017-11-08  8:06             ` Keerthy
2017-11-08  8:21               ` Alexandre Belloni
2017-11-08  8:31                 ` Keerthy
2017-11-08  8:32                   ` Keerthy
2017-11-08  8:35                     ` Alexandre Belloni
2017-11-08  8:48                       ` Keerthy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).