openfirmware
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
October 2010
- 3 participants
- 35 discussions
Author: wmb
Date: Sat Oct 30 06:53:25 2010
New Revision: 1996
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1996
Log:
Completed fix for factoring problem.
Modified:
cpu/arm/mmp2/devices.fth
Modified: cpu/arm/mmp2/devices.fth
==============================================================================
--- cpu/arm/mmp2/devices.fth Sat Oct 30 05:05:10 2010 (r1995)
+++ cpu/arm/mmp2/devices.fth Sat Oct 30 06:53:25 2010 (r1996)
@@ -130,7 +130,7 @@
: my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ;
false constant has-dbgp-regs?
false constant needs-dummy-qh?
- false constant grab-controller
+ : grab-controller ( config-adr -- error? ) drop false ;
fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
end-package
1
0
Author: wmb
Date: Sat Oct 30 05:05:10 2010
New Revision: 1995
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1995
Log:
Added dummy.img
Added:
cpu/arm/olpc/1.75/dummy.img (contents, props changed)
Added: cpu/arm/olpc/1.75/dummy.img
==============================================================================
Binary file. No diff available.
1
0
Author: wmb
Date: Sat Oct 30 05:02:32 2010
New Revision: 1994
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1994
Log:
FAT filesystem reader - handle files larger than 2 GiB (but files larger than 4 GiB will still fail). Is it even possible to have files that large with FAT?
Modified:
ofw/fs/fatfs/read.fth
Modified: ofw/fs/fatfs/read.fth
==============================================================================
--- ofw/fs/fatfs/read.fth Sat Oct 30 05:01:34 2010 (r1993)
+++ ofw/fs/fatfs/read.fth Sat Oct 30 05:02:32 2010 (r1994)
@@ -104,7 +104,7 @@
begin
dup 0>
remaining @ 0> and
- current-position fh_length l@ < and
+ current-position fh_length l@ u< and
last-cluster? 0= and
while ( #cls-remaining )
to-next-cluster
@@ -134,10 +134,10 @@
\ If the last cluster of the file has been read, account for the
\ true length of the file
- fh_length l@ current-position - 0 min + ( bytes-valid )
- 0 max \ **** cpt 12/29/89, neg value must not be returned for appending
+ fh_length l@ current-position - + ( bytes-valid )
false
;
+
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
\
1
0

Oct. 30, 2010
Author: wmb
Date: Sat Oct 30 05:01:34 2010
New Revision: 1993
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1993
Log:
Fixed bug introduced by last checkin (factoring problem).
Modified:
cpu/arm/olpc/1.75/devices.fth
dev/usb2/hcd/ehci/pci.fth
dev/usb2/hcd/ehci/probe.fth
Modified: cpu/arm/olpc/1.75/devices.fth
==============================================================================
--- cpu/arm/olpc/1.75/devices.fth Fri Oct 29 18:17:26 2010 (r1992)
+++ cpu/arm/olpc/1.75/devices.fth Sat Oct 30 05:01:34 2010 (r1993)
@@ -179,7 +179,7 @@
: my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ;
false constant has-dbgp-regs?
false constant needs-dummy-qh?
- false constant grab-controller
+ : grab-controller ( config-adr -- error? ) drop false ;
fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
end-package
Modified: dev/usb2/hcd/ehci/pci.fth
==============================================================================
--- dev/usb2/hcd/ehci/pci.fth Fri Oct 29 18:17:26 2010 (r1992)
+++ dev/usb2/hcd/ehci/pci.fth Sat Oct 30 05:01:34 2010 (r1993)
@@ -43,25 +43,22 @@
drop false ( false )
;
: needs-dummy-qh? ( -- flag ) 0 my-w@ h# 1106 ( VIA ) = ;
-: grab-controller ( -- error? )
- hccparams@ 8 rshift h# ff and dup if ( config-adr )
- dup my-l@ h# 10001 = if ( config-adr )
- h# 100.0000 over my-l! ( config-adr ) \ Ask for it
- true ( config-adr error? )
- d# 100 0 do ( config-adr error? )
- over my-l@ h# 101.0000 and h# 100.0000 = if
- \ Turn off SMIs in Legacy Support Extended CSR
- h# e000.0000 h# 6c my-l! ( config-adr error? )
- 0 my-l@ h# 27cc8086 = if
- h# ffff.0000 h# 70 my-l! \ Clear EHCI Intel special SMIs
- then
- 0= leave ( config-adr error?' )
- then ( config-adr error? )
- d# 10 ms ( config-adr error? )
- loop ( config-adr error? )
- nip exit
- then ( config-adr )
- then ( config-adr )
- drop ( )
- false
+: grab-controller ( config-adr -- error? )
+ dup my-l@ h# 10001 = if ( config-adr )
+ h# 100.0000 over my-l! ( config-adr ) \ Ask for it
+ true ( config-adr error? )
+ d# 100 0 do ( config-adr error? )
+ over my-l@ h# 101.0000 and h# 100.0000 = if
+ \ Turn off SMIs in Legacy Support Extended CSR
+ h# e000.0000 h# 6c my-l! ( config-adr error? )
+ 0 my-l@ h# 27cc8086 = if
+ h# ffff.0000 h# 70 my-l! \ Clear EHCI Intel special SMIs
+ then
+ 0= leave ( config-adr error?' )
+ then ( config-adr error? )
+ d# 10 ms ( config-adr error? )
+ loop ( config-adr error? )
+ nip exit
+ then ( config-adr )
+ drop false ( false )
;
Modified: dev/usb2/hcd/ehci/probe.fth
==============================================================================
--- dev/usb2/hcd/ehci/probe.fth Fri Oct 29 18:17:26 2010 (r1992)
+++ dev/usb2/hcd/ehci/probe.fth Sat Oct 30 05:01:34 2010 (r1993)
@@ -129,10 +129,12 @@
alloc-dma-buf
first-open? if
false to first-open?
- grab-controller if
- ." Can't take control of EHCI from underlying BIOS" cr
- free-dma-buf unmap-regs
- false exit
+ hccparams@ 8 rshift h# ff and ?dup if ( config-adr )
+ grab-controller if
+ ." Can't take control of EHCI from underlying BIOS" cr
+ free-dma-buf unmap-regs
+ false exit
+ then
then
0 ehci-reg@ h# ff and to op-reg-offset
reset-usb
1
0

[commit] r1992 - cpu/arm cpu/arm/mmp2 cpu/arm/olpc/1.75 dev dev/olpc/dcon dev/olpc/kb3700 dev/olpc/mmp2camera dev/pci
by repository service Oct. 29, 2010
by repository service Oct. 29, 2010
Oct. 29, 2010
Author: wmb
Date: Fri Oct 29 18:17:26 2010
New Revision: 1992
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1992
Log:
OLPC XO-1.75 - another checkpoint - more stuff working.
Added:
cpu/arm/mmp2/spimaster.fth
cpu/arm/olpc/1.75/dconsmb.fth
cpu/arm/olpc/1.75/lcd.fth
cpu/arm/olpc/1.75/prefw.bth
dev/olpc/dcon/mmp2dcon.fth
dev/olpc/mmp2camera/
dev/olpc/mmp2camera/ccic.fth
dev/olpc/mmp2camera/loadpkg.fth
dev/olpc/mmp2camera/ov.fth
dev/olpc/mmp2camera/platform.fth
dev/olpc/mmp2camera/smbus.fth
Modified:
cpu/arm/assem.fth
cpu/arm/disassem.fth
cpu/arm/mmp2/sspspi.fth
cpu/arm/mmp2/watchdog.fth
cpu/arm/olpc/1.75/addrs.fth
cpu/arm/olpc/1.75/boardgpio.fth
cpu/arm/olpc/1.75/config.fth
cpu/arm/olpc/1.75/devices.fth
cpu/arm/olpc/1.75/fw.bth
cpu/arm/olpc/1.75/lcdcfg.fth
cpu/arm/olpc/1.75/probemem.fth
cpu/arm/olpc/1.75/sp.bth
dev/olpc/kb3700/spicmd.fth
dev/pci/isakbd.fth
dev/pckbd.fth
dev/ps2mouse.fth
Modified: cpu/arm/assem.fth
==============================================================================
--- cpu/arm/assem.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/assem.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -546,6 +546,7 @@
: amode-rrop2 ( -- ) init-operands get-r12 get-r16 get-opr2 !op ;
: amode-rnop2 ( -- ) init-operands get-r16 get-opr2 !op ;
: amode-rdop2 ( -- ) init-operands get-r12 get-opr2 !op ;
+: amode-rev ( -- ) init-operands get-r12 get-r00 !op ;
: amode-lsm ( -- )
init-operands
@@ -951,6 +952,10 @@
: ldr ( -- ) 0410.0000 {cond} {shbt} ;
: str ( -- ) 0400.0000 {cond} {hbt} ;
+: rev ( -- ) 06bf0f30 {cond} amode-rev ;
+: rev16 ( -- ) 06bf0fb0 {cond} amode-rev ;
+: revsh ( -- ) 06ff0f30 {cond} amode-rev ;
+
: rd-field ( reg# -- ) d# 12 set-field ;
: rb-field ( reg# -- ) d# 16 set-field ;
Modified: cpu/arm/disassem.fth
==============================================================================
--- cpu/arm/disassem.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/disassem.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -251,9 +251,20 @@
imm12 if ., ." #" +/- imm12 u.h then
then
;
+: .rev ( -- ) {<cond>} op.rd, .rm ;
+: .stuff ( -- )
+ 0 d# 28 bits h# 0fff.0ff0 and
+ case
+ h# 06bf0f30 of ." rev" .rev endof
+ h# 06bf0fb0 of ." rev16" .rev endof
+ h# 06ff0f30 of ." revsh" .rev endof
+ ( default )
+ ." undefined" {<cond>}
+ endcase
+;
: .ldr/str ( -- ) \ d# 25 3 bits 2|3 =
0 d# 28 bits h# 0e00.0010 and h# 0600.0010 = if
- ." undefined" {<cond>}
+ .stuff
exit
then
.ld/st ." r" {<cond>} {b} {t}
Added: cpu/arm/mmp2/spimaster.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/spimaster.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,104 @@
+\ See license at end of file
+purpose: Driver for Marvell MMP2 SSP in SPI Master Mode
+
+0 0 " d4035000" " /" begin-package \ SPI interface using SSP1
+
+headerless
+
+" spi" device-name
+
+0 0 encode-bytes
+ " Marvell,ssp-spi" encode-string encode+
+" compatible" property
+
+my-address my-space h# 1000 encode-reg
+" reg" property
+
+\ 1 " #address-cells" integer-property
+\ 0 " #size-cells" integer-property
+
+3 /n* buffer: port-data
+: init-queue ( -- ) port-data 3 na+ bounds ?do -1 i ! /n +loop ;
+
+my-space value ssp-base
+: ssp-sscr0 ( -- adr ) ssp-base ;
+: ssp-sscr1 ( -- adr ) ssp-base la1+ ;
+: ssp-sssr ( -- adr ) ssp-base 2 la+ ;
+: ssp-ssdr ( -- adr ) ssp-base 4 la+ ;
+
+: enable ( -- )
+ h# 87 ssp-sscr0 rl! \ Enable, 8-bit data, SPI normal mode
+;
+: disable ( -- )
+ h# 07 ssp-sscr0 rl! \ 8-bit data, SPI normal mode
+;
+\ Switch to master mode, for testing
+: master ( -- )
+ disable
+ h# 0000.0000 ssp-sscr1 rl! \ master mode
+ enable
+;
+
+: ssp1-clk-on 7 h# d4015050 l! 3 h# d4015050 l! ;
+\ : ssp2-clk-on 7 h# d4015054 l! 3 h# d4015052 l! ;
+\ : ssp3-clk-on 7 h# d4015058 l! 3 h# d4015058 l! ;
+\ : ssp4-clk-on 7 h# d401505c l! 3 h# d401505c l! ;
+
+: wb ( byte -- ) ssp-ssdr rl! ;
+: rb ( -- byte ) ssp-ssdr rl@ . ;
+
+: select-ssp1-pins ( -- ) d# 47 d# 43 do h# c3 i af! loop ;
+
+\ Choose alternate function 4 (SSP3) for the pins we use
+: init-ssp-in-master-mode ( -- )
+ select-ssp1-pins
+ ssp1-clk-on
+ disable \ 8-bit data, SPI normal mode
+ 0 ssp-sscr1 rl! \ master mode
+ \ The enable bit must be set last, after all configuration is done
+ enable \ Enable, 8-bit data, SPI normal mode
+;
+
+: .ssr ssp-sssr rl@ . ;
+: ssp-#bytes ( -- n ) ssp-sssr rl@ d# 12 rshift h# f and ;
+
+0 value open-count
+: open ( -- flag )
+ open-count 0= if
+ my-address my-space h# 1000 " map-in" $call-parent is ssp-base
+ init-ssp-in-master-mode
+ then
+ open-count 1+ to open-count
+ true
+;
+: close ( -- )
+ open-count 1 = if
+ ssp-base h# 1000 " map-in" $call-parent 0 is ssp-base
+ then
+ open-count 1- 0 max to open-count
+;
+end-package
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 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: cpu/arm/mmp2/sspspi.fth
==============================================================================
--- cpu/arm/mmp2/sspspi.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/mmp2/sspspi.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -38,6 +38,10 @@
disable-interrupts
ignore-power-button
ssp-spi-start
+ \ The following clears out some glitches so the chip will respond
+ \ to the ab-id command.
+ 0 spi-cmd spi-cs-off
+ 0 spi-cmd spi-cs-off
;
: use-ssp-spi ( -- )
Modified: cpu/arm/mmp2/watchdog.fth
==============================================================================
--- cpu/arm/mmp2/watchdog.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/mmp2/watchdog.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -16,7 +16,7 @@
: wdt@ ( offset -- value ) wdt-pa + l@ ;
: (reset-all) ( -- )
enable-wdt-clock
- 2 h# 68 wdt! \ set match register
+ 2 h# 68 wdt! \ set match register
3 h# 64 wdt! \ match enable: just interrupt, no reset yet
1 h# 98 wdt! \ Reset counter
begin again
Modified: cpu/arm/olpc/1.75/addrs.fth
==============================================================================
--- cpu/arm/olpc/1.75/addrs.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/addrs.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -12,7 +12,7 @@
\ OFW implementation choices
\ h# 1fe0.0000 constant fw-pa
-0 constant fw-pa
+h# 1fa0.0000 constant fw-pa
[ifdef] virtual-mode
h# f700.0000 constant fw-virt-base
Modified: cpu/arm/olpc/1.75/boardgpio.fth
==============================================================================
--- cpu/arm/olpc/1.75/boardgpio.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/boardgpio.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -19,6 +19,7 @@
d# 34 gpio-dir-out \ EN_WLAN_PWR
d# 35 gpio-dir-out \ EN_SD_PWR
d# 57 gpio-dir-out \ WLAN_PD#
+ d# 58 gpio-set \ WLAN_RESET#
d# 58 gpio-dir-out \ WLAN_RESET#
d# 73 gpio-dir-out \ CAM_RST
@@ -221,7 +222,7 @@
0 af, \ GPIO_160 - ND_RDY[1]
1 af, \ GPIO_161 - ND_IO[12] - Not connected (TP 44)
1 af, \ GPIO_162 - (ND_IO[11]) - DCON_SCL
- 1 af, \ GPIO_163 - (ND_IO[10]) - DCON_SDA
+ 1 pull-up, \ GPIO_163 - (ND_IO[10]) - DCON_SDA
1 af, \ GPIO_164 - (ND_IO[9]) - Not connected (TP106)
0 af, \ GPIO_165 - ND_IO[3]
0 af, \ GPIO_166 - ND_IO[2]
Modified: cpu/arm/olpc/1.75/config.fth
==============================================================================
--- cpu/arm/olpc/1.75/config.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/config.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -1,4 +1,6 @@
create debug-startup
+create olpc
+create trust-ec-keyboard
fload ${BP}/cpu/arm/olpc/1.75/addrs.fth
fload ${BP}/cpu/arm/mmp2/hwaddrs.fth
Added: cpu/arm/olpc/1.75/dconsmb.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/dconsmb.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,122 @@
+: smb-dly 4 us ;
+
+: smb-data-hi ( -- ) d# 163 gpio-set smb-dly ;
+: smb-data-lo ( -- ) d# 163 gpio-clr smb-dly ;
+: smb-clk-hi ( -- ) d# 162 gpio-set smb-dly ;
+: smb-clk-lo ( -- ) d# 162 gpio-clr smb-dly ;
+: smb-data@ ( -- flag ) d# 163 gpio-pin@ ;
+: smb-clk@ ( -- flag ) d# 162 gpio-pin@ ;
+: smb-off ( -- ) d# 163 gpio-dir-in ;
+: smb-on ( -- ) d# 163 gpio-dir-out ;
+: smb-data-dir-out ( -- ) d# 163 gpio-dir-out ;
+: smb-data-dir-in ( -- ) d# 163 gpio-dir-in ;
+
+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-dir-in
+ smb-data-hi
+ smb-clk-hi smb-wait-clk-hi
+ smb-data@ \ drop \ SCCB generates an don't care bit
+ if smb-stop true abort" I2c NAK" then
+ smb-clk-lo
+\ smb-wait-data-hi
+ smb-data-dir-out
+;
+: 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 )
+ smb-data-dir-in
+ 0
+ 8 0 do ( n )
+ smb-clk-hi ( n )
+ 2* smb-data@ if 1 or then ( n' )
+ smb-clk-lo
+ loop
+ smb-data-dir-out
+ swap smb-bit smb-data-hi \ Send ACK or NAK
+;
+
+0 value smb-slave
+: smb-addr ( lowbit -- ) smb-slave or smb-byte ;
+
+: smb-byte! ( byte reg# -- )
+ smb-start
+ 0 smb-addr ( byte reg# )
+ smb-byte ( byte )
+ smb-byte ( )
+ smb-stop
+;
+
+: smb-byte@ ( reg# -- byte )
+ smb-start
+ 0 smb-addr ( reg# )
+ smb-byte ( )
+ smb-stop smb-start \ SCCB bus needs a stop and a start for the second phase
+ 1 smb-addr
+ 1 smb-byte-in ( byte )
+ smb-stop
+;
+
+: 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
+;
+
+: set-dcon-slave ( -- ) h# 1a to smb-slave ;
+: smb-init ( -- ) set-dcon-slave smb-on smb-pulses ;
+
+: dcon@ ( reg# -- word ) set-dcon-slave smb-word@ ;
+: dcon! ( word reg# -- ) set-dcon-slave smb-word! ;
Modified: cpu/arm/olpc/1.75/devices.fth
==============================================================================
--- cpu/arm/olpc/1.75/devices.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/devices.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -86,6 +86,17 @@
\needs md5init fload ${BP}/ofw/ppp/md5.fth \ MD5 hash
+[ifdef] notyet
+fload ${BP}/dev/olpc/confirm.fth \ Selftest interaction modalities
+fload ${BP}/cpu/x86/pc/olpc/mfgdata.fth \ Manufacturing data
+fload ${BP}/cpu/x86/pc/olpc/mfgtree.fth \ Manufacturing data in device tree
+fload ${BP}/cpu/x86/pc/olpc/kbdtype.fth \ Export keyboard type
+
+fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports
+[else]
+: find-tag ( adr len -- false | value$ true ) 2drop false ;
+[then]
+
fload ${BP}/dev/olpc/spiflash/flashif.fth \ Generic FLASH interface
fload ${BP}/dev/olpc/spiflash/spiif.fth \ Generic low-level SPI bus access
@@ -103,14 +114,16 @@
: ofw-fw-filename$ " disk:\boot\olpc.rom" ;
' ofw-fw-filename$ to fw-filename$
-0 [if]
0 0 " d420b000" " /" begin-package
" display" name
fload ${BP}/cpu/arm/olpc/1.75/lcdcfg.fth
-\ fload ${BP}/cpu/arm/mmp2/dsi.fth
- fload ${BP}/cpu/arm/mmp2/lcd.fth
+ fload ${BP}/cpu/arm/olpc/1.75/lcd.fth
+ fload ${BP}/cpu/arm/olpc/1.75/dconsmb.fth \ SMB access to DCON chip - bitbanged
+ fload ${BP}/dev/olpc/dcon/mmp2dcon.fth \ DCON control
+
: display-on
+ init-xo-display \ Turns on DCON
init-lcd
fb-pa hdisp vdisp * >bytes h# ff fill
;
@@ -137,12 +150,15 @@
' display-remove is-remove
' display-selftest is-selftest
end-package
+
devalias screen /display
devalias keyboard /keyboard
-fload ${BP}/ofw/termemu/cp881-16.fth
-[then]
+create 15x30pc " ${BP}/ofw/termemu/15x30pc.psf" $file,
+' 15x30pc to romfont
+
+\ fload ${BP}/ofw/termemu/cp881-16.fth
fload ${BP}/cpu/arm/olpc/1.75/sdhci.fth
@@ -151,6 +167,8 @@
fload ${BP}/dev/olpc/kb3700/spicmd.fth
+devalias keyboard /ec-spi/keyboard
+
0 0 " d4208000" " /" begin-package \ USB Host Controller
h# 200 constant /regs
my-address my-space /regs reg
@@ -165,15 +183,26 @@
fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
end-package
-: usb-power-on ( -- ) d# 82 gpio-set ; \ 1 instead of 82 for XO
+: usb-power-on ( -- ) 1 gpio-set ;
+: unreset-usb-hub ( -- ) d# 146 gpio-set ;
-0 [if]
fload ${BP}/cpu/arm/marvell/utmiphy.fth
-stand-init: Init USB Phy
+
+: start-usb ( -- )
+ h# 9 h# d428285c l! \ Enable clock to USB block
+ unreset-usb-hub
init-usb-phy
;
+
+0 [if]
+stand-init: Init USB Phy
+\ usb-power-on \ The EC now controls the USB power
+ start-usb
+;
[then]
+fload ${BP}/dev/olpc/mmp2camera/loadpkg.fth
+
\ LICENSE_BEGIN
\ Copyright (c) 2010 FirmWorks
\
Modified: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- cpu/arm/olpc/1.75/fw.bth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/fw.bth Fri Oct 29 18:17:26 2010 (r1992)
@@ -1,168 +1,17 @@
purpose: Build OFW Forth dictionary for OLPC XO-1.75
\ See license at end of file
-dictionary: ${BP}/cpu/arm/build/basefw.dic
+dictionary: ${BP}/cpu/arm/olpc/1.75/build/prefw.dic
command: &armforth &dictionary &this
build-now
-" fw.tag" r/w create-file drop tag-file !
+\ " fw.tag" r/w create-file drop tag-file !
hex
\ ' $report-name is include-hook
-' noop is include-hook
+\ ' noop is include-hook
-fload ${BP}/cpu/arm/olpc/1.75/config.fth
-
-: headerless ; : headers ; : headerless0 ;
-
-' (quit) to quit
-
-: \Tags [compile] \ ; immediate
-: \NotTags [compile] \ ; immediate
-
-: RAMbase ( -- adr ) fw-virt-base ;
-: RAMtop ( -- adr ) RAMbase /fw-ram + ;
-
-def-load-base ' load-base set-config-int-default
-
-\ use-movable-vector-base \ Marvell CPU core has a movable vector base
-
-true ' fcode-debug? set-config-int-default
-\ false ' auto-boot? set-config-int-default
-
-
-
-[ifdef] serial-console
-" com1" ' output-device set-config-string-default
-" com1" ' input-device set-config-string-default
-[then]
-
-
-fload ${BP}/cpu/arm/mmp2/rootnode.fth \ Root node mapping - physical mode
-dev /
- " olpc,XO-1.75" model
- " Marvell,Armada 610" encode-string " architecture" property
-\ The clock frequency of the root bus may be irrelevant, since the bus is internal to the SOC
-\ d# 1,000,000,000 " clock-frequency" integer-property
-device-end
-
-: (cpu-arch ( -- adr len )
- " architecture" ['] root-node get-package-property drop
- get-encoded-string
-;
-' (cpu-arch to cpu-arch
-
-\ Memory management services
-[ifdef] virtual-mode
-fload ${BP}/ofw/core/clntmem1.fth \ client services for memory
-[else]
-fload ${BP}/ofw/core/clntphy1.fth \ client services for memory
-: >physical ( va -- pa )
- dup fw-virt-base - fw-virt-size u< if ( va )
- fw-virt-base - fw-pa +
- then
-;
-[then]
-fload ${BP}/ofw/core/memlist.fth \ Resource list common routines
-fload ${BP}/ofw/core/showlist.fth \ Linked list display tool
-fload ${BP}/ofw/core/allocph1.fth \ S Physical memory allocator
-fload ${BP}/ofw/core/availpm.fth \ Available memory list
-
-fload ${BP}/cpu/arm/olpc/1.75/probemem.fth \ Memory probing
-
-stand-init: Probing memory
- " probe" memory-node @ $call-method
-;
-
-[ifdef] virtual-mode
-fload ${BP}/cpu/arm/loadvmem.fth \ /mmu node
-stand-init: MMU
- " /mmu" open-dev mmu-node !
-;
-fload ${BP}/ofw/core/initdict.fth \ Dynamic dictionary allocation
-fload ${BP}/arch/arm/loadarea.fth \ Allocate and map program load area
-[else]
-fload ${BP}/cpu/arm/mmp2/mmuon.fth
-[then]
-
-\ XXX should be elsewhere
-dev /client-services
-: chain ( len args entry size virt -- )
- release ( len args entry )
- h# 8000 alloc-mem h# 8000 + (init-program) ( len args )
- to r1 to r2
- go
-;
-device-end
-
-fload ${BP}/cpu/arm/crc32.fth \ Assembly language Zip CRC calculation
-fload ${BP}/forth/lib/crc32.fth \ High-level portion of CRC calculation
-
-[ifdef] resident-packages
-
-\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation
-support-package: ext2-file-system
- fload ${BP}/ofw/fs/ext2fs/ext2fs.fth \ Linux file system
-end-support-package
-
-[ifdef] jffs2-support
-\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation
-support-package: jffs2-file-system
- fload ${BP}/ofw/fs/jffs2/jffs2.fth \ Journaling flash file system 2
-end-support-package
-[then]
-
-support-package: zip-file-system
- fload ${BP}/ofw/fs/zipfs.fth \ Zip file system
-end-support-package
-[then]
-
-fload ${BP}/ofw/core/osfile.fth \ For testing
-
-\ Load file format handlers
-
-: call32 ;
-
-fload ${BP}/ofw/core/allocsym.fth \ Allocate memory for symbol table
-fload ${BP}/ofw/core/symcif.fth
-fload ${BP}/ofw/core/symdebug.fth
-: release-load-area ( boundary-adr -- ) drop ;
-
-[ifdef] use-elf
-fload ${BP}/ofw/elf/elf.fth
-fload ${BP}/ofw/elf/elfdebug.fth
-[ifdef] virtual-mode
-\ Depends on the assumption that physical memory is mapped 1:1 already
-: (elf-map-in) ( va size -- ) 0 mem-claim drop ;
-[else]
-: (elf-map-in) ( va size -- ) 2drop ;
-[then]
-' (elf-map-in) is elf-map-in
-[then]
-
-\ Reboot and re-entry code
-fload ${BP}/ofw/core/reboot.fth \ Restart the client program
-fload ${BP}/ofw/core/reenter.fth \ Various entries into Forth
-
-headerless
-[ifdef] virtual-mode
-: (initial-heap) ( -- adr len ) sp0 @ ps-size - dict-limit tuck - ;
-[else]
- \ : (initial-heap) ( -- adr len ) RAMtop heap-size ;
-: (initial-heap) ( -- adr len ) limit heap-size ;
-[then]
-' (initial-heap) is initial-heap
-headers
-
-" /openprom" find-device
- " FirmWorks,3.0" encode-string " model" property
-device-end
-
-[ifdef] virtual-mode
-fload ${BP}/cpu/arm/mmusetup.fth \ Initial values for MMU lists
-[then]
-
-: background-rgb ( -- r g b ) h# ff h# ff h# ff ;
+: confirm-selftest? ( -- flag ) true ; \ XXX implement me
fload ${BP}/cpu/arm/olpc/1.75/devices.fth
@@ -175,17 +24,7 @@
warning on
[then]
-true ' local-mac-address? set-config-int-default
-[ifdef] resident-packages
-support-package: nfs
- fload ${BP}/ofw/fs/nfs/loadpkg.fth
-end-support-package
-
-[then]
-devalias nfs net//obp-tftp:last//nfs
-
fload ${BP}/cpu/arm/linux.fth
-h# 20.0000 to linux-params \ The Jasper Linux kernel fails unless the params are between 0x20.0000 and 0x20.4000
d# 9999 to arm-linux-machine-type \ Marvell Jasper
\ Add a tag describing the linear frame buffer
@@ -207,7 +46,7 @@
0 tag-b, \ Rsvd size
d# 24 tag-b, \ Rsvd position
;
-\ ' mmp-fb-tag, to fb-tag,
+' mmp-fb-tag, to fb-tag,
\ fload ${BP}/cpu/arm/mmp2/usb.fth
@@ -253,24 +92,6 @@
;
' (.firmware) to .firmware
-fload ${BP}/ofw/gui/bmptools.fth
-fload ${BP}/dev/null.fth
-fload ${BP}/ofw/core/bailout.fth
-
-\ GUI
-false value gui-safeboot?
-
-: 2tuck ( d1 d2 -- d2 d1 d2 ) 2swap 2over ;
-: user-ok "ok" ; \ This is supposed to check for authorization
-true value user-mode?
-
-fload ${BP}/ofw/gui/loadmenu.fth
-\ fload ${BP}/ofw/gui/insticon.fth
-
-\ Uninstall the diag menu from the general user interface vector
-\ so exiting from emacs doesn't invoke the diag menu.
-' quit to user-interface
-
: screen-#lines ( -- n )
screen-ih 0= if default-#lines exit then
screen-ih package( #lines )package
@@ -327,51 +148,6 @@
fload ${BP}/cpu/arm/saverom.fth \ Save the dictionary for standalone startup
-fload ${BP}/forth/lib/selstr.fth
-
-fload ${BP}/ofw/inet/loadtcp.fth
-
-support-package: http
- fload ${BP}/ofw/inet/http.fth \ HTTP client
-end-support-package
-
-[ifdef] notyet
-fload ${BP}/cpu/x86/pc/olpc/memtest.fth
-[then]
-
-[ifdef] notyet
-fload ${BP}/ofw/wifi/wifi-cfg.fth
-support-package: supplicant
-fload ${BP}/ofw/wifi/loadpkg.fth
-end-support-package
-
-: ofw-ssids ( -- $ ) " OFWSSID" ;
-' ofw-ssids to default-ssids
-[then]
-
-fload ${BP}/ofw/inet/sntp.fth
-: olpc-ntp-servers ( -- )
- " DHCP time 172.18.0.1 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"
-;
-' olpc-ntp-servers to ntp-servers
-: ntp-time&date ( -- s m h d m y )
- ntp-timestamp abort" Can't contact NTP server"
- ntp>time&date
-;
-: .clock ( -- )
- time&date .date space .time ." UTC" cr
-;
-: ntp-set-clock ( -- )
- ntp-time&date " set-time" clock-node @ $call-method
- .clock
-;
-
-[ifdef] use-ppp
-fload ${BP}/ofw/ppp/loadppp.fth
-[then]
-
-" dhcp" ' ip-address set-config-string-default
-
[ifdef] notyet
: c1-idle ( -- ) interrupts-enabled? if halt then ;
' c1-idle to stdin-idle
@@ -386,13 +162,19 @@
" //null" open-dev to null-ih \ For text-off state
;
-
+: keyboard-off ( -- )
+ keyboard-ih if
+ keyboard-ih remove-input
+ keyboard-ih close-dev
+ 0 to keyboard-ih
+ then
+;
: interpreter-init ( -- )
hex
warning on
only forth also definitions
-\ install-alarm
+ install-alarm
page-mode
#line off
@@ -478,14 +260,7 @@
quit
;
-\ This helps with TeraTerm, which sends ESC-O as the arrow key prefix
-also hidden also keys-forth definitions
-warning @ warning off
-: esc-o key lastchar ! [""] esc-[ do-command ;
-warning !
-previous previous definitions
-
-tag-file @ fclose tag-file off
+\ tag-file @ fclose tag-file off
.( --- Saving fw.dic ...)
" fw.dic" $save-forth cr
Added: cpu/arm/olpc/1.75/lcd.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/lcd.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,30 @@
+
+: lcd@ ( offset -- l ) lcd-pa + l@ ;
+: lcd! ( l offset -- ) lcd-pa + l! ;
+
+: init-lcd ( -- )
+ \ Turn on clocks
+ h# 08 pmua-disp-clk-sel + h# d428284c l!
+ h# 09 pmua-disp-clk-sel + h# d428284c l!
+ h# 19 pmua-disp-clk-sel + h# d428284c l!
+ h# 1b pmua-disp-clk-sel + h# d428284c l!
+
+ 0 h# 190 lcd! \ Disable LCD DMA controller
+ fb-pa h# f4 lcd! \ Frame buffer area 0
+ 0 h# f8 lcd! \ Frame buffer area 1
+ hdisp bytes/pixel * h# fc lcd! \ Pitch in bytes
+
+ hdisp vdisp wljoin dup h# 104 lcd! dup h# 108 lcd! h# 118 lcd! \ size, size after zoom, disp
+
+ htotal >chunks vtotal wljoin h# 114 lcd! \ SPUT_V_H_TOTAL
+
+ htotal >chunks hdisp - hbp >chunks - 6 - ( low )
+ hbp >chunks wljoin h# 11c lcd!
+
+ vfp vbp wljoin h# 120 lcd!
+ h# 2000FF00 h# 194 lcd! \ DMA CTRL 1
+ h# 2000000d h# 1b8 lcd! \ Dumb panel controller - 18 bit RGB666 on LDD[17:0]
+ h# 01330133 h# 13c lcd! \ Panel VSYNC Pulse Pixel Edge Control
+ clkdiv h# 1a8 lcd! \ Clock divider
+ h# 00021100 h# 190 lcd! \ DMA CTRL 0 - enable DMA, 24 bpp mode
+;
Modified: cpu/arm/olpc/1.75/lcdcfg.fth
==============================================================================
--- cpu/arm/olpc/1.75/lcdcfg.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/lcdcfg.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -1,17 +1,20 @@
-d# 4 value hsync
-d# 1200 value hdisp
-d# 1456 value htotal .( HTOTAL ???) cr
-d# 212 value hbp
+h# 40001102 value clkdiv \ Display Clock 1 / 2 -> 56.93 MHz
+h# 00000700 value pmua-disp-clk-sel \ PLL1 / 7 -> 113.86 MHz
-d# 4 value vsync
-d# 800 value vdisp
-d# 845 value vtotal .( VTOTAL ???) cr
-d# 31 value vbp
+d# 8 value hsync \ Sync width
+d# 1200 value hdisp \ Display width
+d# 1256 value htotal \ Display + FP + Sync + BP
+d# 24 value hbp \ Back porch
-: hfp ( -- n ) htotal hdisp - hsync - hbp - ;
-: vfp ( -- n ) vtotal vdisp - vsync - vbp - ;
+d# 3 value vsync \ Sync width
+d# 900 value vdisp \ Display width
+d# 912 value vtotal \ Display + FP + Sync + BP
+d# 5 value vbp \ Back porch
-2 constant #lanes
+: hfp ( -- n ) htotal hdisp - hsync - hbp - ; \ 24
+: vfp ( -- n ) vtotal vdisp - vsync - vbp - ; \ 4
+
+3 constant #lanes
3 constant bytes/pixel
d# 24 constant bpp
Added: cpu/arm/olpc/1.75/prefw.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/prefw.bth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,249 @@
+purpose: Build OFW Forth dictionary for OLPC XO-1.75
+\ See license at end of file
+
+dictionary: ${BP}/cpu/arm/build/basefw.dic
+command: &armforth &dictionary &this
+build-now
+
+" prefw.tag" r/w create-file drop tag-file !
+
+hex
+\ ' $report-name is include-hook
+' noop is include-hook
+
+fload ${BP}/cpu/arm/olpc/1.75/config.fth
+
+: headerless ; : headers ; : headerless0 ;
+
+' (quit) to quit
+
+: \Tags [compile] \ ; immediate
+: \NotTags [compile] \ ; immediate
+
+: RAMbase ( -- adr ) fw-virt-base ;
+: RAMtop ( -- adr ) RAMbase /fw-ram + ;
+
+def-load-base ' load-base set-config-int-default
+
+\ use-movable-vector-base \ Marvell CPU core has a movable vector base
+
+true ' fcode-debug? set-config-int-default
+\ false ' auto-boot? set-config-int-default
+
+
+
+[ifdef] serial-console
+" com1" ' output-device set-config-string-default
+" com1" ' input-device set-config-string-default
+[then]
+
+
+fload ${BP}/cpu/arm/mmp2/rootnode.fth \ Root node mapping - physical mode
+dev /
+ " olpc,XO-1.75" model
+ " Marvell,Armada 610" encode-string " architecture" property
+\ The clock frequency of the root bus may be irrelevant, since the bus is internal to the SOC
+\ d# 1,000,000,000 " clock-frequency" integer-property
+device-end
+
+: (cpu-arch ( -- adr len )
+ " architecture" ['] root-node get-package-property drop
+ get-encoded-string
+;
+' (cpu-arch to cpu-arch
+
+\ Memory management services
+[ifdef] virtual-mode
+fload ${BP}/ofw/core/clntmem1.fth \ client services for memory
+[else]
+fload ${BP}/ofw/core/clntphy1.fth \ client services for memory
+: >physical ( va -- pa )
+ dup fw-virt-base - fw-virt-size u< if ( va )
+ fw-virt-base - fw-pa +
+ then
+;
+[then]
+fload ${BP}/ofw/core/memlist.fth \ Resource list common routines
+fload ${BP}/ofw/core/showlist.fth \ Linked list display tool
+fload ${BP}/ofw/core/allocph1.fth \ S Physical memory allocator
+fload ${BP}/ofw/core/availpm.fth \ Available memory list
+
+fload ${BP}/cpu/arm/olpc/1.75/probemem.fth \ Memory probing
+
+stand-init: Probing memory
+ " probe" memory-node @ $call-method
+;
+
+[ifdef] virtual-mode
+fload ${BP}/cpu/arm/loadvmem.fth \ /mmu node
+stand-init: MMU
+ " /mmu" open-dev mmu-node !
+;
+fload ${BP}/ofw/core/initdict.fth \ Dynamic dictionary allocation
+fload ${BP}/arch/arm/loadarea.fth \ Allocate and map program load area
+[else]
+fload ${BP}/cpu/arm/mmp2/mmuon.fth
+[then]
+
+\ XXX should be elsewhere
+dev /client-services
+: chain ( len args entry size virt -- )
+ release ( len args entry )
+ h# 8000 alloc-mem h# 8000 + (init-program) ( len args )
+ to r1 to r2
+ go
+;
+device-end
+
+fload ${BP}/cpu/arm/crc32.fth \ Assembly language Zip CRC calculation
+fload ${BP}/forth/lib/crc32.fth \ High-level portion of CRC calculation
+
+[ifdef] resident-packages
+
+\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation
+support-package: ext2-file-system
+ fload ${BP}/ofw/fs/ext2fs/ext2fs.fth \ Linux file system
+end-support-package
+
+[ifdef] jffs2-support
+\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation
+support-package: jffs2-file-system
+ fload ${BP}/ofw/fs/jffs2/jffs2.fth \ Journaling flash file system 2
+end-support-package
+[then]
+
+support-package: zip-file-system
+ fload ${BP}/ofw/fs/zipfs.fth \ Zip file system
+end-support-package
+[then]
+
+fload ${BP}/ofw/core/osfile.fth \ For testing
+
+\ Load file format handlers
+
+: call32 ;
+
+fload ${BP}/ofw/core/allocsym.fth \ Allocate memory for symbol table
+fload ${BP}/ofw/core/symcif.fth
+fload ${BP}/ofw/core/symdebug.fth
+: release-load-area ( boundary-adr -- ) drop ;
+
+[ifdef] use-elf
+fload ${BP}/ofw/elf/elf.fth
+fload ${BP}/ofw/elf/elfdebug.fth
+[ifdef] virtual-mode
+\ Depends on the assumption that physical memory is mapped 1:1 already
+: (elf-map-in) ( va size -- ) 0 mem-claim drop ;
+[else]
+: (elf-map-in) ( va size -- ) 2drop ;
+[then]
+' (elf-map-in) is elf-map-in
+[then]
+
+\ Reboot and re-entry code
+fload ${BP}/ofw/core/reboot.fth \ Restart the client program
+fload ${BP}/ofw/core/reenter.fth \ Various entries into Forth
+
+headerless
+[ifdef] virtual-mode
+: (initial-heap) ( -- adr len ) sp0 @ ps-size - dict-limit tuck - ;
+[else]
+ \ : (initial-heap) ( -- adr len ) RAMtop heap-size ;
+: (initial-heap) ( -- adr len ) limit heap-size ;
+[then]
+' (initial-heap) is initial-heap
+headers
+
+" /openprom" find-device
+ " FirmWorks,3.0" encode-string " model" property
+device-end
+
+[ifdef] virtual-mode
+fload ${BP}/cpu/arm/mmusetup.fth \ Initial values for MMU lists
+[then]
+
+: background-rgb ( -- r g b ) h# ff h# ff h# ff ;
+
+fload ${BP}/forth/lib/selstr.fth
+
+fload ${BP}/ofw/inet/loadtcp.fth
+
+support-package: http
+ fload ${BP}/ofw/inet/http.fth \ HTTP client
+end-support-package
+
+[ifdef] notyet
+fload ${BP}/cpu/x86/pc/olpc/memtest.fth
+[then]
+
+[ifdef] notyet
+fload ${BP}/ofw/wifi/wifi-cfg.fth
+support-package: supplicant
+fload ${BP}/ofw/wifi/loadpkg.fth
+end-support-package
+
+: ofw-ssids ( -- $ ) " OFWSSID" ;
+' ofw-ssids to default-ssids
+[then]
+
+fload ${BP}/ofw/inet/sntp.fth
+: olpc-ntp-servers ( -- )
+ " DHCP time 172.18.0.1 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"
+;
+' olpc-ntp-servers to ntp-servers
+: ntp-time&date ( -- s m h d m y )
+ ntp-timestamp abort" Can't contact NTP server"
+ ntp>time&date
+;
+: .clock ( -- )
+ time&date .date space .time ." UTC" cr
+;
+: ntp-set-clock ( -- )
+ ntp-time&date " set-time" clock-node @ $call-method
+ .clock
+;
+
+[ifdef] use-ppp
+fload ${BP}/ofw/ppp/loadppp.fth
+[then]
+
+" dhcp" ' ip-address set-config-string-default
+
+fload ${BP}/ofw/gui/bmptools.fth
+fload ${BP}/dev/null.fth
+fload ${BP}/ofw/core/bailout.fth
+
+true ' local-mac-address? set-config-int-default
+[ifdef] resident-packages
+support-package: nfs
+ fload ${BP}/ofw/fs/nfs/loadpkg.fth
+end-support-package
+
+[then]
+devalias nfs net//obp-tftp:last//nfs
+
+\ This helps with TeraTerm, which sends ESC-O as the arrow key prefix
+also hidden also keys-forth definitions
+warning @ warning off
+: esc-o key lastchar ! [""] esc-[ do-command ;
+warning !
+previous previous definitions
+
+\ GUI
+false value gui-safeboot?
+
+: 2tuck ( d1 d2 -- d2 d1 d2 ) 2swap 2over ;
+: user-ok "ok" ; \ This is supposed to check for authorization
+true value user-mode?
+
+fload ${BP}/ofw/gui/loadmenu.fth
+\ fload ${BP}/ofw/gui/insticon.fth
+
+\ Uninstall the diag menu from the general user interface vector
+\ so exiting from emacs doesn't invoke the diag menu.
+' quit to user-interface
+
+tag-file @ fclose tag-file off
+
+.( --- Saving prefw.dic ...)
+" prefw.dic" $save-forth cr
Modified: cpu/arm/olpc/1.75/probemem.fth
==============================================================================
--- cpu/arm/olpc/1.75/probemem.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/probemem.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -24,6 +24,7 @@
2drop " reg" property
\ Claim the memory used by OFW
+ fw-pa /fw-ram 0 claim drop
\ high h# 10.0000 - h# 10.0000 0 claim drop
;
Modified: cpu/arm/olpc/1.75/sp.bth
==============================================================================
--- cpu/arm/olpc/1.75/sp.bth Mon Oct 25 14:42:14 2010 (r1991)
+++ cpu/arm/olpc/1.75/sp.bth Fri Oct 29 18:17:26 2010 (r1992)
@@ -355,6 +355,60 @@
setreg d4282860 b8 \ NAND FLASH PLL1/8 + ECC PLL1/4, AXI clock enabled
setreg d4282860 bf \ plus ECC&controller&AXI released from reset
+ \ Read the SPI FLASH into DRAM
+
+ setreg d4035000 0010000f \ 32-bit, not enabled
+ setreg d4035000 0010008f \ 32-bit, enabled
+
+ setreg d401901c 00004000 \ Drive GPIO46 (SPI CS#) high
+
+ setreg d4019058 00004000 \ Set GPIO46 to output direction
+
+ setreg d401e10c 000000c0 \ GPIO mode for FRM
+ delay 10
+ setreg d4019028 00004000 \ Drive GPIO46 (SPI CS#) low
+
+ set r0,0xd4035000 \ Register base address
+ set r1,0x00100000 \ Remaining length
+ set r2,0x00000000 \ DRAM (and FLASH) address
+
+ orr r3,r2,#0x03000000 \ SPI FLASH command - read (3) with address in low bytes
+ str r3,[r0,#0x10] \ Put command in FIFO
+
+ mov r3,#0 \ Value to write (could be anything)
+ str r3,[r0,#0x10] \ Put dummy value in FIFO to force read
+
+ begin
+ ldr r5,[r0,#0x08] \ Read status
+ ands r5,#8 \ Test RxFIFO not empty bit
+ 0<> until
+ ldr r5,[r0,#0x10] \ Read (and discard) first FIFO entry
+
+ begin
+ str r3,[r0,#0x10] \ Put dummy value in FIFO to keep the read going
+
+ begin
+ ldr r5,[r0,#0x08] \ Read status
+ ands r5,#8 \ Test RxFIFO not empty bit
+ 0<> until
+ ldr r5,[r0,#0x10] \ Read FIFO entry
+
+ rev r5,r5 \ byte reverse because the FIFO is big-endian
+ str r5,[r2],#4 \ Write out
+
+ cmp r2,#0x100000
+ = until
+
+ \ Discard the extra entry just for cleanliness
+ begin
+ ldr r5,[r0,#0x08] \ Read status
+ ands r5,#8 \ Test RxFIFO not empty bit
+ 0<> until
+ ldr r5,[r0,#0x10] \ Read (and discard) first FIFO entry
+
+ setreg d401901c 00004000 \ Drive GPIO46 (SPI CS#) high
+
+
\ Finally, release the reset for the main CPU
set r0,0xd4050020
Added: dev/olpc/dcon/mmp2dcon.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/olpc/dcon/mmp2dcon.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,212 @@
+\ 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 ( -- ) d# 151 gpio-set ;
+: dcon-unload ( -- ) d# 151 gpio-clr ;
+\ : dcon-blnk? ( -- flag ) ; \ Not hooked up
+: dcon-stat@ ( -- n ) h# d4019100 l@ 4 rshift 3 and ;
+: dcon-irq? ( -- flag ) d# 124 gpio-pin@ 0= ;
+
+\ 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 ( -- ) d# 40 ms ;
+
+: mark-time ( -- start-time ) get-msecs ;
+: delta-ms ( start-time -- elapsed-ms ) mark-time swap - ;
+: wait-dcon-mode ( -- retry? )
+ mark-time ( start-time )
+ begin ( start-time )
+ dcon-irq? if ( start-time )
+ dcon-stat@ 2 = if \ DCONSTAT=10 ( start-time )
+ \ Sometimes the DCON ack's the UNLOAD command sooner than it
+ \ should. When that happens, it doesn't really capture the
+ \ new frame data. The workaround is to detect the case and
+ \ retry the sequence.
+ delta-ms d# 20 < ( retry? )
+ exit
+ then ( start-time )
+ then ( start-time )
+ dup delta-ms d# 100 > ( start-time reached? ) \ 100 ms timeout
+ until ( start-time )
+ drop
+ ." Timeout entering DCON mode" cr
+ \ We say false here because we don't want to retry; it probably won't succeed
+ false
+;
+
+: set-source ( vga? -- ) \ true to unfreeze display, false to freeze it
+ 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 ms \ Ensure that that DCON sees the DCONLOAD high
+\ display-on
+ else
+ begin ( )
+ dcon-unload \ Put the DCON in self-refresh mode
+ lock[ wait-dcon-mode ]unlock ( retry? )
+\ display-off ( retry? )
+ while ( )
+ \ We got a false ack from the DCON so start over from LOAD state
+ dcon-load d# 25 ms ( )
+ repeat ( )
+ 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@ ;
+: 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! ;
+
+: backlight-off ( -- ) mode@ 8 invert and mode! ;
+: backlight-on ( -- ) mode@ 8 or mode! ;
+
+\ 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 ( -- )
+ 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)
+
+ h# 0101 h# 41 dcon!
+ h# 0101 h# 42 dcon!
+
+ h# 12 mode!
+;
+: dcon-enable ( -- )
+ dcon-setup
+ true set-color
+ h# f bright!
+;
+
+: video-save
+ 0 set-source \ Freeze image
+\ olpc-lcd-off
+;
+
+: video-restore
+ smb-init
+\ olpc-lcd-mode
+
+\ gp-setup
+ 1 set-source \ Unfreeze image
+;
+
+0 value dcon-found?
+
+: maybe-set-cmos ( -- ) ;
+
+: init-xo-display ( -- )
+ smb-init
+
+\ olpc-lcd-mode
+
+ dcon-load
+ dcon-enable ( maybe-set-cmos )
+ \ dcon-enable leaves mode set to 69 - 40:antialias, 20:swizzle, 8:backlight on, 1:passthru off
+;
+
+\ ' init-xo-display to init-display
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 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/kb3700/spicmd.fth
==============================================================================
--- dev/olpc/kb3700/spicmd.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ dev/olpc/kb3700/spicmd.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -35,12 +35,31 @@
1 " #address-cells" integer-property
0 " #size-cells" integer-property
-3 /n* buffer: port-data
-: init-queue ( -- ) port-data 3 na+ bounds ?do -1 i ! /n +loop ;
-: enque ( data port# -- )
+: encode-unit ( phys -- adr len ) push-hex (u.) pop-base ;
+: decode-unit ( adr len -- phys ) push-hex $number if 0 then pop-base ;
+
+d# 155 constant cmd-gpio#
+d# 125 constant ack-gpio#
+
+\ Channel#(port#) Meaning
+\ 0 Invalid
+\ 1 Switch to Command Mode
+\ 2 Command response
+\ 3 Keyboard
+\ 4 Touchpad
+\ 5 Event
+\ 6 EC Debug
+
+5 constant #ports
+#ports /n* buffer: port-data
+: init-queue ( -- ) port-data #ports /n* bounds ?do -1 i ! /n +loop ;
+: enque ( data channel# -- )
+ 2- ( data queue# )
+ dup #ports >= if 2drop exit then
port-data swap na+ ! ( data adr )
;
-: deque? ( port# -- false | data true )
+: deque? ( channel# -- false | data true )
+ 2- ( queue# )
port-data swap na+ ( adr )
dup @ ( adr data )
dup -1 = if ( adr data )
@@ -70,54 +89,49 @@
enable
;
-: ssp1-clk-on 7 h# d4015050 l! 3 h# d4015050 l! ;
-: ssp2-clk-on 7 h# d4015054 l! 3 h# d4015052 l! ;
+\ : ssp1-clk-on 7 h# d4015050 l! 3 h# d4015050 l! ;
+\ : ssp2-clk-on 7 h# d4015054 l! 3 h# d4015052 l! ;
: ssp3-clk-on 7 h# d4015058 l! 3 h# d4015058 l! ;
-: ssp4-clk-on 7 h# d401505c l! 3 h# d401505c l! ;
+\ : ssp4-clk-on 7 h# d401505c l! 3 h# d401505c l! ;
-: wb ( byte -- ) ssp-ssdr rl! ;
-: rb ( -- byte ) ssp-ssdr rl@ . ;
+: wb ( byte -- ) ssp-ssdr rl! ; \ Debugging tool
+: rb ( -- byte ) ssp-ssdr rl@ . ; \ Debugging tool
\ Wait until the CSS (Clock Synchronization Status) bit is 0
: wait-clk-sync ( -- )
begin ssp-sssr rl@ h# 400.0000 and 0= until
;
-\ Choose alternate function 4 (SSP3) for the pins we use
-: select-ssp3-pins
- h# c4 h# d401e170 rl! \ GPIO74
- h# c4 h# d401e174 rl! \ GPIO75
- h# c4 h# d401e178 rl! \ GPIO76
- h# c4 h# d401e17c rl! \ GPIO77
-;
: init-ssp-in-slave-mode ( -- )
- select-ssp3-pins
ssp3-clk-on
h# 07 ssp-sscr0 rl! \ 8-bit data, SPI normal mode
- h# 1380.0010 ssp-sscr1 rl! \ SCFR=1, slave mode, Rx w/o Tx, early phase
+ h# 1300.0010 ssp-sscr1 rl! \ SCFR=1, slave mode, early phase
\ The enable bit must be set last, after all configuration is done
h# 87 ssp-sscr0 rl! \ Enable, 8-bit data, SPI normal mode
wait-clk-sync
;
-: set-ssp-receive-w/o-transmit ( -- )
- ssp-sscr1 rl@ h# 0080.0000 or ssp-sscr1 rl!
-;
-: clr-ssp-receive-w/o-transmit ( -- )
- ssp-sscr1 rl@ h# 0080.0000 invert and ssp-sscr1 rl!
-;
-0 value ssp-rx-threshold
+2 value ssp-rx-threshold
: set-ssp-fifo-threshold ( n -- ) to ssp-rx-threshold ;
-\ tx fifo trigger threshold?
: .ssr ssp-sssr rl@ . ;
-: ssp-ready? ( -- flag )
- ssp-sssr rl@ d# 12 rshift h# f and ssp-rx-threshold =
+: rxavail ( -- n )
+ ssp-sssr rl@ dup 8 and if ( val )
+ d# 12 rshift h# f and 1+
+ else
+ drop 0
+ then
+;
+: prime-fifo ( -- )
+ ssp-rx-threshold 0 ?do 0 ssp-ssdr l! loop
;
+: rxflush ( -- )
+ begin ssp-sssr rl@ 8 and while ssp-ssdr l@ drop repeat
+;
+: ssp-ready? ( -- flag ) rxavail ssp-rx-threshold >= ;
+false value debug?
\ Set the direction on the ACK and CMD GPIOs
-d# 151 constant cmd-gpio#
-d# 125 constant ack-gpio#
-: init-ec-spi-gpios ( -- )
+: init-gpios ( -- )
cmd-gpio# gpio-dir-out
ack-gpio# gpio-dir-out
;
@@ -125,21 +139,18 @@
: set-cmd ( -- ) cmd-gpio# gpio-set ;
: clr-ack ( -- ) ack-gpio# gpio-clr ;
: set-ack ( -- ) ack-gpio# gpio-set ;
-: fast-ack ( -- ) set-ack clr-ack ;
+: fast-ack ( -- ) set-ack clr-ack debug? if ." ACK " cr then ;
: slow-ack ( -- ) d# 10 ms set-ack d# 10 ms clr-ack ;
-defer pulse-ack ' slow-ack to pulse-ack \ FIXME !!!
-
-0 value ec-spi-cmd-done \ 0 - still waiting, 1 - successful send, 2 - timeout
+defer pulse-ack ' fast-ack to pulse-ack
-6 buffer: ec-cmdbuf
-d# 16 buffer: ec-respbuf
-: expected-response-length ( -- n ) ec-cmdbuf 1+ c@ h# f and ;
-
-: write-cmd-to-ssp-fifo ( -- )
- 6 0 do
- ec-cmdbuf i + c@ ssp-ssdr rl!
- loop
-;
+0 value cmdbuf
+0 value cmdlen
+0 value sticky?
+
+0 value databuf
+0 value datalen
+0 value datain?
+0 value command-finished?
0 value ec-cmd-time-limit
: ec-cmd-timeout? ( -- flag )
@@ -152,100 +163,124 @@
ec-cmd-time-limit 0= if 1 to ec-cmd-time-limit then \ Avoid reserved value
;
-defer ec-spi-state ' noop to ec-spi-state
+defer do-state ' noop to do-state
+defer upstream
-defer ec-spi-upstream
-: ec-spi-response ( -- )
- cancel-cmd-timeout
- expected-response-length 0 ?do
- ssp-ssdr rl@ ec-respbuf i + c!
- loop
- 1 to ec-spi-cmd-done
+: enter-upstream-state ( -- )
2 set-ssp-fifo-threshold
- clr-cmd
- ['] ec-spi-upstream to ec-spi-state
+ ['] upstream to do-state
+;
+: command-done ( -- )
+ cancel-cmd-timeout
+ true to command-finished?
+ sticky? 0= if
+ enter-upstream-state
+ prime-fifo
+ pulse-ack
+ then
+ \ In sticky mode, we hold off on pulsing ACK until we have the
+ \ next command to send.
;
-: ec-spi-switched ( -- )
- set-ssp-receive-w/o-transmit
- expected-response-length if
- expected-response-length set-ssp-fifo-threshold
- ['] ec-spi-response to ec-spi-state
+
+\ Discard 'len' bytes from the Rx FIFO. Used after a send
+\ operation to get rid of the bytes that were received as
+\ a side effect.
+: clean-fifo ( len -- ) 0 ?do ssp-ssdr rl@ drop loop ;
+
+: response ( -- )
+ datalen if
+ \ XXX switch to 64-byte mode if necessary
+ datain? if
+ debug? if ." Data from EC: " then
+ datalen 0 ?do
+ ssp-ssdr rl@
+ debug? if dup . then
+ databuf i + c!
+ loop
+ else
+ \ Unload the spurious (result of sending data) rx bytes from the FIFO
+ datalen clean-fifo
+ then
+ debug? if cr then
+ then
+ command-done
+;
+: switched ( -- )
+ \ Unload the spurious (result of sending command) rx bytes from the FIFO
+ cmdlen clean-fifo
+ datalen if
+ datalen set-ssp-fifo-threshold
+ ['] response to do-state
+ \ XXX switch to 64-byte mode if necessary
+ datain? if
+ prime-fifo
+ else
+ debug? if ." Data to EC: " then
+ datalen 0 ?do
+ databuf i + c@
+ debug? if dup . then
+ ssp-ssdr rl!
+ loop
+ then
+ pulse-ack
else
- ec-spi-response
+ command-done
then
;
-: (ec-spi-upstream) ( -- )
- ssp-ssdr rl@ ssp-ssdr rl@ ( channel# data )
- over 3 = if \ Switched ( channel# data )
- 2drop ( )
- write-cmd-to-ssp-fifo ( )
- clr-ssp-receive-w/o-transmit ( )
- ['] ec-spi-switched to ec-spi-state ( )
- else ( channel# data )
- swap enque ( )
- then
-;
-' (ec-spi-upstream) to ec-spi-upstream
-: init-ec-spi ( -- )
- init-ec-spi-gpios
+: handoff-command ( -- )
+ debug? if ." CMD: " then
+ cmdlen 0 do
+ cmdbuf i + c@
+ debug? if dup . then
+ ssp-ssdr rl!
+ loop
+ debug? if cr then
+ cmdlen set-ssp-fifo-threshold
+ sticky? 0= if clr-cmd then
+ ['] switched to do-state ( )
+ pulse-ack
+;
+: (upstream) ( -- )
+ ssp-ssdr rl@ ssp-ssdr rl@ ( channel# data )
+ debug? if
+ ." UP: " over . dup . cr
+ then
+ over case ( channel# data )
+ 0 of 2drop prime-fifo pulse-ack endof ( channel# data ) \ Invalid
+ 1 of 2drop handoff-command endof ( channel# data ) \ Switched
+ ( default ) ( channel# data channel# )
+ enque prime-fifo pulse-ack ( channel# )
+ endcase
+;
+' (upstream) to upstream
+: init ( -- )
+ init-gpios
init-ssp-in-slave-mode
- set-ssp-receive-w/o-transmit
+ rxflush
+ init-queue
clr-cmd
+ prime-fifo
clr-ack \ Tell EC that it is okay to send
- ['] ec-spi-upstream to ec-spi-state
+ enter-upstream-state
;
-: ec-spi-handle-message ( -- )
- ec-spi-state
- pulse-ack
+: poll ( -- )
+ ssp-ready? if do-state then
+ debug? if key? if key drop debug-me then then
;
-: poll-ec-spi ( -- )
- ssp-ready? if
- exit
- then
- ec-cmd-timeout? if
- clr-cmd
- cancel-cmd-timeout
- 2 to ec-spi-cmd-done \ Timeout
- ['] ec-spi-upstream to ec-spi-state
- exit
- then
- ec-spi-handle-message
-;
-
-: ec-command ( [ args ] #args #results cmd-code -- [ results ] error? )
- ec-cmdbuf 6 erase ( [ args ] #args #results cmd-code )
- ec-cmdbuf c! ( [ args ] #args #results )
- over 4 lshift or ( [ args ] #args #args|#results )
- ec-cmdbuf 1+ c! ( [ args ] #args )
- dup 4 > abort" Too many EC command arguments"
- 0 ?do ( ... arg )
- ec-cmdbuf 2+ i + c! ( ... )
- loop ( )
-
- set-cmd-timeout
- set-cmd
-
- 0 to ec-spi-cmd-done
- begin
- poll-ec-spi
- ec-spi-cmd-done
- until
-
- ec-spi-cmd-done 2 = if true exit then
-
- ec-cmdbuf 1+ c@ 0 ?do \ XXX maybe this loop should go backwards?
- ec-respbuf i + c@
- loop
- false
+: cancel-command ( -- ) \ Called when the command child times out
+ clr-cmd
+ ['] upstream to do-state
+ prime-fifo
+ pulse-ack
;
0 instance value port#
: set-port ( port# -- ) to port# ;
-: put-data ( byte -- ) port# 2 0 d# 99 ec-command ; \ XXX
+\ : put-data ( byte -- ) port# 2 0 d# 99 ec-command ; \ XXX
: get-data? ( -- false | data true )
port# deque? ( false | data true )
- poll-ec-spi
+ poll
;
: get-data ( -- data | -1 ) \ Wait for data from our device
d# 1000 0 do
@@ -254,7 +289,7 @@
loop
true \ abort" Timeout waiting for data from device"
;
-: put-get-data ( cmd -- data | -1 ) put-data get-data ;
+\ : put-get-data ( cmd -- data | -1 ) put-data get-data ;
\ Wait until the device stops sending data
: clear-out-buf ( -- ) begin d# 120 ms get-data? while drop repeat ;
@@ -263,17 +298,182 @@
open-count 0= if
my-address my-space h# 1000 " map-in" $call-parent is ssp-base
\ setup-pin-mux
- init-ec-spi
+ init
then
open-count 1+ to open-count
true
;
: close ( -- )
open-count 1 = if
- ssp-base h# 1000 " map-in" $call-parent 0 is ssp-base
+ ssp-base h# 1000 " map-out" $call-parent 0 is ssp-base
then
open-count 1- 0 max to open-count
;
+
+: data-command ( databuf datalen datain? cmdadr cmdlen more? -- )
+ to sticky? to cmdlen to cmdbuf
+ to datain? to datalen to databuf
+ false to command-finished?
+
+ ['] do-state behavior ['] upstream = if
+ set-cmd-timeout
+ set-cmd
+ else
+ handoff-command
+ then
+ begin poll command-finished? until
+;
+
+: no-data-command ( adr len sticky? -- )
+ >r >r >r 0 0 0 r> r> r> data-command
+;
+
+new-device
+" " " 2" set-args
+" eccmd" name
+my-space " reg" integer-property
+: open ( -- flag )
+ my-unit " set-port" $call-parent
+ true
+;
+: close ( -- )
+;
+8 buffer: ec-cmdbuf
+d# 16 buffer: ec-respbuf
+: expected-response-length ( -- n ) ec-cmdbuf 1+ c@ h# f and ;
+
+0 value #results
+: set-cmdbuf ( [ args ] #args #results cmd-code slen -- )
+ >r ( [ args ] #args #results cmd-code r: slen )
+ ec-cmdbuf 8 erase ( [ args ] #args #results cmd-code )
+ ec-cmdbuf c! ( [ args ] #args #results )
+ to #results ( [ args ] #args )
+ dup ec-cmdbuf 1+ c! ( [ args ] #args r: slen )
+ r> ec-cmdbuf 2+ c! ( [ args ] #args r: )
+ h# f and ( [ args ] #args' )
+ dup 5 > abort" Too many EC command arguments"
+ ec-cmdbuf 3 + swap bounds ?do i c! loop ( )
+;
+: get-results ( -- [ results ] )
+ ec-respbuf #results bounds ?do
+ begin " get-data?" $call-parent until ( byte )
+ i c!
+ loop
+
+ #results 0 ?do \ XXX maybe this loop should go backwards?
+ ec-respbuf i + c@
+ loop
+;
+: ec-command ( [ args ] #args #results cmd-code -- [ results ] error? )
+ 0 set-cmdbuf
+
+ ec-cmdbuf 8 false " no-data-command" $call-parent
+
+ get-results
+ false
+;
+: enter-updater ( -- )
+ 0 0 h# 50 1 set-cmdbuf
+
+ ec-respbuf 1 true ec-cmdbuf 8 true " data-command" $call-parent
+;
+
+create pgm-cmd h# 51 c, h# 84 c, d# 16 c, h# 02 c, h# 00 c, 0 c, 0 c, 0 c,
+create read-cmd h# 51 c, h# 04 c, d# 16 c, h# 03 c, h# 00 c, 0 c, 0 c, 0 c,
+create rdstat-cmd h# 51 c, h# 01 c, d# 01 c, h# 05 c, h# 80 c, 0 c, 0 c, 0 c,
+create wena-cmd h# 51 c, h# 01 c, d# 00 c, h# 06 c, h# 80 c, 0 c, 0 c, 0 c,
+create erase-cmd h# 51 c, h# 01 c, d# 00 c, h# 60 c, h# 80 c, 0 c, 0 c, 0 c,
+
+: set-offset&len ( offset len template -- )
+ >r ( offset len r: template )
+ r@ 2+ c! ( offset r: template )
+ lbsplit drop ( low mid hi r: template )
+ r@ 4 + c! r@ 5 + c! r> 6 + c!
+;
+: flash-command ( datadr datlen in? template -- )
+ 8 true " data-command" $call-parent
+;
+: write-flash-chunk ( adr len offset -- ) \ len limited to 16 bytes for now
+ over pgm-cmd set-offset&len ( adr len )
+ false pgm-cmd flash-command ( )
+;
+: read-flash-chunk ( adr len offset -- )
+ over read-cmd set-offset&len
+ true read-cmd flash-command ( )
+;
+: read-flash-status ( -- stat )
+ ec-respbuf 1 true rdstat-cmd flash-command
+ ec-respbuf c@
+;
+: write-enable-flash ( -- )
+ 0 0 false wena-cmd flash-command
+;
+: erase-flash-all ( -- )
+ 0 0 false erase-cmd flash-command
+;
+: read-flash ( adr len offset -- )
+ swap bounds ?do ( adr )
+ i . (cr ( adr )
+ dup h# 10 i read-flash-chunk ( adr )
+ h# 10 + ( adr' )
+ h# 10 +loop ( adr )
+ drop ( )
+;
+: wait-write-enabled ( -- )
+ write-enable-flash ( adr )
+ begin read-flash-status 2 and until
+;
+: wait-write-done ( -- )
+ begin read-flash-status 1 and 0= until
+;
+
+: erase-flash ( -- )
+ wait-write-enabled
+ erase-flash-all
+ wait-write-done
+;
+
+: write-flash ( adr len offset -- )
+ swap bounds ?do ( adr )
+ i . (cr ( adr )
+ wait-write-enabled
+ dup h# 10 i write-flash-chunk ( adr )
+ wait-write-done ( adr )
+ h# 10 + ( adr' )
+ h# 10 +loop ( adr )
+ drop ( )
+;
+h# 6000 value flash-size
+: get-flash ( -- )
+ load-base flash-size 0 read-flash
+;
+: put-flash ( -- )
+ ." Erasing" cr
+ erase-flash
+ ." Writing" cr
+ load-base flash-size 0 write-flash
+;
+: help ( -- )
+ ." enter-updater" cr
+ ." h# 8000 to flash-size ( default is 6000)" cr
+ ." get-flash" cr
+ ." load-base 100 ldump" cr
+ ." put-flash" cr
+;
+
+finish-device
+
+new-device
+ " " " 3" set-args
+ fload ${BP}/dev/pckbd.fth
+finish-device
+
+new-device
+ " " " 4" set-args
+ fload ${BP}/dev/ps2mouse.fth
+finish-device
+
+
end-package
\ LICENSE_BEGIN
Added: dev/olpc/mmp2camera/ccic.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/olpc/mmp2camera/ccic.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,301 @@
+\ ========================== video capture operations ==========================
+
+d# 640 constant VGA_WIDTH
+d# 480 constant VGA_HEIGHT
+
+VGA_WIDTH VGA_HEIGHT * 2* constant /dma-buf
+3 constant #dma-bufs
+0 value dma-bufs
+0 value dma-bufs-phys
+0 value next-buf
+
+: 'dma-buf ( i -- virt ) /dma-buf * dma-bufs + ;
+: 'dma-buf-phys ( i -- phys ) /dma-buf * dma-bufs-phys + ;
+
+: alloc-dma-bufs ( -- )
+ dma-bufs 0= if
+ /dma-buf #dma-bufs * alloc-capture-buffer to dma-bufs-phys to dma-bufs
+ then
+;
+: free-dma-bufs ( -- )
+ dma-bufs dma-bufs-phys /dma-buf #dma-bufs * " free-capture-buffer" $call-parent
+ 0 to dma-bufs 0 to dma-bufs-phys
+;
+
+: setup-dma ( -- )
+ h# 0440.003c h# 40 cl! \ posted writes, 3 buffers, 256 byte burst, reserved field
+
+ 0 'dma-buf-phys h# 00 cl!
+ 1 'dma-buf-phys h# 04 cl!
+ 2 'dma-buf-phys h# 08 cl!
+;
+
+\ c000.0000 = 0000.0000 for HSYNC/VSYNC format
+\ 0400.0000 for falling vclk
+\ 0200.0000 for VSYNC active low
+\ 0100.0000 for HSYNC active low
+\ 0080.0000 for VSYNC falling edge
+h# 0000.0000 constant polarities
+h# 20 constant rgb-sensor
+h# 080 constant rgb-fb
+h# 00 constant rgb-endian \ 0c bits
+
+\ VGA RGB565
+: setup-image ( -- )
+ VGA_WIDTH 2* h# 24 cl! \ 640*2 stride, UV stride in high bits = 0
+
+ VGA_WIDTH 2* VGA_HEIGHT wljoin h# 34 cl! \ Image size register
+ 0 0 wljoin h# 38 cl! \ Image offset
+
+ polarities rgb-fb or rgb-sensor or rgb-endian or h# 3c cl! \ CTRL0
+;
+
+: interrupts-off ( -- ) 0 h# 2c cl! h# ffffffff h# 30 cl! ;
+: interrupts-on ( -- ) 7 h# 2c cl! h# ffffffff h# 30 cl! ;
+
+: ctlr-config ( -- )
+
+ interrupts-off
+ setup-dma
+ setup-image
+;
+
+: ctlr-start ( -- ) h# 3c dup cl@ 1 or swap cl! ; \ Enable
+: ctlr-stop ( -- ) h# 3c dup cl@ 1 invert and swap cl! ; \ Disable
+
+: read-setup ( -- )
+ camera-config
+ ctlr-config
+ \ Clear all interrupts
+ interrupts-on \ Enable frame done interrupts
+ ctlr-start
+ 0 to next-buf
+;
+
+: power-on ( -- )
+ \ Enable clocks
+ h# 3f h# d4282828 l! \ Clock gating - AHB, Internal PIXCLK, AXI clock always on
+ h# 0003.805b h# d4282850 l! \ PMUA clock config for CCIC - /1, PLL1/16, AXI arb, AXI, perip on
+
+\ h# 0000.0002 h# 88 cl! \ Clock select - PIXMCLK, 797/2 (PLL1/16) / 2 -> 24.9 MHz
+\ h# 4000.0002 h# 88 cl! \ Clock select - AXI, 797/2 (PLL1/16) / 2 -> 24.9 MHz
+ h# 6000.0002 h# 88 cl! \ Clock select - core, 797/2 (PLL1/16) / 2 -> 24.9 MHz
+
+ sensor-power-on 1 ms
+ h# 40 cl@ h# 1000.0000 invert and h# 40 cl! \ Enable pads
+
+ reset-sensor
+ 1 ms
+;
+
+: power-off ( -- )
+ reset-sensor
+ h# 40 cl@ h# 1000.0000 or h# 40 cl! \ Disable pads
+ sensor-power-off
+;
+
+: init ( -- )
+ power-on
+ ov-smb-setup smb-on
+ camera-init
+;
+
+
+\ ============================= read operation ==============================
+
+0 value buf-act
+: /string ( adr len n -- adr' len' ) tuck - -rot + swap ;
+: buf-done? ( -- false | buf-adr true )
+ h# 30 cl@ dup 1 next-buf lshift and if ( value )
+ h# 30 cl! ( )
+ next-buf 'dma-buf ( buf-adr )
+ true ( buf-adr true )
+ else ( value )
+ drop false ( false )
+ then
+;
+
+
+: snap ( timeout -- true | adr false )
+ 0 do
+ buf-done? if ( buf-adr )
+ false unloop exit ( -- buf-adr false )
+ then
+ 1 ms
+ loop
+ true
+;
+
+external
+
+: read ( adr len -- actual )
+ buf-done? if ( adr len buf-adr )
+ -rot /dma-buf min ( buf-adr adr actual )
+ dup >r move r> ( actual )
+ else
+ 2drop 0
+ then
+;
+
+: open ( -- flag )
+ init
+ ov7670-detected? 0= if false exit then
+ alloc-dma-bufs
+ read-setup
+ true
+;
+
+: close ( -- )
+ ctlr-stop
+ interrupts-off
+ power-off
+ free-dma-bufs
+;
+
+
+\ ============================= selftest operation ===========================
+
+d# 5,000 constant movie-time
+0 constant test-x
+0 constant test-y
+
+\ Thanks to Cortland Setlow (AKA Blaketh) for the autobrightness code
+\ and the full-screen + mirrored display.
+
+: autobright ( -- )
+ read-agc 3 + 3 rshift h# f min " bright!" $call-screen
+;
+: full-brightness ( -- ) h# f " bright!" $call-screen ;
+
+code copy16>24-line ( src-adr dst-adr #pixels -- )
+ mov r2,tos \ #pixels in r2
+ ldmia sp!,{r0,r1,tos} \ r0: src, r1: dst, r2: #pixels
+ begin
+ ldrh r3,[r1]
+ inc r1,2
+
+ mov r4,r3,lsr #8
+ and r4,r4,#0xf8
+ strb r4,[r0],#1
+
+ mov r4,r3,lsr #3
+ and r4,r4,#0xfc
+ strb r4,[r0],#1
+
+ mov r4,r3,lsl #3
+ and r4,r4,#0xf8
+ strb r4,[r0],#1
+
+ decs r2,1
+ 0= until
+c;
+
+VGA_WIDTH value rect-w
+VGA_HEIGHT value rect-h
+
+d# 1200 3 * value dst-pitch
+d# 1200 VGA_WIDTH - 2/ value dst-x
+d# 800 VGA_HEIGHT - 2/ value dst-y
+
+: >dst-adr ( adr -- adr' ) dst-y dst-pitch * dst-x + 3 * + ;
+
+VGA_WIDTH 2* value src-pitch
+
+: copy16>24 ( src-adr dst-base -- )
+ >dst-adr ( src-adr dst-adr )
+ rect-h 0 ?do ( src-adr dst-adr )
+ 2dup rect-w copy16>24-line ( scr-adr dst-adr )
+ swap src-pitch + swap dst-pitch + ( scr-adr' dst-adr' )
+ loop ( src-adr dst-adr )
+ 2drop ( )
+;
+
+: display-frame ( adr -- )
+ fb-pa copy16>24
+\ autobright
+;
+
+: timeout-read ( adr len timeout -- actual )
+ >r 0 -rot r> 0 ?do ( actual adr len )
+ 2dup read ?dup if 3 roll drop -rot leave then
+ 1 ms
+ loop 2drop
+;
+
+: shoot-still ( -- error? )
+ d# 1000 snap if true exit then ( adr )
+ display-frame
+ false
+;
+
+: shoot-movie ( -- error? )
+ get-msecs movie-time + ( timeout )
+ begin ( timeout )
+ shoot-still if drop true exit then ( timeout )
+ dup get-msecs - 0<= ( timeout reached )
+ until ( timeout )
+ drop false
+;
+
+: mirrored ( -- ) h# 1e ov@ h# 20 or h# 1e ov! ;
+: unmirrored ( -- ) h# 1e ov@ h# 20 invert and h# 1e ov! ;
+
+: selftest ( -- error? )
+ open 0= if true exit then
+ d# 300 ms
+ unmirrored shoot-still ?dup if close exit then ( error? )
+ d# 1,000 ms
+ mirrored shoot-movie full-brightness ( error? )
+ close ( error? )
+ ?dup 0= if confirm-selftest? then ( error? )
+;
+
+: dump-regs ( run# -- )
+ 0 d# 16 " at-xy" eval
+ ." Pass " .d
+ key upc h# 47 = if ." Good" else ." Bad" then cr \ 47 is G
+
+ ." 0 1 2 3 4 5 6 7 8 9 a b c d e f" cr
+ ." -----------------------------------------------" cr
+ h# ca 0 do
+ i 2 u.r ." : "
+ i h# 10 bounds do
+ i h# ca < if i ov@ 3 u.r then
+ loop
+ cr
+ h# 10 +loop
+;
+
+: xselftest ( -- error? )
+ open 0= if true exit then
+
+ h# 10 0 do
+ shoot-still drop d# 500 ms camera-config config-check
+ i dump-regs
+ loop
+ 0 close ( error? )
+;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 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
Added: dev/olpc/mmp2camera/loadpkg.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/olpc/mmp2camera/loadpkg.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,31 @@
+" " " d420a000" " /" begin-package
+ " camera" device-name
+ 0 0 reg \ A reg property makes "test-all" consider this device
+
+0 [if]
+ : alloc-capture-buffer ( len -- vadr padr )
+ \ XXX need map-in if we should use virtual mode
+ dup " dma-alloc" $call-parent ( len vadr )
+ tuck swap ( vadr vadr len )
+ false " dma-map-in" $call-parent ( vadr padr )
+ ;
+ : free-capture-buffer ( vadr padr len -- )
+ 3dup " dma-map-out" $call-parent ( vadr padr len )
+ nip " dma-free" $call-parent
+ ;
+[else]
+ : alloc-capture-buffer ( len -- vadr padr )
+ drop load-base dup
+ ;
+ : free-capture-buffer ( vadr padr len -- )
+ 3drop
+ ;
+[then]
+
+ fload ${BP}/dev/olpc/mmp2camera/smbus.fth
+ fload ${BP}/dev/olpc/mmp2camera/platform.fth
+ fload ${BP}/dev/olpc/mmp2camera/ov.fth
+ fload ${BP}/dev/olpc/mmp2camera/ccic.fth
+end-package
+
+
Added: dev/olpc/mmp2camera/ov.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/olpc/mmp2camera/ov.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,261 @@
+\ ======================= OV7670 SMBUS operations ==========================
+
+: ov@ ( reg -- data ) ov-smb-setup smb-byte@ ;
+: ov! ( data reg -- ) ov-smb-setup smb-byte! ;
+
+: ovc ( val adr -- )
+ 2dup ov@ ( val reg# val actual )
+ tuck <> if ( val reg# actual )
+ ." Bad camera I2C value at " swap 2 u.r ( val actual )
+ ." expected " swap 2 u.r ." got " 2 u.r cr ( )
+ else ( val reg# actual )
+ 3drop ( )
+ then ( )
+;
+
+\ ============================= camera operations =============================
+
+false value ov7670-detected?
+
+: ((camera-init) ( -- )
+ 80 12 ov! 2 ms \ reset (reads back different)
+ 01 11 ov! \ 30 fps
+ 04 3a ov! \ UYVY or VYUY
+ 00 12 ov! \ VGA
+
+ \ Hardware window
+ 13 17 ov! \ Horiz start high bits
+ 01 18 ov! \ Horiz stop high bits
+ b6 32 ov! \ HREF pieces
+ 0a 19 ov! \ Vert start high bits
+ 7a 1a ov! \ Vert stop high bits
+ 0a 03 ov! \ GAIN, VSTART, VSTOP pieces
+
+ \ Mystery scaling numbers
+ 00 0c ov! \ Control 3
+ 00 3e ov! \ Control 14
+ 3a 70 ov! 35 71 ov! 11 72 ov! f0 73 ov!
+ 02 a2 ov!
+ 00 15 ov! \ Control 10
+
+ \ Gamma curve values
+ 20 7a ov! 10 7b ov! 1e 7c ov! 35 7d ov!
+ 5a 7e ov! 69 7f ov! 76 80 ov! 80 81 ov!
+ 88 82 ov! 8f 83 ov! 96 84 ov! a3 85 ov!
+ af 86 ov! c4 87 ov! d7 88 ov! e8 89 ov!
+
+ \ AGC and AEC parameters
+ e0 13 ov! \ Control 8
+ 00 00 ov! \ Gain lower 8 bits
+ 40 0d ov! \ Control 4 magic reserved bit
+ 18 14 ov! \ Control 9: 4x gain + magic reserved bit
+ 05 a5 ov! \ 50hz banding step limit
+ 07 ab ov! \ 60hz banding step limit
+ 95 24 ov! \ AGC upper limit
+ 33 25 ov! \ AGC lower limit
+ e3 24 ov! \ AGC/AEC fast mode op region
+ 78 9f ov! \ Hist AEC/AGC control 1
+ 68 a0 ov! \ Hist AEC/AGC control 2
+ 03 a1 ov! \ Magic
+ d8 a6 ov! \ Hist AEC/AGC control 3
+ d8 a7 ov! \ Hist AEC/AGC control 4
+ f0 a8 ov! \ Hist AEC/AGC control 5
+ 90 a9 ov! \ Hist AEC/AGC control 6
+ 94 aa ov! \ Hist AEC/AGC control 7
+ e5 13 ov! \ Control 8
+
+ \ Mostly magic
+ 61 0e ov! 4b 0f ov! 02 16 ov! 07 1e ov!
+ 02 21 ov! 91 22 ov! 07 29 ov! 0b 33 ov!
+ 0b 35 ov! 1d 37 ov! 71 38 ov! 2a 39 ov!
+ 78 3c ov! 40 4d ov! 20 4e ov! 00 69 ov!
+ 4a 6b ov! 10 74 ov! 4f 8d ov! 00 8e ov!
+ 00 8f ov! 00 90 ov! 00 91 ov! 00 96 ov!
+ 00 9a ov! 84 b0 ov! 0c b1 ov! 0e b2 ov!
+ 82 b3 ov! 0a b8 ov!
+
+ \ More magic, some of which tweaks white balance
+ 0a 43 ov! f0 44 ov! 34 45 ov! 58 46 ov!
+ 28 47 ov! 3a 48 ov! 88 59 ov! 88 5a ov!
+ 44 5b ov! 67 5c ov! 49 5d ov! 0e 5e ov!
+ 0a 6c ov! 55 6d ov! 11 6e ov!
+ 9f 6f ov! \ 9e for advance AWB
+ 40 6a ov!
+ 40 01 ov! \ Blue gain
+ 60 02 ov! \ Red gain
+ e7 13 ov! \ Control 8
+
+ \ Matrix coefficients
+ 80 4f ov! 80 50 ov! 00 51 ov! 22 52 ov!
+ 5e 53 ov! 80 54 ov! 9e 58 ov!
+
+ 08 41 ov! \ AWB gain enable
+ 00 3f ov! \ Edge enhancement factor
+ 05 75 ov! e1 76 ov! 00 4c ov! 01 77 ov!
+ c3 3d ov! \ Control 13
+ 09 4b ov! 60 c9 ov! \ Reads back differently
+ 38 41 ov! \ Control 16
+ 40 56 ov!
+
+ 11 34 ov!
+ 12 3b ov! \ Control 11
+ 88 a4 ov! 00 96 ov! 30 97 ov! 20 98 ov!
+ 30 99 ov! 84 9a ov! 29 9b ov! 03 9c ov!
+ 5c 9d ov! 3f 9e ov! 04 78 ov!
+
+ \ Extra-weird stuff. Some sort of multiplexor register
+ 01 79 ov! f0 c8 ov!
+ 0f 79 ov! 00 c8 ov!
+ 10 79 ov! 7e c8 ov!
+ 0a 79 ov! 80 c8 ov!
+ 0b 79 ov! 01 c8 ov!
+ 0c 79 ov! 0f c8 ov!
+ 0d 79 ov! 20 c8 ov!
+ 09 79 ov! 80 c8 ov!
+ 02 79 ov! c0 c8 ov!
+ 03 79 ov! 40 c8 ov!
+ 05 79 ov! 30 c8 ov!
+ 26 79 ov!
+
+ \ OVT says that rewrite this works around a bug in 565 mode.
+ \ The symptom of the bug is red and green speckles in the image.
+ 01 11 ov! \ 30 fps def 80
+;
+
+: config-check ( -- )
+ 01 11 ovc \ 30 fps
+ 04 3a ovc \ UYVY or VYUY
+ ( 00 12 ovc ) \ VGA
+
+ \ Hardware window
+ 13 17 ovc \ Horiz start high bits
+ 01 18 ovc \ Horiz stop high bits
+ b6 32 ovc \ HREF pieces
+ ( 0a 19 ovc ) \ Vert start high bits
+ 7a 1a ovc \ Vert stop high bits
+ 0a 03 ovc \ GAIN, VSTART, VSTOP pieces
+
+ \ Mystery scaling numbers
+ 00 0c ovc \ Control 3
+ 00 3e ovc \ Control 14
+ 3a 70 ovc 35 71 ovc 11 72 ovc f0 73 ovc
+ 02 a2 ovc
+ 00 15 ovc \ Control 10
+
+ \ Gamma curve values
+ 20 7a ovc 10 7b ovc 1e 7c ovc 35 7d ovc
+ 5a 7e ovc 69 7f ovc 76 80 ovc 80 81 ovc
+ 88 82 ovc 8f 83 ovc 96 84 ovc a3 85 ovc
+ af 86 ovc c4 87 ovc d7 88 ovc e8 89 ovc
+
+ \ AGC and AEC parameters
+ ( e0 13 ovc ) \ Control 8
+ ( 00 00 ovc ) \ Gain lower 8 bits
+ 40 0d ovc \ Control 4 magic reserved bit
+ ( 18 14 ovc ) \ Control 9: 4x gain + magic reserved bit
+ 05 a5 ovc \ 50hz banding step limit
+ 07 ab ovc \ 60hz banding step limit
+ ( 95 24 ovc ) \ AGC upper limit
+ 33 25 ovc \ AGC lower limit
+ e3 24 ovc \ AGC/AEC fast mode op region
+ 78 9f ovc \ Hist AEC/AGC control 1
+ 68 a0 ovc \ Hist AEC/AGC control 2
+ 03 a1 ovc \ Magic
+ d8 a6 ovc \ Hist AEC/AGC control 3
+ d8 a7 ovc \ Hist AEC/AGC control 4
+ f0 a8 ovc \ Hist AEC/AGC control 5
+ 90 a9 ovc \ Hist AEC/AGC control 6
+ 94 aa ovc \ Hist AEC/AGC control 7
+ ( e5 13 ovc ) \ Control 8
+
+ \ Mostly magic
+ 61 0e ovc 4b 0f ovc 02 16 ovc 07 1e ovc
+ 02 21 ovc 91 22 ovc 07 29 ovc 0b 33 ovc
+ 0b 35 ovc 1d 37 ovc 71 38 ovc 2a 39 ovc
+ 78 3c ovc 40 4d ovc 20 4e ovc 00 69 ovc
+ 4a 6b ovc 10 74 ovc 4f 8d ovc 00 8e ovc
+ 00 8f ovc 00 90 ovc 00 91 ovc 00 96 ovc
+ ( 00 9a ovc ) 84 b0 ovc 0c b1 ovc 0e b2 ovc
+ 82 b3 ovc 0a b8 ovc
+
+ \ More magic, some of which tweaks white balance
+ 0a 43 ovc f0 44 ovc 34 45 ovc 58 46 ovc
+ 28 47 ovc 3a 48 ovc 88 59 ovc 88 5a ovc
+ 44 5b ovc 67 5c ovc 49 5d ovc 0e 5e ovc
+ 0a 6c ovc 55 6d ovc 11 6e ovc
+ 9f 6f ovc \ 9e for advance AWB
+ ( 40 6a ovc )
+ ( 40 01 ovc ) \ Blue gain
+ ( 60 02 ovc ) \ Red gain
+ e7 13 ovc \ Control 8
+
+ \ Matrix coefficients
+ b3 4f ovc b3 50 ovc 00 51 ovc 3d 52 ovc
+ a7 53 ovc e4 54 ovc 9e 58 ovc
+
+ \ 08 41 ovc \ AWB gain enable
+ ( 00 3f ovc ) \ Edge enhancement factor
+ 05 75 ovc e1 76 ovc ( 00 4c ovc ) 01 77 ovc
+ c0 3d ovc \ Control 13
+ 09 4b ovc ( 60 c9 ovc )
+ 38 41 ovc \ Control 16
+ 40 56 ovc
+
+ 11 34 ovc
+ 12 3b ovc \ Control 11
+ 88 a4 ovc 00 96 ovc 30 97 ovc 20 98 ovc
+ 30 99 ovc 84 9a ovc 29 9b ovc 03 9c ovc
+ 5c 9d ovc 3f 9e ovc 04 78 ovc
+
+;
+
+: camera-init ( -- )
+ false to ov7670-detected?
+ ((camera-init)
+ 1d ov@ 1c ov@ bwjoin 7fa2 <> if exit then \ Manufacturing ID
+ b ov@ a ov@ bwjoin 7673 <> if exit then \ Product ID
+ true to ov7670-detected?
+;
+
+\ VGA RGB565
+: init-rgb565 ( -- )
+ 04 12 ov! \ VGA, RGB565
+ 00 8c ov! \ No RGB444
+ 00 04 ov! \ Control 1 (CaFe value is 00, Via is 40 for CCIR656)
+ 10 40 ov! \ RGB565 output
+ 38 14 ov! \ 16x gain ceiling
+ b3 4f ov! \ v-red
+ b3 50 ov! \ v-green
+ 00 51 ov! \ v-blue
+ 3d 52 ov! \ u-red
+ a7 53 ov! \ u-green
+ e4 54 ov! \ u-blue
+ c0 3d ov! \ Gamma enable, UV saturation auto adjust
+;
+
+: read-agc ( -- n )
+ 3 ov@ h# c0 and 2 lshift 0 ov@ or
+;
+
+: read-aec ( -- n )
+ 7 ov@ h# 3f and d# 10 lshift
+ h# 10 ov@ 2 lshift or
+ 4 ov@ 3 and or
+;
+
+: set-hw ( vstop vstart hstop hstart -- )
+ dup 3 >> 17 ov! \ Horiz start high bits
+ over 3 >> 18 ov! \ Horiz stop high bits
+ 32 ov@ swap 7 and or swap 7 and 3 << or 10 ms 32 ov! \ Horiz bottom bits
+
+ dup 2 >> 19 ov! \ Vert start high bits
+ over 2 >> 1a ov! \ Vert start high bits
+ 03 ov@ swap 3 and or swap 3 and 2 << or 10 ms 03 ov! \ Vert bottom bits
+;
+
+: camera-config ( -- )
+ ((camera-init)
+ init-rgb565
+ d# 490 d# 10 d# 14 d# 158 set-hw \ VGA window info
+;
+
Added: dev/olpc/mmp2camera/platform.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/olpc/mmp2camera/platform.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,26 @@
+\ See license at end of file
+purpose: Driver for OLPC camera connected to Via VX855 Video Capture Port
+
+headers
+hex
+
+" OV7670" " sensor" string-property
+
+: ov-smb-setup ( -- )
+ 1 to smb-dly-us
+ d# 108 to smb-clk-gpio# d# 109 to smb-data-gpio#
+ h# 42 to smb-slave
+;
+
+: reset-sensor ( -- ) d# 73 gpio-clr 1 ms d# 73 gpio-set ;
+
+: sensor-power-on ( -- ) d# 145 gpio-set ;
+: sensor-power-off ( -- ) d# 145 gpio-clr ;
+
+\ CAM_HSYNC is on GPIO67, CAM_VSYNC is on GPIO68
+\ PIXMCLK on GPIO69, PIXCLK on GPIO70, PIXDATA[7:0] on GPIO[59:66]
+\ CAM_SCL on GPIO108, CAM_SDA on GPIO109 (bitbang)
+
+: cl! ( l adr -- ) h# d420a000 + rl! ;
+: cl@ ( adr -- l ) h# d420a000 + rl@ ;
+
Added: dev/olpc/mmp2camera/smbus.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/olpc/mmp2camera/smbus.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -0,0 +1,120 @@
+4 value smb-dly-us
+: smb-dly smb-dly-us us ;
+
+0 value smb-data-gpio#
+0 value smb-clk-gpio#
+
+: smb-data-hi ( -- ) smb-data-gpio# gpio-set smb-dly ;
+: smb-data-lo ( -- ) smb-data-gpio# gpio-clr smb-dly ;
+: smb-clk-hi ( -- ) smb-clk-gpio# gpio-set smb-dly ;
+: smb-clk-lo ( -- ) smb-clk-gpio# gpio-clr smb-dly ;
+: smb-data@ ( -- flag ) smb-data-gpio# gpio-pin@ ;
+: smb-clk@ ( -- ) smb-clk-gpio# gpio-pin@ ;
+: smb-off ( -- ) smb-data-gpio# gpio-dir-in ;
+: smb-on ( -- ) smb-data-gpio# gpio-dir-out smb-clk-gpio# gpio-dir-out ;
+: smb-data-dir-out ( -- ) smb-data-gpio# gpio-dir-out ;
+: smb-data-dir-in ( -- ) smb-data-gpio# gpio-dir-in ;
+
+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-dir-in
+ smb-data-hi
+ smb-clk-hi smb-wait-clk-hi
+ smb-data@ \ drop \ SCCB generates an don't care bit
+ if smb-stop smb-data-dir-out true abort" I2c NAK" then
+ smb-clk-lo
+\ smb-wait-data-hi
+ smb-data-dir-out
+;
+: 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 )
+ smb-data-dir-in
+ 0
+ 8 0 do ( n )
+ smb-clk-hi ( n )
+ 2* smb-data@ if 1 or then ( n' )
+ smb-clk-lo
+ loop
+ smb-data-dir-out
+ swap smb-bit smb-data-hi \ Send ACK or NAK
+;
+
+0 value smb-slave
+: smb-addr ( lowbit -- ) smb-slave or smb-byte ;
+
+: smb-byte! ( byte reg# -- )
+ smb-start
+ 0 smb-addr ( byte reg# )
+ smb-byte ( byte )
+ smb-byte ( )
+ smb-stop
+;
+
+: smb-byte@ ( reg# -- byte )
+ smb-start
+ 0 smb-addr ( reg# )
+ smb-byte ( )
+ smb-stop smb-start \ SCCB bus needs a stop and a start for the second phase
+ 1 smb-addr
+ 1 smb-byte-in ( byte )
+ smb-stop
+;
+
+: 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
+;
Modified: dev/pci/isakbd.fth
==============================================================================
--- dev/pci/isakbd.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ dev/pci/isakbd.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -6,11 +6,13 @@
fload ${BP}/dev/i8042.fth
new-device
+ " " " 0" set-args
fload ${BP}/dev/pckbd.fth
\ d# 1 encode-int 3 encode-int encode+ " interrupts" property
finish-device
new-device
+ " " " 1" set-args
fload ${BP}/dev/ps2mouse.fth
\ d# 12 encode-int 3 encode-int encode+ " interrupts" property
finish-device
Modified: dev/pckbd.fth
==============================================================================
--- dev/pckbd.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ dev/pckbd.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -6,14 +6,13 @@
hex
headerless
+my-space " reg " integer-property
" keyboard" device-name
" pnpPNP,303" " compatible" string-property
" keyboard" device-type
-0 " reg" integer-property
-
: kbdtest ;
0 value #queued
@@ -528,7 +527,7 @@
: open ( -- okay? )
kbd-refcount @ if 1 +refcnt true exit then
unlock
- 0 set-port
+ my-space set-port
keyboard-present? if clear-out-buf else reset then
keyboard-present? 0= if false exit then
choose-type
Modified: dev/ps2mouse.fth
==============================================================================
--- dev/ps2mouse.fth Mon Oct 25 14:42:14 2010 (r1991)
+++ dev/ps2mouse.fth Fri Oct 29 18:17:26 2010 (r1992)
@@ -4,7 +4,7 @@
" mouse" device-name
" mouse" device-type
" pnpPNP,f03" " compatible" string-property
-1 " reg" integer-property
+my-space " reg " integer-property
headerless
: get-data ( -- byte ) " get-data" $call-parent ;
@@ -299,7 +299,7 @@
lock[
identify if
\ This port is unresponsive; try the other
- 0 set-port identify if ]unlock true exit then
+ my-unit 1- set-port identify if ]unlock true exit then
then ( id )
dup h# ab = if ( id )
@@ -312,7 +312,7 @@
my-port 0= if ]unlock true exit then
\ Otherwise look for the mouse on the keyboard port
- 0 set-port identify if ]unlock true exit then ( id )
+ my-unit 1- set-port identify if ]unlock true exit then ( id )
then ( id )
]unlock ( id )
@@ -325,7 +325,7 @@
headers
: open ( -- flag )
- 1 set-port
+ my-unit set-port
open-count 0= if
\ The "force" argument causes the open to succeed even if no mouse
1
0

[commit] r1991 - cpu/arm/mmp2 cpu/arm/olpc/1.75 cpu/x86/pc/biosload cpu/x86/pc/olpc cpu/x86/pc/olpc/via dev/mmc/sdhci dev/olpc/kb3700 dev/olpc/spiflash
by repository service Oct. 25, 2010
by repository service Oct. 25, 2010
Oct. 25, 2010
Author: wmb
Date: Mon Oct 25 14:42:14 2010
New Revision: 1991
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1991
Log:
OLPC XO-1.75 - checkpoint of partially working version - SD works and "flash" works (except that you have to issue the command 3 times to sync with the chip).
Added:
cpu/arm/mmp2/draminit.fth
cpu/arm/mmp2/sspspi.fth
cpu/arm/olpc/1.75/addrs.fth
cpu/arm/olpc/1.75/config.fth
cpu/arm/olpc/1.75/fw.bth
cpu/arm/olpc/1.75/ofw.bth
cpu/arm/olpc/1.75/probemem.fth
cpu/arm/olpc/1.75/sdhci.fth
cpu/arm/olpc/1.75/sdregs.fth
cpu/arm/olpc/1.75/spiui.fth
Modified:
cpu/arm/mmp2/clockset.fth
cpu/arm/mmp2/mfpr.fth
cpu/arm/olpc/1.75/boardgpio.fth
cpu/arm/olpc/1.75/devices.fth
cpu/x86/pc/biosload/config.fth
cpu/x86/pc/olpc/versions.fth
cpu/x86/pc/olpc/via/fw-version.fth
dev/mmc/sdhci/sdhci.fth
dev/olpc/kb3700/spicmd.fth
dev/olpc/spiflash/spiflash.fth
Modified: cpu/arm/mmp2/clockset.fth
==============================================================================
--- cpu/arm/mmp2/clockset.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ cpu/arm/mmp2/clockset.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -13,7 +13,8 @@
0021db00 d4050034 l! \ PMUM_PLL2_CTRL2 \ same plus enable
28600322 d4050414 l! \ PMUM_PLL2_CTRL1 \ same as above plus release PLL loop filter
\ select clock source, PJ4-PLL1, SP-PLL1/2, AXI/DDR-PLL1
- 20800000 d4050008 l! \ PMUM_FCCR PLL1 > PJ4 (bits 31:29), PLL1/2 > SP (bits 28:26), PLL1 > AXI&DDR (bits 25:23)
+\ 20800000 d4050008 l! \ PMUM_FCCR PLL1 > PJ4 (bits 31:29), PLL1/2 > SP (bits 28:26), PLL1 > AXI&DDR (bits 25:23)
+ 24800000 d4050008 l! \ PMUM_FCCR PLL1 > PJ4 (bits 31:29), PLL1 > SP (bits 28:26), PLL1 > AXI&DDR (bits 25:23)
\ divider setting and frequency change request, core-800, ddr-400, axi-200
08fd8248 d4282800 l! \ PMUA_CC_SP \ speed change voting, ACLK:7, DCLK:5, BACLK1:1, PCLK:0
78fd8248 d4282804 l! \ PMUA_CC_PJ \
Added: cpu/arm/mmp2/draminit.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/draminit.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,67 @@
+h# d101c000 constant load-base
+: dl
+ load-base ( adr )
+ begin key dup control d <> while ( adr char )
+ over c! 1+ ( adr' )
+ repeat ( adr char )
+ drop ( adr )
+ load-base tuck - evaluate
+;
+: \ h# d parse 2drop ; immediate
+
+: init-mem
+ d0004d56 d0000010 l! \ CONFIG_DECODE_ADDR
+ 000c0001 d0000100 l! \ MMAP0
+ 100c0001 d0000110 l! \ MMAP1
+ 00006420 d0000020 l! \ SDRAM_CONFIG_TYPE1-CS0
+ 00006420 d0000030 l! \ SDRAM_CONFIG_TYPE1-CS1
+ 00000000 d0000b40 l! \ SDRAM_CONFIG_TYPE2-CS0
+ 00000000 d0000b50 l! \ SDRAM_CONFIG_TYPE2-CS1
+ 488700c5 d0000050 l! \ SDRAM_TIMING1 !4cda00c5 tRTP 2>3, tWTR 2>3, tRC 7>1a (7>26)
+ 323300d2 d0000060 l! \ SDRAM_TIMING2 !94860342 tRP 3>9, tRRD 2>4, tRCD 3>8, tWR 3>6, tRFC d>34
+ 20000e12 d0000190 l! \ SDRAM_TIMING3 !2000381b ACS_EXIT_DLY 0>3, ACS_TIMER e>8, OUTEN 0>1, RSVD 0>1
+ 3023009d d00001c0 l! \ SDRAM_TIMING4
+ 00050082 d0000650 l! \ SDRAM_TIMING5 ! 110142 tRAS 5>11, tFAW 8>14
+ 00909064 d0000660 l! \ SDRAM_TIMING6 ! 2424190 tZQCS 9>24, tZQOPER 24>90, tZQINIT 64>190
+ 00005000 d0000080 l! \ SDRAM_CTRL1
+ 00080010 d0000090 l! \ SDRAM_CTRL2
+ c0000000 d00000f0 l! \ SDRAM_CTRL3
+ 20c08115 d00001a0 l! \ SDRAM_CTRL4
+ 01010101 d0000280 l! \ SDRAM_CTRL5_ARB_WEIGHTS
+ 00000000 d0000760 l! \ SDRAM_CTRL6_SDRAM_ODT_CTRL
+ 03000000 d0000770 l! \ SDRAM_CTRL7_SDRAM_ODT_CTRL2
+ 00000133 d0000780 l! \ SDRAM_CTRL8_SDRAM_ODT_CTRL2
+ 01010101 d00007b0 l! \ SDRAM_CTRL11_ARB_WEIGTHS_FAST_QUEUE
+ 0000000f d00007d0 l! \ SDRAM_CTRL13
+ 00000000 d00007e0 l! \ SDRAM_CTRL14
+ 00000000 d0000540 l! \ MCB_CTRL4
+ 00000001 d0000570 l! \ MCB_SLFST_SEL
+ 00000000 d0000580 l! \ MCB_SLFST_CTRL0
+ 00000000 d0000590 l! \ MCB_SLFST_CTRL1
+ 00000000 d00005a0 l! \ MCB_SLFST_CTRL2
+ 00000000 d00005b0 l! \ MCB_SLFST_CTRL3
+ 00000000 d0000180 l! \ CM_WRITE_PROTECTION
+ 00000000 d0000210 l! \ PHY_CTRL11
+ 80000000 d0000240 l! \ PHY_CTRL14 - PHY sync enable
+ 2000ce00 d0000240 l! \ PHY_CTRL14 - PHY DLL Reset (20000000)
+ 0000ce00 d0000240 l! \ PHY_CTRL14 - release reset
+ 0011ce00 d0000200 l! \ PHY_CTRL10
+ 0010311c d0000200 l! \ PHY_CTRL10
+ 20004422 d0000140 l! \ PHY_CTRL3 !20004444 PHY_RFIFO_RPTR_DLY_VAL 2>4, DQ_EXT_DLY 2>4
+ 13300559 d00001d0 l! \ PHY_CTRL7 (0x2330_0339 / 0x133C_2559)
+ 03300990 d00001e0 l! \ PHY_CTRL8
+ 00000077 d00001f0 l! \ PHY_CTRL9
+ 20000088 d0000230 l! \ PHY_CTRL13 (0x2000_0108 / 0x2024_0109)
+ 00000080 d0000e10 l! \ PHY_DLL_CTRL1
+ 00000080 d0000e20 l! \ PHY_DLL_CTRL2
+ 00000080 d0000e30 l! \ PHY_DLL_CTRL3
+ 00000000 d0000e40 l! \ PHY_CTRL_WL_SELECT
+ 00000000 d0000e50 l! \ PHY_CTRL_WL_CTRL0
+ 03000001 d0000120 l! \ USER_INITIATED_COMMAND0 - init command to both CS (need to wait 200 us for tINIT3)
+ 0302003f d0000410 l! \ USER_INITIATED_COMMAND1 - MRW MR63 (RESET) to both CS (need to wait RESET_COUNT)
+ 01001000 d0000120 l! \ USER_INITIATED_COMMAND0 - MRW MR10 (ZQ long cal) to CS0 (need 360 ns delay for tZQCS)
+ 02001000 d0000120 l! \ USER_INITIATED_COMMAND0 - MRW MR10 (ZQ long cal) to CS1 (need 360 ns delay for tZQCS)
+ 03020001 d0000410 l! \ USER_INITIATED_COMMAND1 - MRW MR1 to both CS
+ 03020002 d0000410 l! \ USER_INITIATED_COMMAND1 - MRW MR2 to both CS
+ 03020003 d0000410 l! \ USER_INITIATED_COMMAND1 - MRW MR3 to both CS
+;
Modified: cpu/arm/mmp2/mfpr.fth
==============================================================================
--- cpu/arm/mmp2/mfpr.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ cpu/arm/mmp2/mfpr.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -49,5 +49,6 @@
: af@ ( gpio# -- function# ) gpio>mfpr l@ ;
: af! ( function# gpio# -- ) gpio>mfpr l! ;
: af, ( n -- ) h# c0 + w, ;
+: +fast ( n -- n' ) h# 1800 or ;
: pull-up, ( n -- ) h# c0c0 + w, ;
: pull-dn, ( n -- ) h# a0c0 + w, ;
Added: cpu/arm/mmp2/sspspi.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/sspspi.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,76 @@
+\ See license at end of file
+\ Access primitives for SPI FLASH using Marvell MMP2 SSP
+
+\ Some chips (e.g. Spansion) don't work in hardware mode, so we do
+\ everything in "firmware mode", where we have control over the SPI bus.
+\ Every spicmd! clocks out 8 bits. To read, you have to do a dummy
+\ write of the value 0, then you can read the data from the spidata register.
+
+h# d4035000 value ssp-base \ SSP1
+: ssp-sscr0 ( -- adr ) ssp-base ;
+: ssp-sscr1 ( -- adr ) ssp-base la1+ ;
+: ssp-sssr ( -- adr ) ssp-base 2 la+ ;
+: ssp-ssdr ( -- adr ) ssp-base 4 la+ ;
+
+
+: ssp-spi-start ( -- )
+ h# 07 ssp-sscr0 l!
+ 0 ssp-sscr1 l!
+ h# 87 ssp-sscr0 l!
+ d# 46 gpio-set
+ d# 46 gpio-dir-out
+ h# c0 d# 46 af!
+;
+: ssp-spi-cs-on ( -- ) d# 46 gpio-clr ;
+: ssp-spi-cs-off ( -- ) d# 46 gpio-set ;
+
+: ssp-spi-out-in ( bo -- bi )
+ begin ssp-sssr l@ 4 and until \ Tx not full
+ ssp-ssdr l!
+ begin ssp-sssr l@ 8 and until \ Rx not empty
+ ssp-ssdr l@
+;
+
+: ssp-spi-out ( b -- ) ssp-spi-out-in drop ;
+: ssp-spi-in ( -- b ) 0 ssp-spi-out-in ;
+
+: safe-spi-start
+ disable-interrupts
+ ignore-power-button
+ ssp-spi-start
+;
+
+: use-ssp-spi ( -- )
+ ['] safe-spi-start to spi-start
+ ['] ssp-spi-in to spi-in
+ ['] ssp-spi-out to spi-out
+ ['] ssp-spi-cs-on to spi-cs-on
+ ['] ssp-spi-cs-off to spi-cs-off
+ ['] ssp-spi-reprogrammed to spi-reprogrammed
+ use-spi-flash-read
+;
+use-ssp-spi
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 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
Added: cpu/arm/olpc/1.75/addrs.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/addrs.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,40 @@
+\ Platform design choices
+h# 2000.0000 constant total-ram-size
+
+h# 1fc0.0000 constant fb-pa
+h# 40.0000 constant fb-size \ The screen use a little more than 3 MiB at 1200x900x24
+
+fb-pa constant available-ram-size
+
+
+: (memory?) ( phys -- flag ) total-ram-size u< ;
+' (memory?) to memory?
+
+\ OFW implementation choices
+\ h# 1fe0.0000 constant fw-pa
+0 constant fw-pa
+
+[ifdef] virtual-mode
+h# f700.0000 constant fw-virt-base
+h# 0100.0000 constant fw-virt-size \ 16 megs of mapping space
+[else]
+fw-pa value fw-virt-base
+0 value fw-virt-size
+[then]
+
+h# 0020.0000 constant /fw-ram
+
+h# 0110.0000 constant def-load-base
+
+\ The heap starts at RAMtop, which on this system is "fw-pa /fw-ram +"
+
+h# 10.0000 constant heap-size
+heap-size constant initial-heap-size
+
+h# 40.0000 constant page-table-pa
+
+\ Defined by CPU core
+h# 1000 to pagesize
+d# 12 to pageshift
+h# 10.0000 constant /section
+h# 4000 constant /page-table
Modified: cpu/arm/olpc/1.75/boardgpio.fth
==============================================================================
--- cpu/arm/olpc/1.75/boardgpio.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ cpu/arm/olpc/1.75/boardgpio.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -22,11 +22,13 @@
d# 58 gpio-dir-out \ WLAN_RESET#
d# 73 gpio-dir-out \ CAM_RST
+ d# 125 gpio-set
d# 125 gpio-dir-out \ EC_SPI_ACK
d# 145 gpio-dir-out \ EN_CAM_PWR
d# 146 gpio-dir-out \ HUB_RESET#
d# 151 gpio-dir-out \ DCONLOAD
- d# 151 gpio-dir-out \ EC_SPI_CMD
+ d# 155 gpio-clr
+ d# 155 gpio-dir-out \ EC_SPI_CMD
d# 162 gpio-dir-out \ DCON_SCL
d# 163 gpio-dir-out \ DCON_SDA
@@ -160,7 +162,7 @@
1 af, \ GPIO_110 - (ND_IO[13]) - Not connected (TP43)
1 af, \ GPIO_111 - (ND_IO[8]) - Not connected (TP108)
0 af, \ GPIO_112 - ND_RDY[0]
- 3 af, \ GPIO_113 - (SM_RDY) - MSD_CMD
+ 3 af, \ GPIO_113 - (SM_RDY) - MSD_CMD (externally pulled up)
1 af, \ GPIO_114 - G_CLK_OUT - Not connected (TP93)
4 af, \ GPIO_115 - UART3_TXD (J4)
@@ -175,22 +177,24 @@
3 af, \ GPIO_123 - 32 KHz_CLK_OUT - Not connected (TP92)
0 af, \ GPIO_124 - DCONIRQ
- 0 af, \ GPIO_125 - EC_SPI_ACK
+\ 0 af, \ GPIO_125 - EC_SPI_ACK
+ 0 pull-up, \ GPIO_125 - EC_SPI_ACK
- 3 af, \ GPIO_126 - MSD_DATA2
- 3 af, \ GPIO_127 - MSD_DATA0
+ 3 pull-up, \ GPIO_126 - MSD_DATA2
+ 3 pull-up, \ GPIO_127 - MSD_DATA0
0 af, \ GPIO_128 - EB_MODE#
0 af, \ GPIO_129 - LID_SW#
- 3 af, \ GPIO_130 - MSD_DATA3
- 1 af, \ GPIO_131 - SD_DATA3
- 1 af, \ GPIO_132 - SD_DATA2
- 1 af, \ GPIO_133 - SD_DATA1
- 1 af, \ GPIO_134 - SD_DATA0
- 3 af, \ GPIO_135 - MSD_DATA1
- 1 af, \ GPIO_136 - SD_CMD
+ 3 pull-up, \ GPIO_130 - MSD_DATA3
+ 1 +fast pull-up, \ GPIO_131 - SD_DATA3
+ 1 +fast pull-up, \ GPIO_132 - SD_DATA2
+ 1 +fast pull-up, \ GPIO_133 - SD_DATA1
+ 1 +fast pull-up, \ GPIO_134 - SD_DATA0
+ 3 pull-up, \ GPIO_135 - MSD_DATA1
+\ 1 +fast pull-up, \ GPIO_136 - SD_CMD
+ 1 +fast af, \ GPIO_136 - SD_CMD - CMD is pulled up externally
no-update, \ GPIO_137 - Not connected (TP111)
- 3 af, \ GPIO_138 - MSD_CLK
- 1 af, \ GPIO_139 - SD_CLK
+ 3 pull-up, \ GPIO_138 - MSD_CLK
+ 1 +fast pull-up, \ GPIO_139 - SD_CLK
no-update, \ GPIO_140 - Not connected if R130 is nopop
\ 1 af, \ GPIO_140 - (SD_CD# if R130 is populated)
1 af, \ GPIO_141 - SD_WP
@@ -209,7 +213,7 @@
1 af, \ GPIO_152 - (SM_BELn) - Not connected (TP40)
1 af, \ GPIO_153 - (SM_BEHn) - Not connected (TP105)
0 af, \ GPIO_154 - (SM_INT) - EC_IRQ#
- 1 af, \ GPIO_155 - (EXT_DMA_REQ0) - EC_SPI_CMD
+ 1 pull-dn, \ GPIO_155 - (EXT_DMA_REQ0) - EC_SPI_CMD
no-update, \ GPIO_156 - PRI_TDI (JTAG)
no-update, \ GPIO_157 - PRI_TDS (JTAG)
no-update, \ GPIO_158 - PRI_TDK (JTAG)
Added: cpu/arm/olpc/1.75/config.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/config.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,4 @@
+create debug-startup
+
+fload ${BP}/cpu/arm/olpc/1.75/addrs.fth
+fload ${BP}/cpu/arm/mmp2/hwaddrs.fth
Modified: cpu/arm/olpc/1.75/devices.fth
==============================================================================
--- cpu/arm/olpc/1.75/devices.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ cpu/arm/olpc/1.75/devices.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -1,5 +1,6 @@
fload ${BP}/dev/omap/diaguart.fth \ OMAP UART
-h# d4030000 to uart-base \ UART# base address on MMP2
+h# d4018000 to uart-base \ UART3 base address on MMP2
+\ h# d4030000 to uart-base \ UART1 base address on MMP2
d# 26000000 to uart-clock-frequency
: init-clocks
@@ -12,7 +13,6 @@
h# c1 h# d401e0cc l! \ GPIO30 = af1 for UART1 TXD
h# c4 h# d401e260 l! \ GPIO115 = af4 for UART3 RXD
h# c4 h# d401e264 l! \ GPIO116 = af4 for UART3 TXD
- h# 1b h# d4282854 l! \ SD0 clocks
;
: inituarts ( -- )
@@ -51,17 +51,17 @@
fload ${BP}/cpu/arm/mmp2/mfpr.fth
fload ${BP}/cpu/arm/mmp2/gpio.fth
-fload ${BP}/cpu/arm/olpc/1.75/boardtwsi.fth
+\ fload ${BP}/cpu/arm/olpc/1.75/boardtwsi.fth
fload ${BP}/cpu/arm/olpc/1.75/boardgpio.fth
: init-stuff
- set-camera-domain-voltage
+\ set-camera-domain-voltage
acgr-clocks-on
init-mfprs
set-gpio-directions
init-timers
init-twsi
- power-on-dsi
- power-on-sd
+\ power-on-dsi
+\ power-on-sd
;
stand-init:
init-stuff
@@ -71,19 +71,39 @@
fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer
-0 0 " d4030000" " /" begin-package \ UART1
+0 0 " d4018000" " /" begin-package \ UART3
fload ${BP}/cpu/arm/mmp2/uart.fth
end-package
devalias com1 /uart
: com1 " com1" ;
' com1 is fallback-device
-0 0 " d4018000" " /" begin-package \ UART3
+0 0 " d4030000" " /" begin-package \ UART1
fload ${BP}/cpu/arm/mmp2/uart.fth
end-package
devalias com2 /uart
: com2 " com2" ;
+\needs md5init fload ${BP}/ofw/ppp/md5.fth \ MD5 hash
+
+fload ${BP}/dev/olpc/spiflash/flashif.fth \ Generic FLASH interface
+
+fload ${BP}/dev/olpc/spiflash/spiif.fth \ Generic low-level SPI bus access
+fload ${BP}/dev/olpc/spiflash/spiflash.fth \ SPI FLASH programming
+
+: ignore-power-button ; \ XXX implement me
+: ssp-spi-reprogrammed ;
+: ?erased ( adr len -- flag ) 2drop true ;
+: ?enough-power ( -- ) ;
+
+fload ${BP}/cpu/arm/mmp2/sspspi.fth \ Synchronous Serial Port SPI interface
+
+fload ${BP}/cpu/arm/olpc/1.75/spiui.fth \ User interface for SPI FLASH programming
+\ 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$
+
+0 [if]
0 0 " d420b000" " /" begin-package
" display" name
fload ${BP}/cpu/arm/olpc/1.75/lcdcfg.fth
@@ -122,10 +142,12 @@
devalias keyboard /keyboard
fload ${BP}/ofw/termemu/cp881-16.fth
+[then]
-fload ${BP}/cpu/arm/mmp2/sdhcimmp2.fth
+fload ${BP}/cpu/arm/olpc/1.75/sdhci.fth
-devalias ext /sd/disk@1
+devalias int /sd@d4281000/disk
+devalias ext /sd@d4280000/disk
fload ${BP}/dev/olpc/kb3700/spicmd.fth
@@ -145,10 +167,12 @@
: usb-power-on ( -- ) d# 82 gpio-set ; \ 1 instead of 82 for XO
+0 [if]
fload ${BP}/cpu/arm/marvell/utmiphy.fth
stand-init: Init USB Phy
init-usb-phy
;
+[then]
\ LICENSE_BEGIN
\ Copyright (c) 2010 FirmWorks
Added: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/fw.bth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,519 @@
+purpose: Build OFW Forth dictionary for OLPC XO-1.75
+\ See license at end of file
+
+dictionary: ${BP}/cpu/arm/build/basefw.dic
+command: &armforth &dictionary &this
+build-now
+
+" fw.tag" r/w create-file drop tag-file !
+
+hex
+\ ' $report-name is include-hook
+' noop is include-hook
+
+fload ${BP}/cpu/arm/olpc/1.75/config.fth
+
+: headerless ; : headers ; : headerless0 ;
+
+' (quit) to quit
+
+: \Tags [compile] \ ; immediate
+: \NotTags [compile] \ ; immediate
+
+: RAMbase ( -- adr ) fw-virt-base ;
+: RAMtop ( -- adr ) RAMbase /fw-ram + ;
+
+def-load-base ' load-base set-config-int-default
+
+\ use-movable-vector-base \ Marvell CPU core has a movable vector base
+
+true ' fcode-debug? set-config-int-default
+\ false ' auto-boot? set-config-int-default
+
+
+
+[ifdef] serial-console
+" com1" ' output-device set-config-string-default
+" com1" ' input-device set-config-string-default
+[then]
+
+
+fload ${BP}/cpu/arm/mmp2/rootnode.fth \ Root node mapping - physical mode
+dev /
+ " olpc,XO-1.75" model
+ " Marvell,Armada 610" encode-string " architecture" property
+\ The clock frequency of the root bus may be irrelevant, since the bus is internal to the SOC
+\ d# 1,000,000,000 " clock-frequency" integer-property
+device-end
+
+: (cpu-arch ( -- adr len )
+ " architecture" ['] root-node get-package-property drop
+ get-encoded-string
+;
+' (cpu-arch to cpu-arch
+
+\ Memory management services
+[ifdef] virtual-mode
+fload ${BP}/ofw/core/clntmem1.fth \ client services for memory
+[else]
+fload ${BP}/ofw/core/clntphy1.fth \ client services for memory
+: >physical ( va -- pa )
+ dup fw-virt-base - fw-virt-size u< if ( va )
+ fw-virt-base - fw-pa +
+ then
+;
+[then]
+fload ${BP}/ofw/core/memlist.fth \ Resource list common routines
+fload ${BP}/ofw/core/showlist.fth \ Linked list display tool
+fload ${BP}/ofw/core/allocph1.fth \ S Physical memory allocator
+fload ${BP}/ofw/core/availpm.fth \ Available memory list
+
+fload ${BP}/cpu/arm/olpc/1.75/probemem.fth \ Memory probing
+
+stand-init: Probing memory
+ " probe" memory-node @ $call-method
+;
+
+[ifdef] virtual-mode
+fload ${BP}/cpu/arm/loadvmem.fth \ /mmu node
+stand-init: MMU
+ " /mmu" open-dev mmu-node !
+;
+fload ${BP}/ofw/core/initdict.fth \ Dynamic dictionary allocation
+fload ${BP}/arch/arm/loadarea.fth \ Allocate and map program load area
+[else]
+fload ${BP}/cpu/arm/mmp2/mmuon.fth
+[then]
+
+\ XXX should be elsewhere
+dev /client-services
+: chain ( len args entry size virt -- )
+ release ( len args entry )
+ h# 8000 alloc-mem h# 8000 + (init-program) ( len args )
+ to r1 to r2
+ go
+;
+device-end
+
+fload ${BP}/cpu/arm/crc32.fth \ Assembly language Zip CRC calculation
+fload ${BP}/forth/lib/crc32.fth \ High-level portion of CRC calculation
+
+[ifdef] resident-packages
+
+\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation
+support-package: ext2-file-system
+ fload ${BP}/ofw/fs/ext2fs/ext2fs.fth \ Linux file system
+end-support-package
+
+[ifdef] jffs2-support
+\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation
+support-package: jffs2-file-system
+ fload ${BP}/ofw/fs/jffs2/jffs2.fth \ Journaling flash file system 2
+end-support-package
+[then]
+
+support-package: zip-file-system
+ fload ${BP}/ofw/fs/zipfs.fth \ Zip file system
+end-support-package
+[then]
+
+fload ${BP}/ofw/core/osfile.fth \ For testing
+
+\ Load file format handlers
+
+: call32 ;
+
+fload ${BP}/ofw/core/allocsym.fth \ Allocate memory for symbol table
+fload ${BP}/ofw/core/symcif.fth
+fload ${BP}/ofw/core/symdebug.fth
+: release-load-area ( boundary-adr -- ) drop ;
+
+[ifdef] use-elf
+fload ${BP}/ofw/elf/elf.fth
+fload ${BP}/ofw/elf/elfdebug.fth
+[ifdef] virtual-mode
+\ Depends on the assumption that physical memory is mapped 1:1 already
+: (elf-map-in) ( va size -- ) 0 mem-claim drop ;
+[else]
+: (elf-map-in) ( va size -- ) 2drop ;
+[then]
+' (elf-map-in) is elf-map-in
+[then]
+
+\ Reboot and re-entry code
+fload ${BP}/ofw/core/reboot.fth \ Restart the client program
+fload ${BP}/ofw/core/reenter.fth \ Various entries into Forth
+
+headerless
+[ifdef] virtual-mode
+: (initial-heap) ( -- adr len ) sp0 @ ps-size - dict-limit tuck - ;
+[else]
+ \ : (initial-heap) ( -- adr len ) RAMtop heap-size ;
+: (initial-heap) ( -- adr len ) limit heap-size ;
+[then]
+' (initial-heap) is initial-heap
+headers
+
+" /openprom" find-device
+ " FirmWorks,3.0" encode-string " model" property
+device-end
+
+[ifdef] virtual-mode
+fload ${BP}/cpu/arm/mmusetup.fth \ Initial values for MMU lists
+[then]
+
+: background-rgb ( -- r g b ) h# ff h# ff h# ff ;
+
+fload ${BP}/cpu/arm/olpc/1.75/devices.fth
+
+[ifndef] virtual-mode
+warning off
+: stand-init-io
+ stand-init-io
+ go-fast \ From mmuon.fth
+;
+warning on
+[then]
+
+true ' local-mac-address? set-config-int-default
+[ifdef] resident-packages
+support-package: nfs
+ fload ${BP}/ofw/fs/nfs/loadpkg.fth
+end-support-package
+
+[then]
+devalias nfs net//obp-tftp:last//nfs
+
+fload ${BP}/cpu/arm/linux.fth
+h# 20.0000 to linux-params \ The Jasper Linux kernel fails unless the params are between 0x20.0000 and 0x20.4000
+d# 9999 to arm-linux-machine-type \ Marvell Jasper
+
+\ Add a tag describing the linear frame buffer
+: mmp-fb-tag, ( -- )
+ 8 tag-l,
+ h# 54410008 tag-l, \ ATAG_VIDEOLFB
+ d# 1200 tag-w, \ Width
+ d# 900 tag-w, \ Height
+ d# 24 tag-w, \ Depth
+ d# 1200 3 * tag-w, \ Pitch
+ fb-pa tag-l, \ Base address
+ d# 1200 3 * d# 900 * tag-l, \ Total size - perhaps could be larger
+ 8 tag-b, \ Red size
+ d# 0 tag-b, \ Red position
+ 8 tag-b, \ Green size
+ d# 8 tag-b, \ Green position
+ 8 tag-b, \ Blue size
+ d# 16 tag-b, \ Blue position
+ 0 tag-b, \ Rsvd size
+ d# 24 tag-b, \ Rsvd position
+;
+\ ' mmp-fb-tag, to fb-tag,
+
+\ fload ${BP}/cpu/arm/mmp2/usb.fth
+
+\ false to stand-init-debug?
+true to stand-init-debug?
+
+: protect-fw ( -- ) ;
+
+hex
+: i-key-wait ( ms -- pressed? )
+ cr ." Type 'i' to interrupt stand-init sequence" cr ( ms )
+ 0 do
+ ukey? if
+ ukey upc ascii I = if true unloop exit then
+ then
+ 1 ms
+ loop
+ false
+;
+
+warning @ warning off
+: init
+\ initial-heap add-memory
+ init
+
+ standalone? if
+ disable-interrupts
+ d# 1000
+ i-key-wait if
+\ protect-fw
+ ." Interacting" cr hex interact
+ then
+ \ Turn on USB power here to overlap the time with other startup actions
+ usb-power-on
+ then
+;
+warning !
+[then]
+
+: (.firmware) ( -- )
+ ." Open Firmware " .built cr
+ ." Copyright 2010 FirmWorks All Rights Reserved" cr
+;
+' (.firmware) to .firmware
+
+fload ${BP}/ofw/gui/bmptools.fth
+fload ${BP}/dev/null.fth
+fload ${BP}/ofw/core/bailout.fth
+
+\ GUI
+false value gui-safeboot?
+
+: 2tuck ( d1 d2 -- d2 d1 d2 ) 2swap 2over ;
+: user-ok "ok" ; \ This is supposed to check for authorization
+true value user-mode?
+
+fload ${BP}/ofw/gui/loadmenu.fth
+\ fload ${BP}/ofw/gui/insticon.fth
+
+\ Uninstall the diag menu from the general user interface vector
+\ so exiting from emacs doesn't invoke the diag menu.
+' quit to user-interface
+
+: screen-#lines ( -- n )
+ screen-ih 0= if default-#lines exit then
+ screen-ih package( #lines )package
+;
+' screen-#lines to lines/page
+
+true value text-on?
+: text-off ( -- )
+ text-on? if
+ screen-ih remove-output
+ false to text-on?
+ then
+;
+: text-on ( -- )
+ text-on? 0= if
+ screen-ih add-output
+ cursor-on
+ true to text-on?
+ then
+;
+
+fload ${BP}/cpu/x86/pc/olpc/help.fth
+
+[ifdef] notyet
+fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth
+
+: emacs ( -- )
+ false to already-go?
+ boot-getline to boot-file " rom:emacs" $boot
+;
+
+fload ${BP}/ofw/gui/ofpong.fth
+fload ${BP}/cpu/x86/pc/olpc/life.fth
+[then]
+
+" u:\boot\olpc.fth ext:\boot\olpc.fth int:\boot\olpc.fth ext:\zimage /prober /usb/ethernet /usb/wlan"
+ ' boot-device set-config-string-default
+
+\needs ramdisk " " d# 128 config-string ramdisk
+" " ' boot-file set-config-string-default \ Let the boot script set the cmdline
+
+\ Eliminate 4 second delay in install console for the case where
+\ there is no keyboard. The delay is unnecessary because the screen
+\ does not go blank when the device is closed.
+patch drop ms install-console
+
+alias reboot bye
+
+alias crcgen drop ( crc byte -- crc' )
+
+\ Dictionary growth size for the ARM Image Format header
+\ 1 section before origin section table
+h# 10.0000 h# 8000 - h# 4000 - dictionary-size !
+
+fload ${BP}/cpu/arm/saverom.fth \ Save the dictionary for standalone startup
+
+fload ${BP}/forth/lib/selstr.fth
+
+fload ${BP}/ofw/inet/loadtcp.fth
+
+support-package: http
+ fload ${BP}/ofw/inet/http.fth \ HTTP client
+end-support-package
+
+[ifdef] notyet
+fload ${BP}/cpu/x86/pc/olpc/memtest.fth
+[then]
+
+[ifdef] notyet
+fload ${BP}/ofw/wifi/wifi-cfg.fth
+support-package: supplicant
+fload ${BP}/ofw/wifi/loadpkg.fth
+end-support-package
+
+: ofw-ssids ( -- $ ) " OFWSSID" ;
+' ofw-ssids to default-ssids
+[then]
+
+fload ${BP}/ofw/inet/sntp.fth
+: olpc-ntp-servers ( -- )
+ " DHCP time 172.18.0.1 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"
+;
+' olpc-ntp-servers to ntp-servers
+: ntp-time&date ( -- s m h d m y )
+ ntp-timestamp abort" Can't contact NTP server"
+ ntp>time&date
+;
+: .clock ( -- )
+ time&date .date space .time ." UTC" cr
+;
+: ntp-set-clock ( -- )
+ ntp-time&date " set-time" clock-node @ $call-method
+ .clock
+;
+
+[ifdef] use-ppp
+fload ${BP}/ofw/ppp/loadppp.fth
+[then]
+
+" dhcp" ' ip-address set-config-string-default
+
+[ifdef] notyet
+: c1-idle ( -- ) interrupts-enabled? if halt then ;
+' c1-idle to stdin-idle
+[then]
+
+fload ${BP}/ofw/core/countdwn.fth \ Startup countdown
+
+: console-start ( -- )
+ install-mux-io
+\ cursor-off
+ true to text-on?
+
+ " //null" open-dev to null-ih \ For text-off state
+;
+
+: interpreter-init ( -- )
+ hex
+ warning on
+ only forth also definitions
+
+\ install-alarm
+
+ page-mode
+ #line off
+
+\ .built cr
+;
+
+[ifdef] notyet
+: ?games ( -- )
+ rocker-right game-key? if
+ protect-fw
+ time&date 5drop 1 and if
+ ['] pong guarded
+ else
+ ['] life-demo guarded
+ then
+ power-off
+ then
+;
+: ?diags ( -- )
+ rocker-left game-key? if
+ protect-fw
+ text-on " test-all" ['] eval guarded
+ ." Tests complete - powering off" cr d# 5000 ms power-off
+ then
+;
+
+: ?scan-nand ( -- )
+ rocker-up game-key? if
+ protect-fw text-on ['] scan-nand guarded
+ then
+;
+: ?fs-update ( -- )
+ button-check button-x or button-o or button-square or ( mask )
+ game-key-mask = if protect-fw try-fs-update then
+;
+[then]
+
+: startup ( -- )
+ standalone? 0= if exit then
+
+\ block-exceptions
+ no-page
+
+ console-start
+
+[ifdef] notyet
+ read-game-keys
+[then]
+
+\ text-off
+
+ " probe-" do-drop-in
+
+[ifdef] notyet
+ sound
+ ?games
+[then]
+
+ ['] false to interrupt-auto-boot?
+[ifdef] probe-usb
+ probe-usb
+ report-disk
+ report-keyboard
+[then]
+ " probe+" do-drop-in
+
+ interpreter-init
+[ifdef] notyet
+ ?scan-nand
+ ?diags
+ ?fs-update
+[then]
+\ unblock-exceptions
+ ['] (interrupt-auto-boot?) to interrupt-auto-boot?
+\ ?usb-keyboard
+ auto-banner? if banner then
+
+ auto-boot
+
+ cr cr
+
+ quit
+;
+
+\ This helps with TeraTerm, which sends ESC-O as the arrow key prefix
+also hidden also keys-forth definitions
+warning @ warning off
+: esc-o key lastchar ! [""] esc-[ do-command ;
+warning !
+previous previous definitions
+
+tag-file @ fclose tag-file off
+
+.( --- Saving fw.dic ...)
+" fw.dic" $save-forth cr
+
+fload ${BP}/cpu/arm/mmp2/rawboot.fth
+
+.( --- Saving fw.img --- ) cr " fw.img" $save-rom
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 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
Added: cpu/arm/olpc/1.75/ofw.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/ofw.bth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,55 @@
+purpose: Build Open Firmware for OLPC XO-1.75
+\ See license at end of file
+
+\ in: sp.img
+\ in: fw.img
+command: &builder &this
+build-now
+
+fload ${BP}/cpu/arm/marvell/tim.fth
+
+\ Marvel Trusted Image Module image creation script for
+\ XO-1.75 platform.
+
+tim: 00030102 0 Sky! PXA688
+flash: SPI'10
+timh: TIMH 0 d101f000
+\ Main Processor code loaded into DRAM
+image: OBMI 800 d101c000 ${BP}/cpu/arm/olpc/1.75/dummy.img
+\ Secure Processor code loaded into SRAM
+image: WTMI 1000 d1018000 /scratchbox/users/wmb/home/wmb/cforth.git/build/arm-xo-1.75/shim.img
+image: CFTH 2000 d1000000 /scratchbox/users/wmb/home/wmb/cforth.git/build/arm-xo-1.75/app.img
+\ image: OFW0 20000 00000000 ${BP}/cpu/arm/olpc/1.75/build/fw.img
+anonymous: 20000 ${BP}/cpu/arm/olpc/1.75/build/fw.img
+reserved:
+
+\ fload ${BP}/cpu/arm/olpc/1.75/ddr_samsung_1g.fth
+ term:
+end-reserved
+end-tim
+
+save-image: ofw.rom
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 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
Added: cpu/arm/olpc/1.75/probemem.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/probemem.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,30 @@
+purpose: Memory probing
+copyright: Copyright 1994 FirmWorks All Rights Reserved
+
+" /memory" find-device
+
+headerless
+
+h# ffff.ffff value low
+h# 0 value high
+
+: log&release ( adr len -- )
+ over low umin to low ( adr len )
+ 2dup + high umax to high ( adr len )
+ release
+;
+
+headers
+: probe ( -- )
+ 0 available-ram-size log&release
+\ h# 2000.0000 h# 1000.0000 log&release
+
+ 0 0 encode-bytes ( adr 0 )
+ physavail ['] make-phys-memlist find-node ( adr len prev 0 )
+ 2drop " reg" property
+
+ \ Claim the memory used by OFW
+\ high h# 10.0000 - h# 10.0000 0 claim drop
+;
+
+device-end
Added: cpu/arm/olpc/1.75/sdhci.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/sdhci.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,79 @@
+purpose: Load file for SDHCI (Secure Digital Host Controller Interface)
+
+0 0 " d4280000" " /" begin-package
+
+ fload ${BP}/cpu/arm/olpc/1.75/sdregs.fth
+ fload ${BP}/dev/mmc/sdhci/sdhci.fth
+
+ true to avoid-high-speed?
+
+ hex
+ \ The new clock divisor layout is low 8 bits in [15:8] and high 2 bits in [7:6]
+ \ The resulting 10-bit value is multiplied by 2 to form the divisor for the
+ \ 200 MHz base clock.
+ patch 403 103 card-clock-25 \ n is 4, divisor is 8, clk is 25 MHz
+ patch 203 003 card-clock-50 \ n is 2, divisor is 4, clk is 50 MHz
+ patch 043 8003 card-clock-slow \ n is h# 100 (high 2 bits in [7:6], for divisor of 512 from 200 MHz clock
+
+ : gpio-card-inserted? ( -- flag ) d# 31 gpio-pin@ 0= ;
+ ' gpio-card-inserted? to card-inserted?
+
+ : gpio-power-on ( -- ) sdhci-card-power-on d# 35 gpio-set ;
+ ' gpio-power-on to card-power-on
+
+ : gpio-power-off ( -- ) d# 35 gpio-clr sdhci-card-power-off ;
+ ' gpio-power-off to card-power-off
+
+\ new-device
+\ 2 encode-int " reg" property
+\ " mv8686" " $load-driver" eval drop
+\ finish-device
+
+ new-device
+ 1 encode-int " reg" property
+ fload ${BP}/dev/mmc/sdhci/sdmmc.fth
+ \ fload ${BP}/dev/mmc/sdhci/selftest.fth
+ " external" " slot-name" string-property
+ finish-device
+
+end-package
+
+0 0 " d4281000" " /" begin-package
+
+ fload ${BP}/cpu/arm/olpc/1.75/sdregs.fth
+ fload ${BP}/dev/mmc/sdhci/sdhci.fth
+
+ true to avoid-high-speed?
+
+ hex
+ \ The new clock divisor layout is low 8 bits in [15:8] and high 2 bits in [7:6]
+ \ The resulting 10-bit value is multiplied by 2 to form the divisor for the
+ \ 200 MHz base clock.
+ patch 403 103 card-clock-25 \ n is 4, divisor is 8, clk is 25 MHz
+ patch 203 003 card-clock-50 \ n is 2, divisor is 4, clk is 50 MHz
+ patch 043 8003 card-clock-slow \ n is h# 100 (high 2 bits in [7:6], for divisor of 512 from 200 MHz clock
+
+ ' true to card-inserted?
+
+ : gpio-power-on ( -- ) sdhci-card-power-on d# 33 gpio-set ;
+ ' gpio-power-on to card-power-on
+
+ : gpio-power-off ( -- ) d# 33 gpio-clr sdhci-card-power-off ;
+ ' gpio-power-off to card-power-off
+
+
+ new-device
+ 1 encode-int " reg" property
+ fload ${BP}/dev/mmc/sdhci/sdmmc.fth
+ \ fload ${BP}/dev/mmc/sdhci/selftest.fth
+ " internal" " slot-name" string-property
+ finish-device
+
+end-package
+
+stand-init: \ SDHC clocks
+ h# 41b h# d4282854 l! \ SD0 (external SD) clocks, plus set master clock divisor
+ h# 1b h# d42828e8 l! \ SD2 (internal microSD) clocks
+ h# 70a h# d4200104 l! \ Clock gating
+ h# 70a h# d4201104 l! \ Clock gating
+;
Added: cpu/arm/olpc/1.75/sdregs.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/sdregs.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,22 @@
+h# 200 value /regs \ SDHCI register block
+1 value #slots
+
+0 instance value slot
+0 instance value chip
+
+my-space /regs reg
+
+: map-regs ( -- )
+ chip if exit then
+ slot 1- h# 800 * my-space + /regs " map-in" $call-parent
+ to chip
+;
+: unmap-regs ( -- )
+ chip 0= if exit then
+ chip /regs " map-out" $call-parent
+ 0 to chip
+;
+
+: vendor-modes ( -- ) ;
+: ?cafe-fpga-quirk ( -- ) ;
+: ?via-quirk ( -- ) ;
Added: cpu/arm/olpc/1.75/spiui.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/spiui.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -0,0 +1,391 @@
+\ See license at end of file
+purpose: User interface for reflashing SPI FLASH parts
+
+\ This code is concerned with the user interface for getting
+\ a new firmware image into memory and using it to program
+\ a FLASH device from that image. The details of how to actually
+\ access the FLASH device are defined elsewhere.
+
+h# 4000 constant /chunk \ Convenient sized piece for progress reports
+
+[ifdef] use-flash-nvram
+h# d.0000 constant nvram-offset
+[then]
+
+[ifdef] mfg-data-top
+h# e.0000 constant mfg-data-offset
+mfg-data-offset /flash-block + constant mfg-data-end-offset
+: mfg-data-range ( -- adr len ) mfg-data-top dup last-mfg-data tuck - ;
+
+[ifdef] $call-method
+: make-sn-name ( -- filename$ )
+ " SN" find-tag 0= abort" No serial number in mfg data" ( sn$ )
+ dup if ( sn$ )
+ 2dup + 1- c@ 0= if ( sn$ )
+ 1- ( sn$' ) \ Remove Null
+ then ( sn$ )
+ then ( sn$ )
+ d# 11 over - dup 0> if ( sn$' #excess )
+ /string ( sn$' ) \ Keep last 11 characters
+ else ( sn$' #excess )
+ drop ( sn$ )
+ then ( sn$ )
+
+ " disk:\" "temp place ( sn$' )
+
+ dup 8 > if ( sn$ )
+ over 8 "temp $cat ( sn$ )
+ 8 /string ( sn$' )
+ " ." "temp $cat ( sn$ )
+ then ( sn$ )
+ "temp $cat ( )
+ "temp count ( filename$ )
+;
+
+: save-mfg-data ( -- )
+ make-sn-name ( name$ )
+ ." Creating " 2dup type cr
+ $create-file ( ihandle )
+ dup 0= abort" Can't create file" >r ( r: ihandle )
+ mfg-data-range " write" r@ $call-method ( r: ihandle )
+ r> close-dev
+;
+: restore-mfg-data ( "filename" -- )
+ reading
+ ifd @ fsize dup /flash-block > if ( len )
+ drop ifd @ fclose ( )
+ true abort" File is too big"
+ then ( len )
+ mfg-data-buf swap ( adr len )
+ 2dup ifd @ fgets drop ( adr len )
+ ifd @ fclose
+
+ flash-write-enable
+ mfg-data-offset flash-erase-block ( adr len )
+ mfg-data-end-offset over - ( adr len offset )
+ flash-write ( )
+ flash-write-disable ( )
+;
+[then]
+
+: ?move-mfg-data ( -- )
+ ." Merging existing manufacturing data" cr
+
+ tethered? if
+ \ Read the manufacturing data from the other FLASH
+ flash-buf mfg-data-offset + /flash-block mfg-data-offset flash-read
+ exit
+ then
+
+ \ Copy the entire block containing the manufacturing data into the
+ \ memory buffer. This make verification easier.
+
+ mfg-data-top /flash-block - ( src-adr )
+ flash-buf mfg-data-offset + ( src-adr dst-adr )
+ /flash-block move ( )
+;
+[then]
+
+: write-flash-range ( adr end-offset start-offset -- )
+ ." Writing" cr
+ ?do ( adr )
+ \ Save time - don't write if the data is the same
+ i .x (cr ( adr )
+ spi-us d# 20 >= if ( adr )
+ \ Just write if reading is slow
+ true ( adr must-write? )
+ else ( adr )
+ dup /flash-block i flash-verify ( adr must-write? )
+ then ( adr must-write? )
+
+ if
+ i flash-erase-block
+ dup /flash-block i flash-write ( adr )
+ then
+ /flash-block + ( adr' )
+ /flash-block +loop ( adr )
+ cr drop ( )
+;
+
+: verify-flash-range ( adr end-offset start-offset -- )
+ ." Verifying" cr
+ ?do ( adr )
+ i .x (cr
+ dup /flash-block i flash-verify abort" Verify failed"
+ /flash-block + ( adr' )
+ /flash-block +loop ( adr )
+ cr drop ( )
+;
+
+
+\ Perform a series of sanity checks on the new firmware image.
+
+: check-firmware-image ( adr len -- adr len )
+ dup /flash <> abort" Wrong image length" ( adr len )
+ 2dup + h# 40 - ( adr len signature-adr )
+ dup " CL1" comp abort" No firmware signature" ( adr len signature-adr )
+ ." Firmware: " h# 10 type ( adr len )
+ \ XXX add some more sanity checks
+;
+
+[ifdef] load-base
+: flash-buf load-base ;
+: mfg-data-buf load-base /flash + ;
+[else]
+/flash buffer: flash-buf
+/flash-block buffer: mfg-data-buf
+[then]
+0 value file-loaded?
+
+h# 30 constant crc-offset \ From end (modified in devices.fth for XO 1.5)
+
+: crc ( adr len -- crc ) 0 crctab 2swap ($crc) ;
+
+: ?crc ( -- )
+ ." Checking integrity ..." cr
+
+ flash-buf /flash + crc-offset - ( crc-adr )
+ dup l@ >r ( crc-adr r: crc )
+ -1 over l! ( crc-adr r: crc )
+
+ flash-buf /flash crc ( crc-adr calc-crc r: crc )
+ r@ rot l! ( calc-crc r: crc )
+ r> <> abort" Firmware image has bad internal CRC"
+;
+
+[ifdef] mfg-data-offset
+: ?image-valid ( len -- )
+ /flash <> abort" Image file is the wrong length"
+
+ ." Got firmware version: "
+ flash-buf h# f.ffc0 + dup h# 10 type cr ( adr )
+ " CL1" comp abort" Wrong machine type"
+
+ ?crc
+
+ flash-buf mfg-data-offset + /flash-block ['] ?erased catch
+ abort" Firmware image has data in the manufacturing data block"
+[ifdef] use-flash-nvram
+ flash-buf nvram-offset + /flash-block ['] ?erased catch
+ abort" Firmware image has data in the NVRAM block"
+[then]
+;
+[else]
+: ?image-valid ( len -- )
+ drop
+;
+[then]
+
+: $get-file ( "filename" -- )
+ $read-open
+ flash-buf /flash ifd @ fgets ( len )
+ ifd @ fclose
+
+ ?image-valid
+
+ true to file-loaded?
+;
+
+: ?file ( -- )
+ file-loaded? 0= if
+ ." You must first load a valid FLASH image file with" cr
+ ." get-file filename" cr
+ abort
+ then
+;
+
+: read-flash ( "filename" -- )
+ writing
+ /flash 0 do
+ i .x (cr
+ flash-buf i + /chunk i flash-read
+ /chunk +loop
+ flash-buf /flash ofd @ fputs
+ ofd @ fclose
+;
+
+: verify ( -- ) ?file flash-buf /flash 0 verify-flash-range ;
+
+[ifdef] mfg-data-offset
+: verify-firmware ( -- )
+[ifdef] use-flash-nvram
+ flash-buf nvram-offset 0 verify-flash-range \ Verify first part
+[else]
+ flash-buf mfg-data-offset 0 verify-flash-range \ Verify first part
+[then]
+
+ \ Don't verify the block containing the manufacturing data
+ flash-buf mfg-data-end-offset + /flash mfg-data-end-offset verify-flash-range \ Verify last part
+;
+: write-firmware ( -- )
+[ifdef] use-flash-nvram
+ flash-buf nvram-offset 0 write-flash-range \ Write first part
+[else]
+ flash-buf mfg-data-offset 0 write-flash-range \ Write first part
+[then]
+
+ \ Don't write the block containing the manufacturing data
+
+ flash-buf mfg-data-end-offset + /flash mfg-data-end-offset write-flash-range \ Write last part
+;
+[else]
+: verify-firmware ( -- )
+ flash-buf /flash 0 verify-flash-range \ Verify entire FLASH
+;
+: write-firmware ( -- )
+ flash-buf /flash 0 write-flash-range \ Write entire FLASH
+;
+[then]
+
+: .verify-msg ( -- )
+ ." Type verify if you want to verify the data just written." cr
+ ." Verification will take about 17 minutes if the host is running Linux" cr
+ ." or about 5 minutes if the host is running OFW." cr
+;
+
+: reflash ( -- ) \ Flash from data already in memory
+ ?file
+ flash-write-enable
+
+[ifdef] ?move-mfg-data
+ ?move-mfg-data
+[then]
+
+ write-firmware
+
+ spi-us d# 20 < if
+ ['] verify-firmware catch if
+ ." Verify failed. Retrying once" cr
+ spi-identify
+ write-firmware
+ verify-firmware
+ then
+ flash-write-disable
+ else
+ .verify-msg
+ then
+;
+
+defer fw-filename$ ' null$ to fw-filename$
+
+: get-file ( ["filename"] -- )
+ parse-word ( adr len )
+ dup 0= if 2drop fw-filename$ then ( adr len )
+ ." Reading " 2dup type cr ( adr len )
+ $get-file
+;
+
+: flash ( ["filename"] -- ) get-file ?enough-power reflash ;
+: flash! ( ["filename"] -- ) get-file reflash ;
+
+0 [if]
+\ This is a slower version of "rom-va flash-buf /flash lmove"
+\ It works around the problem that continuous CPU access to the
+\ SPI FLASH starves the EC of instruction fetch cycles, often
+\ causing it to turn off the system.
+0 value rom-va
+: slow-flash-read ( -- )
+ rom-pa /flash root-map-in to rom-va
+ /flash 0 do
+ rom-va i + flash-buf i + h# 1.0000 lmove
+ d# 200 ms
+ h# 1.0000 +loop
+ rom-va /flash root-map-out 0 to rom-va
+;
+
+[ifdef] dev
+dev /flash
+: selftest ( -- error? )
+ .mfg-data cr
+
+ ." Checking SPI FLASH CRC ..."
+ slow-flash-read
+ \ Replace the manufacturing data block with all FF
+ flash-buf mfg-data-offset + /flash-block h# ff fill
+
+ \ Get the CRC and then replace it with -1
+ flash-buf /flash + crc-offset - dup l@ swap
+ -1 swap l!
+
+ flash-buf /flash crc <>
+ dup if ." FAILED" else ." passed" then cr
+;
+device-end
+[then]
+[then]
+
+0 [if]
+\ Erase the first block containing the EC microcode. This is dangerous...
+
+: erase-ec ( -- ) 0 flash-erase-block ;
+\ Erase everything after the first sector, thus preserving
+\ the EC microcode in the first sector.
+
+: erase-firmware ( -- )
+ h# 100000 /flash-block do (cr i .x i flash-erase-block /flash-block +loop cr
+;
+
+: reprogram-firmware ( adr len -- )
+ check-firmware-image ( adr len )
+ /flash-block /string ( adr+ len- ) \ Remove EC ucode from the beginning
+ ." Erasing ..." cr erase-spi-firmware ( adr len )
+ ." Programming..." 2dup /flash-block flash-write cr ( adr len )
+ ." Verifying..." /flash-block flash-verify abort" Verify failed" cr ( )
+;
+
+: flash-bios ( -- )
+ ?file
+
+ \ Don't overwrite the EC code
+ flash-buf /ec + /flash /ec write-flash-range
+
+ .verify-msg
+;
+: verify-bios ( -- ) flash-buf /ec + /flash /ec verify-flash-range ;
+
+: flash-ec ( -- )
+ ?file
+
+ \ Write only the EC code
+ flash-buf /ec 0 write-flash-range
+
+ ." Type verify-ec if you want to verify the data just written." cr
+ ." Verification will take about 1 minute..." cr
+;
+: verify-ec ( -- ) ?file flash-buf /ec 0 verify-flash-range ;
+
+: flash-all ( -- )
+ ?file
+
+ \ Write everything, EC code and BIOS
+ flash-buf /flash 0 write-flash-range
+
+ ." Type verify-all if you want to verify the data just written." cr
+ ." Verification will take about 17 minutes..." cr
+;
+
+[then]
+
+\ 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: cpu/x86/pc/biosload/config.fth
==============================================================================
--- cpu/x86/pc/biosload/config.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ cpu/x86/pc/biosload/config.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -1,34 +1,25 @@
\ See license at end of file
-purpose: Configuration for loading from a USB key via Syslinux
+purpose: Establish configuration definitions
\ --- The environment that "boots" OFW ---
\ - Image Format - Example Media - previous stage bootloader
-\ - (Syslinux) COM32 format - USB Key w/ FAT FS - Syslinux
-create syslinux-loaded
-
-create via-demo
-
create debug-startup
-
-create virtual-mode
-create linux-support
\ create serial-console
-\ create use-usb-debug-port
-create pc
-
-\ create pseudo-nvram
create resident-packages
create addresses-assigned \ Don't reassign PCI addresses
\ create virtual-mode
-create use-root-isa
-\ create use-isa-ide
+\ create use-root-isa
+create use-timestamp-counter
+create use-pci-isa
+create use-isa-ide
create use-ega
create use-elf
+\ create use-ne2000
create use-watch-all
-\ create use-null-nvram
create pseudo-nvram
-create no-floppy-node
+\ create use-null-nvram
+\ create no-floppy-node
fload ${BP}/cpu/x86/pc/biosload/addrs.fth
Modified: cpu/x86/pc/olpc/versions.fth
==============================================================================
--- cpu/x86/pc/olpc/versions.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ cpu/x86/pc/olpc/versions.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -2,7 +2,7 @@
\ The overall firmware revision
macro: FW_MAJOR E
-macro: FW_MINOR 44d
+macro: FW_MINOR 44e
\ The EC microcode
macro: EC_VERSION e34
Modified: cpu/x86/pc/olpc/via/fw-version.fth
==============================================================================
--- cpu/x86/pc/olpc/via/fw-version.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ cpu/x86/pc/olpc/via/fw-version.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -1,3 +1,3 @@
\ The overall firmware revision
macro: FW_MAJOR A
-macro: FW_MINOR 58
+macro: FW_MINOR 58b
Modified: dev/mmc/sdhci/sdhci.fth
==============================================================================
--- dev/mmc/sdhci/sdhci.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ dev/mmc/sdhci/sdhci.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -85,7 +85,8 @@
\ sitting around waiting for insertion/removal events.
\ The debouncer takes about 300 ms to stabilize.
-: card-inserted? ( -- flag )
+defer card-inserted?
+: sdhci-card-inserted? ( -- flag )
get-msecs d# 500 + begin ( time-limit )
\ When the stable bit is set, we can believe the answer
present-state@ h# 20000 and if ( time-limit )
@@ -99,11 +100,14 @@
." SD Card detect unstable!" cr ( )
false ( flag )
;
+' sdhci-card-inserted? to card-inserted?
: write-protected? ( -- flag )
present-state@ h# 80000 and 0=
;
-: card-power-on ( -- )
+defer card-power-on
+defer card-power-off
+: sdhci-card-power-on ( -- )
\ Card power on does not work if a removal interrupt is pending
h# c0 isr! \ Clear any pending insert/remove events
@@ -117,7 +121,10 @@
dup h# 29 cb! ( voltage ) \ First set the voltage
1 or h# 29 cb! ( ) \ Then turn it on
;
-: card-power-off ( -- ) 0 h# 29 cb! ;
+: sdhci-card-power-off ( -- ) 0 h# 29 cb! ;
+
+' sdhci-card-power-on to card-power-on
+' sdhci-card-power-off to card-power-off
: internal-clock-on ( -- )
h# 2c cw@ 1 or h# 2c cw!
Modified: dev/olpc/kb3700/spicmd.fth
==============================================================================
--- dev/olpc/kb3700/spicmd.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ dev/olpc/kb3700/spicmd.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -94,7 +94,7 @@
select-ssp3-pins
ssp3-clk-on
h# 07 ssp-sscr0 rl! \ 8-bit data, SPI normal mode
- h# 1380.0000 ssp-sscr1 rl! \ SCFR=1, slave mode, Rx w/o Tx
+ h# 1380.0010 ssp-sscr1 rl! \ SCFR=1, slave mode, Rx w/o Tx, early phase
\ The enable bit must be set last, after all configuration is done
h# 87 ssp-sscr0 rl! \ Enable, 8-bit data, SPI normal mode
wait-clk-sync
@@ -115,8 +115,8 @@
;
\ Set the direction on the ACK and CMD GPIOs
-d# 78 constant cmd-gpio#
-d# 79 constant ack-gpio#
+d# 151 constant cmd-gpio#
+d# 125 constant ack-gpio#
: init-ec-spi-gpios ( -- )
cmd-gpio# gpio-dir-out
ack-gpio# gpio-dir-out
@@ -125,7 +125,9 @@
: set-cmd ( -- ) cmd-gpio# gpio-set ;
: clr-ack ( -- ) ack-gpio# gpio-clr ;
: set-ack ( -- ) ack-gpio# gpio-set ;
-: pulse-ack ( -- ) clr-ack set-ack ;
+: fast-ack ( -- ) set-ack clr-ack ;
+: slow-ack ( -- ) d# 10 ms set-ack d# 10 ms clr-ack ;
+defer pulse-ack ' slow-ack to pulse-ack \ FIXME !!!
0 value ec-spi-cmd-done \ 0 - still waiting, 1 - successful send, 2 - timeout
@@ -189,7 +191,7 @@
init-ssp-in-slave-mode
set-ssp-receive-w/o-transmit
clr-cmd
- set-ack
+ clr-ack \ Tell EC that it is okay to send
['] ec-spi-upstream to ec-spi-state
;
@@ -208,6 +210,7 @@
['] ec-spi-upstream to ec-spi-state
exit
then
+ ec-spi-handle-message
;
: ec-command ( [ args ] #args #results cmd-code -- [ results ] error? )
Modified: dev/olpc/spiflash/spiflash.fth
==============================================================================
--- dev/olpc/spiflash/spiflash.fth Mon Oct 25 14:34:03 2010 (r1990)
+++ dev/olpc/spiflash/spiflash.fth Mon Oct 25 14:42:14 2010 (r1991)
@@ -262,15 +262,16 @@
\ those commands. The AB command seems to be supported by all
\ of them, so it's a good starting point.
+0 value spi-id#
: spi-identify ( -- )
- ab-id ( id )
-
+ ab-id to spi-id#
\ ST, Spansion, and WinBond all identify as 13
\ For now, we only need to distinguish between if it's
\ a common page-write part or the SST part with its
\ unique auto-increment address writing scheme.
- case
+ spi-id# case
h# 13 of ['] common-write endof
+ h# 34 of ['] common-write endof
h# bf of ['] sst-write endof
h# 14 of
." The SPI FLASH ID reads as 14. This is due to an infrequent hardware problem." cr
@@ -290,7 +291,10 @@
['] write-spi-flash behavior ['] sst-write = if
." SST"
else
- ." type 13 - Spansion, Winbond, or ST"
+ spi-id# case
+ h# 13 of ." type 13 - Spansion, Winbond, or ST" endof
+ h# 34 of ." type 34 - Macronyx" endof
+ endcase
then
;
1
0
Author: wmb
Date: Mon Oct 25 14:34:03 2010
New Revision: 1990
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1990
Log:
Marvell TIM image builder - added "anonymous:" command for including headerless images at specific locations.
Modified:
cpu/arm/marvell/tim.fth
Modified: cpu/arm/marvell/tim.fth
==============================================================================
--- cpu/arm/marvell/tim.fth Mon Oct 18 06:06:51 2010 (r1989)
+++ cpu/arm/marvell/tim.fth Mon Oct 25 14:34:03 2010 (r1990)
@@ -27,7 +27,8 @@
then ( )
;
-: hex, ( -- ) safe-parse-word $hnumber abort" Bad hex number" l, ;
+: get-hex ( -- ) safe-parse-word $hnumber abort" Bad hex number" ;
+: hex, ( -- ) get-hex l, ;
: get-word ( -- adr len ) safe-parse-word ;
: get-filename ( -- adr len ) 0 parse ;
@@ -100,16 +101,18 @@
: $file-size ( adr len -- size )
$read-open ifd @ fsize ifd @ fclose
;
+0 value image-offset
: place-image ( adr len -- size )
$read-open ifd @ fsize ( size )
- here 8 - l@ ( size offset )
+ image-offset ( size offset )
2dup + ?realloc-image ( size offset )
image-adr + over ( size adr size )
ifd @ fgets ( size read-size )
over <> abort" Read failed" ( size )
ifd @ fclose ( size )
\ h# 1000 round-up
- 4 round-up
+ h# 800 round-up
+\ 4 round-up
;
: place-hash \ XXX need to implement non-null hash info
d# 10 0 do 0 l, loop
@@ -118,9 +121,14 @@
: start-image ( adr len -- )
+#images
get-word 2dup 4c, set-last-image
- hex, \ Flash offset
+ get-hex dup to image-offset l, \ Flash offset
hex, \ Load address
;
+: anonymous: \ flash-offset filename
+ get-hex to image-offset
+ get-filename place-image drop
+;
+
: image: \ name flash-offset mem-load-addr filename
start-image
get-filename place-image l,
1
0
Author: wmb
Date: Mon Oct 18 06:06:51 2010
New Revision: 1989
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1989
Log:
ARM - Added empty start-dram-init and end-dram-init words to dram-xdb.fth
Modified:
cpu/arm/olpc/1.75/dram-xdb.fth
Modified: cpu/arm/olpc/1.75/dram-xdb.fth
==============================================================================
--- cpu/arm/olpc/1.75/dram-xdb.fth Mon Oct 18 06:04:01 2010 (r1988)
+++ cpu/arm/olpc/1.75/dram-xdb.fth Mon Oct 18 06:06:51 2010 (r1989)
@@ -72,3 +72,6 @@
." print "" ____^^__\n""" cr
." print ""\n""" cr
;
+
+: start-dram-init ( -- ) ;
+: end-dram-init ( -- ) ;
1
0
Author: wmb
Date: Mon Oct 18 06:04:01 2010
New Revision: 1988
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1988
Log:
ARM - Increased max dictionary size to 1 MiB.
Modified:
cpu/arm/kernrel.fth
Modified: cpu/arm/kernrel.fth
==============================================================================
--- cpu/arm/kernrel.fth Mon Oct 18 06:02:38 2010 (r1987)
+++ cpu/arm/kernrel.fth Mon Oct 18 06:04:01 2010 (r1988)
@@ -2,7 +2,7 @@
\ See license at end of file
\ h# 8.0000 equ max-image
-h# 8.0000 constant max-image
+h# 10.0000 constant max-image
0 value relocation-map
1
0

[commit] r1987 - cpu/arm/marvell cpu/arm/mmp2 cpu/arm/olpc/1.75 cpu/arm/olpc/1.75/build dev/usb2/hcd dev/usb2/hcd/ehci dev/usb2/hcd/uhci
by repository service Oct. 18, 2010
by repository service Oct. 18, 2010
Oct. 18, 2010
Author: wmb
Date: Mon Oct 18 06:02:38 2010
New Revision: 1987
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1987
Log:
Omnibus checkin of new and reorganized files for the OLPC ARM build, preparing for bringup.
Added:
cpu/arm/marvell/utmiphy.fth
cpu/arm/mmp2/boardgpio.fth
cpu/arm/mmp2/boardtwsi.fth
cpu/arm/mmp2/hwaddrs.fth
cpu/arm/mmp2/uart.fth
cpu/arm/olpc/1.75/boardgpio.fth
cpu/arm/olpc/1.75/build/Makefile
cpu/arm/olpc/1.75/devices.fth
cpu/arm/olpc/1.75/dram-forth.fth
cpu/arm/olpc/1.75/draminit.bth
cpu/arm/olpc/1.75/lcdcfg.fth
cpu/arm/olpc/1.75/sp.bth
dev/usb2/hcd/uhci/pci.fth
Modified:
cpu/arm/mmp2/addrs.fth
cpu/arm/mmp2/config.fth
cpu/arm/mmp2/devices.fth
cpu/arm/mmp2/dsi.fth
cpu/arm/mmp2/fw.bth
cpu/arm/mmp2/mfpr.fth
cpu/arm/mmp2/timer.fth
cpu/arm/mmp2/twsi.fth
cpu/arm/olpc/1.75/xo-dram.fth
dev/usb2/hcd/ehci/ehci.bth
dev/usb2/hcd/ehci/ehci.fth
dev/usb2/hcd/ehci/pci.fth
dev/usb2/hcd/ehci/probe.fth
dev/usb2/hcd/ehci/qhtd.fth
dev/usb2/hcd/hcd.fth
dev/usb2/hcd/uhci/uhci.bth
dev/usb2/hcd/uhci/uhci.fth
Added: cpu/arm/marvell/utmiphy.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/marvell/utmiphy.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,48 @@
+\ See license at end of file
+purpose: Init UTMI USB Phy in Marvell SoC
+
+h# d4207004 constant utmi-ctrl
+h# d4207008 constant utmi-pll
+h# d420700c constant utmi-tx
+h# d4207010 constant utmi-rx
+h# d4207014 constant utmi-ivref
+
+: regset ( mask adr -- ) tuck l@ or swap l! ;
+: regclr ( mask adr -- ) tuck l@ swap invert and swap l! ;
+
+: wait-cal ( spins -- )
+ 0 do
+ utmi-pll rl@ h# 0080.0000 and if unloop exit then
+ loop
+ ." PLL calibrate timeout" cr
+;
+: init-usb-phy ( -- )
+ \ Turn on the USB PHY power
+ h# 1010.0000 utmi-ctrl regset \ INPKT_DELAY_SOF, PU_REF
+ h# 2 utmi-ctrl regset \ PLL_PWR_UP
+ h# 1 utmi-ctrl regset \ PWR_UP
+
+ \ Configure the PLLs
+ h# 7e03.ffff utmi-pll regclr \ PLLCALI12, PLLVDD18, PLLVDD12, KVCO, ICP, FBDIV, REFDIV,
+ h# 7e01.aeeb utmi-pll regset \ 3 3 3 3 2 ee b
+
+ h# 00df.c000 utmi-tx regclr \ TXVDD12, CK60_PHSEL, IMPCAL_VTH
+ h# 00c9.4000 utmi-tx regset \ 3 4 5
+
+ h# 0001.80f0 utmi-rx regclr \ REG_SQ_LENGTH, RX_SQ_THRESH
+ h# 0001.000a utmi-rx regset \ 2 a
+
+ d# 10000 wait-cal
+
+ d# 200 us
+ h# 0020.0000 utmi-pll regset \ VCOCAL_START
+ d# 40 us
+ h# 0020.0000 utmi-pll regclr
+
+ d# 200 us
+ h# 0000.1000 utmi-tx regset \ REG_RCAL_START
+ d# 40 us
+ h# 0000.1000 utmi-tx regclr
+
+ d# 1000 wait-cal
+;
Modified: cpu/arm/mmp2/addrs.fth
==============================================================================
--- cpu/arm/mmp2/addrs.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/addrs.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -38,15 +38,3 @@
d# 12 to pageshift
h# 10.0000 constant /section
h# 4000 constant /page-table
-
-\ Defined by MMP2 hardware
-h# d401.9000 constant gpio-base
-h# d405.1024 constant acgr-pa
-h# d401.5000 constant clock-unit-pa
-h# d405.0000 constant main-pmu-pa
-h# d428.2800 constant pmua-pa \ Application processor PMU register base
-h# d420.b800 constant dsi1-pa \ 4-lane controller
-h# d420.ba00 constant dsi2-pa \ 3-lane controller
-h# d420.b000 constant lcd-pa
-h# d401.4000 constant timer-pa
-
Added: cpu/arm/mmp2/boardgpio.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/boardgpio.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,218 @@
+purpose: Board-specific setup details - pin assigments, etc.
+
+: set-camera-domain-voltage
+ aib-unlock
+ h# d401e80c l@ 4 or ( n ) \ Set 1.8V selector bit in AIB_GPIO2_IO
+ aib-unlock
+ h# d401e80c l!
+;
+
+: set-gpio-directions ( -- )
+ 3 h# 38 clock-unit-pa + l! \ Enable clocks in GPIO clock reset register
+
+ h# 000e.0000 gpio-base h# 0c + l! \ Bits 19, 18, 17
+ h# 0704.2000 gpio-base h# 10 + l! \ Bits 58,57,56,50 and 45
+\ h# 03ec.3e00 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:73
+ h# 03ec.3200 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:76 and 73 (leave 74 and 75 as input)
+
+ h# 0200.3c00 gpio-base h# 20 + l! \ Turn off LEDS (3c00) and turn on 5V (0200.0000)
+;
+
+create mfpr-table
+ 1 af, \ GPIO_00 - KP_MKIN[0]
+ 1 af, \ GPIO_01 - KP_MKOUT[0]
+ 1 af, \ GPIO_02 - KP_MKIN[1]
+ 1 af, \ GPIO_03 - KP_MKOUT[1]
+ 1 af, \ GPIO_04 - KP_MKIN[2]
+ 1 af, \ GPIO_05 - KP_MKOUT[2]
+ no-update, \ GPIO_06 - Not used
+ no-update, \ GPIO_07 - Not used
+ no-update, \ GPIO_08 - Not used
+ no-update, \ GPIO_09 - Not used
+ no-update, \ GPIO_10 - Not used
+ no-update, \ GPIO_11 - Not used
+ no-update, \ GPIO_12 - Not used
+ no-update, \ GPIO_13 - Not used
+ no-update, \ GPIO_14 - Not used
+ no-update, \ GPIO_15 - Not used
+ no-update, \ GPIO_16 - Not used
+ 0 af, \ GPIO_17 - BB_GPIO1 (use as GPIO out)
+ 0 af, \ GPIO_18 - BB_GPIO2 (use as GPIO out)
+ 0 af, \ GPIO_19 - BB_GPIO3 (use as GPIO out)
+ 0 af, \ GPIO_20 - ISP_INT (use as GPIO in)
+ 0 af, \ GPIO_21 - WIFI_GPIO2 (use as GPIO i/o)
+ 0 af, \ GPIO_22 - WIFI_GPIO3 (use as GPIO i/o)
+ 0 af, \ GPIO_23 - CODEC_INT (use as GPIO in)
+ 1 af, \ GPIO_24 - I2S_SYSCLK (Codec - HI-FI)
+ 1 af, \ GPIO_25 - SSPA2_SCLK (Codec - HI-FI)
+ 1 af, \ GPIO_26 - SSPA2_SFRM (Codec - HI-FI)
+ 1 af, \ GPIO_27 - SSPA2_TXD (Codec - HI-FI)
+ 1 af, \ GPIO_28 - SSPA2_RXD (Codec - HI-FI)
+ 1 af, \ GPIO_29 - UART1_RXD (Bluetooth)
+ 1 af, \ GPIO_30 - UART1_TXD (Bluetooth)
+ 1 af, \ GPIO_31 - UART1_CTS (Bluetooth)
+ 1 af, \ GPIO_32 - UART1_RTS (Bluetooth)
+ 0 af, \ GPIO_33 - SSPA2_CLK (Codec - LO-FI)
+ 0 af, \ GPIO_34 - SSPA2_FRM (Codec - LO-FI)
+ 0 af, \ GPIO_35 - SSPA2_TXD (Codec - LO-FI)
+ 0 af, \ GPIO_36 - SSPA2_RXD (Codec - LO-FI)
+ 1 af, \ GPIO_37 - MMC2_DAT<3>
+ 1 af, \ GPIO_38 - MMC2_DAT<2>
+ 1 af, \ GPIO_39 - MMC2_DAT<1>
+ 1 af, \ GPIO_40 - MMC2_DAT<0>
+ 1 af, \ GPIO_41 - MMC2_CMD
+ 1 af, \ GPIO_42 - MMC2_CLK
+ 1 af, \ GPIO_43 - TWSI2_SCL (for codec/noise/FM)
+ 1 af, \ GPIO_44 - TWSI2_SDA (for codec/noise/FM)
+ 0 af, \ GPIO_45 - WM8994_LDOEN (use as GPIO out)
+ 0 af, \ GPIO_46 - HDMI_DET (use as GPIO in)
+ 2 af, \ GPIO_47 - SSP2_CLK
+ 2 af, \ GPIO_48 - SSP2_FRM
+ 2 af, \ GPIO_49 - SSP2_RXD
+ 0 af, \ GPIO_50 - GPS_STBY (use as GPIO out)
+ 1 af, \ GPIO_51 - UART3_RXD (debug port)
+ 1 af, \ GPIO_52 - UART3_TXD (debug port)
+ 5 af, \ GPIO_53 - PWM3 (Keypad backlight)
+ 4 af, \ GPIO_54 - HDMI_CEC (MOVED to GPIO 113?)
+ 0 af, \ GPIO_55 - WIFI_GPIO0 (use as GPIO in)
+ 0 af, \ GPIO_56 - WIFI_GPIO1 (use as GPIO out)
+ 0 af, \ GPIO_57 - WIFI_PD_N (use as GPIO out)
+ 0 af, \ GPIO_58 - WIFI_RST_N (use as GPIO out)
+ 1 af, \ GPIO_59 - CCIC_IN<7>
+ 1 af, \ GPIO_60 - CCIC_IN<6>
+ 1 af, \ GPIO_61 - CCIC_IN<5>
+ 1 af, \ GPIO_62 - CCIC_IN<4>
+ 1 af, \ GPIO_63 - CCIC_IN<3>
+ 1 af, \ GPIO_64 - CCIC_IN<2>
+ 1 af, \ GPIO_65 - CCIC_IN<1>
+ 1 af, \ GPIO_66 - CCIC_IN<0>
+ 1 af, \ GPIO_67 - CAM_HSYNC
+ 1 af, \ GPIO_68 - CAM_VSYNC
+ 1 af, \ GPIO_69 - CAM_MCLK
+ 1 af, \ GPIO_70 - CAM_PCLK
+ 1 af, \ GPIO_71 - TWSI3_SCL (for CAM)
+ 1 af, \ GPIO_72 - TWSI3_CLK (for CAM)
+ 0 af, \ GPIO_73 - CCIC_RST_N (use as GPIO out)
+\ 0 af, \ GPIO_74 - LED - ORANGE (use as GPIO out) LCD VSYNC
+\ 0 af, \ GPIO_75 - LED - BLUE (use as GPIO out) LCD HSYNV
+\ 0 af, \ GPIO_76 - LED - RED (use as GPIO out) LCD PCLK
+\ 0 af, \ GPIO_77 - LED - GREEN (use as GPIO out)
+ 4 af, \ GPIO_74 - SSP3_CLK - EC_SPI
+ 4 af, \ GPIO_75 - SSP3_FRM - EC_SPI
+ 4 af, \ GPIO_76 - SSP3_TXD - EC_SPI
+ 4 af, \ GPIO_77 - SSP3_RXD - EC_SPI
+\ 5 af, \ GPIO_78 - SSP4_CLK
+\ 5 af, \ GPIO_79 - SSP4_FRM
+ 0 af, \ GPIO_78 - EC_SPI CMD
+ 0 af, \ GPIO_79 - EC_SPI ACK
+ 5 af, \ GPIO_80 - SSP4_SDA
+ 0 af, \ GPIO_81 - VBUS_FLT_N (use as GPIO in)
+ 0 af, \ GPIO_82 - VBUS_EN (use as GPIO out)
+ 0 af, \ GPIO_83 - LCD_RST_N (use as GPIO out)
+ 0 af, \ GPIO_84 - USB_INT_N (use as GPIO in)
+ 0 af, \ GPIO_85 - USB_RST_N (use as GPIO out)
+ 0 af, \ GPIO_86 - USB_PWDN_N (use as GPIO out)
+ 0 af, \ GPIO_87 - USB_HUB_EN (use as GPIO out)
+ 0 af, \ GPIO_88 - USB_MMC_EN (use as GPIO out)
+ 0 af, \ GPIO_89 - 5V_Enable (use as GPIO out)
+ no-update, \ GPIO_90 - Not used
+ 0 af, \ GPIO_91 - ACC_INT (use as GPIO in)
+ 0 af, \ GPIO_92 - PROX1_INT (use as GPIO in)
+ no-update, \ GPIO_93 - Not used
+ 3 pull-dn, \ GPIO_94 - SPI_CLK
+ 3 pull-up, \ GPIO_95 - SPI_CSO
+ 3 pull-dn, \ GPIO_96 - SPI_SDA
+ 2 af, \ GPIO_97 - TWSI6_SCL (HDMI EDID)
+ 2 af, \ GPIO_98 - TWSI6_SDA (HDMI EDID)
+ 4 af, \ GPIO_99 - TWSI5_SCL (CAP TOUCH)
+ 4 af, \ GPIO_100 - TWSI5_SDA (CAP TOUCH)
+ 0 af, \ GPIO_101 - TSI_INT (use as GPIO in)
+ 0 af, \ GPIO_102 - USIM_UCLK
+ 0 af, \ GPIO_103 - USIM_UIO
+ 0 af, \ GPIO_104 - ND_IO[7]
+ 0 af, \ GPIO_105 - ND_IO[6]
+ 0 af, \ GPIO_106 - ND_IO[5]
+ 0 af, \ GPIO_107 - ND_IO[4]
+ 0 af, \ GPIO_108 - ND_IO[15]
+ 0 af, \ GPIO_109 - ND_IO[14]
+ 0 af, \ GPIO_110 - ND_IO[13]
+ 0 af, \ GPIO_111 - ND_IO[8] Use 2 af, for eMMC
+ 0 af, \ GPIO_112 - ND_RDY[0] Use 2 af, for eMMC
+ no-update, \ GPIO_113 - Not used
+ 1 af, \ GPIO_114 - M/N_CLK_OUT (G_CLK_OUT)
+ 0 af, \ GPIO_115 - GPIO_115 (i/o)
+ 0 af, \ GPIO_116 - GPIO_116 (i/o)
+ 0 af, \ GPIO_117 - GPIO_117 (i/o)
+ 0 af, \ GPIO_118 - GPIO_118 (i/o)
+ 0 af, \ GPIO_119 - GPIO_119 (i/o)
+ 0 af, \ GPIO_120 - GPIO_120 (i/o)
+ 0 af, \ GPIO_121 - GPIO_121 (i/o)
+ 0 af, \ GPIO_122 - GPIO_122 (i/o)
+ 0 af, \ GPIO_123 - MBFLT_N (use as GPIO in)
+ 1 af, \ GPIO_124 - MMC1_DAT[7]
+ 1 af, \ GPIO_125 - MMC1_DAT[6]
+ 0 pull-up, \ GPIO_126 - Board Rev ID bit 0
+ 0 pull-up, \ GPIO_127 - Board Rev ID bit 1
+ 0 pull-up, \ GPIO_128 - Board Rev ID bit 2
+ 1 af, \ GPIO_129 - MMC1_DAT[5]
+ 1 af, \ GPIO_130 - MMC1_DAT[4]
+ 1 af, \ GPIO_131 - MMC1_DAT[3]
+ 1 af, \ GPIO_132 - MMC1_DAT[2]
+ 1 af, \ GPIO_133 - MMC1_DAT[1]
+ 1 af, \ GPIO_134 - MMC1_DAT[0]
+ no-update, \ GPIO_135 - Not used
+ 1 af, \ GPIO_136 - MMC1_CMD
+ no-update, \ GPIO_137 - Not used
+ no-update, \ GPIO_138 - Not used
+ 1 af, \ GPIO_139 - MMC1_CLK
+ 1 af, \ GPIO_140 - MMC1_CD
+ 1 af, \ GPIO_141 - MMC1_WP
+ 0 af, \ GPIO_142 - USIM_RSTn
+ 0 af, \ GPIO_143 - ND_CS[0]
+ 0 af, \ GPIO_144 - ND_CS[1]
+ no-update, \ GPIO_145 - Not used
+ no-update, \ GPIO_146 - Not used
+ 0 af, \ GPIO_147 - ND_WE_N
+ 0 af, \ GPIO_148 - ND_RE_N
+ 0 af, \ GPIO_149 - ND_CLE
+ 0 af, \ GPIO_150 - ND_ALE
+ 2 af, \ GPIO_151 - MMC3_CLK
+ no-update, \ GPIO_152 - Not used
+ no-update, \ GPIO_153 - Not used
+ 0 af, \ GPIO_154 - SM_INT
+ 1 af, \ MMC3_RST_N (use as GPIO)
+ no-update, \ GPIO_156 - PRI_TDI (JTAG)
+ no-update, \ GPIO_157 - PRI_TDS (JTAG)
+ no-update, \ GPIO_158 - PRI_TDK (JTAG)
+ no-update, \ GPIO_159 - PRI_TDO (JTAG)
+ 0 af, \ GPIO_160 - ND_RDY[1]
+ 0 af, \ GPIO_161 - ND_IO[12]
+ 0 af, \ GPIO_162 - ND_IO[11] Use 2 af, for eMMC
+ 0 af, \ GPIO_163 - ND_IO[10] Use 2 af, for eMMC
+ 0 af, \ GPIO_164 - ND_IO[9] Use 2 af, for eMMC
+ 0 af, \ GPIO_165 - ND_IO[3] Use 2 af, for eMMC
+ 0 af, \ GPIO_166 - ND_IO[2] Use 2 af, for eMMC
+ 0 af, \ GPIO_167 - ND_IO[1] Use 2 af, for eMMC
+ 0 af, \ GPIO_168 - ND_IO[0] Use 2 af, for eMMC
+
+: init-mfprs
+ d# 169 0 do
+ mfpr-table i wa+ w@ ( code )
+ dup 8 = if ( code )
+ drop ( )
+ else ( code )
+ i af! ( )
+ then
+ loop
+;
+
+: gpios-for-nand ( -- )
+ h# c0 d# 111 af!
+ h# c0 d# 112 af!
+ d# 169 d# 162 do h# c0 i af! loop
+;
+: gpios-for-emmc ( -- )
+ h# c2 d# 111 af!
+ h# c2 d# 112 af!
+ d# 169 d# 162 do h# c2 i af! loop
+;
Added: cpu/arm/mmp2/boardtwsi.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/boardtwsi.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,172 @@
+purpose: Board-specific details of TWSI-connected devices
+
+\ TWSI devices per channel:
+\ 1 MAX8925 PMIC MAIN 78, PMIC ADC 8e, PMIC RTC d0, MAX8649 c0
+\ 2 WM8994 Audio Codec 34, WM2000 Noise Canceler 74
+\ 3 m6M0 Camera ISP 3e, OV8810 Camera 6c
+\ 4 HMC5843 compass 3c, CM3623 ALS/PS 20+22+b0, BMA150 accelerometer 70
+\ 5 TC358762 MIPI bridge 16, TM-1210 or TM1414 touchscreen 40
+\ 6 HDMI DDC EDID a0
+
+: select-touch-panel ( -- ) h# 40 5 set-twsi-target ;
+: touch-panel-type ( -- n ) select-touch-panel h# bd twsi-b@ ;
+: get-tm1414-data ( -- x y finger-mask )
+ select-touch-panel ( )
+ h# 1a twsi-b@ ( low-y,low-x )
+ dup h# f and h# 18 twsi-b@ 4 lshift or ( low-y,low-x x )
+ swap 4 rshift h# f and h# 19 twsi-b@ 4 lshift or ( x y )
+ h# 15 twsi-b@ ( x y mask )
+;
+: touchpad@ ( -- x y finger-mask ) get-tm1414-data ;
+
+: get-tm1210-data ( -- x y reg7-flick-magnitude reg6-gesture reg0-finger-count )
+ 3 twsi-b@ 2 twsi-b@ bwjoin ( x )
+ 5 twsi-b@ 4 twsi-b@ bwjoin ( x y )
+
+ 7 twsi-b@
+ 6 twsi-b@
+ 0 twsi-b@
+;
+
+: compass@ ( -- x y z temp id )
+ h# 3c 4 set-twsi-target
+ 0 0 twsi-b! \ Config register A
+ h# 50 1 twsi-b! \ Config register B
+ 0 2 twsi-b! \ Mode register
+ 4 twsi-b@ 3 twsi-b@ bwjoin ( x )
+ 6 twsi-b@ 5 twsi-b@ bwjoin ( x y )
+ 8 twsi-b@ 7 twsi-b@ bwjoin ( x y z )
+ h# b twsi-b@ ( x y z temp )
+ h# a twsi-b@ 9 twsi-b@ bwjoin ( x y z temp id )
+;
+
+: select-pmic ( -- ) h# 78 1 set-twsi-target ;
+
+: accel-power-on ( -- ) \ LDO8 - vout is 36, ctl is 34
+ select-pmic
+ d# 3000 d# 750 - d# 50 / h# 36 twsi-b! \ want 3.0V
+ h# 1f h# 34 twsi-b!
+;
+: accel-power-off ( -- ) \ LDO8 - vout is 36, ctl is 34
+ select-pmic
+ h# 1e h# 34 twsi-b!
+;
+: accel@ ( -- x y z temp id )
+ h# 70 4 set-twsi-target
+
+ 2 twsi-b@ 6 rshift ( x-low )
+ 3 twsi-b@ 2 lshift or ( x )
+
+ 4 twsi-b@ 6 rshift ( x y-low )
+ 5 twsi-b@ 2 lshift or ( x y )
+
+ 6 twsi-b@ 6 rshift ( x y z-low )
+ 7 twsi-b@ 2 lshift or ( x y z )
+
+ 8 twsi-b@ 0 twsi-b@ ( x y z temp id )
+;
+
+: init-pals ( -- )
+ h# b0 4 set-twsi-target \ Set PS parameters address
+ 0 1 twsi-write \ clear interrupt settings
+
+ h# 22 4 set-twsi-target \ Device init address
+ h# 10 1 twsi-write \ Init device
+
+ h# 20 4 set-twsi-target \ Ambient Light Sensor address
+ 2 1 twsi-write \ Enable ALS in most sensitive mode, 16-bit data
+;
+: als@ ( -- n )
+ h# 22 4 set-twsi-target \ Ambient Light Sensor LSB address
+ 0 1 twsi-get ( low )
+ h# 20 4 set-twsi-target \ Ambient Light Sensor MSB address
+ 0 1 twsi-get bwjoin ( n )
+;
+
+: proximity@ ( -- byte )
+ h# b0 4 set-twsi-target \ Proximity Sensor address
+ 0 1 twsi-get ( byte )
+;
+
+: lcd-backlight! ( b.intensity -- )
+ select-pmic ( b.intensity )
+ dup if ( b.intensity )
+ h# 85 twsi-b! ( )
+ h# 84 twsi-b@ 1 or h# 84 twsi-b! \ Turn on first LED string
+ else ( 0 )
+ drop ( )
+ h# 84 twsi-b@ 1 invert and h# 84 twsi-b! \ Turn off first LED string
+ then
+;
+
+: keypad-backlight! ( b.intensity -- )
+ select-pmic ( b.intensity )
+ dup if ( b.intensity )
+ h# 85 twsi-b! ( )
+ h# 84 twsi-b@ 3 or h# 84 twsi-b! \ Turn on both LED strings
+ else ( )
+ h# 84 twsi-b@ 3 invert and h# 84 twsi-b! \ Turn off both LED strings
+ then
+;
+
+: power-on-dsi ( -- )
+ select-pmic
+
+ h# 16 h# 22 twsi-b! \ 1.2 volts for LDO3
+ h# 1f h# 20 twsi-b! \ LDO3 enable
+
+ h# 16 h# 16 twsi-b! \ 1.2 volts for LDO17
+ h# 1f h# 14 twsi-b! \ LDO17 enable
+
+ h# 1f h# 34 twsi-b! \ LDO8 enable
+
+ d# 10 ms
+;
+
+: bcd> ( bcd -- binary )
+ dup h# f and swap 4 rshift d# 10 * +
+;
+: twsi-bcd@ ( reg# -- binary ) twsi-b@ bcd> ;
+: get-rtc ( -- )
+ h# d0 1 set-twsi-target
+
+\ 3 twsi-b@ ( dow )
+\
+
+ 0 twsi-bcd@ ( sec )
+ 1 twsi-bcd@ ( sec min )
+ 2 twsi-bcd@ ( sec min hr )
+ 4 twsi-bcd@ ( sec min hr day )
+ 5 twsi-bcd@ ( sec min hr day mon )
+ 6 twsi-bcd@ d# 2000 + ( sec min hr day yr )
+;
+
+: core-voltage! ( mv -- )
+ h# c0 1 set-twsi-target \ MAX8649 power management IC
+
+ d# 750 umax d# 1350 umin \ Clipped voltage
+ d# 750 - d# 10 / ( offset-in-mv/10 )
+ h# 80 or ( code )
+ 2 twsi-b!
+;
+: core-voltage@ ( -- mv )
+ h# c0 1 set-twsi-target \ MAX8649 power management IC
+ 2 twsi-b@ ( code )
+ h# 7f and ( offset-mv/10 )
+ d# 10 * ( offset-mv )
+ d# 750 +
+;
+: .core-voltage ( -- ) core-voltage@ .d ;
+
+: vibrate-on ( -- ) select-pmic h# 1f h# 3c twsi-b! ; \ LDO10
+: vibrate-off ( -- ) select-pmic h# 1e h# 3c twsi-b! ;
+
+: power-on-sd ( -- )
+ select-pmic
+ h# 29 h# 42 twsi-b!
+ h# 1f h# 40 twsi-b!
+;
+: power-off-sd ( -- )
+ select-pmic
+ h# 1e h# 40 twsi-b!
+;
Modified: cpu/arm/mmp2/config.fth
==============================================================================
--- cpu/arm/mmp2/config.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/config.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -1,3 +1,4 @@
create debug-startup
fload ${BP}/cpu/arm/mmp2/addrs.fth
+fload ${BP}/cpu/arm/mmp2/hwaddrs.fth
Modified: cpu/arm/mmp2/devices.fth
==============================================================================
--- cpu/arm/mmp2/devices.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/devices.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -46,6 +46,10 @@
fload ${BP}/cpu/arm/mmp2/timer.fth
fload ${BP}/cpu/arm/mmp2/twsi.fth
fload ${BP}/cpu/arm/mmp2/mfpr.fth
+fload ${BP}/cpu/arm/mmp2/gpio.fth
+
+fload ${BP}/cpu/arm/mmp2/boardtwsi.fth
+fload ${BP}/cpu/arm/mmp2/boardgpio.fth
: init-stuff
set-camera-domain-voltage
acgr-clocks-on
@@ -60,31 +64,12 @@
init-stuff
;
-fload ${BP}/cpu/arm/mmp2/gpio.fth
fload ${BP}/cpu/arm/mmp2/irq.fth
fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer
-0 0 " d4018000" " /" begin-package
- " uart" name
- h# d4018000 h# 20 reg
-
- : write ( adr len -- actual )
- 0 max tuck ( actual adr actual )
- bounds ?do i c@ uemit loop ( actual )
- ;
- : read ( adr len -- actual )
- 0= if drop 0 exit then
- ukey? if ( adr )
- ukey swap c! 1 ( actual )
- else ( adr )
- drop -2 ( -2 )
- then
- ;
- : open ( -- okay? ) true ;
- : close ( -- ) ;
- : install-abort ;
- : remove-abort ;
+0 0 " d4018000" " /" begin-package \ UART3
+ fload ${BP}/cpu/arm/mmp2/uart.fth
end-package
devalias com1 /uart
: com1 " com1" ;
@@ -135,6 +120,26 @@
fload ${BP}/dev/olpc/kb3700/spicmd.fth
+0 0 " d4208000" " /" begin-package
+ h# 200 constant /regs
+ my-address my-space /regs reg
+ : my-map-in ( len -- adr )
+ my-space swap " map-in" $call-parent h# 100 + ( adr )
+ 3 over h# a8 + rl! ( adr ) \ Force host mode
+ ;
+ : my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ;
+ false constant has-dbgp-regs?
+ false constant needs-dummy-qh?
+ false constant grab-controller
+ fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
+end-package
+
+: usb-power-on ( -- ) d# 82 gpio-set ; \ 1 instead of 82 for XO
+
+fload ${BP}/cpu/arm/marvell/utmiphy.fth
+stand-init: Init USB Phy
+ init-usb-phy
+;
\ LICENSE_BEGIN
\ Copyright (c) 2010 FirmWorks
Modified: cpu/arm/mmp2/dsi.fth
==============================================================================
--- cpu/arm/mmp2/dsi.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/dsi.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -45,7 +45,7 @@
2 ms
d# 83 gpio-clr 1 ms d# 83 gpio-set 1 ms \ LCD_RST_N line resets DSI bridge
- 5 set-address h# 16 set-slave \ TWSI address of TC358762 MIPI DSI bridge
+ h# 16 5 set-twsi-target \ TWSI address of TC358762 MIPI DSI bridge
\ Data Reg#.......
0 h# 047c dsi-twsi! \ Turn off sleep mode
2 ms
@@ -142,7 +142,7 @@
: .dsi ( index -- ) dup 3 u.r space dsi-twsi@ 8 u.r cr ;
: .dsiw ( index -- ) dup 3 u.r space dsi-twsi-w@ 8 u.r cr ;
: dump-dsi ( -- )
- 5 set-address 16 set-slave
+ 16 5 set-twsi-target
47c .dsi
210 .dsi
470 .dsi
Modified: cpu/arm/mmp2/fw.bth
==============================================================================
--- cpu/arm/mmp2/fw.bth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/fw.bth Mon Oct 18 06:02:38 2010 (r1987)
@@ -215,7 +215,6 @@
true to stand-init-debug?
: protect-fw ( -- ) ;
-: usb-power-on ( -- ) ;
hex
: i-key-wait ( ms -- pressed? )
@@ -236,7 +235,6 @@
standalone? if
disable-interrupts
-[ifdef] notdef
d# 1000
i-key-wait if
\ protect-fw
@@ -244,7 +242,6 @@
then
\ Turn on USB power here to overlap the time with other startup actions
usb-power-on
-[then]
then
;
warning !
Added: cpu/arm/mmp2/hwaddrs.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/hwaddrs.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,11 @@
+\ Defined by MMP2 hardware
+h# d401.9000 constant gpio-base
+h# d405.1024 constant acgr-pa
+h# d401.5000 constant clock-unit-pa
+h# d405.0000 constant main-pmu-pa
+h# d428.2800 constant pmua-pa \ Application processor PMU register base
+h# d420.b800 constant dsi1-pa \ 4-lane controller
+h# d420.ba00 constant dsi2-pa \ 3-lane controller
+h# d420.b000 constant lcd-pa
+h# d401.4000 constant timer-pa
+
Modified: cpu/arm/mmp2/mfpr.fth
==============================================================================
--- cpu/arm/mmp2/mfpr.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/mfpr.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -1,26 +1,12 @@
+purpose: Pin multiplexing for ARMADA 610 chip (no board details)
+
: aib-unlock
h# baba h# d4015068 l! \ Unlock sequence
h# eb10 h# d401506c l!
;
-: set-camera-domain-voltage
- aib-unlock
- h# d401e80c l@ 4 or ( n ) \ Set 1.8V selector bit in AIB_GPIO2_IO
- aib-unlock
- h# d401e80c l!
-;
: acgr-clocks-on ( -- )
h# 0818.F33C acgr-pa l! \ Turn on all clocks
;
-: set-gpio-directions ( -- )
- 3 h# 38 clock-unit-pa + l! \ Enable clocks in GPIO clock reset register
-
- h# 000e.0000 gpio-base h# 0c + l! \ Bits 19, 18, 17
- h# 0704.2000 gpio-base h# 10 + l! \ Bits 58,57,56,50 and 45
-\ h# 03ec.3e00 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:73
- h# 03ec.3200 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:76 and 73 (leave 74 and 75 as input)
-
- h# 0200.3c00 gpio-base h# 20 + l! \ Turn off LEDS (3c00) and turn on 5V (0200.0000)
-;
hex
create mfpr-offsets \ GPIOs
@@ -60,211 +46,8 @@
;
: no-update, ( -- ) 8 w, ; \ 8 is a reserved bit; the code skips these
+: af@ ( gpio# -- function# ) gpio>mfpr l@ ;
+: af! ( function# gpio# -- ) gpio>mfpr l! ;
: af, ( n -- ) h# c0 + w, ;
: pull-up, ( n -- ) h# c0c0 + w, ;
: pull-dn, ( n -- ) h# a0c0 + w, ;
-
-create mfpr-table
- 1 af, \ GPIO_00 - KP_MKIN[0]
- 1 af, \ GPIO_01 - KP_MKOUT[0]
- 1 af, \ GPIO_02 - KP_MKIN[1]
- 1 af, \ GPIO_03 - KP_MKOUT[1]
- 1 af, \ GPIO_04 - KP_MKIN[2]
- 1 af, \ GPIO_05 - KP_MKOUT[2]
- no-update, \ GPIO_06 - Not used
- no-update, \ GPIO_07 - Not used
- no-update, \ GPIO_08 - Not used
- no-update, \ GPIO_09 - Not used
- no-update, \ GPIO_10 - Not used
- no-update, \ GPIO_11 - Not used
- no-update, \ GPIO_12 - Not used
- no-update, \ GPIO_13 - Not used
- no-update, \ GPIO_14 - Not used
- no-update, \ GPIO_15 - Not used
- no-update, \ GPIO_16 - Not used
- 0 af, \ GPIO_17 - BB_GPIO1 (use as GPIO out)
- 0 af, \ GPIO_18 - BB_GPIO2 (use as GPIO out)
- 0 af, \ GPIO_19 - BB_GPIO3 (use as GPIO out)
- 0 af, \ GPIO_20 - ISP_INT (use as GPIO in)
- 0 af, \ GPIO_21 - WIFI_GPIO2 (use as GPIO i/o)
- 0 af, \ GPIO_22 - WIFI_GPIO3 (use as GPIO i/o)
- 0 af, \ GPIO_23 - CODEC_INT (use as GPIO in)
- 1 af, \ GPIO_24 - I2S_SYSCLK (Codec - HI-FI)
- 1 af, \ GPIO_25 - SSPA2_SCLK (Codec - HI-FI)
- 1 af, \ GPIO_26 - SSPA2_SFRM (Codec - HI-FI)
- 1 af, \ GPIO_27 - SSPA2_TXD (Codec - HI-FI)
- 1 af, \ GPIO_28 - SSPA2_RXD (Codec - HI-FI)
- 1 af, \ GPIO_29 - UART1_RXD (Bluetooth)
- 1 af, \ GPIO_30 - UART1_TXD (Bluetooth)
- 1 af, \ GPIO_31 - UART1_CTS (Bluetooth)
-\
- 1 af, \ GPIO_32 - UART1_RTS (Bluetooth)
- 0 af, \ GPIO_33 - SSPA2_CLK (Codec - LO-FI)
- 0 af, \ GPIO_34 - SSPA2_FRM (Codec - LO-FI)
- 0 af, \ GPIO_35 - SSPA2_TXD (Codec - LO-FI)
- 0 af, \ GPIO_36 - SSPA2_RXD (Codec - LO-FI)
- 1 af, \ GPIO_37 - MMC2_DAT<3>
- 1 af, \ GPIO_38 - MMC2_DAT<2>
- 1 af, \ GPIO_39 - MMC2_DAT<1>
- 1 af, \ GPIO_40 - MMC2_DAT<0>
- 1 af, \ GPIO_41 - MMC2_CMD
- 1 af, \ GPIO_42 - MMC2_CLK
- 1 af, \ GPIO_43 - TWSI2_SCL (for codec/noise/FM)
- 1 af, \ GPIO_44 - TWSI2_SDA (for codec/noise/FM)
- 0 af, \ GPIO_45 - WM8994_LDOEN (use as GPIO out)
- 0 af, \ GPIO_46 - HDMI_DET (use as GPIO in)
- 2 af, \ GPIO_47 - SSP2_CLK
- 2 af, \ GPIO_48 - SSP2_FRM
- 2 af, \ GPIO_49 - SSP2_RXD
- 0 af, \ GPIO_50 - GPS_STBY (use as GPIO out)
- 1 af, \ GPIO_51 - UART3_RXD (debug port)
- 1 af, \ GPIO_52 - UART3_TXD (debug port)
- 5 af, \ GPIO_53 - PWM3 (Keypad backlight)
- 4 af, \ GPIO_54 - HDMI_CEC (MOVED to GPIO 113?)
- 0 af, \ GPIO_55 - WIFI_GPIO0 (use as GPIO in)
- 0 af, \ GPIO_56 - WIFI_GPIO1 (use as GPIO out)
- 0 af, \ GPIO_57 - WIFI_PD_N (use as GPIO out)
- 0 af, \ GPIO_58 - WIFI_RST_N (use as GPIO out)
- 1 af, \ GPIO_59 - CCIC_IN<7>
- 1 af, \ GPIO_60 - CCIC_IN<6>
- 1 af, \ GPIO_61 - CCIC_IN<5>
- 1 af, \ GPIO_62 - CCIC_IN<4>
- 1 af, \ GPIO_63 - CCIC_IN<3>
-\
- 1 af, \ GPIO_64 - CCIC_IN<2>
- 1 af, \ GPIO_65 - CCIC_IN<1>
- 1 af, \ GPIO_66 - CCIC_IN<0>
- 1 af, \ GPIO_67 - CAM_HSYNC
- 1 af, \ GPIO_68 - CAM_VSYNC
- 1 af, \ GPIO_69 - CAM_MCLK
- 1 af, \ GPIO_70 - CAM_PCLK
- 1 af, \ GPIO_71 - TWSI3_SCL (for CAM)
- 1 af, \ GPIO_72 - TWSI3_CLK (for CAM)
- 0 af, \ GPIO_73 - CCIC_RST_N (use as GPIO out)
-\ 0 af, \ GPIO_74 - LED - ORANGE (use as GPIO out) LCD VSYNC
-\ 0 af, \ GPIO_75 - LED - BLUE (use as GPIO out) LCD HSYNV
-\ 0 af, \ GPIO_76 - LED - RED (use as GPIO out) LCD PCLK
-\ 0 af, \ GPIO_77 - LED - GREEN (use as GPIO out)
- 4 af, \ GPIO_74 - SSP3_CLK - EC_SPI
- 4 af, \ GPIO_75 - SSP3_FRM - EC_SPI
- 4 af, \ GPIO_76 - SSP3_TXD - EC_SPI
- 4 af, \ GPIO_77 - SSP3_RXD - EC_SPI
-\ 5 af, \ GPIO_78 - SSP4_CLK
-\ 5 af, \ GPIO_79 - SSP4_FRM
- 0 af, \ GPIO_78 - EC_SPI CMD
- 0 af, \ GPIO_79 - EC_SPI ACK
- 5 af, \ GPIO_80 - SSP4_SDA
- 0 af, \ GPIO_81 - VBUS_FLT_N (use as GPIO in)
- 0 af, \ GPIO_82 - VBUS_EN (use as GPIO out)
- 0 af, \ GPIO_83 - LCD_RST_N (use as GPIO out)
- 0 af, \ GPIO_84 - USB_INT_N (use as GPIO in)
- 0 af, \ GPIO_85 - USB_RST_N (use as GPIO out)
- 0 af, \ GPIO_86 - USB_PWDN_N (use as GPIO out)
- 0 af, \ GPIO_87 - USB_HUB_EN (use as GPIO out)
- 0 af, \ GPIO_88 - USB_MMC_EN (use as GPIO out)
- 0 af, \ GPIO_89 - 5V_Enable (use as GPIO out)
- no-update, \ GPIO_90 - Not used
- 0 af, \ GPIO_91 - ACC_INT (use as GPIO in)
- 0 af, \ GPIO_92 - PROX1_INT (use as GPIO in)
- no-update, \ GPIO_93 - Not used
- 3 pull-dn, \ GPIO_94 - SPI_CLK
- 3 pull-up, \ GPIO_95 - SPI_CSO
-\
- 3 pull-dn, \ GPIO_96 - SPI_SDA
- 2 af, \ GPIO_97 - TWSI6_SCL (HDMI EDID)
- 2 af, \ GPIO_98 - TWSI6_SDA (HDMI EDID)
- 4 af, \ GPIO_99 - TWSI5_SCL (CAP TOUCH)
- 4 af, \ GPIO_100 - TWSI5_SDA (CAP TOUCH)
- 0 af, \ GPIO_101 - TSI_INT (use as GPIO in)
- 0 af, \ GPIO_102 - USIM_UCLK
- 0 af, \ GPIO_103 - USIM_UIO
- 0 af, \ GPIO_104 - ND_IO[7]
- 0 af, \ GPIO_105 - ND_IO[6]
- 0 af, \ GPIO_106 - ND_IO[5]
- 0 af, \ GPIO_107 - ND_IO[4]
- 0 af, \ GPIO_108 - ND_IO[15]
- 0 af, \ GPIO_109 - ND_IO[14]
- 0 af, \ GPIO_110 - ND_IO[13]
- 0 af, \ GPIO_111 - ND_IO[8] Use 2 af, for eMMC
- 0 af, \ GPIO_112 - ND_RDY[0] Use 2 af, for eMMC
- no-update, \ GPIO_113 - Not used
- 1 af, \ GPIO_114 - M/N_CLK_OUT (G_CLK_OUT)
- 0 af, \ GPIO_115 - GPIO_115 (i/o)
- 0 af, \ GPIO_116 - GPIO_116 (i/o)
- 0 af, \ GPIO_117 - GPIO_117 (i/o)
- 0 af, \ GPIO_118 - GPIO_118 (i/o)
- 0 af, \ GPIO_119 - GPIO_119 (i/o)
- 0 af, \ GPIO_120 - GPIO_120 (i/o)
- 0 af, \ GPIO_121 - GPIO_121 (i/o)
- 0 af, \ GPIO_122 - GPIO_122 (i/o)
- 0 af, \ GPIO_123 - MBFLT_N (use as GPIO in)
- 1 af, \ GPIO_124 - MMC1_DAT[7]
- 1 af, \ GPIO_125 - MMC1_DAT[6]
- 0 pull-up, \ GPIO_126 - Board Rev ID bit 0
- 0 pull-up, \ GPIO_127 - Board Rev ID bit 1
-\
- 0 pull-up, \ GPIO_128 - Board Rev ID bit 2
- 1 af, \ GPIO_129 - MMC1_DAT[5]
- 1 af, \ GPIO_130 - MMC1_DAT[4]
- 1 af, \ GPIO_131 - MMC1_DAT[3]
- 1 af, \ GPIO_132 - MMC1_DAT[2]
- 1 af, \ GPIO_133 - MMC1_DAT[1]
- 1 af, \ GPIO_134 - MMC1_DAT[0]
- no-update, \ GPIO_135 - Not used
- 1 af, \ GPIO_136 - MMC1_CMD
- no-update, \ GPIO_137 - Not used
- no-update, \ GPIO_138 - Not used
- 1 af, \ GPIO_139 - MMC1_CLK
- 1 af, \ GPIO_140 - MMC1_CD
- 1 af, \ GPIO_141 - MMC1_WP
- 0 af, \ GPIO_142 - USIM_RSTn
- 0 af, \ GPIO_143 - ND_CS[0]
- 0 af, \ GPIO_144 - ND_CS[1]
- no-update, \ GPIO_145 - Not used
- no-update, \ GPIO_146 - Not used
- 0 af, \ GPIO_147 - ND_WE_N
- 0 af, \ GPIO_148 - ND_RE_N
- 0 af, \ GPIO_149 - ND_CLE
- 0 af, \ GPIO_150 - ND_ALE
- 2 af, \ GPIO_151 - MMC3_CLK
- no-update, \ GPIO_152 - Not used
- no-update, \ GPIO_153 - Not used
- 0 af, \ GPIO_154 - SM_INT
- 1 af, \ MMC3_RST_N (use as GPIO)
- no-update, \ GPIO_156 - PRI_TDI (JTAG)
- no-update, \ GPIO_157 - PRI_TDS (JTAG)
- no-update, \ GPIO_158 - PRI_TDK (JTAG)
- no-update, \ GPIO_159 - PRI_TDO (JTAG)
-\
- 0 af, \ GPIO_160 - ND_RDY[1]
- 0 af, \ GPIO_161 - ND_IO[12]
- 0 af, \ GPIO_162 - ND_IO[11] Use 2 af, for eMMC
- 0 af, \ GPIO_163 - ND_IO[10] Use 2 af, for eMMC
- 0 af, \ GPIO_164 - ND_IO[9] Use 2 af, for eMMC
- 0 af, \ GPIO_165 - ND_IO[3] Use 2 af, for eMMC
- 0 af, \ GPIO_166 - ND_IO[2] Use 2 af, for eMMC
- 0 af, \ GPIO_167 - ND_IO[1] Use 2 af, for eMMC
- 0 af, \ GPIO_168 - ND_IO[0] Use 2 af, for eMMC
-
-: init-mfprs
- d# 169 0 do
- mfpr-table i wa+ w@ ( code )
- dup 8 = if ( code )
- drop ( )
- else ( code )
- i gpio>mfpr l! ( )
- then
- loop
-;
-
-: af! ( function# gpio# -- ) gpio>mfpr l! ;
-: gpios-for-nand ( -- )
- h# c0 d# 111 af!
- h# c0 d# 112 af!
- d# 169 d# 162 do h# c0 i af! loop
-;
-: gpios-for-emmc ( -- )
- h# c2 d# 111 af!
- h# c2 d# 112 af!
- d# 169 d# 162 do h# c2 i af! loop
-;
Modified: cpu/arm/mmp2/timer.fth
==============================================================================
--- cpu/arm/mmp2/timer.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/timer.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -21,7 +21,7 @@
7 h# 84 timer!
;
-
+[ifdef] arm-assembler
code timer0@ ( -- n ) \ 6.5 MHz
psh tos,sp
set r1,0xD4014000
@@ -48,6 +48,11 @@
mov r0,r0
ldr tos,[r1,#0x30]
c;
+[else]
+: timer0@ ( -- n ) 1 h# d40140a4 l! h# d4014028 l@ ;
+: timer1@ ( -- n ) 1 h# d40140a8 l! h# d401402c l@ ;
+: timer2@ ( -- n ) 1 h# d40140ac l! h# d4014030 l@ ;
+[then]
: timer0-status@ ( -- n ) h# d4014034 l@ ;
: timer1-status@ ( -- n ) h# d4014038 l@ ;
Modified: cpu/arm/mmp2/twsi.fth
==============================================================================
--- cpu/arm/mmp2/twsi.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/mmp2/twsi.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -23,20 +23,14 @@
create clock-offsets
h# 04 c, h# 08 c, h# 0c c, h# 10 c, h# 7c c, h# 80 c,
-create slave-addresses \ per channel
-h# 78 c, \ 1 MAX8925 PMIC MAIN 78, PMIC ADC 8e, PMIC RTC d0, MAX8649 c0
-h# 34 c, \ 2 WM8994 Audio Codec 34, WM2000 Noise Canceler 74
-h# 3e c, \ 3 m6M0 Camera ISP 3e, OV8810 Camera 6c
-h# 3c c, \ 4 HMC5843 compass 3c, CM3623 ALS/PS 20+22+b0, BMA150 accelerometer 70
-h# 16 c, \ 5 TC358762 MIPI bridge 16, TM-1210 or TM1414 touchscreen 40
-h# a0 c, \ 6 HDMI DDC EDID a0
-
-: set-slave ( n -- ) to slave-address ;
-: set-address ( n -- ) \ Channel numbers range from 1 to 6
+: set-twsi-channel ( channel -- )
1-
- channel-bases over na+ @ to chip ( n )
- dup clock-offsets + c@ clock-unit-pa + to clock-reg ( n )
- slave-addresses + c@ set-slave
+ channel-bases over na+ @ to chip ( channel )
+ clock-offsets + c@ clock-unit-pa + to clock-reg ( )
+;
+: set-twsi-target ( slave channel -- ) \ Channel numbers range from 1 to 6
+ set-twsi-channel
+ to slave-address
;
\ Bit defines
@@ -56,7 +50,7 @@
bbu_ICR_IUE bbu_ICR_SCLE or constant iue+scle
: init-twsi-channel ( channel# -- )
- set-address
+ set-twsi-channel
7 clock-reg l! 3 clock-reg l! \ Set then clear reset bit
1 us
iue+scle bbu_ICR_UR or cr! \ Reset the unit
@@ -64,6 +58,9 @@
0 sar! \ Set host slave address
0 cr! \ Disable interrupts
;
+: init-twsi ( -- )
+ 7 1 do i init-twsi-channel loop
+;
: twsi-run ( extra-flags -- )
iue+scle or bbu_ICR_TB or cr! ( )
@@ -140,186 +137,3 @@
: twsi-b@ ( reg -- byte ) 1 1 twsi-get ;
: twsi-b! ( byte reg -- ) 2 twsi-write ;
-
-: select-touch-panel ( -- )
- 5 set-address
- h# 40 set-slave
-;
-: touch-panel-type ( -- n )
- select-touch-panel
- h# bd twsi-b@
-;
-: get-tm1414-data ( -- x y finger-mask )
- select-touch-panel ( )
- h# 1a twsi-b@ ( low-y,low-x )
- dup h# f and h# 18 twsi-b@ 4 lshift or ( low-y,low-x x )
- swap 4 rshift h# f and h# 19 twsi-b@ 4 lshift or ( x y )
- h# 15 twsi-b@ ( x y mask )
-;
-: touchpad@ ( -- x y finger-mask ) get-tm1414-data ;
-
-: get-tm1210-data ( -- x y reg7-flick-magnitude reg6-gesture reg0-finger-count )
- 3 twsi-b@ 2 twsi-b@ bwjoin ( x )
- 5 twsi-b@ 4 twsi-b@ bwjoin ( x y )
-
- 7 twsi-b@
- 6 twsi-b@
- 0 twsi-b@
-;
-
-: select-compass ( -- )
- 4 set-address
- h# 3c set-slave
-;
-
-: compass@ ( -- x y z temp id )
- select-compass
- 0 0 twsi-b! \ Config register A
- h# 50 1 twsi-b! \ Config register B
- 0 2 twsi-b! \ Mode register
- 4 twsi-b@ 3 twsi-b@ bwjoin ( x )
- 6 twsi-b@ 5 twsi-b@ bwjoin ( x y )
- 8 twsi-b@ 7 twsi-b@ bwjoin ( x y z )
- h# b twsi-b@ ( x y z temp )
- h# a twsi-b@ 9 twsi-b@ bwjoin ( x y z temp id )
-;
-
-: select-pmic ( -- ) 1 set-address h# 78 set-slave ;
-
-: accel-power-on ( -- ) \ LDO8 - vout is 36, ctl is 34
- select-pmic
- d# 3000 d# 750 - d# 50 / h# 36 twsi-b! \ want 3.0V
- h# 1f h# 34 twsi-b!
-;
-: accel-power-off ( -- ) \ LDO8 - vout is 36, ctl is 34
- select-pmic
- h# 1e h# 34 twsi-b!
-;
-: accel@ ( -- x y z temp id )
- 4 set-address
- h# 70 set-slave
-
- 2 twsi-b@ 6 rshift ( x-low )
- 3 twsi-b@ 2 lshift or ( x )
-
- 4 twsi-b@ 6 rshift ( x y-low )
- 5 twsi-b@ 2 lshift or ( x y )
-
- 6 twsi-b@ 6 rshift ( x y z-low )
- 7 twsi-b@ 2 lshift or ( x y z )
-
- 8 twsi-b@ 0 twsi-b@ ( x y z temp id )
-;
-
-: init-pals ( -- )
- 4 set-address
-
- h# b0 set-slave \ Set PS parameters address
- 0 1 twsi-write \ clear interrupt settings
-
- h# 22 set-slave \ Device init address
- h# 10 1 twsi-write \ Init device
-
- h# 20 set-slave \ Ambient Light Sensor address
- 2 1 twsi-write \ Enable ALS in most sensitive mode, 16-bit data
-;
-: als@ ( -- n )
- 4 set-address
- h# 22 set-slave \ Ambient Light Sensor LSB address
- 0 1 twsi-get ( low )
- h# 20 set-slave \ Ambient Light Sensor MSB address
- 0 1 twsi-get bwjoin ( n )
-;
-
-: proximity@ ( -- byte )
- 4 set-address
- h# b0 set-slave \ Proximity Sensor address
- 0 1 twsi-get ( byte )
-;
-
-: lcd-backlight! ( b.intensity -- )
- select-pmic ( b.intensity )
- dup if ( b.intensity )
- h# 85 twsi-b! ( )
- h# 84 twsi-b@ 1 or h# 84 twsi-b! \ Turn on first LED string
- else ( 0 )
- drop ( )
- h# 84 twsi-b@ 1 invert and h# 84 twsi-b! \ Turn off first LED string
- then
-;
-
-: keypad-backlight! ( b.intensity -- )
- select-pmic ( b.intensity )
- dup if ( b.intensity )
- h# 85 twsi-b! ( )
- h# 84 twsi-b@ 3 or h# 84 twsi-b! \ Turn on both LED strings
- else ( )
- h# 84 twsi-b@ 3 invert and h# 84 twsi-b! \ Turn off both LED strings
- then
-;
-
-: init-twsi ( -- )
- 7 1 do i init-twsi-channel loop
-;
-: power-on-dsi ( -- )
- select-pmic
-
- h# 16 h# 22 twsi-b! \ 1.2 volts for LDO3
- h# 1f h# 20 twsi-b! \ LDO3 enable
-
- h# 16 h# 16 twsi-b! \ 1.2 volts for LDO17
- h# 1f h# 14 twsi-b! \ LDO17 enable
-
- h# 1f h# 34 twsi-b! \ LDO8 enable
-
- d# 10 ms
-;
-
-: bcd> ( bcd -- binary )
- dup h# f and swap 4 rshift d# 10 * +
-;
-: twsi-bcd@ ( reg# -- binary ) twsi-b@ bcd> ;
-: get-rtc ( -- )
- 1 set-address
- h# d0 set-slave
-
-\ 3 twsi-b@ ( dow )
-\
-
- 0 twsi-bcd@ ( sec )
- 1 twsi-bcd@ ( sec min )
- 2 twsi-bcd@ ( sec min hr )
- 4 twsi-bcd@ ( sec min hr day )
- 5 twsi-bcd@ ( sec min hr day mon )
- 6 twsi-bcd@ d# 2000 + ( sec min hr day yr )
-;
-
-: core-voltage! ( mv -- )
- 1 set-address h# c0 set-slave \ MAX8649 power management IC
-
- d# 750 umax d# 1350 umin \ Clipped voltage
- d# 750 - d# 10 / ( offset-in-mv/10 )
- h# 80 or ( code )
- 2 twsi-b!
-;
-: core-voltage@ ( -- mv )
- 1 set-address h# c0 set-slave \ MAX8649 power management IC
- 2 twsi-b@ ( code )
- h# 7f and ( offset-mv/10 )
- d# 10 * ( offset-mv )
- d# 750 +
-;
-: .core-voltage ( -- ) core-voltage@ .d ;
-
-: vibrate-on ( -- ) select-pmic h# 1f h# 3c twsi-b! ; \ LDO10
-: vibrate-off ( -- ) select-pmic h# 1e h# 3c twsi-b! ;
-
-: power-on-sd ( -- )
- select-pmic
- h# 29 h# 42 twsi-b!
- h# 1f h# 40 twsi-b!
-;
-: power-off-sd ( -- )
- select-pmic
- h# 1e h# 40 twsi-b!
-;
Added: cpu/arm/mmp2/uart.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/uart.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,19 @@
+ " uart" name
+ my-space h# 20 reg
+
+ : write ( adr len -- actual )
+ 0 max tuck ( actual adr actual )
+ bounds ?do i c@ uemit loop ( actual )
+ ;
+ : read ( adr len -- actual )
+ 0= if drop 0 exit then
+ ukey? if ( adr )
+ ukey swap c! 1 ( actual )
+ else ( adr )
+ drop -2 ( -2 )
+ then
+ ;
+ : open ( -- okay? ) true ;
+ : close ( -- ) ;
+ : install-abort ;
+ : remove-abort ;
Added: cpu/arm/olpc/1.75/boardgpio.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/boardgpio.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,236 @@
+purpose: Board-specific setup details - pin assigments, etc.
+
+: set-camera-domain-voltage
+ aib-unlock
+ h# d401e80c l@ 4 or ( n ) \ Set 1.8V selector bit in AIB_GPIO2_IO
+ aib-unlock
+ h# d401e80c l!
+;
+
+: set-gpio-directions ( -- )
+ 3 h# 38 clock-unit-pa + l! \ Enable clocks in GPIO clock reset register
+
+ d# 01 gpio-dir-out \ EN_USB_PWR
+ d# 04 gpio-dir-out \ COMPASS_SCL
+ d# 08 gpio-dir-out \ AUDIO_RESET#
+ d# 10 gpio-dir-out \ LED_STORAGE
+ d# 11 gpio-dir-out \ VID2
+ d# 33 gpio-dir-out \ EN_MSD_PWR
+ d# 34 gpio-dir-out \ EN_WLAN_PWR
+ d# 35 gpio-dir-out \ EN_SD_PWR
+ d# 57 gpio-dir-out \ WLAN_PD#
+ d# 58 gpio-dir-out \ WLAN_RESET#
+ d# 73 gpio-dir-out \ CAM_RST
+
+ d# 125 gpio-dir-out \ EC_SPI_ACK
+ d# 145 gpio-dir-out \ EN_CAM_PWR
+ d# 146 gpio-dir-out \ HUB_RESET#
+ d# 151 gpio-dir-out \ DCONLOAD
+ d# 151 gpio-dir-out \ EC_SPI_CMD
+
+ d# 162 gpio-dir-out \ DCON_SCL
+ d# 163 gpio-dir-out \ DCON_SDA
+;
+
+create mfpr-table
+ no-update, \ GPIO_00 - Not connected (TP57)
+ 0 af, \ GPIO_01 - EN_USB_PWR
+ no-update, \ GPIO_02 - Not connected (TP54)
+ no-update, \ GPIO_03 - Not connected (TP53)
+ 0 af, \ GPIO_04 - COMPASS_SCL (bitbang)
+ 0 af, \ GPIO_05 - COMPASS_SDA (bitbang)
+ 0 af, \ GPIO_06 - G_SENSOR_INT
+ 0 af, \ GPIO_07 - AUDIO_IRQ#
+ 0 af, \ GPIO_08 - AUDIO_RESET#
+ 0 af, \ GPIO_09 - COMPASS_INT
+ 0 af, \ GPIO_10 - LED_STORAGE
+ 0 af, \ GPIO_11 - VID2
+ no-update, \ GPIO_12 - Not connected (TP52)
+ no-update, \ GPIO_13 - Not connected (TP116)
+ no-update, \ GPIO_14 - Not connected (TP64)
+ no-update, \ GPIO_15 - Not connected (TP55)
+ 0 af, \ GPIO_16 - KEY_IN_1
+ 0 af, \ GPIO_17 - KEY_IN_2
+ 0 af, \ GPIO_18 - KEY_IN_3
+ 0 af, \ GPIO_19 - KEY_IN_4
+ 0 af, \ GPIO_20 - KEY_IN_5
+ no-update, \ GPIO_21 - Not connected (TP63)
+ no-update, \ GPIO_22 - Not connected (TP118)
+ no-update, \ GPIO_23 - Not connected (TP61)
+ 1 af, \ GPIO_24 - I2S_SYSCLK (Codec)
+ 1 af, \ GPIO_25 - I2S_BITCLK (Codec)
+ 1 af, \ GPIO_26 - I2S_SYNC (Codec)
+ 1 af, \ GPIO_27 - I2S_DATA_OUT (Codec)
+ 1 af, \ GPIO_28 - I2S_DATA_IN (Codec)
+ 1 af, \ GPIO_29 - UART1_RXD (debug board)
+ 1 af, \ GPIO_30 - UART1_TXD (debug board)
+ 0 af, \ GPIO_31 - SD_CD# (via GPIO)
+ no-update, \ GPIO_32 - Not connected (TP58)
+ 0 af, \ GPIO_33 - EN_MSD_PWR
+ 0 af, \ GPIO_34 - EN_WLAN_PWR
+ 0 af, \ GPIO_35 - EN_SD_PWR
+ no-update, \ GPIO_36 - Not connected (TP115)
+ 1 af, \ GPIO_37 - SDDA_D3
+ 1 af, \ GPIO_38 - SDDA_D2
+ 1 af, \ GPIO_39 - SDDA_D1
+ 1 af, \ GPIO_40 - SDDA_D0
+ 1 af, \ GPIO_41 - SDDA_CMD
+ 1 af, \ GPIO_42 - SDDA_CLK
+ 3 af, \ GPIO_43 - SPI_MISO (SSP1) (OFW Boot FLASH)
+ 3 af, \ GPIO_44 - SPI_MOSI
+ 3 af, \ GPIO_45 - SPI_CLK
+ 3 af, \ GPIO_46 - SPI_FRM
+ 3 af, \ GPIO_47 - G_SENSOR_SDL (TWSI6)
+ 3 af, \ GPIO_48 - G_SENSOR_SDA
+ no-update, \ GPIO_49 - Not connected (TP62)
+ no-update, \ GPIO_50 - Not connected (TP114)
+ no-update, \ GPIO_51 - Not connected (TP59)
+ no-update, \ GPIO_52 - Not connected (TP113)
+ 2 af, \ GPIO_53 - RTC_SCK (TWSI2) if R124 populated
+ 2 af, \ GPIO_54 - RTC_SDA (TWSI2) if R125 populated
+\ no-update, \ GPIO_53 - Not connected if nopop R124 to use TWSI6 for RTC
+\ no-update, \ GPIO_54 - Not connected if nopop R125 to use TWSI6 for RTC
+ no-update, \ GPIO_55 - Not connected (TP51)
+ no-update, \ GPIO_56 - Not connected (TP60)
+ 0 af, \ GPIO_57 - WLAN_PD#
+ 0 af, \ GPIO_58 - WLAN_RESET#
+
+ 1 af, \ GPIO_59 - PIXDATA7
+ 1 af, \ GPIO_60 - PIXDATA6
+ 1 af, \ GPIO_61 - PIXDATA5
+ 1 af, \ GPIO_62 - PIXDATA4
+ 1 af, \ GPIO_63 - PIXDATA3
+ 1 af, \ GPIO_64 - PIXDATA2
+ 1 af, \ GPIO_65 - PIXDATA1
+ 1 af, \ GPIO_66 - PIXDATA0
+ 1 af, \ GPIO_67 - CAM_HSYNC
+ 1 af, \ GPIO_68 - CAM_VSYNC
+ 1 af, \ GPIO_69 - PIXMCLK
+ 1 af, \ GPIO_70 - PIXCLK
+
+ 1 af, \ GPIO_71 - EC_SCL (TWSI3)
+ 1 af, \ GPIO_72 - EC_SDA
+ 0 af, \ GPIO_73 - CAM_RST (use as GPIO out)
+
+ 1 af, \ GPIO_74 - GFVSYNC
+ 1 af, \ GPIO_75 - GFHSYNC
+ 1 af, \ GPIO_76 - GFDOTCLK
+ 1 af, \ GPIO_77 - GF_LDE
+ 1 af, \ GPIO_78 - GFRDATA0
+ 1 af, \ GPIO_79 - GFRDATA1
+ 1 af, \ GPIO_80 - GFRDATA2
+ 1 af, \ GPIO_81 - GFRDATA3
+ 1 af, \ GPIO_82 - GFRDATA4
+ 1 af, \ GPIO_83 - GFRDATA5
+ 1 af, \ GPIO_84 - GFGDATA0
+ 1 af, \ GPIO_85 - GFGDATA1
+ 1 af, \ GPIO_86 - GFGDATA2
+ 1 af, \ GPIO_87 - GFGDATA3
+ 1 af, \ GPIO_88 - GFGDATA4
+ 1 af, \ GPIO_89 - GFGDATA5
+ 1 af, \ GPIO_90 - GFBDATA0
+ 1 af, \ GPIO_91 - GFBDATA1
+ 1 af, \ GPIO_92 - GFBDATA2
+ 1 af, \ GPIO_93 - GFBDATA3
+ 1 af, \ GPIO_94 - GFBDATA4
+ 1 af, \ GPIO_95 - GFBDATA5
+
+ no-update, \ GPIO_96 - Not connected (TP112)
+
+ no-update, \ GPIO_97 - Not connected (R100 nopop) if we use TWSI2 for RTC
+ no-update, \ GPIO_98 - Not connected (R106 nopop) if we use TWSI2 for RTC
+\ 2 af, \ GPIO_97 - RTC_SCK (TWSI6) if R100 populated
+\ 2 af, \ GPIO_98 - RTC_SDA (TWSI6) if R106 populated
+
+ 0 af, \ GPIO_99 - TOUCH_SCR_INT
+ 0 af, \ GPIO_100 - DCONSTAT0
+ 0 af, \ GPIO_101 - DCONSTAT1
+
+ no-update, \ GPIO_102 - (USIM_CLK) - Not connected (TP48)
+ no-update, \ GPIO_103 - (USIM_IO) - Not connected (TP50)
+
+ 0 af, \ GPIO_104 - ND_IO[7]
+ 0 af, \ GPIO_105 - ND_IO[6]
+ 0 af, \ GPIO_106 - ND_IO[5]
+ 0 af, \ GPIO_107 - ND_IO[4]
+
+ 1 af, \ GPIO_108 - CAM_SDL - Use as GPIO, bitbang
+ 1 af, \ GPIO_109 - CAM_SDA - Use as GPIO, bitbang
+
+ 1 af, \ GPIO_110 - (ND_IO[13]) - Not connected (TP43)
+ 1 af, \ GPIO_111 - (ND_IO[8]) - Not connected (TP108)
+ 0 af, \ GPIO_112 - ND_RDY[0]
+ 3 af, \ GPIO_113 - (SM_RDY) - MSD_CMD
+ 1 af, \ GPIO_114 - G_CLK_OUT - Not connected (TP93)
+
+ 4 af, \ GPIO_115 - UART3_TXD (J4)
+ 4 af, \ GPIO_116 - UART3_RXD (J4)
+ 3 af, \ GPIO_117 - UART4_RXD - Not connected (TP117)
+ 3 af, \ GPIO_118 - UART4_TXD - Not connected (TP56)
+ 3 af, \ GPIO_119 - SDI_CLK (SSP3)
+ 3 af, \ GPIO_120 - SDI_CS#
+ 3 af, \ GPIO_121 - SDI_MOSI
+ 3 af, \ GPIO_122 - SDI_MISO
+
+ 3 af, \ GPIO_123 - 32 KHz_CLK_OUT - Not connected (TP92)
+
+ 0 af, \ GPIO_124 - DCONIRQ
+ 0 af, \ GPIO_125 - EC_SPI_ACK
+
+ 3 af, \ GPIO_126 - MSD_DATA2
+ 3 af, \ GPIO_127 - MSD_DATA0
+ 0 af, \ GPIO_128 - EB_MODE#
+ 0 af, \ GPIO_129 - LID_SW#
+ 3 af, \ GPIO_130 - MSD_DATA3
+ 1 af, \ GPIO_131 - SD_DATA3
+ 1 af, \ GPIO_132 - SD_DATA2
+ 1 af, \ GPIO_133 - SD_DATA1
+ 1 af, \ GPIO_134 - SD_DATA0
+ 3 af, \ GPIO_135 - MSD_DATA1
+ 1 af, \ GPIO_136 - SD_CMD
+ no-update, \ GPIO_137 - Not connected (TP111)
+ 3 af, \ GPIO_138 - MSD_CLK
+ 1 af, \ GPIO_139 - SD_CLK
+ no-update, \ GPIO_140 - Not connected if R130 is nopop
+\ 1 af, \ GPIO_140 - (SD_CD# if R130 is populated)
+ 1 af, \ GPIO_141 - SD_WP
+
+ no-update, \ GPIO_142 - (USIM_RSTn) - Not connected (TP49)
+ 0 af, \ GPIO_143 - ND_CS0#
+ 0 af, \ GPIO_144 - ND_CS1#
+ 1 af, \ GPIO_145 - EN_CAM_PWR
+ 1 af, \ GPIO_146 - HUB_RESET#
+
+ 0 af, \ GPIO_147 - ND_WE_N
+ 0 af, \ GPIO_148 - ND_RE_N
+ 0 af, \ GPIO_149 - ND_CLE
+ 0 af, \ GPIO_150 - ND_ALE
+ 1 af, \ GPIO_151 - DCONLOAD
+ 1 af, \ GPIO_152 - (SM_BELn) - Not connected (TP40)
+ 1 af, \ GPIO_153 - (SM_BEHn) - Not connected (TP105)
+ 0 af, \ GPIO_154 - (SM_INT) - EC_IRQ#
+ 1 af, \ GPIO_155 - (EXT_DMA_REQ0) - EC_SPI_CMD
+ no-update, \ GPIO_156 - PRI_TDI (JTAG)
+ no-update, \ GPIO_157 - PRI_TDS (JTAG)
+ no-update, \ GPIO_158 - PRI_TDK (JTAG)
+ no-update, \ GPIO_159 - PRI_TDO (JTAG)
+ 0 af, \ GPIO_160 - ND_RDY[1]
+ 1 af, \ GPIO_161 - ND_IO[12] - Not connected (TP 44)
+ 1 af, \ GPIO_162 - (ND_IO[11]) - DCON_SCL
+ 1 af, \ GPIO_163 - (ND_IO[10]) - DCON_SDA
+ 1 af, \ GPIO_164 - (ND_IO[9]) - Not connected (TP106)
+ 0 af, \ GPIO_165 - ND_IO[3]
+ 0 af, \ GPIO_166 - ND_IO[2]
+ 0 af, \ GPIO_167 - ND_IO[1]
+ 0 af, \ GPIO_168 - ND_IO[0]
+
+: init-mfprs
+ d# 169 0 do
+ mfpr-table i wa+ w@ ( code )
+ dup 8 = if ( code )
+ drop ( )
+ else ( code )
+ i af! ( )
+ then
+ loop
+;
Added: cpu/arm/olpc/1.75/build/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/build/Makefile Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,64 @@
+ROMNAME=ofw
+
+BASEDIR= `(cd ../../../../..; pwd;)`
+
+OS := $(shell uname)
+HOSTCPU= $(shell ${BASEDIR}/forth/lib/hostcpu.sh)
+HOSTDIR= ../../../../${HOSTCPU}/${OS}
+BUILDSH= ${BASEDIR}/forth/lib/build.sh
+
+TAGFILES= ../../../build/*.tag *.tag
+CLIENTDIR=../../../../../clients
+CLIENTPROGS=
+
+all: ${ROMNAME}.rom tags
+
+${ROMNAME}.tag: ${ROMNAME}.rom
+
+tags: ${ROMNAME}.tag
+ @${BASEDIR}/forth/lib/toctags ${BASEDIR} ${TAGFILES}
+
+${ROMNAME}.rom: FORCE build ${CLIENTPROGS} ${HOSTDIR}/forth
+ ./build $@
+
+${HOSTDIR}/forth:
+ @make -C ${HOSTDIR} forth
+
+../../build/inflate.bin:
+ @make -C ../../build inflate.bin
+
+build:
+ @ln -sf ${BUILDSH} build
+
+clean:
+ rm -f *.dic *.log headers *~ *.elf *.di *.img builton.fth build *.rom *.version tags *.tag
+
+clean-all: clean
+ @make -C ../../build clean
+ @make -C ${HOSTDIR} clean
+
+.PHONY: FORCE clean all clean-all
+
+# LICENSE_BEGIN
+# Copyright (c) 2009 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
Added: cpu/arm/olpc/1.75/devices.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/devices.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,175 @@
+fload ${BP}/dev/omap/diaguart.fth \ OMAP UART
+h# d4030000 to uart-base \ UART# base address on MMP2
+d# 26000000 to uart-clock-frequency
+
+: init-clocks
+ -1 h# d4051024 l! \ PMUM_CGR_PJ - everything on
+ h# 07 h# d4015064 l! \ APBC_AIB_CLK_RST - reset, functional and APB clock on
+ h# 03 h# d4015064 l! \ APBC_AIB_CLK_RST - release reset, functional and APB clock on
+ h# 13 h# d401502c l! \ APBC_UART1_CLK_RST - VCTCXO, functional and APB clock on (26 mhz)
+ h# 13 h# d4015034 l! \ APBC_UART3_CLK_RST - VCTCXO, functional and APB clock on (26 mhz)
+ h# c1 h# d401e0c8 l! \ GPIO29 = af1 for UART1 RXD
+ h# c1 h# d401e0cc l! \ GPIO30 = af1 for UART1 TXD
+ h# c4 h# d401e260 l! \ GPIO115 = af4 for UART3 RXD
+ h# c4 h# d401e264 l! \ GPIO116 = af4 for UART3 TXD
+ h# 1b h# d4282854 l! \ SD0 clocks
+;
+
+: inituarts ( -- )
+ init-clocks
+
+ h# 40 1 uart! \ Marvell-specific UART Enable bit
+ 3 3 uart! \ 8 bits, no parity
+ 7 2 uart! \ Clear and enable FIFOs
+ d# 38400 baud
+;
+
+fload ${BP}/forth/lib/sysuart.fth \ Set console I/O vectors to UART
+
+0 value keyboard-ih
+0 value screen-ih
+
+fload ${BP}/ofw/core/muxdev.fth \ I/O collection/distribution device
+
+\ Install the simple UART driver from the standalone I/O init chain
+warning off
+: stand-init-io ( -- )
+ stand-init-io
+ inituarts install-uart-io
+ ." UART installed" cr
+;
+warning on
+
+\ Create a pseudo-device that presents the dropin modules as a filesystem.
+fload ${BP}/ofw/fs/dropinfs.fth
+
+\ This devalias lets us say, for example, "dir rom:"
+devalias rom /dropin-fs
+
+fload ${BP}/cpu/arm/mmp2/timer.fth
+fload ${BP}/cpu/arm/mmp2/twsi.fth
+fload ${BP}/cpu/arm/mmp2/mfpr.fth
+fload ${BP}/cpu/arm/mmp2/gpio.fth
+
+fload ${BP}/cpu/arm/olpc/1.75/boardtwsi.fth
+fload ${BP}/cpu/arm/olpc/1.75/boardgpio.fth
+: init-stuff
+ set-camera-domain-voltage
+ acgr-clocks-on
+ init-mfprs
+ set-gpio-directions
+ init-timers
+ init-twsi
+ power-on-dsi
+ power-on-sd
+;
+stand-init:
+ init-stuff
+;
+
+fload ${BP}/cpu/arm/mmp2/irq.fth
+
+fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer
+
+0 0 " d4030000" " /" begin-package \ UART1
+ fload ${BP}/cpu/arm/mmp2/uart.fth
+end-package
+devalias com1 /uart
+: com1 " com1" ;
+' com1 is fallback-device
+
+0 0 " d4018000" " /" begin-package \ UART3
+ fload ${BP}/cpu/arm/mmp2/uart.fth
+end-package
+devalias com2 /uart
+: com2 " com2" ;
+
+0 0 " d420b000" " /" begin-package
+ " display" name
+ fload ${BP}/cpu/arm/olpc/1.75/lcdcfg.fth
+\ fload ${BP}/cpu/arm/mmp2/dsi.fth
+
+ fload ${BP}/cpu/arm/mmp2/lcd.fth
+ : display-on
+ init-lcd
+ fb-pa hdisp vdisp * >bytes h# ff fill
+ ;
+ : map-frame-buffer ( -- )
+ fb-pa to frame-buffer-adr
+ ;
+ " display" device-type
+ " ISO8859-1" encode-string " character-set" property
+ 0 0 encode-bytes " iso6429-1983-colors" property
+
+ : display-install ( -- )
+ display-on
+ default-font set-font
+ map-frame-buffer
+ width height ( width height )
+ over char-width / over char-height / ( width height rows cols )
+ /scanline depth fb-install ( )
+ ;
+
+ : display-remove ( -- ) ;
+ : display-selftest ( -- failed? ) false ;
+
+ ' display-install is-install
+ ' display-remove is-remove
+ ' display-selftest is-selftest
+end-package
+devalias screen /display
+
+devalias keyboard /keyboard
+
+fload ${BP}/ofw/termemu/cp881-16.fth
+
+fload ${BP}/cpu/arm/mmp2/sdhcimmp2.fth
+
+devalias ext /sd/disk@1
+
+fload ${BP}/dev/olpc/kb3700/spicmd.fth
+
+0 0 " d4208000" " /" begin-package \ USB Host Controller
+ h# 200 constant /regs
+ my-address my-space /regs reg
+ : my-map-in ( len -- adr )
+ my-space swap " map-in" $call-parent h# 100 + ( adr )
+ 3 over h# a8 + rl! ( adr ) \ Force host mode
+ ;
+ : my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ;
+ false constant has-dbgp-regs?
+ false constant needs-dummy-qh?
+ false constant grab-controller
+ fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
+end-package
+
+: usb-power-on ( -- ) d# 82 gpio-set ; \ 1 instead of 82 for XO
+
+fload ${BP}/cpu/arm/marvell/utmiphy.fth
+stand-init: Init USB Phy
+ init-usb-phy
+;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 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
Added: cpu/arm/olpc/1.75/dram-forth.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/dram-forth.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,57 @@
+\ Generate an XDB (Marvell Extreme Debugger) script from DRAM setup info
+
+0 value this-reg-xt
+0 value this-reg-adr
+0 value this-reg-value
+: note-mem-reg ( apf -- )
+ dup body> to this-reg-xt
+ @ +mem-ctrl to this-reg-adr
+ 0 to this-reg-value
+;
+' note-mem-reg to do-mem-reg
+
+: (do-bits) ( value start #bits -- )
+ drop lshift this-reg-value or to this-reg-value
+;
+' (do-bits) to do-bits
+
+: .xl ( n -- )
+ push-hex
+ <# u# u# u# u# u# u# u# u# u#> 2dup type
+ pop-base
+;
+: xdb-outbits ( -- )
+ 3 spaces
+ this-reg-value .xl
+ space
+ this-reg-adr .xl
+ ." l! \ "
+ this-reg-xt >name name>string type
+ cr
+;
+' xdb-outbits to outbits
+
+: show-auto-cal ( -- )
+;
+
+: wait-dram-init ( -- )
+ cr
+ ." begin h# d00001b0 l@ 1 and until" cr
+ cr
+;
+
+: wait-tzqinit ( -- ) ;
+
+: do-dummy-reads ( -- )
+ ." d# 131 0 do 0 l@ drop loop \ dummy reads" cr
+;
+
+: show-dll-delay ( -- )
+ ." ."" DLL_DELAY from PHY_CTRL_14: "" d0000240 l@ 8 rshift h# ff and .x cr" cr
+;
+: start-dram-init ( -- )
+ ." : init-dram" cr
+;
+: end-dram-init ( -- )
+ ." ;" cr
+;
Added: cpu/arm/olpc/1.75/draminit.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/draminit.bth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,9 @@
+purpose: Build Open Firmware for Marvell MMP2
+\ See license at end of file
+
+command: &builder &this
+build-now
+
+fload ../dram.fth
+fload ../dram-forth.fth
+fload ../xo-dram.fth
Added: cpu/arm/olpc/1.75/lcdcfg.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/lcdcfg.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,24 @@
+d# 4 value hsync
+d# 1200 value hdisp
+d# 1456 value htotal .( HTOTAL ???) cr
+d# 212 value hbp
+
+d# 4 value vsync
+d# 800 value vdisp
+d# 845 value vtotal .( VTOTAL ???) cr
+d# 31 value vbp
+
+: hfp ( -- n ) htotal hdisp - hsync - hbp - ;
+: vfp ( -- n ) vtotal vdisp - vsync - vbp - ;
+
+2 constant #lanes
+3 constant bytes/pixel
+d# 24 constant bpp
+
+: >bytes ( pixels -- chunks ) bytes/pixel * ;
+: >chunks ( pixels -- chunks ) >bytes #lanes / ;
+
+alias width hdisp
+alias height vdisp
+alias depth bpp
+width >bytes constant /scanline
Added: cpu/arm/olpc/1.75/sp.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/sp.bth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,397 @@
+purpose: Load file for ARM Forth kernel
+\ See license at end of file
+
+command: &builder &this
+build-now
+
+[ifndef] arm-assembler \ Make sure we have the ARM assembler
+only forth also definitions
+
+fload ${BP}/forth/lib/bitops.fth
+\needs set-relocation-bit defer set-relocation-bit \ keep init-assem happy
+
+\ only forth also meta also definitions
+
+fload ${BP}/cpu/arm/assem.fth
+fload ${BP}/cpu/arm/code.fth
+
+[then]
+: assembler ( -- ) arm-assembler ;
+: setreg \ reg value ( -- )
+ safe-parse-word $hnumber abort" Bad number"
+ safe-parse-word $hnumber abort" Bad number"
+ swap
+ " set r1,``" evaluate
+ " set r0,``" evaluate
+ " str r0,[r1]" evaluate
+;
+: getreg \ reg ( -- )
+ safe-parse-word $hnumber abort" Bad number"
+ " set r1,``" evaluate
+ " ldr r0,[r1]" evaluate
+;
+: putreg \ reg ( -- )
+ " str r0,[r1]" evaluate
+;
+: bitset \ reg ( -- )
+ safe-parse-word $hnumber abort" Bad number"
+ " orr r0,r0,``" evaluate
+;
+: bitclr \ reg ( -- )
+ safe-parse-word $hnumber abort" Bad number"
+ " bic r0,r0,``" evaluate
+;
+
+label unreset
+ \ From jasper.c
+ setreg d4051024 ffffffff \ PMUM_CGR_PJ - Clocks on
+
+ setreg D42828dc 1FFFF \ PMUA_GLB_CLK_CTRL - Enable CLK66 to APB, PLL2/12/6/3/16/8/4/2/1, PLL1/12/6/3/16/8/4
+
+ setreg D4015064 07 \ AIB clock
+ setreg D4015064 03 \ AIB clock
+
+ setreg D401502c 13 \ UART1 clk - 26 MHz
+ setreg D4015034 13 \ UART3 clk - 26 MHz
+
+ getreg D401E160 \ G_CLK_REQ
+ bitset 4000 \ Enable pullup
+ putreg
+
+ setreg D4015000 83 \ APBC_RTC_CLK_RST - Enable RTC clock and power
+
+ setreg D4015024 05 \ APBC_TIMERS1_CLK_RST - Reset
+ setreg D4015024 33 \ APBC_TIMERS1_CLK_RST - Enable Timers at 26 MHz
+
+ getreg d4282c08 \ SCU_PJ4_CPU_CONF
+ bitset 40 \ Bit 6 - bypass clock gate
+ bitset 200 \ Bit 9 - allow CPU in WFI to be woken up by Multi-ICE as well as by interrupt
+ bitset 2000 \ Bit 13 - disable MMU translation abort for L2 cache
+ bitset 4000 \ Bit 14 - bypass clock gate in L2 cache
+ bitset 80000 \ Bit 19 - L2 Cache burst 8 enable
+ bitclr 800000 \ Bit 23 - use slow queue for CPU to DDR access
+ putreg
+
+ \ Now change the frequency
+ \ from freq_ll.S
+
+ set r4, 0xd0000000 \ DMEM base address
+ set r5, 0xd4050000 \ PMUM base address
+ set r6, 0xd4282800 \ PMUA base address
+
+ set r7, 0xffffffff \ All clocks ON
+ str r7, [r5, #0x0024] \ PMUM_CGR_SP
+ set r7, 0x00061808 \ Reserved bits, but supposed to "allow freq"
+ str r7, [r6, #0x88] \ PMUA_DEBUG
+
+ \ change to PLL1/2 first, start-up operation point
+ set r7, 0x00000000
+ str r7, [r5, #0x8]
+ set r7, 0x08fd96d9
+ str r7, [r6, #0x00]
+ set r7, 0x78fd96d9
+ str r7, [r6, #0x04]
+
+ \ select PLL2 frequency, 520MHz
+ set r7, 0x08600322 \ Bandgap+charge pump+VCO loading+regulator defaults, 486.3-528.55 PLL2 (bits 10:6)
+ str r7, [r5, #0x0414] \ PMUM_PLL2_CTRL1
+ set r7, 0x00FFFE00 \ refclk divisor and feedback divisors at max, software controls activation
+ str r7, [r5, #0x0034] \ PMUM_PLL2_CTRL2
+ set r7, 0x0021da00 \ refclk divisor=4, feedback divisor=0x76=118, software controls activation
+ str r7, [r5, #0x0034] \ PMUM_PLL2_CTRL1
+ set r7, 0x0021db00 \ same plus enable
+ str r7, [r5, #0x0034] \ PMUM_PLL2_CTRL2
+ set r7, 0x28600322 \ same as above plus release PLL loop filter
+ str r7, [r5, #0x0414] \ PMUM_PLL2_CTRL1
+ \ select clock source, PJ4-PLL1, SP-PLL1/2, AXI/DDR-PLL1
+ set r7, 0x20800000 \ PLL1 > PJ4 (bits 31:29), PLL1/2 > SP (bits 28:26), PLL1 > AXI&DDR (bits 25:23)
+ str r7, [r5, #0x0008] \ PMUM_FCCR
+ \ divider setting and frequency change request, core-800, ddr-400, axi-200
+ set r7, 0x08fd8248 \ speed change voting, ACLK:3, DCLK:0, BACLK1:1, PCLK:0
+ str r7, [r6, #0x00] \ PMUA_CC_SP
+ set r7, 0x78fd8248 \ etc - hard to decipher
+ str r7, [r6, #0x04] \ PMUA_CC_PJ
+
+ \ DDR recalibration after frequency change
+ \ CONFIG_DECODE_ADDR
+ set r7, 0xD0004D56
+ str r7, [r4, #0x010]
+
+ \ This is for Elpida DDR2 512M
+ \ MMAP
+ set r7, 0x000C0001
+ str r7, [r4, #0x100]
+ set r7, 0x100C0001
+ str r7, [r4, #0x110]
+
+ \ CONFIG_TYPE
+ set r7, 0x00006420
+ str r7, [r4, #0x020]
+ set r7, 0x00006420
+ str r7, [r4, #0x030]
+ set r7, 0x00000000
+ str r7, [r4, #0xB40]
+ set r7, 0x00000000
+ str r7, [r4, #0xB50]
+
+ \ TIMING
+ set r7, 0x4CDA00C5
+ str r7, [r4, #0x050]
+ set r7, 0x94860342
+ str r7, [r4, #0x060]
+ set r7, 0x2000381B
+ str r7, [r4, #0x190]
+ set r7, 0x3023009D
+ str r7, [r4, #0x1C0]
+ set r7, 0x00110142
+ str r7, [r4, #0x650]
+ set r7, 0x02424190
+ str r7, [r4, #0x660]
+ \ End of Elpida-specific stuff
+
+ \ CTRL
+ set r7, 0x00005000
+ str r7, [r4, #0x080]
+ set r7, 0x00080010
+ str r7, [r4, #0x090]
+ set r7, 0xC0000000
+ str r7, [r4, #0x0F0]
+ set r7, 0x20C08115
+ str r7, [r4, #0x1A0]
+ set r7, 0x01010101
+ str r7, [r4, #0x280]
+ set r7, 0x00000000
+ str r7, [r4, #0x760]
+ set r7, 0x03000000
+ str r7, [r4, #0x770]
+ set r7, 0x00000133
+ str r7, [r4, #0x780]
+ set r7, 0x01010101
+ str r7, [r4, #0x7B0]
+ set r7, 0x0000000F
+ str r7, [r4, #0x7D0]
+ set r7, 0x00000000
+ str r7, [r4, #0x7E0]
+
+ \ MCB
+ set r7, 0x00000000
+ str r7, [r4, #0x540]
+ set r7, 0x00000001
+ str r7, [r4, #0x570]
+ set r7, 0x00000000
+ str r7, [r4, #0x580]
+ set r7, 0x00000000
+ str r7, [r4, #0x590]
+ set r7, 0x00000000
+ str r7, [r4, #0x5A0]
+ set r7, 0x00000000
+ str r7, [r4, #0x5B0]
+
+ \ WRITE_PROTECTION
+ set r7, 0x00000000
+ str r7, [r4, #0x180]
+
+ \ __PHY Deskew PLL config and PHY initialization
+ set r7, 0x00000000
+ str r7, [r4, #0x210]
+ set r7, 0x80000000
+ str r7, [r4, #0x240]
+
+ \ DLL reset, Need this after any DCLK freq change
+ set r8, 0x20000000
+ ldr r7, [r4, #0x240]
+ orr r7, r7, r8
+ str r7, [r4, #0x240]
+ set r8, 0xdFFFFFFF
+ ldr r7, [r4, #0x240]
+ and r7, r7, r8
+ str r7, [r4, #0x240]
+
+ \ Pad drive strength auto calibration
+ set r8, 0x00110000
+ ldr r7, [r4, #0x200]
+ orr r7, r7, r8
+ str r7, [r4, #0x200]
+ ldr r7, [r4, #0x240]
+ set r8, 0xFFFeFFFF
+ ldr r7, [r4, #0x200]
+ and r7, r7, r8
+ str r7, [r4, #0x200]
+
+ \ Elpida DDR2 512M-specific
+ set r7, 0x20004444
+ str r7, [r4, #0x140]
+ set r7, 0x13300559
+ str r7, [r4, #0x1D0]
+ set r7, 0x03300990
+ str r7, [r4, #0x1E0]
+ set r7, 0x00000077
+ str r7, [r4, #0x1F0]
+ \ End of Elpida-specific
+
+ set r7, 0x20000088
+ str r7, [r4, #0x230]
+ set r7, 0x00000080
+ str r7, [r4, #0xE10]
+ set r7, 0x00000080
+ str r7, [r4, #0xE20]
+ set r7, 0x00000080
+ str r7, [r4, #0xE30]
+
+ set r7, 0x00000000
+ str r7, [r4, #0xE40]
+ set r7, 0x00000000
+ str r7, [r4, #0xE50]
+
+ \ initialize LPDDR2
+ set r7, 0x03000001
+ str r7, [r4, #0x120]
+ ldr r7, [r4, #0x1B0]
+ set r7, 0x0302003F
+ str r7, [r4, #0x410]
+ set r7, 0x01001000
+ str r7, [r4, #0x120]
+ set r7, 0x02001000
+ str r7, [r4, #0x120]
+ set r7, 0x03020001
+ str r7, [r4, #0x410]
+ set r7, 0x03020002
+ str r7, [r4, #0x410]
+ set r7, 0x03020003
+ str r7, [r4, #0x410]
+
+\ End of frequency change
+
+ setreg d4282110 0 \ Release global IRQ0 mask
+
+ setreg d4283894 11000008 \ DFI chip select timing configuration for CS1
+
+ setreg d428290c 600 \ Power up audio module
+ setreg d428290c 610 \ and enable peripheral clock
+ setreg d428290c 710 \ and disable isolation
+ setreg d428290c 712 \ and release reset
+
+ setreg d4050040 d0080040 \ I2S0 SYSCLK_EN, PLL1/2, denom=0x10, numerator=0x40
+ setreg d4050044 d0040040 \ I2S0 SYSCLK_EN, PLL1/2, denom=0x08, numerator=0x40
+
+ setreg d42a0c3c 10800 \ Undocumented register in SSPA
+ setreg d42a0c34 211921 \ Undocumented register in SSPA
+
+ setreg d428285c 08 \ Enable AXI clock to USB
+ setreg d428285c 09 \ and release from reset
+
+ setreg d42828f8 18 \ Enable HSIC1 SPH Controller Clock and AXI Clock
+ setreg d42828f8 1b \ and release from reset
+
+ setreg d42828fc 18 \ Undocumented, probably another USB HSIC
+ setreg d42828fc 1b \ Undocumented ..
+
+ setreg d4282900 18 \ Enable FSIC SPH Controller Clock and AXI Clock
+ setreg d4282900 1b \ and release from reset
+
+ setreg d4282848 08 \ Enable AXI clock to IRE
+ setreg d4282848 09 \ and release from reset
+
+ setreg D4015004 03 \ Enable TWSI1 clk
+ \ Delay 99999
+
+ setreg d4282854 1b \ Enable SDHC0 clk
+ setreg d42828e8 1b \ Enable SDHC3 clk
+
+ getreg d42828a4 \ Vmeta
+ bitset 400 \ Module powered up
+ bitclr 200 \ Inputs isolated
+ putreg
+ bitset 008 \ AXI clock enabled
+ putreg
+ bitset 001 \ AXI released from reset
+ putreg
+ bitset 010 \ Peripheral clock enabled
+ putreg
+ bitset 002 \ Peripheral released from reset
+ putreg
+ bitset 020 \ PLL2/3
+ putreg
+ bitset 004 \ Reserved
+ putreg
+ bitset 100 \ Isolation disabled
+ putreg
+ bitclr 240 \ Input isolation disabled, (bit 6 is part of the clock select field)
+ putreg
+ \ Whew, that was tedious
+
+ setreg d428284c 08 \ PMUA_DISPLAY1_CLK_RES_CTL - AXI Clk enabled
+ setreg d428284c 09 \ plus AXI released from reset
+ setreg d428284c 19 \ plus peripheral clock enabled
+ setreg d428284c 1b \ plus peripheral released from reset
+
+ setreg d4015038 03 \ Use 32 kHz clock input (bit 1 reserved)
+
+\ mrc p15,0,r0,c1,c0,2
+\ orr r0,r0,#0xf \ Enable MMX
+\ mcr p15,0,r0,c1,c0,2
+
+\ Allow access of performance counters (PMU) from user space
+\ mov r0, #0x1
+\ mrc p15, 0, r0, c9, c14, 0
+\ orr r0, r0, #0x1
+\ mcr p15, 0, r0, c9, c14, 0
+
+\ Ensure branch prediction is enabled - BPU (Default)
+\ mrc p15, 0, r0, c1, c0, 0
+\ orr r0, r0, #0x800
+\ mcr p15, 0, r0, c1, c0, 0
+
+\ setreg d4015064 03 \ AIB clock, redundant with above
+
+\ //BU_REG_WRITE( SMC_CSDFICFGX, 0x51890009 ); // SMC_CSDFICFG0
+\ //BU_REG_WRITE( SMC_CSADRMAPX, 0x10000F00 ); // SMC_CSADRMAP0
+\ //BU_REG_WRITE(0xd4283824, 0xC6CFF2C9 );
+\ setreg d4283894 11000008 \ DFI, redundant with above
+
+\ setreg d4015000 83 \ RTC, redundant with above
+ setreg d4015074 03 \ MPMU, clocks on
+ setreg d4282864 09 \ DMA enabled and release from reset
+ setreg d4282860 b8 \ NAND FLASH PLL1/8 + ECC PLL1/4, AXI clock enabled
+ setreg d4282860 bf \ plus ECC&controller&AXI released from reset
+
+\ Finally, release the reset for the main CPU
+
+ set r0,0xd4050020
+ ldr r1,[r0]
+ bic r1,r1,#2
+ str r1,[r0]
+
+ begin
+ mcr p15,0,r0,cr7,cr0,4 \ Wait For Interrupt
+ again
+
+end-code
+
+writing sp.img
+ unreset here over - ofd @ fputs
+ofd @ fclose
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2008 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: cpu/arm/olpc/1.75/xo-dram.fth
==============================================================================
--- cpu/arm/olpc/1.75/xo-dram.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ cpu/arm/olpc/1.75/xo-dram.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -73,6 +73,8 @@
\ tCKSRE max(5nCK, 10ns)
\ tCKSRX max(5nCK, 10ns)
+start-dram-init
+
mmap0
h# 0000.0000 d# 23 rshift start-addr
h# 4000.0000 log2 d# 16 - area-length
@@ -554,3 +556,5 @@
do-dummy-reads
show-dll-delay
+
+end-dram-init
Modified: dev/usb2/hcd/ehci/ehci.bth
==============================================================================
--- dev/usb2/hcd/ehci/ehci.bth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/ehci/ehci.bth Mon Oct 18 06:02:38 2010 (r1987)
@@ -11,6 +11,7 @@
" ehci" encode-string " device_type" property
+fload ${BP}/dev/usb2/hcd/ehci/pci.fth
fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
end0
Modified: dev/usb2/hcd/ehci/ehci.fth
==============================================================================
--- dev/usb2/hcd/ehci/ehci.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/ehci/ehci.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -12,24 +12,11 @@
0 value ehci-reg
0 value op-reg-offset
-h# 100 constant /regs
-
-\ Configuration space registers
-my-address my-space encode-phys
- 0 encode-int encode+ 0 encode-int encode+
-\ EHCI operational registers
-0 0 my-space 0200.0010 + encode-phys encode+
- 0 encode-int encode+ /regs encode-int encode+
-" reg" property
-
: map-regs ( -- )
- 4 my-w@ h# 16 or 4 my-w! \ memory write and invalidate, bus master, mem
- 0 0 my-space h# 0200.0010 + /regs map-in to ehci-reg
+ /regs my-map-in to ehci-reg
;
: unmap-regs ( -- )
- \ Don't disable because somebody else might be using the controller.
- \ 4 my-w@ 7 invert and 4 my-w!
- ehci-reg /regs map-out 0 to ehci-reg
+ ehci-reg /regs my-map-out 0 to ehci-reg
;
: ehci-reg@ ( idx -- data ) ehci-reg + rl@ ;
@@ -101,23 +88,14 @@
0 value dbgp-offset
0 value dbgp-bar
-: find-dbgp-regs ( -- )
- h# 34 my-l@ ( capability-ptr )
- begin dup while ( cap-offset )
- dup my-b@ h# 0a = if ( cfg-adr )
- 2+ my-w@ ( dbgp-ptr )
- dup h# 1fff and to dbgp-offset ( )
- d# 13 rshift 7 and 1- /l* h# 10 + to dbgp-bar
- exit
- then ( cfg-adr )
- 1+ my-b@ ( cap-offset' )
- repeat ( cap-offset )
- drop
-;
: debug-port-active? ( -- flag )
hcsparams@ h# f0.0000 and 0= if false exit then
- find-dbgp-regs
- dbgp-offset 0= if false exit then
+ has-dbgp-regs? if ( offset bar )
+ to dbgp-bar to dbgp-offset
+ else ( )
+ false exit
+ then
+
\ We should take dbgp-bar into account, but for now we
\ just assume it's the same BAR as for the main registers.
dbgp-offset ehci-reg@
Modified: dev/usb2/hcd/ehci/pci.fth
==============================================================================
--- dev/usb2/hcd/ehci/pci.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/ehci/pci.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -1,16 +1,67 @@
+h# 100 constant /regs
+
\ Configuration space registers
my-address my-space encode-phys
0 encode-int encode+ 0 encode-int encode+
+
\ EHCI operational registers
0 0 my-space 0200.0010 + encode-phys encode+
-0 encode-int encode+ h# 100 encode-int encode+
+0 encode-int encode+ /regs encode-int encode+
" reg" property
+: my-b@ ( offset -- b ) my-space + " config-b@" $call-parent ;
+: my-b! ( b offset -- ) my-space + " config-b!" $call-parent ;
+
+: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ;
+: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ;
+
+: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ;
+: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ;
+
: my-map-in ( len -- adr )
>r 0 0 my-space h# 0200.0010 + r> " map-in" $call-parent
4 my-w@ h# 16 or 4 my-w! \ Set MWI, bus mastering, and mem enable
;
: my-map-out ( adr len -- )
- 4 my-w@ 7 invert and 4 my-w!
+ \ Don't disable because somebody else might be using the controller.
+ \ 4 my-w@ 7 invert and 4 my-w!
" map-out" $call-parent
;
+
+: has-dbgp-regs? ( -- false | offset bar true)
+ h# 34 my-l@ ( capability-ptr )
+ begin dup while ( cap-offset )
+ dup my-b@ h# 0a = if ( cfg-adr )
+ 2+ my-w@ ( dbgp-ptr )
+ dup h# 1fff and ( offset )
+ d# 13 rshift 7 and 1- /l* h# 10 + ( offset bar )
+ true ( offset bar true )
+ exit
+ then ( cfg-adr )
+ 1+ my-b@ ( cap-offset' )
+ repeat ( cap-offset )
+ drop false ( false )
+;
+: needs-dummy-qh? ( -- flag ) 0 my-w@ h# 1106 ( VIA ) = ;
+: grab-controller ( -- error? )
+ hccparams@ 8 rshift h# ff and dup if ( config-adr )
+ dup my-l@ h# 10001 = if ( config-adr )
+ h# 100.0000 over my-l! ( config-adr ) \ Ask for it
+ true ( config-adr error? )
+ d# 100 0 do ( config-adr error? )
+ over my-l@ h# 101.0000 and h# 100.0000 = if
+ \ Turn off SMIs in Legacy Support Extended CSR
+ h# e000.0000 h# 6c my-l! ( config-adr error? )
+ 0 my-l@ h# 27cc8086 = if
+ h# ffff.0000 h# 70 my-l! \ Clear EHCI Intel special SMIs
+ then
+ 0= leave ( config-adr error?' )
+ then ( config-adr error? )
+ d# 10 ms ( config-adr error? )
+ loop ( config-adr error? )
+ nip exit
+ then ( config-adr )
+ then ( config-adr )
+ drop ( )
+ false
+;
Modified: dev/usb2/hcd/ehci/probe.fth
==============================================================================
--- dev/usb2/hcd/ehci/probe.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/ehci/probe.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -51,29 +51,6 @@
dup portsc@ swap portsc! ( ) \ Clear connection change bit
;
-: grab-controller ( -- error? )
- hccparams@ 8 rshift h# ff and dup if ( config-adr )
- dup my-l@ h# 10001 = if ( config-adr )
- h# 100.0000 over my-l! ( config-adr ) \ Ask for it
- true ( config-adr error? )
- d# 100 0 do ( config-adr error? )
- over my-l@ h# 101.0000 and h# 100.0000 = if
- \ Turn off SMIs in Legacy Support Extended CSR
- h# e000.0000 h# 6c my-l! ( config-adr error? )
- 0 my-l@ h# 27cc8086 = if
- h# ffff.0000 h# 70 my-l! \ Clear EHCI Intel special SMIs
- then
- 0= leave ( config-adr error?' )
- then ( config-adr error? )
- d# 10 ms ( config-adr error? )
- loop ( config-adr error? )
- nip exit
- then ( config-adr )
- then ( config-adr )
- drop ( )
- false
-;
-
: probe-setup ( -- )
\ Set active-package so device nodes can be added and removed
my-self ihandle>phandle push-package
Modified: dev/usb2/hcd/ehci/qhtd.fth
==============================================================================
--- dev/usb2/hcd/ehci/qhtd.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/ehci/qhtd.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -633,8 +633,9 @@
dummy-qh ?dup if free-qh 0 to dummy-qh then
;
+
: ?alloc-dummy-qh ( -- )
- 0 my-w@ h# 1106 ( VIA ) = if alloc-dummy-qh then
+ needs-dummy-qh? if alloc-dummy-qh then
;
\ The words this calls are written so they can be called again
Modified: dev/usb2/hcd/hcd.fth
==============================================================================
--- dev/usb2/hcd/hcd.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/hcd.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -58,18 +58,6 @@
\ Common routines
\ ---------------------------------------------------------------------------
-: my-b@ ( offset -- b ) my-space + " config-b@" $call-parent ;
-: my-b! ( b offset -- ) my-space + " config-b!" $call-parent ;
-
-: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ;
-: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ;
-
-: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ;
-: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ;
-
-: map-in ( phys.lo,md,hi len -- vaddr ) " map-in" $call-parent ;
-: map-out ( vaddr size -- ) " map-out" $call-parent ;
-
\ XXX Room for improvement: keep tab of hcd-map-in's to improve performance.
: hcd-map-in ( virt size -- phys ) false dma-map-in ;
: hcd-map-out ( virt phys size -- ) dma-map-out ;
Added: dev/usb2/hcd/uhci/pci.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/usb2/hcd/uhci/pci.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -0,0 +1,32 @@
+h# 400 constant /regs
+
+\ Configuration space registers
+my-address my-space encode-phys
+ 0 encode-int encode+ 0 encode-int encode+
+\ UHCI operational registers
+0 0 my-space 0100.0020 + encode-phys encode+
+ 0 encode-int encode+ h# 400 encode-int encode+
+" reg" property
+
+: my-b@ ( offset -- b ) my-space + " config-b@" $call-parent ;
+: my-b! ( b offset -- ) my-space + " config-b!" $call-parent ;
+
+: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ;
+: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ;
+
+: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ;
+: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ;
+
+: my-map-in ( len -- adr )
+ >r
+ 0 0 my-space h# 0100.0020 + r> " map-in" $call-parent ( adr )
+ 4 my-w@ h# 17 or 4 my-w! ( adr )
+;
+: my-map-out ( adr len -- )
+ 4 my-w@ 7 invert and 4 my-w! ( adr len )
+ " map-out" $call-parent ( )
+;
+
+: ?disable-smis ( -- )
+ 0 my-l@ h# 27c88086 = if h# af00 h# 80 my-w! then
+;
Modified: dev/usb2/hcd/uhci/uhci.bth
==============================================================================
--- dev/usb2/hcd/uhci/uhci.bth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/uhci/uhci.bth Mon Oct 18 06:02:38 2010 (r1987)
@@ -11,6 +11,7 @@
" uhci" encode-string " device_type" property
+fload ${BP}/dev/usb2/hcd/uhci/pci.fth
fload ${BP}/dev/usb2/hcd/uhci/loadpkg.fth
end0
Modified: dev/usb2/hcd/uhci/uhci.fth
==============================================================================
--- dev/usb2/hcd/uhci/uhci.fth Mon Oct 18 05:25:53 2010 (r1986)
+++ dev/usb2/hcd/uhci/uhci.fth Mon Oct 18 06:02:38 2010 (r1987)
@@ -10,24 +10,10 @@
0 value open-count
0 value uhci-reg
-h# 400 constant /regs
-
-\ Configuration space registers
-my-address my-space encode-phys
- 0 encode-int encode+ 0 encode-int encode+
-\ UHCI operational registers
-0 0 my-space 0100.0020 + encode-phys encode+
- 0 encode-int encode+ /regs encode-int encode+
-" reg" property
-
-: map-regs ( -- )
- 4 my-w@ h# 17 or 4 my-w!
- 0 0 my-space h# 0100.0020 + /regs map-in to uhci-reg
-;
+: map-regs ( -- ) /regs my-map-in to uhci-reg ;
: unmap-regs ( -- )
- 4 my-w@ 7 invert and 4 my-w!
- uhci-reg /regs map-out 0 to uhci-reg
+ uhci-reg /regs my-map-out 0 to uhci-reg
;
: uhci-b@ ( idx -- data ) uhci-reg + rb@ ;
@@ -52,10 +38,6 @@
: portsc@ ( port -- data ) 2* 10 + uhci-w@ ;
: portsc! ( data port -- ) 2* 10 + uhci-w! ;
-: ?disable-smis ( -- )
- 0 my-l@ h# 27c88086 = if h# af00 h# 80 my-w! then
-;
-
: reset-usb ( -- )
uhci-reg dup 0= if map-regs then
4 usbcmd! \ Global reset
1
0