bcm: cleanup clock code
- disable local clock on interrupt to prevent accidents when reenabling - always regitster local clock interrupt handler, even for cpu0 - simplify microdelay() - don't mess with watchdog
This commit is contained in:
parent
f17a5cc2cf
commit
0fc2adb43d
1 changed files with 7 additions and 15 deletions
|
@ -98,7 +98,7 @@ localclockintr(Ureg *ureg, void *)
|
||||||
{
|
{
|
||||||
if(m->machno == 0)
|
if(m->machno == 0)
|
||||||
panic("cpu0: Unexpected local generic timer interrupt");
|
panic("cpu0: Unexpected local generic timer interrupt");
|
||||||
cpwrsc(0, CpTIMER, CpTIMERphys, CpTIMERphysctl, Imask|Enable);
|
cpwrsc(0, CpTIMER, CpTIMERphys, CpTIMERphysctl, Imask);
|
||||||
timerintr(ureg, 0);
|
timerintr(ureg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +109,6 @@ clockshutdown(void)
|
||||||
|
|
||||||
tm = (Armtimer*)ARMTIMER;
|
tm = (Armtimer*)ARMTIMER;
|
||||||
tm->ctl = 0;
|
tm->ctl = 0;
|
||||||
if(cpuserver)
|
|
||||||
wdogfeed();
|
|
||||||
else
|
|
||||||
wdogoff();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -129,6 +125,7 @@ clockinit(void)
|
||||||
*(ulong*)(ARMLOCAL + Prescaler) = 0x06aaaaab; /* divide by (2^31/Prescaler) for 1Mhz */
|
*(ulong*)(ARMLOCAL + Prescaler) = 0x06aaaaab; /* divide by (2^31/Prescaler) for 1Mhz */
|
||||||
}
|
}
|
||||||
cpwrsc(0, CpTIMER, CpTIMERphys, CpTIMERphysctl, Imask);
|
cpwrsc(0, CpTIMER, CpTIMERphys, CpTIMERphysctl, Imask);
|
||||||
|
intrenable(IRQcntpns, localclockintr, nil, 0, "clock");
|
||||||
}
|
}
|
||||||
|
|
||||||
tn = (Systimers*)SYSTIMERS;
|
tn = (Systimers*)SYSTIMERS;
|
||||||
|
@ -150,8 +147,7 @@ clockinit(void)
|
||||||
tm->load = 0;
|
tm->load = 0;
|
||||||
tm->ctl = TmrPrescale1|CntEnable|CntWidth32;
|
tm->ctl = TmrPrescale1|CntEnable|CntWidth32;
|
||||||
intrenable(IRQtimer3, clockintr, nil, 0, "clock");
|
intrenable(IRQtimer3, clockintr, nil, 0, "clock");
|
||||||
}else
|
}
|
||||||
intrenable(IRQcntpns, localclockintr, nil, 0, "clock");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -230,14 +226,10 @@ ulong
|
||||||
void
|
void
|
||||||
microdelay(int n)
|
microdelay(int n)
|
||||||
{
|
{
|
||||||
Systimers *tn;
|
ulong now;
|
||||||
u32int now, diff;
|
|
||||||
|
|
||||||
diff = n + 1;
|
now = µs();
|
||||||
tn = (Systimers*)SYSTIMERS;
|
while(µs() - now < n);
|
||||||
now = tn->clo;
|
|
||||||
while(tn->clo - now < diff)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue