[openfirmware] r1223 - cpu/x86/pc cpu/x86/pc/olpc/via dev/olpc/dcon dev/via/unichrome

svn at openfirmware.info svn at openfirmware.info
Thu Jun 25 23:15:53 CEST 2009


Author: wmb
Date: 2009-06-25 23:15:53 +0200 (Thu, 25 Jun 2009)
New Revision: 1223

Modified:
   cpu/x86/pc/linux.fth
   cpu/x86/pc/olpc/via/addrs.fth
   cpu/x86/pc/olpc/via/config.fth
   cpu/x86/pc/olpc/via/fw.bth
   cpu/x86/pc/olpc/via/ioinit.fth
   cpu/x86/pc/olpc/via/olpc.bth
   cpu/x86/pc/olpc/via/resume.bth
   cpu/x86/pc/olpc/via/romreset.bth
   cpu/x86/pc/olpc/via/suspend.fth
   cpu/x86/pc/olpc/via/versions.fth
   dev/olpc/dcon/viadcon.fth
   dev/via/unichrome/unichrome.fth
Log:
Via checkpoint - suspend/resume works, ACPI starting to get there



Modified: cpu/x86/pc/linux.fth
===================================================================
--- cpu/x86/pc/linux.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/linux.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -146,7 +146,7 @@
 ;
 
 \ If we are running in physical address mode, make a page directory
-\ that will map up when the kernel turns on paging.
+\ that will map us when the kernel turns on paging.
 [ifdef] fw-map-limit
 : v=p-pde  ( adr -- )
    dup h# 83 or  cr3@  rot d# 22 rshift la+  l!

Modified: cpu/x86/pc/olpc/via/addrs.fth
===================================================================
--- cpu/x86/pc/olpc/via/addrs.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/addrs.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -50,24 +50,27 @@
 
 h# d000.0000 constant fb-pci-base
 h# f000.0000 constant gfx-pci-base
-h# fe01.a000 constant ohci-pci-base
-h# fe01.b000 constant ehci-pci-base
-h# fe02.4000 constant sd-pci-base
-h# fe02.8000 constant camera-pci-base
-h# fec0.0000 constant io-apic-mmio-base
+\ h# fe01.a000 constant ohci-pci-base
+\ h# fe01.b000 constant ehci-pci-base
+\ h# fe02.4000 constant sd-pci-base
+\ h# fe02.8000 constant camera-pci-base
 h# fed0.0000 constant hpet-mmio-base
 h# fed3.0000 constant spi-mmio-base
-h# fed4.0000 constant wdt-mmio-base
+\ h# fed4.0000 constant wdt-mmio-base
+h# fec0.0000 constant io-apic-mmio-base
 h# fee0.0000 constant apic-mmio-base
 
 h#   400 constant acpi-io-base
 h#   500 constant smbus-io-base
+h#  4080 constant uart-dma-io-base
 
 h# e0000 constant rsdp-adr
 h# e0040 constant rsdt-adr
 h# e0080 constant fadt-adr
 h# e0180 constant facs-adr
 h# e01c0 constant dbgp-adr
+h# e0200 constant madt-adr  \ MADT is 5a byts long
+h# e0280 constant hpet-adr
 h# fc000 constant dsdt-adr
 h# fd000 constant ssdt-adr
 

Modified: cpu/x86/pc/olpc/via/config.fth
===================================================================
--- cpu/x86/pc/olpc/via/config.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/config.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -18,7 +18,7 @@
 
 \ create coreboot-loaded
 
-\ create virtual-mode
+create virtual-mode
 create addresses-assigned  \ Define if base addresses are already assigned
 \ create serial-console      \ Define to default to serial port for console
 create pc

Modified: cpu/x86/pc/olpc/via/fw.bth
===================================================================
--- cpu/x86/pc/olpc/via/fw.bth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/fw.bth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -255,11 +255,9 @@
    false
 ;
 
