Author: wmb Date: 2009-05-31 12:15:56 +0200 (Sun, 31 May 2009) New Revision: 1206
Added: dev/olpc/dcon/viadcon.fth dev/via/unichrome/dconsmb.fth Modified: cpu/x86/acpitimer.fth cpu/x86/apic.fth cpu/x86/pc/olpc/via/addrs.fth cpu/x86/pc/olpc/via/config.fth cpu/x86/pc/olpc/via/devices.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/pcinode.fth cpu/x86/pc/olpc/via/romreset.bth cpu/x86/pc/olpc/via/versions.fth cpu/x86/pc/resetend.fth dev/olpc/dcon/dcon.fth dev/olpc/spiflash/spiui.fth dev/via/unichrome/loadpkg.fth dev/via/unichrome/unichrome.fth ofw/gui/button.fth ofw/gui/dialog.fth ofw/gui/graphics.fth ofw/gui/iconmenu.fth ofw/gui/insticon.fth ofw/gui/mouse.fth Log: VIA version - checkpoint - more stuff works.
Modified: cpu/x86/acpitimer.fth =================================================================== --- cpu/x86/acpitimer.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/acpitimer.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -1,9 +1,16 @@ \ See license at end of file purpose: Timing functions using the ACPI timer
+: acpi-b@ ( reg# -- b ) acpi-io-base + pc@ ; +: acpi-b! ( b reg# -- ) acpi-io-base + pc! ; +: acpi-w@ ( reg# -- w ) acpi-io-base + pw@ ; +: acpi-w! ( w reg# -- ) acpi-io-base + pw! ; +: acpi-l@ ( reg# -- l ) acpi-io-base + pl@ ; +: acpi-l! ( l reg# -- ) acpi-io-base + pl! ; + \ The ACPI timer counts at 3.579545 MHz. \ 3.579545 * 1024 is 3665 -: acpi-timer@ ( -- counts ) acpi-io-base 8 + pl@ ; +: acpi-timer@ ( -- counts ) 8 acpi-l@ ; : acpi-us ( us -- ) d# 3664 * d# 10 rshift acpi-timer@ + ( end ) begin dup acpi-timer@ - 0< until ( end )
Modified: cpu/x86/apic.fth =================================================================== --- cpu/x86/apic.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/apic.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -157,11 +157,13 @@
0 value apic-ih 0 value io-apic-ih -stand-init: APIC + +: init-apic ( -- ) " /apic" open-dev to apic-ih " /io-apic" open-dev to io-apic-ih ;
+ 0 [if] \ For tdcr (3e0): \ Divisor: 1 2 4 8 16 32 64 128
Modified: cpu/x86/pc/olpc/via/addrs.fth =================================================================== --- cpu/x86/pc/olpc/via/addrs.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/addrs.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -19,8 +19,10 @@
dropin-base h# 20 + constant ResetBase \ Location of "reset" dropin in ROM
+h# 3b00.0000 value fw-pa \ Changed in probemem.fth +\ h# 3bc0.0000 value fw-pa \ Changed in probemem.fth \ h# 1bc0.0000 value fw-pa \ Changed in probemem.fth -h# bc0.0000 value fw-pa \ Changed in probemem.fth +\ h# bc0.0000 value fw-pa \ Changed in probemem.fth h# 20.0000 constant /fw-ram [then]
Modified: cpu/x86/pc/olpc/via/config.fth =================================================================== --- cpu/x86/pc/olpc/via/config.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/config.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -7,7 +7,7 @@ \ create demo-board create xo-board [ifdef] xo-board -\ create use-ec +create use-ec [then]
\ --- The environment that "boots" us ---
Modified: cpu/x86/pc/olpc/via/devices.fth =================================================================== --- cpu/x86/pc/olpc/via/devices.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/devices.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -20,6 +20,15 @@
fload ${BP}/cpu/x86/pc/olpc/via/smbus.fth \ SMBUS driver fload ${BP}/cpu/x86/apic.fth \ APIC driver + +stand-init: APIC +[ifdef] use-apic + init-apic +[else] + 0. 1b msr! +[then] +; + fload ${BP}/cpu/x86/pc/olpc/via/dumpvia.fth \ Dump a bunch of registers
stand-init: CPU node @@ -260,10 +269,15 @@
fload ${BP}/dev/olpc/kb3700/ecserial.fth \ Serial access to EC chip
-.( Implement ignore-power-button) cr +.( XXX Implement ignore-power-button) cr : ignore-power-button ( -- ) ; fload ${BP}/dev/olpc/kb3700/ecio.fth \ I/O space access to EC chip
+.( XXX Fix ec cmd66) cr +patch drop ec-cmd66 kbc-off +[then] + +[ifdef] use-ec-Later fload ${BP}/cpu/x86/pc/olpc/via/boardrev.fth \ Board revision decoding [then]
@@ -273,7 +287,7 @@ decode-int nip nip d# 1000000 / ;
-[ifdef] use-ec +[ifdef] use-ec-Later stand-init: Date to EC time&date d# 2000 - ['] ec-date! catch if 3drop then 3drop @@ -290,7 +304,7 @@ ; [then]
-[ifdef] use-ec +[ifdef] use-ec-Later stand-init: PCI properties " /pci" find-device board-revision h# b18 < if @@ -307,13 +321,19 @@ [ifdef] use-ec fload ${BP}/cpu/x86/pc/olpc/mfgdata.fth \ Manufacturing data fload ${BP}/cpu/x86/pc/olpc/mfgtree.fth \ Manufacturing data in device tree +.( XXX Reinstate kbdtype.fth) cr \ fload ${BP}/cpu/x86/pc/olpc/kbdtype.fth \ Export keyboard type
+[ifdef] use-ec-Later fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports - +[else] +: ?enough-power ; +[then] + fload ${BP}/dev/olpc/spiflash/spiflash.fth \ SPI FLASH programming fload ${BP}/dev/olpc/spiflash/spiui.fth \ User interface for SPI FLASH programming -fload ${BP}/dev/olpc/spiflash/recover.fth \ XO-to-XO SPI FLASH recovery +h# 2c to crc-offset +\ fload ${BP}/dev/olpc/spiflash/recover.fth \ XO-to-XO SPI FLASH recovery
: ofw-fw-filename$ " disk:\boot\olpc.rom" ; ' ofw-fw-filename$ to fw-filename$ @@ -327,9 +347,9 @@ [then]
0 0 " 1,0" " /pci" begin-package -\ fload ${BP}/dev/olpc/dcon/dconsmb.fth \ SMB access to DCON chip -\ fload ${BP}/dev/olpc/dcon/dcon.fth \ DCON control fload ${BP}/dev/via/unichrome/loadpkg.fth \ Geode display + fload ${BP}/dev/via/unichrome/dconsmb.fth \ SMB access to DCON chip + fload ${BP}/dev/olpc/dcon/viadcon.fth \ DCON control
0 0 encode-bytes h# 8200.0810 +i 0+i fb-pci-base +i 0+i h# d000.0000 +i \ Frame buffer @@ -342,7 +362,7 @@
fload ${BP}/cpu/x86/adpcm.fth \ ADPCM decoding
-[ifdef] use-ec +[ifdef] use-ec-Later warning @ warning off : stand-init stand-init
Modified: cpu/x86/pc/olpc/via/fw.bth =================================================================== --- cpu/x86/pc/olpc/via/fw.bth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/fw.bth 2009-05-31 10:15:56 UTC (rev 1206) @@ -300,7 +300,6 @@ fload ${BP}/dev/null.fth fload ${BP}/ofw/core/bailout.fth
-[ifdef] Later \ GUI false value gui-safeboot?
@@ -313,8 +312,9 @@ fload ${BP}/cpu/x86/pc/olpc/banner.fth
fload ${BP}/ofw/gui/loadmenu.fth +fload ${BP}/ofw/gui/insticon.fth +[ifdef] Later fload ${BP}/cpu/x86/pc/olpc/disptest.fth -\ fload ${BP}/ofw/gui/insticon.fth
: setup-for-linux ( -- ) [ ' linux-hook behavior compile, ] \ Chain to old behavior @@ -379,7 +379,7 @@ [then] [then]
-" /xp disk:\boot\olpc.fth sd:\boot\olpc.fth nand:\boot\olpc.fth /prober /usb/ethernet /usb/wlan" +" /xp u:\boot\olpc.fth sd:\boot\olpc.fth nand:\boot\olpc.fth /prober /usb/ethernet /usb/wlan" ' boot-device set-config-string-default
\needs ramdisk " " d# 128 config-string ramdisk @@ -395,6 +395,15 @@ " console=ttyS0,115200 ide=nodma pmedia=ataflash nosmp noacpi" to boot-file " c:\vmlinuz" to boot-device ; +: okern +\ " c:\initrd.gz" to ramdisk +[ifdef] use-apic + " root=/dev/sda1 console=ttyS0,115200 acpi=off rootwait" to boot-file +[else] + " root=/dev/sda1 console=ttyS0,115200 acpi=off rootwait noapic nolapic" to boot-file +[then] + " u:\vmlinuz" to boot-device +;
[ifdef] Later : dimmer ( -- ) screen-ih if " dimmer" screen-ih $call-method then ; @@ -703,7 +712,7 @@ : s3 ( -- ) ;
-[ifdef] use-ec +[ifdef] use-ec-Later \ Fancy battery charge logger. fload ${BP}/cpu/x86/pc/olpc/charge.fth [then]
Modified: cpu/x86/pc/olpc/via/ioinit.fth =================================================================== --- cpu/x86/pc/olpc/via/ioinit.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/ioinit.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -25,7 +25,9 @@ end-table
0 3 devfunc +[ifdef] use-apic 86 38 38 mreg \ SMM and APIC Decoding: enable APIC lowest int arb, IOAPIC split decode, MSI (SMM later) +[then] end-table
\ Additional Power Management Setup not in coreboot @@ -75,7 +77,7 @@ [then] end-table
-0 [if] +1 [if] d# 15 0 devfunc \ EIDE tuning 40 02 02 mreg \ Enable primary channel 4a ff 5e mreg \ Drive1 timing @@ -156,14 +158,23 @@ .( Check interrupt routing) cr 55 ff a0 mreg \ INTA and External General interrupt routing - INTA:IRQ10 56 ff b9 mreg \ INTB,C routing - INTC:IRQ11, INTB:IRQ9 +[ifdef] demo-board 57 f0 a0 mreg \ INTD routing - INTD:IRQ10 +[then] +[ifdef] xo-board + 57 f0 a0 mreg \ INTD routing - INTD:IRQ10 (leave IRQ12 for PS2 mouse) +[then] .( Check RTC century byte mapping to cmos 32 - see d17f0 rx58) cr +[ifdef] use-apic 58 40 40 mreg \ Enable Internal APIC +[then] [ifdef] xo-board 59 ff 18 mreg \ Keyboard (ports 60,64) and ports 62,66 on LPC bus (EC) [then] +[ifdef] use-apic \ 5b 10 10 mreg \ Enable APIC Clock Gating 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 @@ -198,11 +209,12 @@ \ 97 ff 81 mreg \ GPIO4/5 not KBDT/KBCK \ [then]
- 9b ff 88 mreg \ 80 undoc but is LVDS power. 0 forces LVDS power off, 1 lets 3d5.D2[7,6,3] control it [ifdef] xo-board + 9b ff 89 mreg \ 80 undoc but is LVDS power. 00 forces LVDS power off, 80 lets 3d5.D2[7,6,3] control it; 1 selects GPO11/12 instead of CR_PWSEL/CR_PWOFF (DCONLOAD) 9f ff 08 mreg \ Slot 3 is SDIO, no pullup on KB/MS, fastest SD [then] [ifdef] demo-board + 9b ff 88 mreg \ 80 undoc but is LVDS power. 0 forces LVDS power off, 1 lets 3d5.D2[7,6,3] control it 9f ff ad mreg \ be like Phx (slot 3 is Card Reader not SDIO) [then]
@@ -222,11 +234,14 @@ e4 ff a0 mreg \ Enable short C3/C4 (80), select various multi-function pins [then] [ifdef] xo-board - e4 ff c0 mreg \ Enable short C3/C4 (80), select GPO10 (10) (USB_PWR_EN) + 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) [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 +[ifdef] use-apic e7 80 80 mreg \ Enable APIC Cycle Reflect to ALL Bus Master Activity Effective Signal +[then] fc 06 04 mreg \ DPSLP# to SLP# Latency Adjustment - 22.5 us end-table
@@ -266,16 +281,18 @@ 41 01 01 mreg \ Dynamic clock for HDAC end-table
+[ifdef] use-apic \ APIC setup 0 2 devfunc 59 01 01 mreg \ MSI Flat model support 5c 10 10 mreg \ Data bit 11 mask for MSI 97 01 01 mreg \ Redirect lowest priority MSI requests to APIC 00 end-table +[then]
- 0 3 devfunc - 86 38 38 mreg \ SMM and APIC Decoding: enable APIC lowest int arb, IOAPIC split decode, MSI (SMM later) - end-table +\ 0 3 devfunc +\ 86 38 38 mreg \ SMM and APIC Decoding: enable APIC lowest int arb, IOAPIC split decode, MSI (SMM later) +\ end-table
\ Low 2 bits of 86: \ x1 to write to SMM shadow memory behind VGA
Modified: cpu/x86/pc/olpc/via/olpc.bth =================================================================== --- cpu/x86/pc/olpc/via/olpc.bth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/olpc.bth 2009-05-31 10:15:56 UTC (rev 1206) @@ -79,8 +79,8 @@
" paging.di" $add-file " ${BP}/cpu/x86/build/inflate.bin" " inflate" $add-dropin -\ " fw.img" " firmware" $add-deflated-dropin - " fw.img" " firmware" $add-dropin + " fw.img" " firmware" $add-deflated-dropin +\ " fw.img" " firmware" $add-dropin
" ${BP}/dev/usb2/hcd/ohci/build/ohci.fc" " class0c0310" $add-deflated-dropin " ${BP}/dev/usb2/hcd/ehci/build/ehci.fc" " class0c0320" $add-deflated-dropin @@ -195,15 +195,7 @@
/l buffer: crcbuf /rom buffer: filebuf -0 ofd @ fseek
-\ Read the entire image, compute the CRC, and store it h# 30 from the end -filebuf /rom ofd @ fgets /rom <> abort" Can't read back image" -0 crctab filebuf /rom ($crc) crcbuf ! - -/rom h# 2c - ofd @ fseek -crcbuf /l ofd @ fputs - \ Via SIP ROM pointer \ The address "-30" is fixed by the VX855 hardware. \ We get to choose the address ffffffa0 @@ -213,6 +205,14 @@
/rom h# 80 - ofd @ fseek sipbuf /sipbuf ofd @ fputs + +\ Read the entire image, compute the CRC, and store it h# 30 from the end +0 ofd @ fseek +filebuf /rom ofd @ fgets /rom <> abort" Can't read back image" +0 crctab filebuf /rom ($crc) crcbuf ! + +/rom h# 2c - ofd @ fseek +crcbuf /l ofd @ fputs [then]
ofd @ fclose
Modified: cpu/x86/pc/olpc/via/pcinode.fth =================================================================== --- cpu/x86/pc/olpc/via/pcinode.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/pcinode.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -95,24 +95,36 @@ endcase ;
+: set-level-trigger ( irq# -- irq# ) + dup 8 /mod ( irq# low high ) + h# 4d0 + ( irq# low reg# ) + 1 rot lshift ( irq# reg# bitmask ) + over pc@ or ( irq# reg# newvalue ) + swap pc! +; + \ Determine the parent interrupt information (the "interrupt line" in PCI \ parlance) from the child's "interrupt pin" and the child's address, \ returning "int-line true" if the child's interrupt line register should \ be set or "false" otherwise. +.( XXX make assign-int-line depend on PIC vs. APIC mode) cr : assign-int-line ( phys.hi.func INTx -- irq true ) - \ Reiterate the value that is already in the int line register, - \ which was placed there by lower level init code + \ Get the value from the platform-specific mapping registers + \ XXX PIC version is below - need APIC version too drop case - h# 5800 of 1 pirq@ true exit endof \ USB device - PIRQB - h# 6000 of 0 pirq@ true exit endof \ SDIO - PIRQA - h# 6800 of 0 pirq@ true exit endof \ SDC - PIRQA - h# 7800 of 1 pirq@ true exit endof \ EIDE - PIRQB - h# 8000 of 0 pirq@ true exit endof \ UHCI01 - PIRQ A - h# 8100 of 1 pirq@ true exit endof \ UHCI23 - PIRQ B - h# 8200 of 2 pirq@ true exit endof \ UHCI45 - PIRQ C - h# 8400 of 3 pirq@ true exit endof \ EHCI - PIRQ D - h# a000 of 1 pirq@ true exit endof \ HDAudio - PIRQ B - ( default ) dup h# 3c + config-b@ true rot \ Reiterate previous setting + \ Wouldn't it be nice if you could get the argument to pirq@ from + \ the interrupt pin register (offset 3d)? But that doesn't work, + \ because some devices say pin A but use PIRQB. + h# 5800 of 1 pirq@ set-level-trigger true exit endof \ USB device - PIRQB + h# 6000 of 0 pirq@ set-level-trigger true exit endof \ SDIO - PIRQA + h# 6800 of 0 pirq@ set-level-trigger true exit endof \ SDC - PIRQA + h# 7800 of 1 pirq@ set-level-trigger true exit endof \ EIDE - PIRQB + h# 8000 of 0 pirq@ set-level-trigger true exit endof \ UHCI01 - PIRQ A + h# 8100 of 1 pirq@ set-level-trigger true exit endof \ UHCI23 - PIRQ B + h# 8200 of 2 pirq@ set-level-trigger true exit endof \ UHCI45 - PIRQ C + h# 8400 of 3 pirq@ set-level-trigger true exit endof \ EHCI - PIRQ D + h# a000 of 1 pirq@ set-level-trigger true exit endof \ HDAudio - PIRQ B + ( default ) dup h# 3c + config-b@ dup if set-level-trigger then true rot \ Reiterate previous setting endcase ;
Modified: cpu/x86/pc/olpc/via/romreset.bth =================================================================== --- cpu/x86/pc/olpc/via/romreset.bth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/romreset.bth 2009-05-31 10:15:56 UTC (rev 1206) @@ -158,6 +158,7 @@
fload ${BP}/cpu/x86/pc/olpc/via/startmtrrinit.fth \ Cache is now setup normally, backed by memory + h# 20.0000 # esp mov
char o report h# 1e port80
Modified: cpu/x86/pc/olpc/via/versions.fth =================================================================== --- cpu/x86/pc/olpc/via/versions.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/olpc/via/versions.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -2,7 +2,7 @@
\ The overall firmware revision macro: FW_MAJOR A -macro: FW_MINOR 03e +macro: FW_MINOR 03g
\ The EC microcode macro: EC_VERSION a00 @@ -11,7 +11,8 @@ \ Temporarily uncomment the line and modify the path as necessary \ macro: GET_EC cp pq3a00.img ec.img \ macro: GET_EC cp "/c/Documents and Settings/Mitch Bradley/My Documents/OLPC/VIA/ecimage.bin" ec.img -macro: GET_EC cp /via/ecimage.bin ec.img +\ macro: GET_EC cp /via/ecimage.bin ec.img +macro: GET_EC cp ecimagep.bin ec.img
macro: KEYS mpkeys \ macro: KEYS testkeys
Modified: cpu/x86/pc/resetend.fth =================================================================== --- cpu/x86/pc/resetend.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ cpu/x86/pc/resetend.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -83,9 +83,9 @@ \ and use it to inflate the firmware into RAM ax push \ Save address of firmware dropin
-ascii h report +\ ascii h report
- h# 23 # al mov al h# 80 # out + \ h# 23 # al mov al h# 80 # out " inflate" $find-dropin, \ Assemble call to find-dropin with literal arg
4 [ax] cx mov \ Length of inflater (byte-swapped) @@ -95,7 +95,7 @@
cld rep byte movs \ Copy the inflater
- h# 24 # al mov al h# 80 # out +\ h# 24 # al mov al h# 80 # out ax pop \ Recover base address of firmware dropin
d# 32 # ax add \ Skip dropin header @@ -105,10 +105,13 @@ 0 # push \ No-header flag - 0 means expect a header workspace # push \ Scratch RAM for inflater
+\ h# 25 # al mov al h# 80 # out +\ ascii m report + inflate-base # ax mov \ Base address of inflater + ax call \ Inflate the firmware + h# 25 # al mov al h# 80 # out ascii m report - inflate-base # ax mov \ Base address of inflater - ax call \ Inflate the firmware else ax push h# 26 # al mov al h# 80 # out
Modified: dev/olpc/dcon/dcon.fth =================================================================== --- dev/olpc/dcon/dcon.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ dev/olpc/dcon/dcon.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -169,7 +169,7 @@ h# 0101 h# 41 dcon! h# 0101 h# 42 dcon! then - h# 12 mode! + h# 12 mode! \ 10:blanking on, 2:sleep mode on ; : dcon-enable ( -- ) dcon-setup
Added: dev/olpc/dcon/viadcon.fth =================================================================== --- dev/olpc/dcon/viadcon.fth (rev 0) +++ dev/olpc/dcon/viadcon.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -0,0 +1,243 @@ +\ See license at end of file +\ " dcon" device-name + +\ DCON internal registers, accessed via I2C +\ 0 constant DCON_ID +\ 1 constant DCON_MODE +\ 2 constant DCON_HRES +\ 3 constant DCON_HTOTAL +\ 4 constant DCON_HSYNC_WIDTH +\ 5 constant DCON_VRES +\ 6 constant DCON_VTOTAL +\ 7 constant DCON_VSYNC_WIDTH +\ 8 constant DCON_TIMEOUT +\ 9 constant DCON_SCAN_INT +\ d# 10 constant DCON_BRIGHT + +\ Mode register bits +\ h# 1 constant DM_PASSTHRU +\ h# 2 constant DM_SLEEP +\ h# 4 constant DM_SLEEP_AUTO +\ h# 8 constant DM_BL_ENABLE +\ h# 10 constant DM_BLANK +\ h# 20 constant DM_CSWIZZLE +\ h# 40 constant DM_COL_AA +\ h# 80 constant DM_MONO_LUMA +\ h# 100 constant DM_SCAN_INT +\ h# 200 constant DM_CLOCKDIV +\ 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! ; +: 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<> ; +: dcon-clr-irq ( -- ) h# 20 1 smb-reg! ; + +\ DCONSTAT values: 0 SCANINT 1 SCANINT_DCON 2 DISPLAYLOAD 3 MISSED + +1 value vga? \ VGA +0 value color? \ COLOUR + +\ : gxfb! ( l offset -- ) gxfb-dc-regs + rl! ; \ Probably should be IO mapped + +d# 905 value resumeline \ Configurable; should be set from args + +: wait-output ( -- ) + \ Wait for up to a second for our output to coincide with DCON's + d# 1000 0 do + dcon-blnk? 0= if unloop exit then + 1 ms + loop + ." Wait for VGA ready timed out" cr +; + +: wait-dcon-mode ( -- ) + d# 100 ms-factor * tsc@ drop + ( end-time ) + begin ( end-time ) + dcon-irq? if + dcon-stat@ dcon-clr-irq 2 = if \ DCONSTAT=10 + drop exit + then + then + dup tsc@ drop - 0< ( end-time reached? ) + until ( end-time ) + drop + ." Timeout entering DCON mode" cr +; + +: set-source ( vga? -- ) + dup vga? = if drop exit then ( source ) + dup to vga? ( source ) + if +\ unblank-display + d# 50 ms + wait-output + dcon-load \ Put the DCON in VGA-refreshed mode + d# 25 us +\ display-on + else + dcon-unload \ Put the DCON in self-refresh mode + lock[ wait-dcon-mode ]unlock +\ display-off + then +; + +\ gx_configure_tft(info); + +: try-dcon! ( w reg# -- ) + ['] dcon! catch if 2drop smb-stop 1 ms smb-off 1 ms smb-on then +; + +: mode! ( mode -- ) 1 dcon! ; +: hres! ( hres -- ) 2 dcon! ; \ def: h# 458 d# 1200 +: htotal! ( htotal -- ) 3 dcon! ; \ def: h# 4e8 d# 1256 +: hsync! ( sync -- ) 4 dcon! ; \ def: h# 1808 d# 24,8 +: vres! ( vres -- ) 5 dcon! ; \ def: h# 340 d# 900 +: vtotal! ( htotal -- ) 6 dcon! ; \ def: h# 390 d# 912 +: vsync! ( sync -- ) 7 dcon! ; \ def: h# 403 d# 4,3 +: timeout! ( to -- ) 8 dcon! ; \ def: h# ffff +: scanint! ( si -- ) 9 dcon! ; \ def: h# 0000 +: bright! ( level -- ) d# 10 dcon! ; \ def: h# xxxF +: bright@ ( -- level ) d# 10 dcon@ ; +: brighter ( -- ) bright@ 1+ h# f min bright! ; +: dimmer ( -- ) bright@ 1- 0 max bright! ; + +\ Color swizzle, AA, no passthrough, backlight +: set-color ( color? -- ) + dup to color? + if h# 69 else h# 89 then mode! +; + +\ Setup so it can be called by execute-device-method +: dcon-off ( -- ) smb-init h# 12 ['] mode! catch if drop then ; + +: dcon2? ( -- flag ) + 0 ['] dcon@ catch if ( x ) + drop smb-init ( ) + 0 ['] dcon@ catch if drop false exit then + then + h# dc02 = +; + +: dcon-setup ( -- ) + \ 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) + + h# 0101 h# 41 dcon! + h# 0101 h# 42 dcon! + + h# 12 mode! +; +: dcon-enable ( -- ) + dcon-setup + true set-color + h# f bright! +; + +0 [if] +dconstat dconblnk or dconirq or constant in-gpios +dconload constant out-gpios + +: dcon-gpio-init ( -- ) + out-gpios in-gpios wljoin OUT_EN gpio! + in-gpios out-gpios wljoin IN_EN gpio! + + dconirq >set INV_EN gpio! + + dconirq dconblnk or ( events ) + +\ Linux doesn't want me to turn these on +\ dup >set EVNT_EN gpio! +\ dup >set IN_FLTR_EN gpio! \ Enable counter for GPIO7 (DCONIRQ) +\ dup >clr EVNTCNT_EN gpio! +\ d# 12 gpio-base h# f7 + rb! \ GPIO_FE7_SEL +\ dup >clr h# 44 gpio! \ NEGEDGE_EN + +\ 0 gpio-base h# d8 + rw! \ GPIO_FLTR7_AMNT + + h# e0 gpio@ h# 0fff.ffff and h# 2000.0000 or h# e0 gpio! \ p512 Map X + h# e4 gpio@ h# fff0.ffff and h# 0000.0000 or h# e4 gpio! \ p511 Map Y + +[ifdef] dcon-interrupts + h# 5140.0023 rdmsr ( lo hi ) drop ( lo ) + h# ff0f.fffff and h# 0050.0000 or 0 wrmsrl \ p 381 unrestricted Z + 0 h# 4d0 pc! \ IRQs 0-7 edge sensitive +[then] + + ( events ) + dup >set IN_EN gpio! + >set h# 4c gpio! \ GPIOL_NEGEDGE_STS - clear detected edges + + dcon-load + + \ ['] dcon-interrupt 5 request_irq +; +[then] + +0 value dcon-found? + +d# 440 8 / constant dcon-flag + +: maybe-set-cmos ( -- ) 1 dcon-flag cmos! ; + +: panel + smb-init + 0 dcon@ . + + 0 9 cr 0 h# 70 h# 11 crt-mask + 0 h# 80 h# 17 crt-mask + + d# 1200 d# 900 d# 16 set-primary-mode + + 00 07 h# 79 crt-mask \ Disable scaling + 8 8 h# 6a crt-mask + + \ 1 01 h# 88 crt-mask Something to do with LVDS; check + \ set vclk + \ VIASetOutputPath + 00 08 h# 6b crt-mask +\ DisableSecondDisplayChannel XXX check me out + 08 08 h# 6a crt-mask + +\ VIALCDPatchSkew +\ VIASetDisplayChannel Seems to be lvds-specific + + 40 40 h# 16 seq! \ Check what is VIASR - is it really seq! ? + +\ VIALoadLCDPatchRegs + + dcon-load + dcon-enable ( maybe-set-cmos ) + \ dcon-enable leaves mode set to 69 - 40:antialias, 20:swizzle, 8:backlight on, 1:passthru off + 2 bright! \ lower brightness for testing + +; + + + +\ LICENSE_BEGIN +\ Copyright (c) 2006 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: dev/olpc/spiflash/spiui.fth =================================================================== --- dev/olpc/spiflash/spiui.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ dev/olpc/spiflash/spiui.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -66,7 +66,7 @@ [then] 0 value file-loaded?
-h# 30 constant crc-offset \ From end +h# 30 constant crc-offset \ From end (modified in devices.fth for XO 1.5)
: crc ( adr len -- crc ) 0 crctab 2swap ($crc) ;
Added: dev/via/unichrome/dconsmb.fth =================================================================== --- dev/via/unichrome/dconsmb.fth (rev 0) +++ dev/via/unichrome/dconsmb.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -0,0 +1,99 @@ +: smb-dly 4 us ; +: crtsp-set ( mask -- ) h# 26 seq@ or h# 26 seq! smb-dly ; +: crtsp-clr ( mask -- ) invert h# 26 seq@ and h# 26 seq! smb-dly ; +: crtsp@ ( mask -- flag ) h# 26 seq@ and 0<> ; + +: smb-data-hi ( -- ) h# 10 crtsp-set ; +: smb-data-lo ( -- ) h# 10 crtsp-clr ; +: smb-clk-hi ( -- ) h# 20 crtsp-set ; +: smb-clk-lo ( -- ) h# 20 crtsp-clr ; +: smb-data@ ( -- flag ) 4 crtsp@ ; +: smb-clk@ ( -- ) 8 crtsp@ ; +\ : smb-on ( -- ) 1 crtsp-set h# 30 crtsp-set d# 10 ms ; +: smb-off ( -- ) 1 crtsp-clr ; +: smb-on ( -- ) h# 31 crtsp-set ; +: smb-bit@ ( -- ) smb-clk-hi h# 26 seq@ 4 and 0<> smb-clk-lo ; + +h# 3500 constant smb-clk-timeout-us +\ Slave can flow control by holding CLK low temporarily +: smb-wait-clk-hi ( -- ) + smb-clk-timeout-us 0 do + smb-clk@ if smb-dly unloop exit then 1 us + loop + true abort" I2C clock stuck low" +; +: smb-data-hi-w ( -- ) smb-data-hi smb-wait-clk-hi ; + +h# 3500 constant smb-data-timeout-us +: smb-wait-data-hi ( -- ) + smb-data-timeout-us 0 do + smb-data@ if unloop exit then 1 us + loop + true abort" I2C data stuck low" +; + +: smb-restart ( -- ) + smb-clk-hi smb-data-lo smb-clk-lo +; + +: smb-start ( -- ) smb-clk-hi smb-data-hi smb-data-lo smb-clk-lo ; +: smb-stop ( -- ) smb-clk-lo smb-data-lo smb-clk-hi smb-data-hi ; + +: smb-get-ack ( -- ) + smb-data-hi + smb-clk-hi smb-wait-clk-hi + smb-data@ if smb-stop true abort" I2c NAK" then + smb-clk-lo +\ smb-wait-data-hi +; +: smb-bit ( flag -- ) + if smb-data-hi else smb-data-lo then + smb-clk-hi smb-wait-clk-hi smb-clk-lo +; + +: smb-byte ( b -- ) + 8 0 do ( b ) + dup h# 80 and smb-bit ( b ) + 2* ( b' ) + loop ( b ) + drop ( ) + smb-get-ack +; +: smb-byte-in ( ack=0/nak=1 -- b ) + 0 + 8 0 do ( n ) + smb-clk-hi ( n ) + 2* smb-data@ if 1 or then ( n' ) + smb-clk-lo + loop + swap smb-bit smb-data-hi \ Send ACK or NAK +; + +0 value smb-slave +: smb-addr ( lowbit -- ) smb-slave or smb-byte ; +: smb-word! ( word reg# -- ) + smb-start + 0 smb-addr ( word reg# ) + smb-byte ( word ) + wbsplit swap smb-byte smb-byte ( ) + smb-stop +; + +: smb-word@ ( reg# -- word ) + smb-start + 0 smb-addr ( reg# ) + smb-byte ( ) + smb-restart + 1 smb-addr ( ) + 0 smb-byte-in 1 smb-byte-in bwjoin ( word ) + smb-stop +; + +\ This can useful for clearing out DCON SMB internal state +: smb-pulses ( -- ) + d# 32 0 do smb-clk-lo smb-clk-hi loop +; +: smb-init ( -- ) smb-on smb-pulses ; + +: dcon@ ( reg# -- word ) h# 1a to smb-slave smb-word@ ; +: dcon! ( word reg# -- ) h# 1a to smb-slave smb-word! ;
Modified: dev/via/unichrome/loadpkg.fth =================================================================== --- dev/via/unichrome/loadpkg.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ dev/via/unichrome/loadpkg.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -14,6 +14,9 @@ defer windex! \ Write index for palatte write defer index! \ Index for generic IO defer video-on +: color! ( r g b color# -- ) 2drop 2drop ; +: color@ ( color# -- r g b ) drop 0 0 0 ; + fload ${BP}/dev/video/controlr/vga.fth \ Standard VGA interfaces fload ${BP}/dev/via/unichrome/unichrome.fth \ Controller code \ fload ${BP}/dev/via/unichrome/accel2d.fth \ Accelerator
Modified: dev/via/unichrome/unichrome.fth =================================================================== --- dev/via/unichrome/unichrome.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ dev/via/unichrome/unichrome.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -73,6 +73,7 @@ 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 + 1200 w, 900 w, 1240 w, 1208 w, 1216 w, 912 w, 905 w, 907 w, hex 9d 8c 85 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 @@ -499,6 +500,17 @@ ; [then]
+[ifdef] xo-board +: setup-lcd ( -- ) + h# 80 h# f3 crt-set \ 18-bit TTL LCD mode + h# 10 h# 30 h# 1e crt-mask \ DVP pads controlled by other control +\ h# 30 h# 30 h# 1e crt-mask \ DVP pads controlled by PMS +\ h# 0f h# 0f h# 65 crt-mask \ High drive for DVP + +\ h# 80 h# 9b crt! \ DVP mode - alpha:80, VSYNC:40, HSYNC:20, secondary:10, clk polarity:8, clk adjust:7 +; +[then] + hex 0 [if] : .cr
Modified: ofw/gui/button.fth =================================================================== --- ofw/gui/button.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ ofw/gui/button.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -67,10 +67,10 @@ : lowlight-button ( x y -- ) background -rot def-button-wh 1 box ; : (down-button) ( x y w h -- ) button-wh 2! button-xy 2! - button-wh 2@ -8 -8 xy+ * dup >r alloc-mem >r + button-wh 2@ -8 -8 xy+ * dup >r alloc-pixels >r r@ button-xy 2@ 4 4 xy+ button-wh 2@ -8 -8 xy+ read-rectangle r@ button-xy 2@ 5 5 xy+ button-wh 2@ -8 -8 xy+ draw-rectangle - r> r> free-mem + r> r> free-pixels
button-color interior-xy button-wh 2@ -4 -4 xy+ 2 box button-shadow interior-xy button-width 4 - hline @@ -79,10 +79,10 @@ : (up-button) ( x y w h -- ) button-wh 2! button-xy 2!
- button-wh 2@ -8 -8 xy+ * dup >r alloc-mem >r + button-wh 2@ -8 -8 xy+ * dup >r alloc-pixels >r r@ button-xy 2@ 5 5 xy+ button-wh 2@ -8 -8 xy+ read-rectangle r@ button-xy 2@ 4 4 xy+ button-wh 2@ -8 -8 xy+ draw-rectangle - r> r> free-mem + r> r> free-pixels
button-color interior-xy button-wh 2@ -4 -4 xy+ 2 box button-shadow interior-xy button-width 4 - hline
Modified: ofw/gui/dialog.fth =================================================================== --- ofw/gui/dialog.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ ofw/gui/dialog.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -40,12 +40,12 @@ 2variable back-wh : save-rectangle ( x y w h -- ) back-wh 2! back-xy 2! - back-wh 2@ * alloc-mem to backing-adr + back-wh 2@ * alloc-pixels to backing-adr backing-adr back-xy 2@ back-wh 2@ read-rectangle ; : restore-rectangle ( -- ) backing-adr back-xy 2@ back-wh 2@ draw-rectangle - backing-adr back-wh 2@ * free-mem + backing-adr back-wh 2@ * free-pixels set-description-region ;
Modified: ofw/gui/graphics.fth =================================================================== --- ofw/gui/graphics.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ ofw/gui/graphics.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -67,6 +67,10 @@ " set-colors" $call-screen ;
+: bytes/pixel ( -- n ) " depth" $call-screen 8 / ; +: alloc-pixels ( #pixels -- adr ) bytes/pixel * alloc-mem ; +: free-pixels ( adr #pixels -- ) bytes/pixel * free-mem ; + : fill-rectangle ( color x y w h - ) ?inset " fill-rectangle" $call-screen ; @@ -79,7 +83,7 @@ : draw-rectangle ( address x y w h - ) ?inset " draw-rectangle" $call-screen ; -headerless + : read-rectangle ( address x y w h - ) ?inset " read-rectangle" $call-screen ;
Modified: ofw/gui/iconmenu.fth =================================================================== --- ofw/gui/iconmenu.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ ofw/gui/iconmenu.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -328,6 +328,7 @@ mouse-ih 0= if " /mouse" open-dev to mouse-ih then + alloc-mouse-cursor then ;
Modified: ofw/gui/insticon.fth =================================================================== --- ofw/gui/insticon.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ ofw/gui/insticon.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -4,8 +4,10 @@ \ fload ${BP}/ofw/gui/macosi.fth \ Boot/install MacOS items \ fload ${BP}/ofw/gui/nti.fth \ Boot/install NT items \ fload ${BP}/ofw/gui/aixi.fth \ Boot AIX item + +: boot-configure ; fload ${BP}/ofw/gui/linuxi.fth \ Boot Linux item -fload ${BP}/ofw/gui/osi.fth \ Install OS items +\ fload ${BP}/ofw/gui/osi.fth \ Install OS items
fload ${BP}/ofw/gui/demoi.fth \ Demo license items and background \ fload ${BP}/ofw/gui/confvari.fth \ Configuration variables item @@ -24,7 +26,7 @@
about-item 2 0 selected install-icon license-item 2 1 install-icon -\ help-item 2 2 install-icon \ Requires EMACS client + help-item 2 2 install-icon \ Requires EMACS client
restart-item 2 3 install-icon forth-item 2 cols 1- install-icon @@ -37,8 +39,8 @@ \ os-items \ In row 0 linux-item 0 0 install-icon \ In row 0
- " Menu: Install Operating Systems " - ['] installation-menu install.icon 0 3 install-icon +\ " Menu: Install Operating Systems " +\ ['] installation-menu install.icon 0 3 install-icon ;
' demo-menu to root-menu
Modified: ofw/gui/mouse.fth =================================================================== --- ofw/gui/mouse.fth 2009-05-29 02:26:07 UTC (rev 1205) +++ ofw/gui/mouse.fth 2009-05-31 10:15:56 UTC (rev 1206) @@ -52,9 +52,14 @@ 3drop ;
-cursor-w cursor-h * constant /rect -/rect buffer: old-rect -/rect buffer: new-rect +0 value /rect +0 value old-rect +0 value new-rect +: alloc-mouse-cursor ( -- ) + cursor-w cursor-h * bytes/pixel * to /rect + cursor-w cursor-h * alloc-pixels to old-rect + cursor-w cursor-h * alloc-pixels to new-rect +;
: merge-cursor ( -- ) 0f white-bits new-rect merge-rect