Changeset 3634


Ignore:
Timestamp:
Apr 2, 2013, 4:49:01 AM (2 years ago)
Author:
quozl
Message:

OLPC XO-1.75 XO-4 - rely on the RTC register oscillator stop flag to signal when to reinitialise the data. However, already manufactured laptops do not have the oscillator stop flag in the RTC registers cleared, so detect these by absence of a "cv" tag, and add the tag once the flag has been reset.

Location:
cpu/arm/olpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpu/arm/olpc/build-fw.fth

    r3623 r3634  
    222222fload ${BP}/dev/olpc/spiflash/spiui.fth      \ User interface for SPI FLASH programming
    223223\ fload ${BP}/dev/olpc/spiflash/recover.fth    \ XO-to-XO SPI FLASH recovery
     224
     225\ This must be defined after spiui.fth,
     226\ otherwise spiui will choose some wrong code
     227: rom-pa  ( -- adr )  mfg-data-buf mfg-data-offset -  ;  \ Fake out setwp.fth
     228fload ${BP}/cpu/x86/pc/olpc/setwp.fth
     229
    224230: ofw-fw-filename$  " disk:\boot\olpc.rom"  ;
    225231' ofw-fw-filename$ to fw-filename$
     
    322328   \ use RTC 32kHz clock as SoC external slow clock
    323329   h# 38 mpmu@ 1 or h# 38 mpmu!
     330   \ if the clock valid tag is absent, clear the stop flag and add the tag
     331   " cv" find-tag  0=  if
     332      ." RTC oscillator stop flag one-off wipe (no cv tag)" cr
     333      " unstop" clock-node @ $call-method
     334      " "(00)" " cv" $add-tag \ a reboot expected here
     335      begin wfi again
     336   then
     337   2drop
     338   \ check the clock stop flag and reinit if necessary
     339   " verify" clock-node @ $call-method
    324340;
    325341
     
    590606' linux-hook-emmc to linux-hook
    591607[then]
    592 
    593 \ This must be defined after spiui.fth, otherwise spiui will choose some wrong code
    594 : rom-pa  ( -- adr )  mfg-data-buf mfg-data-offset -  ;  \ Fake out setwp.fth
    595 fload ${BP}/cpu/x86/pc/olpc/setwp.fth
    596608
    597609fload ${BP}/cpu/arm/olpc/help.fth
  • cpu/arm/olpc/rtc.fth

    r3631 r3634  
    1313headerless
    1414
    15 : reinit
     15\ if the oscillator stop flag is set the RTC counter and RTC SRAM
     16\ contents cannot be trusted.
     17
     18: stopped?  ( -- stopped? )  \ check the oscillator stop flag
     19   7 rtc@ h# 20 and
     20;
     21
     22: unstop  ( -- )  \ clear the oscillator stop flag
     23   7 rtc@ h# 20 invert and 7 rtc!
     24;
     25
     26: reinit  \ reinitialise the RTC counter
    1627   h# 20 h#  8 rtc! \ century
    1728   h# 13 h#  6 rtc! \ year
     
    2536;
    2637
    27 : ?clear
    28    h# 3f rtc@  h# 3e rtc@  bwjoin  h# 55aa  <>  if
    29       h# 20 h# 10  do  0 i rtc!  loop  \ wipe cmos@ cmos! area
    30       h# 55aa  wbsplit  h# 3e rtc!  h# 3f rtc!
    31       ." RTC SRAM cleared" cr
    32    then
     38h# 55aa value sram-marker  \ our magic marker for RTC SRAM
     39
     40: sram-corrupt?  ( -- corrupt? )  \ is the RTC SRAM corrupt?
     41   h# 3f rtc@  h# 3e rtc@  bwjoin  sram-marker  <>
     42;
     43
     44: sram-reinit  ( -- )  \ reinitialise the RTC SRAM
     45   h# 20 h# 10  do  0 i rtc!  loop  \ wipe cmos@ cmos! area
     46   sram-marker  wbsplit  h# 3e rtc!  h# 3f rtc!
     47   ." RTC SRAM cleared" cr
    3348;
    3449
    3550headers
     51: verify  ( -- )  \ check RTC for loss of data and reinitialise if so
     52   stopped?  if
     53      \ RTC says data is lost
     54      [ifndef] olpc-cl2  reinit  [then]  \ requested by Daniel Drake
     55      unstop
     56   then
     57   sram-corrupt?  if  sram-reinit  reinit  then
     58;
     59
    3660: open  ( -- okay )
    3761   my-unit " set-address" $call-parent
     
    5276      drop true                ( true )
    5377   then                        ( okay? )
    54 
    55    \ check and clear the oscillator stop flag
    56    7 rtc@ h# 20 and  if
    57       reinit
    58       7 rtc@ h# 20 invert and 7 rtc!
    59    then
    60 
    61    \ manage legacy RTC CMOS usage
    62    ?clear
    6378
    6479   \ enable 32kHz clock output
Note: See TracChangeset for help on using the changeset viewer.