Author: wmb Date: Fri Oct 8 08:34:38 2010 New Revision: 1965 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1965
Log: ARM MMP2 - mods to make it work when booted directly from NAND without an intermediate loader.
Added: cpu/arm/mmp2/fw.bth cpu/arm/mmp2/rawboot.fth Modified: cpu/arm/mmp2/addrs.fth cpu/arm/mmp2/devices.fth cpu/arm/mmp2/mfpr.fth cpu/arm/mmp2/mmuon.fth cpu/arm/mmp2/ofw.bth cpu/arm/mmp2/twsi.fth
Modified: cpu/arm/mmp2/addrs.fth ============================================================================== --- cpu/arm/mmp2/addrs.fth Fri Oct 8 08:31:34 2010 (r1964) +++ cpu/arm/mmp2/addrs.fth Fri Oct 8 08:34:38 2010 (r1965) @@ -11,7 +11,8 @@ ' (memory?) to memory?
\ OFW implementation choices -h# 1fe0.0000 constant fw-pa +\ h# 1fe0.0000 constant fw-pa +0 constant fw-pa
[ifdef] virtual-mode h# f700.0000 constant fw-virt-base @@ -30,8 +31,7 @@ h# 10.0000 constant heap-size heap-size constant initial-heap-size
-h# 4000 constant page-table-pa - +h# 40.0000 constant page-table-pa
\ Defined by CPU core h# 1000 to pagesize
Modified: cpu/arm/mmp2/devices.fth ============================================================================== --- cpu/arm/mmp2/devices.fth Fri Oct 8 08:31:34 2010 (r1964) +++ cpu/arm/mmp2/devices.fth Fri Oct 8 08:34:38 2010 (r1965) @@ -1,5 +1,15 @@ fload ${BP}/dev/omap/diaguart.fth \ OMAP UART h# d4018000 to uart-base \ UART# base address on MMP2 +d# 26000000 to uart-clock-frequency +defer init-clocks ' noop to init-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
@@ -13,9 +23,16 @@ : 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/twsi.fth fload ${BP}/cpu/arm/mmp2/timer.fth fload ${BP}/cpu/arm/mmp2/mfpr.fth @@ -27,6 +44,7 @@ init-timers init-twsi power-on-dsi + power-on-sd ; stand-init: init-stuff @@ -106,3 +124,5 @@
devalias ext /sd/disk@1
+fload ${BP}/dev/olpc/kb3700/spicmd.fth +
Added: cpu/arm/mmp2/fw.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/fw.bth Fri Oct 8 08:34:38 2010 (r1965) @@ -0,0 +1,525 @@ +purpose: Build Open Firmware for Marvell MMP2 +\ 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/mmp2/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 / + " Marvell,Bonnell" 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/mmp2/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/mmp2/devices.fth + +[ifndef] virtual-mode +warning off +: stand-init-io + stand-init-io + ." Going fast" cr + go-fast \ From mmuon.fth + ." Gone fast" cr +; +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# 2382 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# 800 tag-w, \ Width + d# 480 tag-w, \ Height + d# 24 tag-w, \ Depth + d# 800 3 * tag-w, \ Pitch + fb-pa tag-l, \ Base address + d# 800 3 * d# 480 * 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 ( -- ) ; +: usb-power-on ( -- ) ; + +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 +hex + here . cr + limit . cr + initial-heap . . cr + vector-base . cr +[ifdef] notdef + 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] + 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 + +\ 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/mfpr.fth ============================================================================== --- cpu/arm/mmp2/mfpr.fth Fri Oct 8 08:31:34 2010 (r1964) +++ cpu/arm/mmp2/mfpr.fth Fri Oct 8 08:34:38 2010 (r1965) @@ -1,9 +1,11 @@ -: set-camera-domain-voltage +: aib-unlock h# baba h# d4015068 l! \ Unlock sequence - h# ec10 h# d401506c l! + 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 - h# baba h# d4015068 l! \ Unlock sequence - h# ec10 h# d401506c l! + aib-unlock h# d401e80c l! ; : acgr-clocks-on ( -- ) @@ -138,12 +140,18 @@ 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) - 5 af, \ GPIO_78 - SSP4_CLK - 5 af, \ GPIO_79 - SSP4_FRM +\ 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) @@ -184,10 +192,10 @@ 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) + 3 af, \ GPIO_119 - GPIO_119 (i/o) + 3 af, \ GPIO_120 - GPIO_120 (i/o) + 3 af, \ GPIO_121 - GPIO_121 (i/o) + 3 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]
Modified: cpu/arm/mmp2/mmuon.fth ============================================================================== --- cpu/arm/mmp2/mmuon.fth Fri Oct 8 08:31:34 2010 (r1964) +++ cpu/arm/mmp2/mmuon.fth Fri Oct 8 08:34:38 2010 (r1965) @@ -24,7 +24,7 @@
: ofw-sections ( -- ) h# 0000.0000 h# c0e over fb-pa map-sections \ Cache and write bufferable - fw-pa h# c0e over /fw-ram map-sections \ Cache and write bufferable +\ fw-pa h# c0e over /fw-ram map-sections \ Cache and write bufferable fb-pa h# c06 over fb-size map-sections \ Write bufferable h# d400.0000 h# c02 over h# 0040.0000 map-sections \ I/O - no caching or buffering ;
Modified: cpu/arm/mmp2/ofw.bth ============================================================================== --- cpu/arm/mmp2/ofw.bth Fri Oct 8 08:31:34 2010 (r1964) +++ cpu/arm/mmp2/ofw.bth Fri Oct 8 08:34:38 2010 (r1965) @@ -1,503 +1,22 @@ purpose: Build Open Firmware for Marvell MMP2 \ See license at end of file
-dictionary: ${BP}/cpu/arm/build/basefw.dic +dictionary: ${BP}/cpu/arm/mmp2/build/fw.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/mmp2/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 / - " Marvell,Bonnell" 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/mmp2/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 +: (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# d4015034 l! \ APBC_UART3_CLK_RST - VCTCXO, functional and APB clock on (26 mhz) + h# c1 h# d401e120 l! \ GPIO51 = af1 for UART3 RXD + h# c1 h# d401e124 l! \ GPIO52 = af1 for UART3 TXD + h# 1b h# d4282854 l! \ SD0 clocks ; -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 - -support-package: dropin-file-system - fload ${BP}/ofw/fs/dropinfs.fth \ Dropin 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/mmp2/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# 2382 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# 800 tag-w, \ Width - d# 480 tag-w, \ Height - d# 24 tag-w, \ Depth - d# 800 3 * tag-w, \ Pitch - fb-pa tag-l, \ Base address - d# 800 3 * d# 480 * 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 ( -- ) ; -: usb-power-on ( -- ) ; - -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 -[ifdef] notdef - 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] - 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 +' (init-clocks) to init-clocks
-fload ${BP}/cpu/arm/mmp2/boot.fth +fload ${BP}/cpu/arm/mmp2/rawboot.fth
.( --- Saving ofw.rom --- ) cr " ofw.rom" $save-rom
Added: cpu/arm/mmp2/rawboot.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/rawboot.fth Fri Oct 8 08:34:38 2010 (r1965) @@ -0,0 +1,18 @@ +\ This is some glue code to convert the machine setup that QEMU gives us +\ to the setup that start-forth (see arm/boot.fth) wants. +\ We get here via a call instruction at origin+8, which is inserted below + +code stand-cold-code ( r0: 0 r1: board-id r2: &kernel-args lr: &aif_header+8c ) + here origin 8 + put-call \ Insert call instruction + + \ Put the arguments in safe registers + sub r6,lr,#0x8c \ r6 points to header (lr set by code at origin) + mov r7,#0 \ r7: functions + add r8,r6,`/fw-ram` \ r8: memtop - 2MiB above load address + \ r9 is up + mov r10,#0 \ r10: argc + mov r11,r2 \ r11: argv (kernel args) + mov r12,`initial-heap-size` \ r12: initial-heap-size + + b 'code start-forth \ Branch to the generic startup code +end-code
Modified: cpu/arm/mmp2/twsi.fth ============================================================================== --- cpu/arm/mmp2/twsi.fth Fri Oct 8 08:31:34 2010 (r1964) +++ cpu/arm/mmp2/twsi.fth Fri Oct 8 08:34:38 2010 (r1965) @@ -314,3 +314,12 @@ : 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! +;
openfirmware@openfirmware.info