From: Tony Lindgren <tony@atomide.com>
To: Dmitry Krivoschekov <dmitry.krivoschekov@gmail.com>
Cc: "Pakaravoor, Jagadeesh" <j-pakaravoor@ti.com>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH resend v2] TWL4030-RTC: Fix the broken functionality
Date: Tue, 9 Sep 2008 10:44:35 -0700 [thread overview]
Message-ID: <20080909174434.GS29054@atomide.com> (raw)
In-Reply-To: <48B2A600.2060406@gmail.com>
* Dmitry Krivoschekov <dmitry.krivoschekov@gmail.com> [080825 05:31]:
> Pakaravoor, Jagadeesh wrote:
> > From: Jagadeesh Bhaskar Pakaravoor <j-pakaravoor@ti.com>
> >
> > rtc_irq_set_freq() function takes only powers of 2 as a valid
> > argument. This stipulates that an ioctl call on /dev/rtc0
> > can accept values of 1,2,4 and 8 only. But the function
> > twl4030_rtc_irq_set_freq() takes only values 0-3. RTC_INTERRUPTS_REG
> > of TWL4030 also requires value in the range 0-3 for the interrupt
> > period. Hence it is required to map the argument from the powers of 2,
> > to the corresponding numbers 0-3, via a call to ilog2.
> >
> Note, the rtc_irq_set_freq() function accepts a frequency measured in
> Hz. That is, those values (1,2,4 and 8) should be interpreted as 1Hz,
> 2Hz, 4Hz and 8Hz while you consider them as 1 == 1 sec period, 2 == 1
> minute period, 4 == 1 hour period and 8 == 1 day period, that is wrong.
>
> Yes, TWL4030 RTC has the capability to set only those four periods which
> does not fit well to periodic IRQ concept of RTC framework. But it does
> not mean you can violate a common concept of periodic IRQs.
>
> The patch might be acceptable as a temporary workaround, but obviously
> it won't be accepted in mainline, as well as commit
> 7ef9abe1e9cf53c2dd7556f12d35b06053847f72 which has introduced periodic
> IRQ functionality to rtc-twl4030 driver.
Sounds like this still needs work, so not pushing.
Tony
>
>
> Thanks,
> Dmitry
>
> > Signed-off-by: Jagadeesh Bhaskar Pakaravoor <j-pakaravoor@ti.com>
> > ---
> > Fixing a bug in the last patch: argument to set_rtc_irq_bit()
> > function should have been "value" instead of "freq".
> > Index: my-local-git-dir/drivers/rtc/rtc-twl4030.c
> > ===================================================================
> > --- my-local-git-dir.orig/drivers/rtc/rtc-twl4030.c 2008-08-22 17:37:33.000000000 +0530
> > +++ my-local-git-dir/drivers/rtc/rtc-twl4030.c 2008-08-22 19:25:41.616786397 +0530
> > @@ -38,6 +38,7 @@
> > #include <linux/i2c/twl4030-rtc.h>
> > #include <linux/io.h>
> > #include <linux/irq.h>
> > +#include <linux/log2.h>
> >
> > #include <asm/mach/time.h>
> > #include <asm/system.h>
> > @@ -363,14 +364,26 @@ out:
> > static int twl4030_rtc_irq_set_freq(struct device *dev, int freq)
> > {
> > struct rtc_device *rtc = dev_get_drvdata(dev);
> > + u8 value;
> >
> > - if (freq < 0 || freq > 3)
> > + /* RTC_INTERRUPTS_REG takes the value of 0 for interrupts every
> > + * second, 1 for every minute, 2 every hour and 3 every day.
> > + * But freq is in 2^N format, which needs to be converted back.
> > + */
> > + value = ilog2(freq);
> > + if (value < 0 || value > 3)
> > return -EINVAL;
> >
> > - rtc->irq_freq = freq;
> > + rtc->irq_freq = value;
> > +
> > + /* Clear the current periodicity of irq*/
> > + mask_rtc_irq_bit(0x3);
> >
> > - /* set rtc irq freq to user defined value */
> > - set_rtc_irq_bit(freq);
> > + /* If the new value is non-zero, set the new periodicity */
> > + if (value) {
> > + /* set rtc irq freq to user defined value */
> > + set_rtc_irq_bit(value);
> > + }
> >
> > return 0;
> > }
> >
> > --
> > With Regards,
> > Jagadeesh Bhaskar P
> >
> > ----------------------------
> > Some men see things as they are and say why - I dream things that never were and say why not.
> > - George Bernard Shaw
> > -------------------
> > --
> > 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
> >
>
> --
> 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
next prev parent reply other threads:[~2008-09-09 17:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-25 9:51 [PATCH resend v2] TWL4030-RTC: Fix the broken functionality Pakaravoor, Jagadeesh
2008-08-25 12:30 ` Dmitry Krivoschekov
2008-09-09 17:44 ` Tony Lindgren [this message]
2008-09-09 18:35 ` David Brownell
2008-09-09 19:16 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080909174434.GS29054@atomide.com \
--to=tony@atomide.com \
--cc=dmitry.krivoschekov@gmail.com \
--cc=j-pakaravoor@ti.com \
--cc=linux-omap@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox