mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-07 14:54:52 +00:00
nuc900/rtc: change the waiting for device ready implement
- add an mdelay(1) to the polling loop to cause less frequent access to the hardware register. - change the return value from ENODEV to EPERM if the loop timed out. I think the 'Operation not permitted' description is more suitable for the meaning of 'check_rtc_access_enable()' function, it just be used to judge rtc access operation is permitted or not. Signed-off-by: Wan ZongShun <mcuos.com@gmail.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
5fc79d85d2
commit
0a89b55364
1 changed files with 7 additions and 8 deletions
|
@ -85,22 +85,21 @@ static irqreturn_t nuc900_rtc_interrupt(int irq, void *_rtc)
|
||||||
|
|
||||||
static int *check_rtc_access_enable(struct nuc900_rtc *nuc900_rtc)
|
static int *check_rtc_access_enable(struct nuc900_rtc *nuc900_rtc)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i, timeout = 0x1000;
|
||||||
__raw_writel(INIRRESET, nuc900_rtc->rtc_reg + REG_RTC_INIR);
|
__raw_writel(INIRRESET, nuc900_rtc->rtc_reg + REG_RTC_INIR);
|
||||||
|
|
||||||
mdelay(10);
|
mdelay(10);
|
||||||
|
|
||||||
__raw_writel(AERPOWERON, nuc900_rtc->rtc_reg + REG_RTC_AER);
|
__raw_writel(AERPOWERON, nuc900_rtc->rtc_reg + REG_RTC_AER);
|
||||||
|
|
||||||
for (i = 0; i < 1000; i++) {
|
while (!(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
|
||||||
if (__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
|
&& timeout--)
|
||||||
return 0;
|
mdelay(1);
|
||||||
}
|
|
||||||
|
|
||||||
if ((__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB) == 0x0)
|
if (!timeout)
|
||||||
return ERR_PTR(-ENODEV);
|
return ERR_PTR(-EPERM);
|
||||||
|
|
||||||
return ERR_PTR(-EPERM);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nuc900_rtc_bcd2bin(unsigned int timereg,
|
static void nuc900_rtc_bcd2bin(unsigned int timereg,
|
||||||
|
|
Loading…
Add table
Reference in a new issue