Message ID | 1412881594-25678-8-git-send-email-johan@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Oct 09, 2014 at 09:06:29PM +0200, Johan Hovold wrote: > Some legacy RTC IP revisions has a power-up reset flag in the status > register that later revisions lack. > > As this flag is always read back as set on later revisions (or is > overloaded with a different flag), make sure to only clear the flag and > print the info message on legacy platforms. > > Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Felipe Balbi <balbi@ti.com> > --- > drivers/rtc/rtc-omap.c | 23 +++++++++++++++++------ > 1 file changed, 17 insertions(+), 6 deletions(-) > > diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c > index 1c58920b0c88..0ef016553a97 100644 > --- a/drivers/rtc/rtc-omap.c > +++ b/drivers/rtc/rtc-omap.c > @@ -118,6 +118,12 @@ > */ > #define OMAP_RTC_HAS_32KCLK_EN BIT(2) > > +/* > + * Some legacy RTC IP revisions has a power-up reset flag which later > + * revisions lack. > + */ > +#define OMAP_RTC_HAS_POWER_UP_RESET BIT(3) > + > static void __iomem *rtc_base; > > #define rtc_read(addr) readb(rtc_base + (addr)) > @@ -347,6 +353,7 @@ static int omap_rtc_timer; > static struct platform_device_id omap_rtc_devtype[] = { > { > .name = DRIVER_NAME, > + .driver_data = OMAP_RTC_HAS_POWER_UP_RESET, > }, > [OMAP_RTC_DATA_AM3352_IDX] = { > .name = "am3352-rtc", > @@ -376,7 +383,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev) > { > struct resource *res; > struct rtc_device *rtc; > - u8 reg, new_ctrl; > + u8 reg, mask, new_ctrl; > const struct platform_device_id *id_entry; > const struct of_device_id *of_id; > > @@ -429,12 +436,16 @@ static int __init omap_rtc_probe(struct platform_device *pdev) > > /* clear old status */ > reg = rtc_read(OMAP_RTC_STATUS_REG); > - if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) { > - dev_info(&pdev->dev, "RTC power up reset detected\n"); > - rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG); > + > + mask = OMAP_RTC_STATUS_ALARM; > + if (id_entry->driver_data & OMAP_RTC_HAS_POWER_UP_RESET) { > + mask |= OMAP_RTC_STATUS_POWER_UP; > + if (reg & OMAP_RTC_STATUS_POWER_UP) > + dev_info(&pdev->dev, "RTC power up reset detected\n"); > } > - if (reg & (u8) OMAP_RTC_STATUS_ALARM) > - rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); > + > + if (reg & mask) > + rtc_write(reg & mask, OMAP_RTC_STATUS_REG); > > /* handle periodic and alarm irqs */ > if (devm_request_irq(&pdev->dev, omap_rtc_timer, rtc_irq, 0, > -- > 2.0.4 >
On Fri, Oct 10, 2014 at 01:00:54PM -0500, Felipe Balbi wrote: > On Thu, Oct 09, 2014 at 09:06:29PM +0200, Johan Hovold wrote: > > Some legacy RTC IP revisions has a power-up reset flag in the status > > register that later revisions lack. > > > > As this flag is always read back as set on later revisions (or is > > overloaded with a different flag), make sure to only clear the flag and > > print the info message on legacy platforms. > > > > Signed-off-by: Johan Hovold <johan@kernel.org> > > Reviewed-by: Felipe Balbi <balbi@ti.com> oh, btw. This should be done for DT probes too.
On Fri, Oct 10, 2014 at 01:02:56PM -0500, Felipe Balbi wrote: > On Fri, Oct 10, 2014 at 01:00:54PM -0500, Felipe Balbi wrote: > > On Thu, Oct 09, 2014 at 09:06:29PM +0200, Johan Hovold wrote: > > > Some legacy RTC IP revisions has a power-up reset flag in the status > > > register that later revisions lack. > > > > > > As this flag is always read back as set on later revisions (or is > > > overloaded with a different flag), make sure to only clear the flag and > > > print the info message on legacy platforms. > > > > > > Signed-off-by: Johan Hovold <johan@kernel.org> > > > > Reviewed-by: Felipe Balbi <balbi@ti.com> > > oh, btw. This should be done for DT probes too. What do you mean? This is for DT probes (of "ti,da830-rtc" and "ti,am3352-rtc"). DT probing of legacy RTC IPs is currently not supported. Are you suggesting I should add a new compatible string for that? Johan
Hi, On Sat, Oct 11, 2014 at 12:20:04PM +0200, Johan Hovold wrote: > On Fri, Oct 10, 2014 at 01:02:56PM -0500, Felipe Balbi wrote: > > On Fri, Oct 10, 2014 at 01:00:54PM -0500, Felipe Balbi wrote: > > > On Thu, Oct 09, 2014 at 09:06:29PM +0200, Johan Hovold wrote: > > > > Some legacy RTC IP revisions has a power-up reset flag in the status > > > > register that later revisions lack. > > > > > > > > As this flag is always read back as set on later revisions (or is > > > > overloaded with a different flag), make sure to only clear the flag and > > > > print the info message on legacy platforms. > > > > > > > > Signed-off-by: Johan Hovold <johan@kernel.org> > > > > > > Reviewed-by: Felipe Balbi <balbi@ti.com> > > > > oh, btw. This should be done for DT probes too. > > What do you mean? This is for DT probes (of "ti,da830-rtc" and > "ti,am3352-rtc"). DT probing of legacy RTC IPs is currently not > supported. > > Are you suggesting I should add a new compatible string for that? it seemed to me that you're only passing the new flag through platform_device_id table, not DT table. Did I miss something ?
On Sat, Oct 11, 2014 at 07:50:07PM -0500, Felipe Balbi wrote: > Hi, > > On Sat, Oct 11, 2014 at 12:20:04PM +0200, Johan Hovold wrote: > > On Fri, Oct 10, 2014 at 01:02:56PM -0500, Felipe Balbi wrote: > > > On Fri, Oct 10, 2014 at 01:00:54PM -0500, Felipe Balbi wrote: > > > > On Thu, Oct 09, 2014 at 09:06:29PM +0200, Johan Hovold wrote: > > > > > Some legacy RTC IP revisions has a power-up reset flag in the status > > > > > register that later revisions lack. > > > > > > > > > > As this flag is always read back as set on later revisions (or is > > > > > overloaded with a different flag), make sure to only clear the flag and > > > > > print the info message on legacy platforms. > > > > > > > > > > Signed-off-by: Johan Hovold <johan@kernel.org> > > > > > > > > Reviewed-by: Felipe Balbi <balbi@ti.com> > > > > > > oh, btw. This should be done for DT probes too. > > > > What do you mean? This is for DT probes (of "ti,da830-rtc" and > > "ti,am3352-rtc"). DT probing of legacy RTC IPs is currently not > > supported. > > > > Are you suggesting I should add a new compatible string for that? > > it seemed to me that you're only passing the new flag through > platform_device_id table, not DT table. Did I miss something ? Ah, that's just the way the driver currently encodes the IP revision differences. The platform_device_id entries are references from of_device_id data. Should probably clean that up as well. Thanks again for the review. I'll post a new version when I'm back from Düsseldorf and ELC-E/Plumbers. Johan
Hi, On Sun, Oct 12, 2014 at 08:42:40PM +0200, Johan Hovold wrote: > On Sat, Oct 11, 2014 at 07:50:07PM -0500, Felipe Balbi wrote: > > Hi, > > > > On Sat, Oct 11, 2014 at 12:20:04PM +0200, Johan Hovold wrote: > > > On Fri, Oct 10, 2014 at 01:02:56PM -0500, Felipe Balbi wrote: > > > > On Fri, Oct 10, 2014 at 01:00:54PM -0500, Felipe Balbi wrote: > > > > > On Thu, Oct 09, 2014 at 09:06:29PM +0200, Johan Hovold wrote: > > > > > > Some legacy RTC IP revisions has a power-up reset flag in the status > > > > > > register that later revisions lack. > > > > > > > > > > > > As this flag is always read back as set on later revisions (or is > > > > > > overloaded with a different flag), make sure to only clear the flag and > > > > > > print the info message on legacy platforms. > > > > > > > > > > > > Signed-off-by: Johan Hovold <johan@kernel.org> > > > > > > > > > > Reviewed-by: Felipe Balbi <balbi@ti.com> > > > > > > > > oh, btw. This should be done for DT probes too. > > > > > > What do you mean? This is for DT probes (of "ti,da830-rtc" and > > > "ti,am3352-rtc"). DT probing of legacy RTC IPs is currently not > > > supported. > > > > > > Are you suggesting I should add a new compatible string for that? > > > > it seemed to me that you're only passing the new flag through > > platform_device_id table, not DT table. Did I miss something ? > > Ah, that's just the way the driver currently encodes the IP revision > differences. The platform_device_id entries are references from > of_device_id data. Should probably clean that up as well. oh, alright :-) > Thanks again for the review. I'll post a new version when I'm back from no problem.
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 1c58920b0c88..0ef016553a97 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -118,6 +118,12 @@ */ #define OMAP_RTC_HAS_32KCLK_EN BIT(2) +/* + * Some legacy RTC IP revisions has a power-up reset flag which later + * revisions lack. + */ +#define OMAP_RTC_HAS_POWER_UP_RESET BIT(3) + static void __iomem *rtc_base; #define rtc_read(addr) readb(rtc_base + (addr)) @@ -347,6 +353,7 @@ static int omap_rtc_timer; static struct platform_device_id omap_rtc_devtype[] = { { .name = DRIVER_NAME, + .driver_data = OMAP_RTC_HAS_POWER_UP_RESET, }, [OMAP_RTC_DATA_AM3352_IDX] = { .name = "am3352-rtc", @@ -376,7 +383,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev) { struct resource *res; struct rtc_device *rtc; - u8 reg, new_ctrl; + u8 reg, mask, new_ctrl; const struct platform_device_id *id_entry; const struct of_device_id *of_id; @@ -429,12 +436,16 @@ static int __init omap_rtc_probe(struct platform_device *pdev) /* clear old status */ reg = rtc_read(OMAP_RTC_STATUS_REG); - if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) { - dev_info(&pdev->dev, "RTC power up reset detected\n"); - rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG); + + mask = OMAP_RTC_STATUS_ALARM; + if (id_entry->driver_data & OMAP_RTC_HAS_POWER_UP_RESET) { + mask |= OMAP_RTC_STATUS_POWER_UP; + if (reg & OMAP_RTC_STATUS_POWER_UP) + dev_info(&pdev->dev, "RTC power up reset detected\n"); } - if (reg & (u8) OMAP_RTC_STATUS_ALARM) - rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); + + if (reg & mask) + rtc_write(reg & mask, OMAP_RTC_STATUS_REG); /* handle periodic and alarm irqs */ if (devm_request_irq(&pdev->dev, omap_rtc_timer, rtc_irq, 0,
Some legacy RTC IP revisions has a power-up reset flag in the status register that later revisions lack. As this flag is always read back as set on later revisions (or is overloaded with a different flag), make sure to only clear the flag and print the info message on legacy platforms. Signed-off-by: Johan Hovold <johan@kernel.org> --- drivers/rtc/rtc-omap.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)