[openfirmware] [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
repository service
svn at openfirmware.info
Mon Oct 25 14:42:15 CEST 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 at 1
+devalias int /sd at d4281000/disk
+devalias ext /sd at 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
;
More information about the openfirmware
mailing list