diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2020-01-31 19:39:32 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2020-03-24 10:21:06 +0100 |
commit | cc140b30c2cccc8a8312c51304a41d1101ae4b55 (patch) | |
tree | 6d099ddfaa982eebdbdddac7f2eb59f71aea2e09 | |
parent | 08a4e3fe6c0ab00ef4296bfcd035147a4d4a9d88 (diff) | |
download | openfirmware-cc140b30c2cccc8a8312c51304a41d1101ae4b55.tar.gz |
mmp3/ariel: add Dell Ariel board support
This is the board used in Dell Wyse 3020 thin client. It's based on
MMP3, reusing most of OLPC XO-4 support.
-rw-r--r-- | cpu/arm/mmp3/ariel/build-fw.fth | 599 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/build/.gitignore | 3 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/build/Makefile | 70 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/cforth.bth | 9 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/config.fth | 15 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/fw.bth | 13 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/gpiopins.fth | 8 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/lcdcfg.fth | 16 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/ofw.bth | 132 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/prefw.bth | 13 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/resetvec.bth | 7 | ||||
-rw-r--r-- | cpu/arm/mmp3/ariel/spiui.fth | 173 |
12 files changed, 1058 insertions, 0 deletions
diff --git a/cpu/arm/mmp3/ariel/build-fw.fth b/cpu/arm/mmp3/ariel/build-fw.fth new file mode 100644 index 00000000..0ce370b0 --- /dev/null +++ b/cpu/arm/mmp3/ariel/build-fw.fth @@ -0,0 +1,599 @@ +purpose: Common code for build OFW Forth dictionaries for Dell Ariel (Wyse 3020) +\ See license at end of file + +hex + +warning @ warning off +: stand-init-io + stand-init-io + init-timers +; +warning ! + +root-device + " Dell Ariel" model + " marvell,mmp3" +compatible + " dell,wyse-ariel" +compatible + + " /interrupt-controller@d4282000" encode-phandle " interrupt-parent" property + 0 0 " ranges" property +device-end + +fload ${BP}/cpu/arm/olpc/fbnums.fth +fload ${BP}/cpu/arm/olpc/fbmsg.fth + +fload ${BP}/dev/omap/diaguart.fth + +d# 26000000 to uart-clock-frequency + +\ CForth has already set up the serial port +: inituarts ( -- ) ; + +fload ${BP}/forth/lib/sysuart.fth \ Set console I/O vectors to UART + +: poll-tty ( -- ) ubreak? if user-abort then ; \ BREAK detection +: install-abort ( -- ) ['] poll-tty d# 100 alarm ; + +0 value dcon-ih +0 value keyboard-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 install-abort +; +warning on + +[ifdef] use-null-nvram +\ For not storing configuration variable changes across reboots ... +\ This is useful for "turnkey" systems where configurability would +\ increase support costs. + +fload ${BP}/cpu/x86/pc/nullnv.fth +stand-init: Null-NVRAM + " /null-nvram" open-dev to nvram-node + ['] init-config-vars catch drop +; +[then] + +[ifdef] use-flash-nvram +\ For configuration variables stored in a sector of the boot FLASH ... + +\ Create a node below the top-level FLASH node to access the portion +\ containing the configuration variables. +0 0 " d0000" " /flash" begin-package + " nvram" device-name + + h# 10000 constant /device + fload ${BP}/dev/subrange.fth +end-package + +stand-init: NVRAM + " /nvram" open-dev to nvram-node + ['] init-config-vars catch drop +; +[then] + +\ 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/mmp3/l2cache.fth +fload ${BP}/cpu/arm/mmp3/cpunode.fth +fload ${BP}/cpu/arm/mmp3/scu.fth + +fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer + +fload ${BP}/cpu/arm/mmp2/twsi-i2c.fth +devalias i2c2 /i2c@d4011000 +dev /i2c@d4011000 + new-device + fload ${BP}/dev/ds1338.fth + finish-device + new-device + fload ${BP}/dev/88pm867.fth + finish-device +device-end +devalias i2c3 /i2c@d4032000 +dev /i2c@d4032000 + new-device + fload ${BP}/dev/video/dacs/ch7033.fth + finish-device +device-end +devalias i2c4 /i2c@d4033800 +devalias i2c5 /i2c@d4033000 +dev /i2c@d4033000 + new-device + fload ${BP}/dev/kb3930.fth + finish-device +device-end +dev /i2c@d4031000 " disabled" " status" string-property device-end +dev /i2c@d4034000 " disabled" " status" string-property device-end + +0 0 " " " /" begin-package + " dvi-connector" name + " dvi-connector" +compatible + " /i2c@d4033800" encode-phandle " ddc-i2c-bus" property + + " /gpio" encode-phandle + dvi1-hpd-gpio# encode-int encode+ + d# 1 encode-int encode+ + " hpd-gpios" property + + 0 0 " digital" property + 0 0 " analog" property + + new-device + " port" device-name + new-device + " endpoint" device-name + finish-device + finish-device +end-package + +" /dvi-connector/port/endpoint" " /vga-dvi-encoder/ports/port@1/endpoint" link-endpoints + +fload ${BP}/cpu/arm/mmp2/uart.fth +dev /uart@d4030000 " disabled" " status" string-property device-end +dev /uart@d4017000 " disabled" " status" string-property device-end +dev /uart@d4016000 " disabled" " status" string-property device-end + +devalias serial2 /uart@d4018000 +: com1 " /uart@d4018000" ; +' com1 is fallback-device + +\ \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 + +fload ${BP}/cpu/arm/mmp2/sspspi.fth \ Synchronous Serial Port SPI interface + +fload ${BP}/cpu/arm/mmp2/ssp-spi.fth \ SSP device nodes +dev /spi@d4035000 + " /gpio" encode-phandle + spi-flash-cs-gpio# encode-int encode+ + d# 1 encode-int encode+ + " cs-gpios" property + + \ Create the top-level device node to access the entire boot FLASH device + new-device + " flash" device-name + " jedec,spi-nor" +compatible + " winbond,w25q32" +compatible + d# 104000000 " spi-max-frequency" integer-property + 0 0 " m25p,fast-read" property + 0 " reg" integer-property + /rom value /device + fload ${BP}/dev/nonmmflash.fth + finish-device +device-end +dev /spi@d4036000 " disabled" " status" string-property device-end +dev /spi@d4037000 " disabled" " status" string-property device-end +dev /spi@d4039000 " disabled" " status" string-property device-end + +\ Create a node below the top-level FLASH node to accessing the portion +\ containing the dropin modules +0 0 " 20000" " /flash" begin-package + " dropins" device-name + + /rom h# 20000 - constant /device + fload ${BP}/dev/subrange.fth +end-package + +devalias dropins /dropins + +load-base constant flash-buf + +fload ${BP}/cpu/arm/mmp3/ariel/spiui.fth \ User interface for SPI FLASH programming + +\ Reserve memory for the framebuffer +0 0 " " " /" begin-package + " reserved-memory" name + 1 " #address-cells" integer-property + 1 " #size-cells" integer-property + 0 0 encode-bytes " ranges" property + + new-device + " framebuffer" device-name + " marvell,armada-framebuffer" +compatible + " marvell,mmp2-framebuffer" +compatible + h# 02000000 " size" integer-property + h# 02000000 " alignment" integer-property + 0 0 encode-bytes " no-map" property + finish-device +end-package + +0 0 " f0400000" " /" begin-package + " vmeta" name + my-address my-space h# 400000 reg + + " mrvl,mmp2-vmeta" +compatible + + " /clocks" encode-phandle mmp2-vmeta-clk# encode-int encode+ " clocks" property + " VMETACLK" " clock-names" string-property + d# 26 " interrupts" integer-property +end-package + +fload ${BP}/cpu/arm/mmp3/ariel/lcdcfg.fth +fload ${BP}/cpu/arm/olpc/lcd.fth + +" /display/port/endpoint" " /vga-dvi-encoder/ports/port@0/endpoint" link-endpoints + +fload ${BP}/cpu/arm/mmp3/galcore.fth + +\ fload ${BP}/cpu/arm/mmp3/ariel/sdhci.fth + +fload ${BP}/cpu/arm/mmp2/sdhci.fth +dev /sdhci@d4281000 + d# 15 encode-int " clk-delay-cycles" property + d# 50000000 " max-frequency" integer-property + 0 0 " non-removable" property + d# 8 " bus-width" integer-property + 0 0 " cap-mmc-highspeed" property + + : write-protected? false ; + new-device + fload ${BP}/dev/mmc/sdhci/sdmmc.fth + fload ${BP}/dev/mmc/sdhci/selftest.fth + " internal" " slot-name" string-property + finish-device +device-end +dev /sdhci@d4280000 " disabled" " status" string-property device-end +dev /sdhci@d4280800 " disabled" " status" string-property device-end +dev /sdhci@d4281800 " disabled" " status" string-property device-end +devalias int /sd/sdhci@d4281000/disk + +0 0 " " " /" begin-package + " spi" device-name + " spi-gpio" +compatible + 1 " #address-cells" integer-property + 0 " #size-cells" integer-property + + : decode-unit ( adr len -- phys ) $number if 0 then ; + : encode-unit ( phys -- adr len ) (u.) ; + : open ( -- true ) true ; + : close ( -- ) ; + + " /gpio" encode-phandle d# 55 encode-int encode+ d# 0 encode-int encode+ " gpio-sck" property + " /gpio" encode-phandle d# 57 encode-int encode+ d# 0 encode-int encode+ " gpio-miso" property + " /gpio" encode-phandle d# 58 encode-int encode+ d# 0 encode-int encode+ " gpio-mosi" property + " /gpio" encode-phandle d# 56 encode-int encode+ d# 0 encode-int encode+ " cs-gpios" property + + new-device + " power-button" name + 0 " reg" integer-property + " ene,kb3930-input" +compatible + " dell,wyse-ariel-ec-input" +compatible + d# 33000000 " spi-max-frequency" integer-property + " /gpio" encode-phandle " interrupt-parent" property + d# 60 encode-int d# 1 encode-int encode+ " interrupts" property + finish-device +end-package + +fload ${BP}/ofw/core/fdt.fth + +autoload: mmp3-gic- defines: mmp3-gic +0 value no-mmp3-gic? + +autoload: olpc-compat- defines: olpc-compat +0 value olpc-compat? + +fload ${BP}/cpu/arm/linux.fth + +\ Create the alias unless it already exists +: $?devalias ( alias$ value$ -- ) + 2over not-alias? if $devalias exit then ( alias$ value$ alias$ ) + 2drop 4drop +; + +: ?report-device ( alias$ pathname$ -- ) + 2dup locate-device 0= if ( alias$ pathname$ phandle ) + drop ( alias$ pathname$ ) + 2over 2over $?devalias ( alias$ pathname$ ) + then ( alias$ pathname$ ) + 4drop ( ) +; + +: report-disk ( -- ) + " disk" " /usb@d4208000/disk" ?report-device +; + +: report-keyboard ( -- ) + " usb-keyboard" " /usb@d4208000/keyboard" ?report-device +; + +: report-net ( -- ) + " net" " /usb@f0001000/hub@1,0/ethernet@2,0" ?report-device +; + +: disable-unpopulated ( -- ) + " /usb@f0001000/hub@1,0/scsi@1,0" find-device + " disabled" " status" string-property + device-end +; + +fload ${BP}/cpu/arm/mmp3/usb2phy.fth +fload ${BP}/cpu/arm/olpc/usb.fth +fload ${BP}/cpu/arm/mmp3/hsic.fth +devalias u /usb@d4208000/disk + +fload ${BP}/cpu/arm/firfilter.fth + +fload ${BP}/cpu/x86/adpcm.fth \ ADPCM decoding +d# 32 is playback-volume + +stand-init: RTC + " /i2c@d4011000/rtc@68" open-dev clock-node ! + \ use RTC 32kHz clock as SoC external slow clock + h# 38 mpmu@ 1 or h# 38 mpmu! + \ check the clock stop flag and reinit if necessary + " verify" clock-node @ $call-method +; + +stand-init: More memory + extra-mem-va /extra-mem add-memory +; + +fload ${BP}/cpu/arm/mmp3/thermal.fth +fload ${BP}/cpu/arm/mmp2/fuse.fth + +[ifndef] virtual-mode +warning off +: stand-init-io + stand-init-io + go-fast \ From mmuon.fth +; +warning on +[then] + +\ The bottom of extra-mem is the top of DMA memory. +\ We give everything up to that address to Linux. +: olpc-memory-limit ( -- adr ) extra-mem-va >physical ; +' olpc-memory-limit to memory-limit +: olpc-mapped-limit ( -- adr ) dma-mem-va >physical ; +' olpc-mapped-limit to mapped-limit + +machine-type to arm-linux-machine-type + +false to stand-init-debug? +\ true to stand-init-debug? + +fload ${BP}/ofw/core/countdwn.fth \ Startup countdown + +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 + d# 1000 us \ 1000 us is more precise than 1 ms, which is often close to 2 ms + loop + false +; + +\ 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/arm/mmp2/clocks.fth + +: console-start ( -- ) + " /vga-dvi-encoder" open-dev to dcon-ih + install-mux-io + cursor-off + true to text-on? + + " //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 +; + +: teardown-mux-io ( -- ) + install-uart-io + text-off + keyboard-off + fallback-out-ih remove-output + fallback-in-ih remove-input + stdin off + stdout off + in-mux-ih close-dev + out-mux-ih close-dev +; +: quiesce ( -- ) + usb-quiet + teardown-mux-io + timers-off + unload-crypto +; + +\ This must precede the loading of gui.fth, which chains from linux-hook's behavior +' quiesce to linux-hook + +fload ${BP}/cpu/arm/mmp2/showirqs.fth + +fload ${BP}/cpu/arm/mmp3/dramrecal.fth +: linux-hook-smp ( -- ) + [ ' linux-hook behavior compile, ] \ Chain to old behavior + enable-smp +; +' linux-hook-smp to linux-hook + +code halt ( -- ) wfi c; + +fload ${BP}/cpu/arm/mmp2/rtc.fth \ Internal RTC, used for wakeups + +: emacs ( -- ) + false to already-go? + boot-getline to boot-file " rom:emacs" $boot +; +: tsc@ ( -- d.ticks ) timer0@ u>d ; +d# 6500 constant ms-factor + +fload ${BP}/cpu/arm/bootascall.fth + +d# 999 ' screen-#rows set-config-int-default \ Expand the terminal emulator to fill the screen +d# 999 ' screen-#columns set-config-int-default \ Expand the terminal emulator to fill the screen + +fload ${BP}/cpu/x86/pc/olpc/gridmap.fth \ Gridded display tools +fload ${BP}/cpu/x86/pc/olpc/life.fth +fload ${BP}/ofw/gui/ofpong.fth + +" u:\boot\olpc.fth int:\boot\olpc.fth net" ' 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 + +2 config-int auto-boot-countdown + +\ 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 + +: interpreter-init ( -- ) + hex + warning on + only forth also definitions + + install-alarm + + page-mode + #line off +; + +: startup ( -- ) + standalone? 0= if exit then + + no-page + + disable-user-aborts + console-start + + " probe-" do-drop-in + + unused-core-off + + install-alarm + + auto-banner? if banner then + + ['] false to interrupt-auto-boot? + probe-usb + report-disk + report-keyboard + report-net + disable-unpopulated + + " probe+" do-drop-in + + interpreter-init + + ['] (interrupt-auto-boot?) to interrupt-auto-boot? + + ?usb-keyboard + + auto-boot + + cursor-on + + enable-user-aborts + quit +; + +: enable-serial ; +fload ${BP}/cpu/x86/pc/olpc/terminal.fth \ Serial terminal emulator + +\ Embedded Controller interface + +0 value ec-ih + +: ec-power-off ( -- ) " power-off" ec-ih $call-method ; +: ec-reboot ( -- ) " reboot" ec-ih $call-method ; +' ec-power-off to power-off + +stand-init: Embedded Controller + " /embedded-controller" open-dev to ec-ih + ['] ec-reboot to bye + \ Start turn off amber, turn on green LED + " leds-start" ec-ih $call-method + \ Power on the USB ports, just in case EC had them disabled + " usb-ports-power-on" ec-ih $call-method +; + +: (go-hook) ( -- ) + [ ' go-hook behavior compile, ] + \ Start flashing green upon booot + " leds-boot" ec-ih $call-method +; +' (go-hook) to go-hook + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ Copyright (c) 2020 Lubomir Rintel <lkundrak@v3.sk> +\ +\ 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 diff --git a/cpu/arm/mmp3/ariel/build/.gitignore b/cpu/arm/mmp3/ariel/build/.gitignore new file mode 100644 index 00000000..66f087ae --- /dev/null +++ b/cpu/arm/mmp3/ariel/build/.gitignore @@ -0,0 +1,3 @@ +armforth +build/build +cforth diff --git a/cpu/arm/mmp3/ariel/build/Makefile b/cpu/arm/mmp3/ariel/build/Makefile new file mode 100644 index 00000000..000b7446 --- /dev/null +++ b/cpu/arm/mmp3/ariel/build/Makefile @@ -0,0 +1,70 @@ +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=${CLIENTDIR}/emacs/arm/emacs + +all: ${ROMNAME}.rom tags + +${ROMNAME}.tag: ${ROMNAME}.rom + +tags: ${ROMNAME}.tag + @${BASEDIR}/forth/lib/toctags ${BASEDIR} ${TAGFILES} + +${ROMNAME}.rom: FORCE build ${CLIENTPROGS} ${HOSTDIR}/forth ${HOSTDIR}/armforth + ./build $@ + +${HOSTDIR}/forth: + @make -C ${HOSTDIR} forth + +${HOSTDIR}/armforth: + @make -C ${HOSTDIR} armforth + +../../build/inflate.bin: + @make -C ../../build inflate.bin + +${CLIENTDIR}/emacs/arm/emacs: + @make -C ${CLIENTDIR}/emacs/arm emacs + +build: + @ln -sf ${BUILDSH} build + +clean: + rm -f *.dic *.log headers *~ *.elf *.di *.img builton.fth build *.rom 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 diff --git a/cpu/arm/mmp3/ariel/cforth.bth b/cpu/arm/mmp3/ariel/cforth.bth new file mode 100644 index 00000000..756b1ae4 --- /dev/null +++ b/cpu/arm/mmp3/ariel/cforth.bth @@ -0,0 +1,9 @@ +purpose: Fetch and compile CForth for IPL on the MM core + +command: &builder &this +build-now + +macro: CFORTH_VERSION d3370770888eca85c2a64e5da551091f90c341cb +macro: CFORTH_BUILD_DIR cforth/build/arm-ariel + +fload ${BP}/cpu/arm/olpc/build-cforth.fth diff --git a/cpu/arm/mmp3/ariel/config.fth b/cpu/arm/mmp3/ariel/config.fth new file mode 100644 index 00000000..f6f8b270 --- /dev/null +++ b/cpu/arm/mmp3/ariel/config.fth @@ -0,0 +1,15 @@ +create use-null-nvram +create use-elf + +fload ${BP}/cpu/arm/mmp3/soc-config.fth +fload ${BP}/cpu/arm/mmp2/hwaddrs.fth +fload ${BP}/cpu/arm/olpc/addrs.fth +fload ${BP}/cpu/arm/mmp3/ariel/gpiopins.fth + +h# 40.0000 constant /rom \ Total size of SPI FLASH + +: crc-offset /rom h# 30 - ; \ e.g. 3f.ffd0 +: signature-offset crc-offset h# 10 - ; \ e.g. 3e.ffc0 +: signature$ " Ariel" ; + +d# 4154 constant machine-type \ MACH_QSEVEN diff --git a/cpu/arm/mmp3/ariel/fw.bth b/cpu/arm/mmp3/ariel/fw.bth new file mode 100644 index 00000000..a053f40e --- /dev/null +++ b/cpu/arm/mmp3/ariel/fw.bth @@ -0,0 +1,13 @@ +purpose: Build OFW Forth dictionary for Dell Ariel (Wyse 3020) + +dictionary: ${BP}/cpu/arm/mmp3/ariel/build/prefw.dic +command: &armforth &dictionary &this +build-now + +" fw.tag" r/w create-file drop tag-file ! + +fload ${BP}/cpu/arm/mmp3/ariel/build-fw.fth + +h# d4018000 to uart-base + +fload ${BP}/cpu/arm/olpc/save-fw.fth diff --git a/cpu/arm/mmp3/ariel/gpiopins.fth b/cpu/arm/mmp3/ariel/gpiopins.fth new file mode 100644 index 00000000..b9b75ae5 --- /dev/null +++ b/cpu/arm/mmp3/ariel/gpiopins.fth @@ -0,0 +1,8 @@ +\ GPIO pin assignments - Ariel + +d# 46 constant spi-flash-cs-gpio# +d# 56 constant ec-input-gpio# +d# 62 constant dvi1-hpd-gpio# +d# 63 constant hsic-reset-gpio# +d# 126 constant ec-off-pulse-gpio# +d# 127 constant ec-off-type-gpio# diff --git a/cpu/arm/mmp3/ariel/lcdcfg.fth b/cpu/arm/mmp3/ariel/lcdcfg.fth new file mode 100644 index 00000000..9e31fa02 --- /dev/null +++ b/cpu/arm/mmp3/ariel/lcdcfg.fth @@ -0,0 +1,16 @@ +h# 20001101 value clkdiv +h# 00000C00 value pmua-disp-clk-sel + +d# 136 value hsync \ Sync width +d# 1024 value hdisp \ Display width +d# 1344 value htotal \ Display + FP + Sync + BP +d# 160 value hbp \ Back porch + +d# 6 value vsync \ Sync width +d# 768 value vdisp \ Display width +d# 806 value vtotal \ Display + FP + Sync + BP +d# 29 value vbp \ Back porch + +4 value #lanes +4 value bytes/pixel +d# 32 value bpp diff --git a/cpu/arm/mmp3/ariel/ofw.bth b/cpu/arm/mmp3/ariel/ofw.bth new file mode 100644 index 00000000..f847e4e8 --- /dev/null +++ b/cpu/arm/mmp3/ariel/ofw.bth @@ -0,0 +1,132 @@ +purpose: Construct the Open Firmware module collection + +command: &builder &this +in: ${BP}/cpu/arm/mmp3/ariel/build/fw.img +in: ${BP}/cpu/arm/mmp3/ariel/build/resetvec.img +in: ${BP}/dev/usb2/device/hub/build/hub.fc +in: ${BP}/dev/usb2/device/generic/build/generic.fc +in: ${BP}/dev/usb2/device/net/build/usbnet.fc +in: ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc +in: ${BP}/dev/usb2/device/mouse/build/usbmouse.fc +in: ${BP}/dev/usb2/device/serial/build/usbserial.fc +in: ${BP}/dev/usb2/device/storage/build/usbstorage.fc +in: ${BP}/clients/emacs/arm/emacs +in: cforth.img +build-now + +fload ${BP}/cpu/arm/mmp3/ariel/config.fth + +\ Always re-create the builton.fth file when we make a new rom.img +fload ${BP}/cpu/x86/pc/builton.bth + +fload ${BP}/forth/lib/crc32.fth + +hex + +: pad-file ( location -- ) + ofd @ fsize + 2dup u< abort" The ROM image is too large" + ?do h# ff ofd @ fputc loop +; + +fload ${BP}/cpu/arm/marvell/tim.fth + +\ Marvell Non-Trusted Image Module image creation script for XO-4.0 platform. + +tim: 00030400 0 DELL PXA212x + flash: SPI'10 + timh: TIMH 0 d101f000 + image: OBMI 2000 d1000000 cforth.img + reserved: + \ Disable USB download/init by enabling the FFUART for download + \ This works around a PHY init erratum for the B0 chip + uart: 00004646 1 + term: + end-reserved +end-tim + +h# 20.0000 to reserved-start +h# 20.0000 to reserved-end + +.( --- Saving as ofw.rom ) cr +writing ofw.rom + tim$ ofd @ fputs + + dropin-offset pad-file + +\ Loads the set of drivers that is common to different output formats + + " ${BP}/cpu/arm/build/inflate.bin" " inflate" $add-dropin + " fw.img" " firmware" $add-deflated-dropin +\ " fw.img" " firmware" $add-dropin + " resetvec.img" " reset" $add-dropin + + " ${BP}/cpu/arm/mmp3/gic.fth" " mmp3-gic-" $add-dropin + " ${BP}/cpu/arm/olpc/4.0/compat.fth" " olpc-compat-" $add-dropin +\ " ${BP}/dev/usb2/hcd/ehci/build/ehci.fc" " class0c0320" $add-deflated-dropin + " ${BP}/dev/usb2/device/hub/build/hub.fc" " usb,class9" $add-deflated-dropin + " ${BP}/dev/usb2/device/generic/build/generic.fc" " usbdevice" $add-deflated-dropin + " ${BP}/dev/usb2/device/net/build/usbnet.fc" " usbnet" $add-deflated-dropin + " ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc" " usb,class3,1,1" $add-deflated-dropin + " ${BP}/dev/usb2/device/mouse/build/usbmouse.fc" " usb,class3,1,2" $add-deflated-dropin + " ${BP}/dev/usb2/device/serial/build/usbserial.fc" " usbserial" $add-deflated-dropin + " ${BP}/dev/usb2/device/storage/build/usbstorage.fc" " usbstorage" $add-deflated-dropin + + " builton.fth" " probe-" $add-dropin + + " ${BP}/ofw/inet/telnetd.fth" " telnetd" $add-deflated-dropin + + " ${BP}/ofw/termemu/gallant.obf" " font" $add-deflated-dropin + + " ${BP}/clients/emacs/x86/emacs.rc" " emacs.rc" $add-deflated-dropin + " ${BP}/clients/emacs/emacs.hlp" " emacs.hlp" $add-deflated-dropin + " ${BP}/clients/emacs/arm/emacs" " emacs" $add-deflated-dropin + +.( Dropin top is ) ofd @ fsize .x cr + +/rom pad-file + +\ Insert the machine signature +h# 10 buffer: signature +signature h# 10 blank +signature$ signature swap move +signature-offset ofd @ fseek +signature h# 10 ofd @ fputs + +/l buffer: crcbuf +/rom buffer: filebuf + +\ Read the entire image, compute the CRC, and store it in the CRC location +0 ofd @ fseek +filebuf /rom ofd @ fgets /rom <> abort" Can't read back image" +0 crctab filebuf /rom ($crc) crcbuf ! + +crc-offset ofd @ fseek +crcbuf /l ofd @ fputs + +ofd @ fclose + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ Copyright (c) 2020 Lubomir Rintel <lkundrak@v3.sk> +\ +\ 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 diff --git a/cpu/arm/mmp3/ariel/prefw.bth b/cpu/arm/mmp3/ariel/prefw.bth new file mode 100644 index 00000000..84140f73 --- /dev/null +++ b/cpu/arm/mmp3/ariel/prefw.bth @@ -0,0 +1,13 @@ +purpose: Build OFW Forth dictionary for Dell Ariel (Wyse 3020) +\ See license at end of file + +dictionary: ${BP}/cpu/arm/build/basefw.dic +command: &armforth &dictionary &this +build-now + +\ This line must be in this file instead of in prefw.fth so the definitions +\ in config.fth will be tagged. +" prefw.tag" r/w create-file drop tag-file ! + +fload ${BP}/cpu/arm/mmp3/ariel/config.fth +fload ${BP}/cpu/arm/olpc/prefw.fth diff --git a/cpu/arm/mmp3/ariel/resetvec.bth b/cpu/arm/mmp3/ariel/resetvec.bth new file mode 100644 index 00000000..a93ce4ee --- /dev/null +++ b/cpu/arm/mmp3/ariel/resetvec.bth @@ -0,0 +1,7 @@ +purpose: Build script for low-level startup code + +command: &builder &this +build-now + +fload ${BP}/cpu/arm/mmp3/ariel/config.fth +fload ${BP}/cpu/arm/olpc/resetvec.fth diff --git a/cpu/arm/mmp3/ariel/spiui.fth b/cpu/arm/mmp3/ariel/spiui.fth new file mode 100644 index 00000000..5460bdf5 --- /dev/null +++ b/cpu/arm/mmp3/ariel/spiui.fth @@ -0,0 +1,173 @@ +purpose: User interface for reflashing SPI FLASH parts +\ See license at end of file + +\ 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 + +defer spi-progress ' 2drop to spi-progress ( offset size -- ) + +: 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 + i /flash spi-progress ( adr ) + /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. + +0 value file-loaded? + +: crc ( adr len -- crc ) 0 crctab 2swap ($crc) ; + +: ?crc ( -- ) + ." Checking integrity ..." cr + + flash-buf 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" +; + +: ?image-valid ( len -- ) + /flash <> abort" Image file is the wrong length" + + flash-buf signature-offset + + signature$ comp abort" Wrong machine signature" + + ?crc +; + +: $get-file ( "filename" -- ) + $read-open + flash-buf h# 40.0000 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 ; + +: write-firmware ( -- ) + flash-buf /flash 0 write-flash-range \ Write first part +; +: verify-firmware ( -- ) + flash-buf /flash 0 verify-flash-range \ Verify first part +; + +: .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 + + write-firmware + + spi-us d# 20 < if + ['] verify-firmware catch if + ." Verify failed. Retrying once" cr + spi-identify + write-firmware + verify-firmware + then + /flash dup spi-progress + 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 reflash ; + +: safe-flash-read ( -- ) + flash-buf /flash 0 flash-read +; + +\ 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 |