Author: quozl Date: Mon Nov 28 06:37:17 2011 New Revision: 2706 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2706
Log: OLPC XO-1.75 - synchronise EC flags flash page when reprogramming manufacturing tags #11493 (thanks to Mitch for initial design on 22nd August), and fix flash-ec which was failing if any flags were set.
Modified: cpu/arm/olpc/1.75/ecflash.fth cpu/arm/olpc/1.75/edi.fth cpu/x86/pc/olpc/setwp.fth
Modified: cpu/arm/olpc/1.75/ecflash.fth ============================================================================== --- cpu/arm/olpc/1.75/ecflash.fth Mon Nov 28 01:05:38 2011 (r2705) +++ cpu/arm/olpc/1.75/ecflash.fth Mon Nov 28 06:37:17 2011 (r2706) @@ -36,6 +36,25 @@ ; \ Tells the EC to auto-restart after power cycling : set-ec-reboot ( -- ) 1 h# f018 edi-b! ; +: ?reflash-ec-flags ( adr -- ) + use-edi-spi ( adr ) + spi-start ( adr ) \ avoids holding EC in reset + load-base /flash-page ec-flags-offset edi-read-flash ( adr ) + dup load-base /flash-page comp ( adr different? ) + if + edi-open ( adr ) + hdd-led-on ( adr ) + ec-flags-offset erase-page ( adr ) + ec-flags-offset edi-program-page ( ) + hdd-led-off + set-ec-reboot + unreset-8051 \ should not return + ec-power-cycle + then + drop ( ) + use-ssp-spi +; +: ignore-ec-flags ( adr -- ) ec-flags-offset + /flash-page erase ; : reflash-ec hdd-led-on [ifdef] cl2-a1 @@ -50,13 +69,14 @@ ." Verifying ..." load-base /ec-flash + /ec-flash 0 edi-read-flash [then] + load-base ignore-ec-flags + load-base /ec-flash + ignore-ec-flags load-base load-base /ec-flash + /ec-flash comp abort" Miscompare!" cr hdd-led-off [ifndef] cl2-a1 ." Restarting EC and rebooting" cr - d# 2000 ms set-ec-reboot unreset-8051 [then]
Modified: cpu/arm/olpc/1.75/edi.fth ============================================================================== --- cpu/arm/olpc/1.75/edi.fth Mon Nov 28 01:05:38 2011 (r2705) +++ cpu/arm/olpc/1.75/edi.fth Mon Nov 28 06:37:17 2011 (r2706) @@ -69,6 +69,7 @@ ; : unreset-8051 ( -- ) \ Reset 8-5 h# f010 edi-b@ 1 invert and h# f010 edi-b! + d# 2000 ms ;
\ 0 in bit 0 selects masked ROM as code source for 8051, 1 selects FLASH
Modified: cpu/x86/pc/olpc/setwp.fth ============================================================================== --- cpu/x86/pc/olpc/setwp.fth Mon Nov 28 01:05:38 2011 (r2705) +++ cpu/x86/pc/olpc/setwp.fth Mon Nov 28 06:37:17 2011 (r2706) @@ -33,17 +33,48 @@ \ Set and clear the write-protect tag by copying, erasing, rewriting
: (put-mfg-data) + hdd-led-on mfg-data-buf mfg-data-end-offset mfg-data-offset write-flash-range + hdd-led-off ;
: ram-find-tag ( name$ -- false | data$ true ) mfg-data-buf /flash-block + (find-tag) ;
+\ FIXME: ifdef XO-1.75 + +: set-cp ( adr -- ) + " CP" find-tag if ( adr len ) + 2drop [char] C ( expected ) + else ( ) + 0 ( expected ) + then ( expected ) + swap c! ( ) +; + +: set-ap ( adr -- ) + " AP" find-tag if ( adr len ) + 2drop [char] A ( expected ) + else ( ) + 0 ( expected ) + then ( expected ) + swap 1+ c! ( ) +; + +/flash-page buffer: ec-flags-buf +: ?sync-ec ( -- ) + ec-flags-buf /flash-page erase + ec-flags-buf set-cp + ec-flags-buf set-ap + ec-flags-buf ?reflash-ec-flags +; + \ Write mfg data from RAM to FLASH : put-mfg-data ( -- ) spi-start spi-identify (put-mfg-data) + ?sync-ec spi-reprogrammed ;
openfirmware@openfirmware.info