From: rajeev-dlh.kumar@st.com (rajeev)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH resend] rtc: Adding support for spear rtc
Date: Thu, 28 Apr 2011 11:11:04 +0530 [thread overview]
Message-ID: <4DB8FDF0.5070604@st.com> (raw)
In-Reply-To: <20110425152117.424cdba1.akpm@linux-foundation.org>
On 4/26/2011 3:51 AM, Andrew Morton wrote:
> On Mon, 25 Apr 2011 17:00:26 +0530
> Viresh Kumar <viresh.kumar@st.com> wrote:
>> From: Rajeev Kumar <rajeev-dlh.kumar@st.com>
>> +static void rtc_wait_not_busy(struct spear_rtc_config *config)
>> +{
>> + int status, count = 0;
>> + unsigned long flags;
>> +
>> + /* Assuming BUSY may stay active for 80 msec) */
>> + for (count = 0; count < 80; count++) {
>> + spin_lock_irqsave(&config->lock, flags);
>> + status = readl(config->ioaddr + STATUS_REG);
>> + spin_unlock_irqrestore(&config->lock, flags);
>> + if ((status & STATUS_BUSY) == 0)
>> + break;
>> + /* check status busy, after each msec */
>> + msleep(1);
>> + }
>> +}
>
> Question. What activity causes STATUS_BUSY to become set?
>
STATUS_BUSY is (PD | PT), where
[3] PD: Pending write to Date register.
[2] PT: Pending write to Time register.
So, when we have updated date and time, these bits ensures that date and time
are actually written in h/w.
>>
>> ...
>>
>> +static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm)
>> +{
>> + struct platform_device *pdev = to_platform_device(dev);
>> + struct rtc_device *rtc = platform_get_drvdata(pdev);
>> + struct spear_rtc_config *config = dev_get_drvdata(&rtc->dev);
>> + unsigned int time, date;
>> +
>> + /* we don't report wday/yday/isdst ... */
>> + rtc_wait_not_busy(config);
>
> Because here, we've waited for STATUS_BUSY to clear, but we don't
> appear to have taken any steps to prevent it from getting set again
> while these steps:
>
>> + time = readl(config->ioaddr + TIME_REG);
>> + date = readl(config->ioaddr + DATE_REG);
>> + tm->tm_sec = (time >> SECOND_SHIFT) & SECOND_MASK;
>> + tm->tm_min = (time >> MINUTE_SHIFT) & MIN_MASK;
>> + tm->tm_hour = (time >> HOUR_SHIFT) & HOUR_MASK;
>> + tm->tm_mday = (date >> MDAY_SHIFT) & DAY_MASK;
>> + tm->tm_mon = (date >> MONTH_SHIFT) & MONTH_MASK;
>> + tm->tm_year = (date >> YEAR_SHIFT) & YEAR_MASK;
>
> are in progress?
>
Because, we haven't written anything to date and time regs and so BUSY will not
be set again during these steps.
Best Rgds
Rajeev
prev parent reply other threads:[~2011-04-28 5:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-25 11:30 [PATCH resend] rtc: Adding support for spear rtc Viresh Kumar
2011-04-25 22:21 ` Andrew Morton
2011-04-28 5:41 ` rajeev [this message]
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=4DB8FDF0.5070604@st.com \
--to=rajeev-dlh.kumar@st.com \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.