-[ifdef] Later
 false value secure?
 
 : protect-fw  ( -- )  secure?  if  ec-indexed-io-off  then  ;
-[then]
 
 \ stand-init-debug?  [if]
 warning @  warning off 
@@ -271,9 +269,7 @@
       disable-interrupts
       d# 1000
       i-key-wait  if
-  [ifdef] Later
          protect-fw
-  [then]
          ." Interacting" cr  hex interact
       then
 
@@ -313,20 +309,21 @@
 
 fload ${BP}/ofw/gui/loadmenu.fth
 fload ${BP}/ofw/gui/insticon.fth
-[ifdef] Later
-fload ${BP}/cpu/x86/pc/olpc/disptest.fth
 
-: setup-for-linux  ( -- )
-   [ ' linux-hook behavior compile, ]    \ Chain to old behavior
-   vpci-devices-on   \ Do this after quieting USB
-;
-' setup-for-linux to linux-hook
 : screen-#lines  ( -- n )
    screen-ih 0=  if  default-#lines exit  then
    screen-ih  package( #lines )package
 ;
 ' screen-#lines to lines/page
 
+[ifdef] Later
+fload ${BP}/cpu/x86/pc/olpc/disptest.fth
+: setup-for-linux  ( -- )
+   [ ' linux-hook behavior compile, ]    \ Chain to old behavior
+   \ whatever
+;
+' setup-for-linux to linux-hook
+
 fload ${BP}/cpu/x86/pc/olpc/help.fth
 fload ${BP}/cpu/x86/pc/olpc/gui.fth
 [then]
@@ -347,10 +344,11 @@
    boot-getline to boot-file   " rom:emacs" $boot
 ;
 
+fload ${BP}/cpu/x86/pc/olpc/via/acpi.fth
+
 [ifdef] Later
 fload ${BP}/cpu/x86/pc/rmtools.fth
 fload ${BP}/dev/geode/smi.fth
-fload ${BP}/cpu/x86/pc/olpc/acpi.fth
 fload ${BP}/cpu/x86/pc/olpc/smbios.fth
 \ fload ${BP}/cpu/x86/pc/biosload/rmenter.fth
 fload ${BP}/cpu/x86/pc/biosints.fth
@@ -364,11 +362,12 @@
 [ifdef] wlan-wackup
 fload ${BP}/cpu/x86/pc/olpc/wlantest.fth
 
-fload ${BP}/cpu/x86/pc/olpc/rtcwake.fth
 ' gx-power-off to power-off
 [then]
 [then]
 
+fload ${BP}/cpu/x86/pc/olpc/rtcwake.fth
+
 [ifdef] Later
 [ifdef] use-ega
 : ega-output  ( -- )
@@ -407,10 +406,8 @@
    " u:\vmlinuz" to boot-device
 ;
 
-[ifdef] Later
 : dimmer  ( -- )  screen-ih  if  " dimmer" screen-ih $call-method  then  ;
 : brighter  ( -- )  screen-ih  if  " brighter" screen-ih $call-method  then  ;
-[then]
 
 [ifdef] Later
 dev /8042/keyboard
@@ -457,6 +454,9 @@
 
    ec-reboot   \ Tell the EC to reboot us, so the EC can reset too
 [then]
+   \ Prevent "resume from S3" on restart
+   4 acpi-w@  h# 1c00 invert and  4 acpi-w!
+
    6 h# cf9 pc!  \ In case the EC doesn't do it
    begin  halt  again
 ;
@@ -577,9 +577,9 @@
 ;
 [then]
 
-[ifdef] Later
 : console-start  ( -- )
    " screen" open-dev  ?dup  if
+      dup to screen-ih
       set-stdout
 \       logo-banner drop
 \       close-dev
@@ -592,7 +592,6 @@
 \   ." nvramrc" cr
 \   use-nvramrc?  if  nvramrc safe-evaluate  then
 ;
-[then]
 
 : debug-interact  ( -- )
    early-interact?  if
@@ -646,6 +645,7 @@
 
    ?factory-mode
    ?factory-boot-sequence
+[then]
 
    console-start
 
@@ -656,8 +656,10 @@
    then
 
    read-game-keys
-[then]
+
+[ifdef] Later
    stdout off  \ 
+[then]
 
    " probe-" do-drop-in
 
@@ -683,8 +685,8 @@
 [then]
    ['] (interrupt-auto-boot?) to interrupt-auto-boot?
    ?usb-keyboard
-   install-console
-   install-dual-console
+\   install-console
+\   install-dual-console
    banner
    auto-boot
 
@@ -705,13 +707,8 @@
 \   " wifi media lab 802.11" eval
 \   " flash http:\\18.85.46.172\new.rom" eval
 ;
+: urom  " flash! u:\new.rom" eval  ;
 
-: sci-wakeup ( -- ) ;
-\ : acpi-l@  ( index -- l )  drop 0  ;
-\ : acpi-l!  ( l index -- )  2drop  ;
-: s3  ( -- )  ;
-
-
 [ifdef] use-ec-Later
 \ Fancy battery charge logger.
 fload ${BP}/cpu/x86/pc/olpc/charge.fth

Modified: cpu/x86/pc/olpc/via/ioinit.fth
===================================================================
--- cpu/x86/pc/olpc/via/ioinit.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/ioinit.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -182,9 +182,12 @@
    5b 53 53 mreg  \ Enable APIC Clock Gating - 43 res be like Phx
 [then]
    68 80 80 mreg  \ Enable HPETs
-   69 ff 00 mreg  \ HPET base low
-   6a ff d0 mreg  \ HPET base mid
-   6b ff fe mreg  \ HPET base high
+
+hpet-mmio-base lbsplit swap 2swap swap  drop  ( bits31:24 bits23:16 bits15:8 )
+   69 ff rot mreg  \ HPET base low
+   6a ff rot mreg  \ HPET base mid
+   6b ff rot mreg  \ HPET base high
+
    6e ff 18 mreg  \ COMB not pos decoded but otherwise set to 2f8, COMA pos decoded at 3f8
    70 ff 06 mreg  \ SVID backdoor
    71 ff 11 mreg  \ SVID backdoor
@@ -193,6 +196,7 @@
    80 20 20 mreg  \ Debounce power button
    81 08 08 mreg  \ 32-bit ACPI timer
 \  81 08 00 mreg  \ 24-bit ACPI timer - why?
+   82 0f 0a mreg  \ Direct SCI to IRQ 10 (0xa)
    84 ff da mreg  \ IRQs 7,6,4,3,1 are primary wakeups
    85 ff 40 mreg  \ IRQ 14 is primary wakeup
    8a 9f 1f mreg  \ C-state auto switching with normal latencies
@@ -226,14 +230,19 @@
 
    b4 80 00 mreg  \ No positive decoding for UART1 ???
    b7 40 40 mreg  \ 40 res be like Phx
-   b8 fc 80 mreg  \ UART DMA Control Registers Base low (port is 4080)
-   b9 ff 40 mreg  \ UART DMA Control Registers Base high
+uart-dma-io-base wbsplit swap  ( bits15:8 bits7:0 )
+   b8 fc rot mreg  \ UART DMA Control Registers Base low (port is 4080)
+   b9 ff rot mreg  \ UART DMA Control Registers Base high
    ba 77 44 mreg  \ COM1 DMA Channel Selects - DMA0 for both Transmit and Receive
-   bc ff 00 mreg  \ SPI MMIO Base Address 15:8  (address is fed30000)
-   bd ff d3 mreg  \ SPI MMIO Base Address 23:16
-   be ff fe mreg  \ SPI MMIO Base Address 31:24
-   d0 f0 00 mreg  \ SMBUS IO Base Address low (port is 0500)
-   d1 ff 05 mreg  \ SMBUS IO Base Address high
+
+spi-mmio-base lbsplit swap 2swap swap  drop  ( bits31:24 bits23:16 bits15:8 )
+   bc ff rot mreg  \ SPI MMIO Base Address 15:8  (address is fed30000)
+   bd ff rot mreg  \ SPI MMIO Base Address 23:16
+   be ff rot mreg  \ SPI MMIO Base Address 31:24
+
+smbus-io-base wbsplit swap  ( bits15:8 bits7:0 )
+   d0 f0 rot mreg  \ SMBUS IO Base Address low (port is 0500)
+   d1 ff rot mreg  \ SMBUS IO Base Address high
    d2 0f 01 mreg  \ Enable SMBUS and set other characteristics
    e2 80 80 mreg  \ Inhibit C4 during USB isochronous transaction
 [ifdef] demo-board
@@ -241,7 +250,7 @@
 [then]
 [ifdef] xo-board
    e3 04 04 mreg  \ Select GPIO8 (DCONBLNK) instead of SSPICLK
-   e4 ff c8 mreg  \ Enable short C3/C4 (80), select GPO10 (10) (USB_PWR_EN), GPO10/11 (08)
+   e4 ff c8 mreg  \ Enable short C3/C4 (80), select GPO10 (40) (USB_PWR_EN), GPI10/11 (08)
 [then]
    e5 60 60 mreg  \ Enable NM bus master as source of bus master status, enable NB int to wakeup from Cx
    e6 20 20 mreg  \ Enable USB Device Mode Bus Master as Break Event
@@ -258,9 +267,11 @@
 0 [if]
    61 ff 2a mreg  \ Page C ROM shadow - C0000-CBFFF RO, CC000-CFFFF off
    62 ff 00 mreg  \ Page D ROM shadow - D0000-DFFFF off
-   63 f3 a0 mreg  \ Page E/F ROM shadow - E0000-EFFFF RO, F0000-FFFFF RO, no memory hole
-   64 ff aa mreg  \ Page E ROM shadow - E0000-EFFFF RO
+\   63 f3 a0 mreg  \ Page E/F ROM shadow - E0000-EFFFF RO, F0000-FFFFF RO, no memory hole
+\   64 ff aa mreg  \ Page E ROM shadow - E0000-EFFFF RW
 [then]
+   63 fc f0 mreg  \ Page E/F ROM shadow - E0000-EFFFF RW, F0000-FFFFF RW, no memory hole
+   64 ff ff mreg  \ Page E ROM shadow - E0000-EFFFF RW
    70 fb 82 mreg  \ CPU to PCI flow control - CPU to PCI posted write, Enable Delay Transaction
    72 af ee mreg  \ Read caching and prefix - various knobs (40 bit is reserved)
    73 79 01 mreg  \ Enable PCI broken master timer & various knobs
@@ -304,3 +315,5 @@
    \ x1 to write to SMM shadow memory behind VGA
    \ 00 to run - Axxxxx hits VGA in normal mode, hits shadow DRAM in SMM
    \ 01 to access VGA when in SMM (data cycles only)
+
+acpi-io-base h# 4c + port-rl  h# 400 bitset  ax dx out  \ Set USB power high

Modified: cpu/x86/pc/olpc/via/olpc.bth
===================================================================
--- cpu/x86/pc/olpc/via/olpc.bth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/olpc.bth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -27,9 +27,9 @@
 in: ${BP}/dev/ide/build/idehier.fc
 \ in: ${BP}/dev/ide/build/leghier.fc
 \ in: ${BP}/cpu/x86/pc/olpc/via/build/camera.fc
-\ in: ${BP}/cpu/x86/pc/olpc/via/build/dsdt.aml
+in: ${BP}/cpu/x86/pc/olpc/via/build/dsdt.aml
 \ in: ${BP}/cpu/x86/pc/olpc/via/build/mcastnand.bin
-\ in: ${BP}/dev/hdaudio/build/hdaudio.fc
+in: ${BP}/dev/hdaudio/build/hdaudio.fc
 in: sd8686.bin
 
 
@@ -112,8 +112,8 @@
 
    " ${BP}/ofw/fcode/memtest.fth"  " memtest.fth"          $add-deflated-dropin
 
+   " ${BP}/dev/hdaudio/build/hdaudio.fc"         " class040300"   $add-deflated-dropin
 [ifdef] Later
-   " ${BP}/dev/hdaudio/build/hdaudio.fc"         " class040300"   $add-deflated-dropin
 
    " ${BP}/ofw/inet/telnetd.fth"          " telnetd"             $add-deflated-dropin
 
@@ -154,13 +154,15 @@
    " fs.public"                                 " fspubkey"      $add-dropin \ Incompressible
    " lease.public"                              " leasepubkey"   $add-dropin \ Incompressible
    " developer.public"                          " develpubkey"   $add-dropin \ Incompressible
-
+[then]
    " sourceurl"   " sourceurl"                    $add-dropin
 
    " ${BP}/cpu/x86/pc/olpc/images/Edge1-8k-EQ-Comp-Amp-Short.wav"  " splash"   $add-deflated-dropin
+
    " ${BP}/cpu/x86/pc/olpc/via/build/dsdt.aml"      " dsdt"            $add-deflated-dropin
 \  " ${BP}/cpu/x86/pc/olpc/via/build/ssdt.aml"      " ssdt"            $add-deflated-dropin
 
+[ifdef] Later
    " ${BP}/cpu/x86/pc/olpc/via/build/nandblaster_rx.bin" " nb_rx"      $add-deflated-dropin
    " ${BP}/cpu/x86/pc/olpc/via/build/nandblaster_tx.bin" " nb_tx"      $add-deflated-dropin
 [then]

Modified: cpu/x86/pc/olpc/via/resume.bth
===================================================================
--- cpu/x86/pc/olpc/via/resume.bth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/resume.bth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -65,7 +65,7 @@
    ax      si  mov                \ Save PDIR VA
    0 [si]  cx  mov  forget-msr    \ Save old PDIR entry 0
    h# 83 # 0 [ax] mov             \ Punch a 4M mapping 0->0 into the page directory
-   cr3 ax mov  ax cr3 mov         \ Invalide the TLB to activate the mapping
+   cr3 ax mov  ax cr3 mov         \ Invalidate the TLB to activate the mapping
    h# f0060 # ax mov  ax jmp      \ Jump to suspend-physical, disabling paging
    h# 60 pad-to
 
@@ -146,28 +146,34 @@
 
    \ This is where the Geode sets up the sleep/wakeup sequence timing
 
+[ifdef] notdef
    \ Clear existing wakeup status
-   h# 400 port-rw  ax dx out
+   h# 400 port-rw  op: ax dx out
+[then] \ notdef
 
    \ The caller chooses the wakeup conditions, so we don't do it here
-   h# ffff h# 420 port-wl   \ Clear all status bits
+   h# ffff h# 420 port-ww   \ Clear all status bits
 
    h# fe resume-progress
 
    wbinvd                                 \ Flush the cache
 
+[ifdef] delete-me
    \ Setup the register values in advance so the active instruction sequence
    \ is as short as possible, thus keeping all the activity in one cache line.
-   h# 0400 h# 404 port-ww               \ Setup sleep type
+\   h# 0400 h# 404 port-ww               \ Setup sleep type
+[then]
 
+[ifdef] notdef
    \ Align to a cache line boundary
    also forth
    begin  here asm-base - h# 1f and  while  h# 90 c,  repeat  \ Align with NOPs
    previous
+[then]
 
    h# 2400 h# 404 port-ww               \ Go to sleep
 
-   h# fff # cx mov  begin  nop  loopa   \ Spin in this cache line while going down
+   h# 1000000 # cx mov  begin  nop  loopa   \ Spin in this cache line while going down
 
    \ If the processor didn't really go down, perhaps because a wakeup event was
    \ already pending, proceed as with a wakeup

Modified: cpu/x86/pc/olpc/via/romreset.bth
===================================================================
--- cpu/x86/pc/olpc/via/romreset.bth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/romreset.bth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -120,15 +120,10 @@
    acpi-io-base 1 + 8888 config-ww   \ Set ACPI base address
    8c 8881 config-wb   \ Enable ACPI regs, 32-bit PM timer, guard RTC against power glitches
    acpi-io-base 4 + port-rw           \ Get APCI Status register
-   d# 10 # ax shr  7 # ax and  1 # ax cmp  =  if   \ Wakeup from S3
-      char r report
-      resume-data  # sp mov
-      resume-entry # ax mov  ax call   \ This might return if checksumming fails
-      char x report
-   else                                            \ Not a wakeup from S3
+   d# 10 # ax shr  7 # ax and  1 # ax cmp  <>  if   \ Wakeup from S3
       \ This turns an OS reboot into a real cold start - from coreboot
-      380 config-rb  ax ax or  0<>  if             \ C-page shadowing not on yet
-         6 cf9 port-wb                             \ Force a full system reset
+      h# 380 config-rb  ax ax or  0<>  if          \ C-page shadowing not on yet
+         6 h# cf9 port-wb                          \ Force a full system reset
          char X report      
          begin  hlt  again
       then
@@ -165,6 +160,22 @@
 \  fload ${BP}/cpu/x86/pc/ramtest.fth
 
    fload ${BP}/cpu/x86/pc/olpc/via/startmtrrinit.fth
+
+   fload ${BP}/cpu/x86/pc/olpc/via/ioinit.fth
+
+   acpi-io-base 4 + port-rw           \ Get APCI Status register
+   ax bx mov
+   d# 10 # ax shr  7 # ax and  1 # ax cmp  =  if   \ Wakeup from S3
+      \ Set sleep type field to 0 to prevent looping here if resume fails
+      bx ax mov  h# 1c00 invert # ax and  acpi-io-base 4 + # dx mov  op: ax dx out
+      char r report
+
+      resume-data  # sp mov
+      resume-entry # ax mov  ax call   \ This might return if checksumming fails
+      char x report
+   then                                            \ Not a wakeup from S3
+
+
    \ Cache is now setup normally, backed by memory
    h# 20.0000 # esp mov
 
@@ -173,8 +184,6 @@
 
 \   fload ${BP}/cpu/x86/pc/olpc/via/startgtlinit.fth
 
-   fload ${BP}/cpu/x86/pc/olpc/via/ioinit.fth
-
 \ Enable the keyboard controller
    
 \   8851 config-rb  2 # ax or  ax bx mov

Modified: cpu/x86/pc/olpc/via/suspend.fth
===================================================================
--- cpu/x86/pc/olpc/via/suspend.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/suspend.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -25,7 +25,8 @@
    \ any status bits in the low half of the register.
    0 acpi-l@ h# 100.0000 or  0 acpi-l!
 
-   h# ffff h# 20 acpi-w!  \ Clear PME status bits
+\ Unnecessary, as asm code does it
+\   h# ffff h# 20 acpi-w!  \ Clear PME status bits
 \ XXX may need to clear other status bits elsewhere as well
 
 \  sum-forth
@@ -44,9 +45,9 @@
    again   
 ;
 : suspend
-\  " video-save" screen-ih $call-method  \ Freeze display
-  s3
-\   " video-restore" screen-ih $call-method  \ Unfreeze display
+   " video-save" screen-ih $call-method  \ Freeze display
+   s3
+   " video-restore" screen-ih $call-method  \ Unfreeze display
 \   " /usb at f,5" open-dev  ?dup  if  " do-resume" 2 pick $call-method  close-dev  then
 ;
 alias s suspend

Modified: cpu/x86/pc/olpc/via/versions.fth
===================================================================
--- cpu/x86/pc/olpc/via/versions.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ cpu/x86/pc/olpc/via/versions.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -2,7 +2,7 @@
 
 \ The overall firmware revision
 macro: FW_MAJOR A
-macro: FW_MINOR 03m
+macro: FW_MINOR 03t
 
 \ The EC microcode
 macro: EC_VERSION 1_9_1

Modified: dev/olpc/dcon/viadcon.fth
===================================================================
--- dev/olpc/dcon/viadcon.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ dev/olpc/dcon/viadcon.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -28,8 +28,13 @@
 \ h# 4000 constant DM_DEBUG
 \ h# 8000 constant DM_SELFTEST
 
-: dcon-load  ( -- )  h# 4c acpi-b@  h# 04 or  h# 4c acpi-b!  ;
-: dcon-unload  ( -- )  h# 4c acpi-b@  h# 04 invert and  h# 4c acpi-b!  ;
+\ Enable SMBALRT# IRQ as DCON IRQ
+: dcon-enable-irq  ( -- )  8 8 smb-reg!  ;
+\ Disable SMBALRT# IRQ as DCON IRQ; leaving it enabled causes spurious S3 wakeups
+: dcon-disable-irq  ( -- )  0 8 smb-reg!  ;
+
+: dcon-load  ( -- )  h# 4f acpi-b@  h# 04 or  h# 4f acpi-b!  ;
+: dcon-unload  ( -- )  h# 4f acpi-b@  h# 04 invert and  h# 4f acpi-b!  ;
 : dcon-blnk?  ( -- flag )  h# 4a acpi-b@ 4 and 0<>  ;
 : dcon-stat@  ( -- n )  h# 4b acpi-b@ 3 and  ;
 : dcon-irq?  ( -- flag )  1 smb-reg@ h# 20 and 0<>  ;
@@ -54,9 +59,11 @@
 ;
 
 : wait-dcon-mode  ( -- )
+   dcon-enable-irq
    d# 100 ms-factor *  tsc@ drop +  ( end-time )
    begin                            ( end-time )
       dcon-irq?  if
+         dcon-disable-irq
          dcon-stat@  dcon-clr-irq  2 =  if  \ DCONSTAT=10
             drop exit   
          then            
@@ -64,6 +71,7 @@
       dup tsc@ drop - 0<            ( end-time reached? )
    until                            ( end-time )
    drop
+   dcon-disable-irq
    ." Timeout entering DCON mode" cr
 ;
 
@@ -121,7 +129,26 @@
    h# dc02 =
 ;
 
+: dcon-gpio-init  ( -- )
+   \ Redundant with code in cpu/x86/pc/olpc/via/ioinit.fth
+   h# 88e3 config-b@ 4 or h# 88e3 config-b!
+   h# 88e4 config-b@  h# 48 or  h# 88e4 config-b!
+;
+
 : dcon-setup  ( -- )
+   dcon-gpio-init
+
+   0 dcon@ drop  0 dcon@ drop
+
+[ifdef] notdef
+   d# 1200 2 dcon!  \ HResolution
+   d# 1240 3 dcon!  \ HTotal
+   h# 0608 4 dcon!  \ HSyncstart (6+900=906), HSyncwidth (8)
+   d#  900 5 dcon!  \ VResolution
+   d#  912 6 dcon!  \ VTotal
+   h# 0502 7 dcon!  \ VSyncstart (5+900=905), VSyncwidth (2)
+[then]
+   
    \ Switch to OLPC mode
    h# c040  h# 3a dcon!   \ SDRAM Setup/Hold time.  Default of e040 fails
    h# 0000  h# 41 dcon!   \ Himax suggested this sequence (0 then 0101)
@@ -137,6 +164,18 @@
    h# f bright!
 ;
 
+: video-save
+   0 set-source  \ Freeze image
+   olpc-lcd-off
+;
+
+: video-restore
+   smb-init
+   dcon-gpio-init
+   olpc-lcd-mode
+   1 set-source  \ Unfreeze image
+;
+
 0 [if]
 dconstat dconblnk or dconirq or  constant in-gpios  
 dconload constant out-gpios

Modified: dev/via/unichrome/unichrome.fth
===================================================================
--- dev/via/unichrome/unichrome.fth	2009-06-25 21:13:27 UTC (rev 1222)
+++ dev/via/unichrome/unichrome.fth	2009-06-25 21:15:53 UTC (rev 1223)
@@ -77,11 +77,18 @@
   640 w,  480 w,  800 w,  656 w,  752 w,  525 w,  489 w,  523 w,  hex  8d 10 05 cf pll,  decimal
   800 w,  600 w, 1056 w,  840 w,  968 w,  628 w,  600 w,  619 w,  hex  70 0c 05 0f pll,  decimal
  1024 w,  768 w, 1344 w, 1048 w, 1184 w,  806 w,  770 w,  776 w,  hex  b6 0c 05 cf pll,  decimal
-\ This clock value doesn't work very well with iga1, but it is good with iga2/lcd
-\ 1200 w,  900 w, 1264 w, 1210 w, 1242 w,  912 w,  900 w,  910 w,  hex  05 0c a0 cf pll,  decimabl
+
+\ This clock value doesn't work very well with iga1, but it is good with iga2/lcd - 57.273 MHz
+\ 1200 w,  900 w, 1264 w, 1210 w, 1242 w,  912 w,  900 w,  910 w,  hex  05 0c a0 cf pll,  decimal
+
+\ This supposedly matches the Geode setup - 56.199 MHz (Geode is 56.229)
+ 1200 w,  900 w, 1240 w, 1208 w, 1216 w, 912 w,  905 w,  910 w,  hex  05 0c 9d cf pll,  decimal
+
 \ 1200 w,  900 w, 1264 w, 1210 w, 1242 w,  912 w,  900 w,  910 w,  hex  9d 8c 85 cf pll,  decimal
 \ 1200 w,  900 w, 1240 w, 1208 w, 1216 w,  912 w,  905 w,  907 w,  hex  9d 8c 85 cf pll,  decimal
- 1200 w,  900 w, 1240 w, 1206 w, 1214 w,  912 w,  905 w,  907 w,  hex  05 0c 9f cf pll,  decimal
+
+\ VIA's latest recommendation - 56.916 MHz
+\ 1200 w,  900 w, 1240 w, 1206 w, 1214 w,  912 w,  905 w,  907 w,  hex  05 0c 9f cf pll,  decimal
  1280 w,  768 w, 1664 w, 1344 w, 1472 w,  798 w,  770 w,  777 w,  hex  6f 08 05 4f pll,  decimal
  1280 w,  800 w, 1680 w, 1352 w, 1480 w,  831 w,  802 w,  808 w,  hex  46 88 83 4f pll,  decimal
  1280 w, 1024 w, 1688 w, 1328 w, 1440 w, 1066 w, 1024 w, 1027 w,  hex  97 08 05 0f pll,  decimal
@@ -536,6 +543,7 @@
    d# 1200 d# 900 set-secondary-mode
 
 \   60 60 9b crt-mask  \ Sync polarity - negative
+   60 60 78 seq-mask  \ Sync polarity - negative
 
    00 07 79 crt-mask  \ Disable scaling
    00 37 a3 crt-mask  \ iga2 from S.L., start addr
@@ -551,12 +559,15 @@
    0d fb crt!
 \   00 08 h# 6b crt-mask  \ Not simultaneous mode
 
-   40 40 16 seq!  \ Check what is VIASR - is it really seq! ? - reserved bits, apparently control something about using crt and lcd at the same time
+   40 40 16 seq-mask  \ reserved bits, apparently control something about using crt and lcd at the same time
 ;
 : olpc-crt-off  ( -- )
    00 30 1b seq-mask  \ IGA1 engine clock off
    30 30 36 crt-mask  \ DAC off
 ;
+: olpc-lcd-off  ( -- )
+   00 c0 1b seq-mask  \ IGA2 engine clock off
+;
 
 hex
 0 [if]




More information about the openfirmware mailing list