UPSTREAM: rtc: Check update-in-progress bit
While the real-time clock updates its count, values may not be correctly read or written. On reads, ensure the UIP bit is clear which guarantees a minimum of 244 microseconds exists before the update begins. Writes already avoid the problem by disabling the RTC count via the SET bit. BUG=None BRANCH=None TEST=None Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Reviewed-on: https://review.coreboot.org/17369 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Change-Id: I39e34493113015d32582f1c280fafa9e97f43a40 Reviewed-on: https://chromium-review.googlesource.com/412852 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
d722ad983a
commit
ae1dc9a24d
2 changed files with 12 additions and 0 deletions
|
|
@ -112,6 +112,16 @@ static inline unsigned char cmos_read(unsigned char addr)
|
|||
return inb(RTC_BASE_PORT + offs + 1);
|
||||
}
|
||||
|
||||
/* Upon return the caller is guaranteed 244 microseconds to complete any
|
||||
* RTC operations. wait_uip may be called a single time prior to multiple
|
||||
* accesses, but sequences requiring more time should call wait_uip again.
|
||||
*/
|
||||
static inline void wait_uip(void)
|
||||
{
|
||||
while (cmos_read(RTC_REG_A) & RTC_UIP)
|
||||
;
|
||||
}
|
||||
|
||||
static inline void cmos_write_inner(unsigned char val, unsigned char addr)
|
||||
{
|
||||
int offs = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue