Changeset 3049


Ignore:
Timestamp:
Jul 11, 2012, 3:50:11 AM (3 years ago)
Author:
wmb
Message:

OLPC - omnibus change to greatly reduce the number of platform-specific ifdefs. The GPIOs are now named in <platform>/config.fth and referenced by name in common code. The drivers that differ between platforms are loaded in <platform>/fw.bth instead of in build-fw.fth . Hopefully this will make the code easier to maintain.

Files:
7 added
31 edited

Legend:

Unmodified
Added
Removed
  • cpu/arm/mmp2/dramrecal.fth

    r2992 r3049  
    648648: setup-key-wakeup  ( -- )
    649649   d# 24 d# 15 do  h# b0 i af!  loop  \ Wake SoC on game keys
    650    h# 220 d#  71 af!  \ Wake SoC on KBD CLK falling edge
    651    h# 221 d# 160 af!  \ Wake SoC on TPD CLK falling edge
     650[ifdef] soc-kbd-clk-gpio#
     651   h# 220 soc-kbd-clk-gpio# af!  \ Wake SoC on KBD CLK falling edge
     652   h# 221 soc-tpd-clk-gpio# af!  \ Wake SoC on TPD CLK falling edge
     653[then]
    652654   h# 4  h# 4c +mpmu  io-set  \ Pin edge (GPIO per datasheet) wakes SoC
    653655   ['] disable-int40 d# 40 interrupt-handler!
     
    750752;
    751753
    752 : keyboard-power-on   ( -- )  d# 148 gpio-clr  ;
    753 : keyboard-power-off  ( -- )  d# 148 gpio-set  ;
    754 : wlan-power-on   ( -- )  d# 34 gpio-set  ;
    755 : wlan-power-off  ( -- )  d# 34 gpio-clr  h# 040 d# 34 af!  h# 040 d# 57 af!  h# 040 d# 58 af!  ;
    756 : wlan-stay-on  ( -- )  h# 140 d# 34 af!  h# 140 d# 57 af!  h# 140 d# 58 af!  ;
     754[ifdef] soc-en-kbd-pwr-gpio#
     755: keyboard-power-on   ( -- )  soc-en-kbd-pwr-gpio# gpio-clr  ;
     756: keyboard-power-off  ( -- )  soc-en-kbd-pwr-gpio# gpio-set  ;
     757[else]
     758: keyboard-power-on   ( -- )  ;
     759: keyboard-power-off  ( -- )  ;
     760[then]
     761: wlan-power-on   ( -- )  en-wlan-pwr-gpio# gpio-set  ;
     762: wlan-power-off  ( -- )  en-wlan-pwr-gpio# gpio-clr  h# 040 en-wlan-pwr-gpio# af!  h# 040 wlan-pd-gpio# af!  h# 040 wlan-reset-gpio# af!  ;
     763: wlan-stay-on  ( -- )  h# 140 en-wlan-pwr-gpio# af!  h# 140 wlan-pd-gpio# af!  h# 140 wlan-reset-gpio# af!  ;
    757764
    7587650 value sleep-mask
  • cpu/arm/mmp2/sspspi.fth

    r2400 r3049  
    2121   0 ssp-sscr1 io!
    2222   h# 87 ssp-sscr0 io!   
    23    d# 46 gpio-set
    24    d# 46 gpio-dir-out
    25    h# c0 d# 46 af!
     23   spi-flash-cs-gpio# gpio-set
     24   spi-flash-cs-gpio# gpio-dir-out
     25   h# c0 spi-flash-cs-gpio# af!
    2626;
    27 : ssp-spi-cs-on   ( -- )  d# 46 gpio-clr  ;
    28 : ssp-spi-cs-off  ( -- )  d# 46 gpio-set  ;
     27: ssp-spi-cs-on   ( -- )  spi-flash-cs-gpio# gpio-clr  ;
     28: ssp-spi-cs-off  ( -- )  spi-flash-cs-gpio# gpio-set  ;
    2929
    3030code ssp-spi-out-in  ( bo -- bi )
  • cpu/arm/olpc/1.75/compass.fth

    r2406 r3049  
    33
    44: set-compass-slave  ( -- )
    5    4 to smb-clock-gpio#
    6    5 to smb-data-gpio#
     5   compass-scl-gpio# to smb-clock-gpio#
     6   compass-sda-gpio# to smb-data-gpio#
    77   h# 3c to smb-slave
    88   smb-data-gpio# gpio-dir-out
  • cpu/arm/olpc/1.75/config.fth

    r2726 r3049  
    1 \ create cl2-a1
    21create debug-startup
    32create olpc
     
    65create use-null-nvram
    76create use-elf
     7create has-sp-kbd
     8create has-dcon
    89
    910fload ${BP}/cpu/arm/mmp2/hwaddrs.fth
    1011fload ${BP}/cpu/arm/olpc/addrs.fth
    1112
    12 create machine-signature ," CL2"
     13[ifdef] use-flash-nvram
     14h# d.0000 constant nvram-offset
     15[then]
     16
     17h#  e.0000 constant mfg-data-offset     \ Offset to manufacturing data area in SPI FLASH
     18h#  f.0000 constant mfg-data-end-offset \ Offset to end of manufacturing data area in SPI FLASH
     19h#  f.ffd8 constant crc-offset
     20
     21h# 10.0000 constant /rom           \ Total size of SPI FLASH
     22
     23: signature$    " CL2"  ;
     24: model$        " olpc,XO-1.75"  ;
     25: compatible$   " olpc,xo-1.75"  ;
     26
     27d#  9999 constant machine-type  \ Backwards compatibility with non-device-tree kernel
     28
     29char 4 constant expected-ec-version
     30h# 8000 value /ec-flash
     31
     32h# 10000 constant l2-#sets
     33
     34d# 108 constant cam-scl-gpio#
     35d# 109 constant cam-sda-gpio#
     36
     37d# 102 constant cam-rst-gpio#
     38d# 150 constant cam-pwr-gpio#
     39
     40d#  46 constant spi-flash-cs-gpio#
     41
     42d# 155 constant ec-spi-cmd-gpio#
     43d# 125 constant ec-spi-ack-gpio#
     44
     45d# 161 constant dcon-scl-gpio#
     46d# 110 constant dcon-sda-gpio#
     47
     48d# 124 constant dcon-irq-gpio#
     49d# 142 constant dcon-load-gpio#
     50
     51d#  34 constant en-wlan-pwr-gpio#
     52d#  57 constant wlan-pd-gpio#
     53d#  58 constant wlan-reset-gpio#
     54
     55d# 146 constant usb-hub-reset-gpio#
     56
     57d# 149 constant emmc-rst-gpio#
     58
     59d#  73 constant sec-trg-gpio#
     60
     61d#  53 constant rtc-scl-gpio#
     62d#  54 constant rtc-sda-gpio#
     63
     64d# 104 constant ec-edi-cs-gpio#
     65d# 105 constant ec-edi-mosi-gpio#
     66d# 106 constant ec-edi-clk-gpio#
     67
     68\ d#  56 constant boot-dev-sel-gpio#  \ revision-dependent, determined at run time
     69
     70d# 129 constant lid-switch-gpio#
     71d# 128 constant ebook-mode-gpio#
     72
     73d# 143 constant mic-ac/dc-gpio#
     74d#   8 constant audio-reset-gpio#
     75d#  97 constant hp-plug-gpio#
     76
     77d#  10 constant led-storage-gpio#
     78d#  11 constant vid2-gpio#
     79
     80d# 160 constant soc-tpd-clk-gpio#
     81d# 107 constant soc-tpd-dat-gpio#
     82
     83d#  71 constant soc-kbd-clk-gpio#
     84d#  72 constant soc-kbd-dat-gpio#
     85d# 148 constant soc-en-kbd-pwr-gpio#
     86
     87d# 144 constant cam-pwrdn-gpio#
     88
     89d#   4 constant compass-scl-gpio#
     90d#   5 constant compass-sda-gpio#
     91
     92d#  15 constant rotate-gpio#
  • cpu/arm/olpc/1.75/fw.bth

    r2726 r3049  
    99
    1010fload ${BP}/cpu/arm/olpc/build-fw.fth
     11
     12\ The internal SD card shares the host controller circuitry with
     13\ the internal eMMC, so you can only use one at a time.  A GPIO
     14\ chooses which one to use.  The intended usage is to "repair"
     15\ boards with a broken eMMC chip by inserting a microSD and grounding
     16\ the GPIO.
     17
     18: clx-touch?  ( -- )  board-revision h# 3a18 >=  ;
     19: boot-dev-sel-gpio#  ( -- n )  clx-touch?  if  2  else  d# 56  then  ;
     20
     21fload ${BP}/cpu/arm/olpc/emmc.fth
     22
     23\ Device node for internal microSD
     24dev /sd
     25   new-device
     26      1 encode-int " reg" property
     27      fload ${BP}/dev/mmc/sdhci/sdmmc.fth
     28      fload ${BP}/dev/mmc/sdhci/selftest.fth
     29      " external" " slot-name" string-property
     30   finish-device
     31device-end
     32
     33devalias int /sd/disk@3
     34devalias ext /sd/disk@1
     35
     36fload ${BP}/cpu/arm/olpc/1.75/lcdcfg.fth
     37fload ${BP}/cpu/arm/olpc/1.75/usb.fth
     38fload ${BP}/cpu/arm/olpc/rm3150-touchscreen.fth
     39fload ${BP}/cpu/arm/olpc/1.75/compass.fth
     40fload ${BP}/cpu/arm/olpc/1.75/switches.fth
     41fload ${BP}/cpu/arm/olpc/1.75/leds.fth
     42fload ${BP}/cpu/arm/olpc/1.75/testinstructions.fth
     43fload ${BP}/cpu/arm/olpc/gpio-gamekeys.fth
     44fload ${BP}/cpu/arm/olpc/test-tweaks.fth
     45
     46fload ${BP}/cpu/arm/olpc/save-fw.fth
  • cpu/arm/olpc/1.75/lcdcfg.fth

    r2015 r3049  
    1 h# 40001102 value clkdiv  \ Display Clock 1 / 2 -> 56.93 MHz
    2 h# 00000700 value pmua-disp-clk-sel  \ PLL1 / 7 -> 113.86 MHz
     1dev /display
    32
    4 d#    8 value hsync  \ Sync width
    5 d# 1200 value hdisp  \ Display width
    6 d# 1256 value htotal \ Display + FP + Sync + BP
    7 d#   24 value hbp    \ Back porch
    8 
    9 d#    3 value vsync  \ Sync width
    10 d#  900 value vdisp  \ Display width
    11 d#  912 value vtotal \ Display + FP + Sync + BP
    12 d#    5 value vbp    \ Back porch
    13 
    14 : hfp  ( -- n )  htotal hdisp -  hsync -  hbp -  ;  \ 24
    15 : vfp  ( -- n )  vtotal vdisp -  vsync -  vbp -  ;  \ 4
    16 
    17 0 [if]
    18 3 constant #lanes
    19 3 constant bytes/pixel
    20 d# 24 constant bpp
    21 [else]
    22 2 constant #lanes
    23 2 constant bytes/pixel
    24 d# 16 constant bpp
     3[ifdef] has-dcon
     4   fload ${BP}/dev/olpc/dcon/mmp2dcon.fth        \ DCON control
    255[then]
    266
    27 : >bytes   ( pixels -- chunks )  bytes/pixel *  ;
    28 : >chunks  ( pixels -- chunks )  >bytes #lanes /  ;
    29 
    30 alias width  hdisp
    31 alias height vdisp
    32 alias depth  bpp
    33 width >bytes constant /scanline 
     7device-end
  • cpu/arm/olpc/1.75/leds.fth

    r2682 r3049  
    88: close  ( -- )  ;
    99
     10: hdd-led-off     ( -- )  led-storage-gpio# gpio-clr  ;
     11: hdd-led-on      ( -- )  led-storage-gpio# gpio-set  ;
     12: hdd-led-toggle  ( -- )  led-storage-gpio# gpio-pin@  if  hdd-led-off  else  hdd-led-on  then  ;
     13
    1014: selftest  ( -- )
    11     ." Flashing LEDs" cr
     15   ." Flashing LEDs" cr
    1216
    1317   d# 10 0 do  ols-led-on d# 200 ms ols-led-off d# 200 ms  loop
  • cpu/arm/olpc/1.75/olpc.bth

    r3047 r3049  
    163163h# 10 buffer: signature
    164164signature h# 10 blank
    165 machine-signature count   signature         swap move
     165signature$  signature  swap move
    166166" ${FW_VERSION}" expand$  signature     6 + swap move
    167167" ${FW_PREFIX}${FW_MAJOR}" expand$  signature d# 13 + swap move
  • cpu/arm/olpc/1.75/usb.fth

    r3023 r3049  
    22\ See license at end of file
    33
    4 0 0  " d4208000"  " /" begin-package  \ USB Host Controller
    5    h# 200 constant /regs
    6    my-address my-space /regs reg
    7    : my-map-in  ( len -- adr )
    8       my-space swap  " map-in" $call-parent  h# 100 +  ( adr )
    9    ;
    10    : my-map-out  ( adr len -- )  swap h# 100 - swap " map-out" $call-parent  ;
    11    " /pmua" encode-phandle 5 encode-int encode+ " clocks" property
    12    d# 44 " interrupts" integer-property
    13 
    14    false constant has-dbgp-regs?
    15    false constant needs-dummy-qh?
    16    : grab-controller  ( config-adr -- error? )  drop false  ;
    17    fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
    18 \  false to delay?  \ No need for a polling delay on this platform
    19    : otg-set-host-mode  3 h# a8 ehci-reg!  ;  \ Force host mode
    20    ' otg-set-host-mode to set-host-mode
    21 
     4dev /usb@d4208000
    225   \ Port 1 on the hub is connected to unused pins on the WLAN connector,
    236   \ so testing it is confusing
     
    269   \ Port 4 is right lower
    2710   " 3,4,2" " usb-hub-test-list" string-property
    28    : sleep  ( -- )  true to first-open?  ;
    29    : wake  ( -- )  ;
    30 end-package
     11device-end
    3112
    32 \ Turn on USB power after a delay, to ensure that USB devices are reset correctly on boot
    33 : usb-power-on  ( -- )  ;  \ The EC controls the USB power
    34 : reset-usb-hub  ( -- )  d# 146 gpio-clr  d# 10 ms  d# 146 gpio-set  ;
    35 
    36 : init-usb  ( -- )
    37    h# 9 h# 5c pmua!  \ Enable clock to USB block
    38    reset-usb-hub
    39    init-usb-phy
     13: (reset-usb-hub)  ( -- )
     14   usb-hub-reset-gpio# gpio-clr  d# 10 ms  usb-hub-reset-gpio# gpio-set
    4015;
    41 
    42 stand-init: Init USB Phy
    43 \  usb-power-on   \ The EC now controls the USB power
    44    init-usb
    45 ;
    46 
    47 d# 350 config-int usb-delay  \ Milliseconds to wait before probing hub ports
     16' (reset-usb-hub) to reset-usb-hub
    4817
    4918devalias u    /usb/disk
    50 
    51 \ Like $show-devs, but ignores pagination keystrokes
    52 : $nopage-show-devs  ( nodename$ -- )
    53    ['] exit? behavior >r  ['] false to exit?
    54    $show-devs
    55    r> to exit?
    56 ;
    57 
    58 \ Restrict selftest to external USB ports 1,2,3
    59 \ dev /  3 " usb-test-ports" integer-property  dend
    60 
    61 : (probe-usb2)  ( -- )
    62    " device_type" get-property  if  exit  then
    63 [ifdef] use-usb-debug-port
    64    \ I haven't figured out how to turn on the EHCI cleanly
    65    \ when the Debug Port is running
    66    dbgp-off
    67 [then]
    68    get-encoded-string  " ehci" $=  if
    69       pwd$ open-dev  ?dup  if  close-dev  then
    70    then
    71 ;
    72 : (show-usb2)  ( -- )
    73    " device_type" get-property  if  exit  then
    74    get-encoded-string  " ehci" $=  if
    75       pwd$ $nopage-show-devs
    76    then
    77 ;
    78 
    79 true value first-usb-probe?
    80 : (silent-probe-usb)  ( -- )  " /" ['] (probe-usb2) scan-subtree  ;
    81 : silent-probe-usb  ( -- )
    82    (silent-probe-usb)
    83    report-disk report-net report-keyboard
    84 ;
    85 : probe-usb  ( -- )
    86    first-usb-probe?  if
    87       false to first-usb-probe?
    88       \ Initial probe to awaken the hub
    89       (silent-probe-usb)
    90       \ A little delay to let slow devices like USB scanner wake up
    91       d# 150 ms
    92    then
    93    silent-probe-usb
    94 
    95    ." USB devices:" cr
    96    " /" ['] (show-usb2) scan-subtree
    97 
    98 ;
    99 alias p2 probe-usb
    100 
    101 0 value usb-keyboard-ih
    102 
    103 : attach-usb-keyboard  ( -- )
    104    " usb-keyboard" expand-alias  if   ( devspec$ )
    105       drop " /usb"  comp  0=  if      ( )
    106          " usb-keyboard" open-dev to usb-keyboard-ih
    107          usb-keyboard-ih add-input
    108          exit
    109       then
    110    else                               ( devspec$ )
    111       2drop
    112    then
    113 ;
    114 
    115 : detach-usb-keyboard  ( -- )
    116    usb-keyboard-ih  if
    117       usb-keyboard-ih remove-input
    118       usb-keyboard-ih close-dev
    119       0 to usb-keyboard-ih
    120    then
    121 ;
    122 
    123 : ?usb-keyboard  ( -- )
    124    attach-usb-keyboard
    125 ;
    126 
    127 : usb-quiet  ( -- )
    128    detach-usb-keyboard
    129    " /usb" " reset-usb" execute-device-method drop
    130 ;
    131 
    132 : suspend-usb  ( -- )
    133    detach-usb-keyboard
    134    " /usb" " sleep" execute-device-method drop
    135 ;
    136 : has-children?   ( devspec$ -- flag )
    137    locate-device  if  false  else  child 0<>  then
    138 ;
    139 : any-usb-devices?  ( -- flag )  " /usb/hub" has-children?  ;
    140 : resume-usb  ( -- )
    141    init-usb
    142    " /usb" " wake" execute-device-method drop
    143    any-usb-devices?  if
    144       d# 2000 ms  \ USB misses devices if you probe too soon
    145    then
    146    silent-probe-usb
    147    attach-usb-keyboard
    148 ;
    149 
    150 \ Unlink every node whose phys.hi component matches port
    151 : port-match?  ( port -- flag )
    152    get-unit  if  drop false exit  then
    153    get-encoded-int =
    154 ;
    155 : rm-usb-children  ( port -- )
    156    device-context? 0=  if  drop exit  then
    157    also                             ( port )
    158    'child                           ( port prev )
    159    first-child  begin while         ( port prev )
    160       over port-match?  if          ( port prev )
    161          'peer link@  over link!    ( port prev )      \ Disconnect
    162       else                          ( port prev )
    163          drop 'peer                 ( port prev' )
    164       then                          ( port prev )
    165    next-child  repeat               ( port prev )
    166    2drop                            ( )
    167    previous definitions
    168 ;
    169 
    170 \ LICENSE_BEGIN
    171 \ Copyright (c) 2010 FirmWorks
    172 \
    173 \ Permission is hereby granted, free of charge, to any person obtaining
    174 \ a copy of this software and associated documentation files (the
    175 \ "Software"), to deal in the Software without restriction, including
    176 \ without limitation the rights to use, copy, modify, merge, publish,
    177 \ distribute, sublicense, and/or sell copies of the Software, and to
    178 \ permit persons to whom the Software is furnished to do so, subject to
    179 \ the following conditions:
    180 \
    181 \ The above copyright notice and this permission notice shall be
    182 \ included in all copies or substantial portions of the Software.
    183 \
    184 \ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    185 \ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    186 \ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    187 \ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    188 \ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    189 \ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    190 \ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    191 \
    192 \ LICENSE_END
  • cpu/arm/olpc/3.0/config.fth

    r2727 r3049  
    11create debug-startup
    22create olpc
    3 create trust-ec-keyboard
     3create olpc-cl3
    44create use-null-nvram
    55create use-elf
    6 create olpc-cl3
     6create use-screen-kbd
     7create use-small-font
    78
    89fload ${BP}/cpu/arm/mmp2/hwaddrs.fth
    910fload ${BP}/cpu/arm/olpc/addrs.fth
    1011
    11 create machine-signature ," CL3"
     12[ifdef] use-flash-nvram
     13h# d.0000 constant nvram-offset
     14[then]
     15
     16h#  e.0000 constant mfg-data-offset     \ Offset to manufacturing data area in SPI FLASH
     17h#  f.0000 constant mfg-data-end-offset \ Offset to end of manufacturing data area in SPI FLASH
     18h#  f.ffd8 constant crc-offset
     19
     20h# 10.0000 constant /rom           \ Total size of SPI FLASH
     21
     22: signature$   " CL3"  ;
     23: model$       " olpcXO-3.0"  ;
     24: compatible$  " olpcxo-3.0"  ;
     25
     26d# 10000 constant machine-type  \ Backwards compatibility with non-device-tree kernel
     27
     28char 4 constant expected-ec-version
     29h# 8000 value /ec-flash
     30
     31h# 10000 constant l2-#sets
     32
     33d#  56 constant boot-dev-sel-gpio#
     34
     35d#   4 constant cam-scl-gpio#
     36d#   5 constant cam-sda-gpio#
     37
     38d#  10 constant cam-rst-gpio#
     39d# 150 constant cam-pwr-gpio#
     40d#   9 constant cam-pwrdn-gpio#
     41
     42d#  46 constant spi-flash-cs-gpio#
     43
     44d# 155 constant ec-spi-cmd-gpio#
     45d# 125 constant ec-spi-ack-gpio#
     46
     47\ CL3 has no DCON
     48
     49d#  34 constant en-wlan-pwr-gpio#
     50d#  57 constant wlan-pd-gpio#
     51d#  58 constant wlan-reset-gpio#
     52
     53d# 146 constant usb-hub-reset-gpio#
     54
     55d# 149 constant emmc-rst-gpio#
     56
     57d# 142 constant sec-trg-gpio#
     58
     59d#  53 constant rtc-scl-gpio#
     60d#  54 constant rtc-sda-gpio#
     61
     62d# 104 constant ec-edi-cs-gpio#
     63d# 105 constant ec-edi-mosi-gpio#
     64d# 106 constant ec-edi-clk-gpio#
     65
     66d# 143 constant mic-ac/dc-gpio#
     67d#   8 constant audio-reset-gpio#
     68d#  97 constant hp-plug-gpio#
     69d#  11 constant vid2-gpio#
  • cpu/arm/olpc/3.0/fw.bth

    r2727 r3049  
    99
    1010fload ${BP}/cpu/arm/olpc/build-fw.fth
     11
     12fload ${BP}/cpu/arm/olpc/emmc.fth
     13devalias int /sd/disk@3
     14
     15fload ${BP}/cpu/arm/olpc/3.0/lcdcfg.fth
     16fload ${BP}/cpu/arm/olpc/3.0/usb.fth
     17fload ${BP}/cpu/arm/olpc/exc7200-touchscreen.fth
     18fload ${BP}/cpu/arm/olpc/3.0/switches.fth
     19fload ${BP}/cpu/arm/olpc/3.0/leds.fth
     20fload ${BP}/cpu/arm/olpc/3.0/testinstructions.fth
     21fload ${BP}/cpu/arm/olpc/test-tweaks.fth
     22
     23fload ${BP}/cpu/arm/olpc/save-fw.fth
  • cpu/arm/olpc/3.0/lcdcfg.fth

    r2757 r3049  
    1 h# 40001102 value clkdiv  \ Display Clock 1 / 2 -> 56.93 MHz
    2 h# 00000700 value pmua-disp-clk-sel  \ PLL1 / 7 -> 113.86 MHz
     1dev /display
    32
    4 d#    8 value hsync  \ Sync width
    5 d# 1024 value hdisp  \ Display width
    6 d# 1344 value htotal \ Display + FP + Sync + BP
    7 d#   24 value hbp    \ Back porch
     3d# 1024 to hdisp  \ Display width
     4d# 1344 to htotal \ Display + FP + Sync + BP
    85
    9 d#    3 value vsync  \ Sync width
    10 d#  768 value vdisp  \ Display width
    11 d#  806 value vtotal \ Display + FP + Sync + BP
    12 d#    5 value vbp    \ Back porch
     6d#  768 to vdisp  \ Display width
     7d#  806 to vtotal \ Display + FP + Sync + BP
    138
    14 : hfp  ( -- n )  htotal hdisp -  hsync -  hbp -  ;  \ 24
    15 : vfp  ( -- n )  vtotal vdisp -  vsync -  vbp -  ;  \ 4
     9: pwm-bright!  ( level -- )  d# 15 min  h# 11 *  h# 1a404 io!  ;
     10' pwm-bright! to bright!
    1611
    17 0 [if]
    18 3 constant #lanes
    19 3 constant bytes/pixel
    20 d# 24 constant bpp
    21 [else]
    22 2 constant #lanes
    23 2 constant bytes/pixel
    24 d# 16 constant bpp
    25 [then]
     12: pwm-backlight-on  ( -- )  d# 15 bright!  ;
     13' pwm-backlight-on  to backlight-on
    2614
    27 : >bytes   ( pixels -- chunks )  bytes/pixel *  ;
    28 : >chunks  ( pixels -- chunks )  >bytes #lanes /  ;
     15: pwm-backlight-off  ( -- )  0 bright!  ;
     16' pwm-backlight-off  to backlight-off
    2917
    30 alias width  hdisp
    31 alias height vdisp
    32 alias depth  bpp
    33 width >bytes constant /scanline 
    34 
    35 : bright!  ( level -- )  d# 15 min  h# 11 *  h# 1a404 io!  ;
    36 : backlight-on  ( -- )  d# 15 bright!  ;
    37 : backlight-off  ( -- )  0 bright!  ;
    3818: setup-pwm2  ( -- )
    3919   7 h# 1503c io!  3 h# 1503c io!  \ Turn on the PWM1 clock and release reset - PWM2 depends on it
     
    6343   backlight-on
    6444;
    65 : init-xo-display  ( -- )   ;  \ CForth has already turned it on
     45\  ' lcd-power-on to init-panel  \ Unnecessary as CForth has already done it
    6646
    6747: set-source  ( flag -- )  drop  ;  \ No DCON
    6848true constant vga?  \ No DCON, hence never frozen
     49
     50device-end
  • cpu/arm/olpc/3.0/leds.fth

    r2769 r3049  
    11\ See license at end of file
    2 purpose: Driver/selftest for OLPC XO-1.75 LEDs
     2purpose: Driver/selftest for OLPC XO-3.0 LEDs
    33
    440 0  " 0"  " /" begin-package
     
    99
    1010: selftest  ( -- )
    11     ." Flashing LEDs" cr
    12 
    13 \   d# 10 0 do  ols-led-on d# 200 ms ols-led-off d# 200 ms  loop
    14 \   ols-led-ec-control
    15 \   ols-assy-mode-on
     11   ." Flashing LEDs" cr
    1612
    1713   " /wlan:quiet" test-dev  " /wlan:quiet" test-dev  \ Twice for longer flashing
    18 
    19 \   ols-assy-mode-off
    2014
    2115   confirm-selftest?
  • cpu/arm/olpc/3.0/olpc.bth

    r2735 r3049  
    166166h# 10 buffer: signature
    167167signature h# 10 blank
    168 machine-signature count   signature         swap move
     168signature$  signature  swap move
    169169" ${FW_VERSION}" expand$  signature     6 + swap move
    170170" ${FW_PREFIX}${FW_MAJOR}" expand$  signature d# 13 + swap move
  • cpu/arm/olpc/3.0/switches.fth

    r2727 r3049  
    22purpose: Driver/selftest for OLPC lid and ebook switches
    33
     4\ The XO-3.0 has no switches, but we need the device node
     5\ because the suspend/resume test gets added to that node later.
    460 0  " 0"  " /" begin-package
    57" switches" device-name
  • cpu/arm/olpc/3.0/usb.fth

    r3048 r3049  
    22\ See license at end of file
    33
    4 0 0  " d4208000"  " /" begin-package  \ USB OTG Host Controller
    5    h# 200 constant /regs
    6    my-address my-space /regs reg
    7    : my-map-in  ( len -- adr )
    8       my-space swap  " map-in" $call-parent  h# 100 +  ( adr )
    9    ;
    10    : my-map-out  ( adr len -- )  swap h# 100 - swap " map-out" $call-parent  ;
    11    " /pmua" encode-phandle 5 encode-int encode+ " clocks" property
    12    d# 44 " interrupts" integer-property
    13 
    14    false constant has-dbgp-regs?
    15    false constant needs-dummy-qh?
    16    : grab-controller  ( config-adr -- error? )  drop false  ;
    17    fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
    18 \  false to delay?  \ No need for a polling delay on this platform
    19    : otg-set-host-mode  3 h# a8 ehci-reg!  ;  \ Force host mode
    20    ' otg-set-host-mode to set-host-mode
    21 
     4dev /usb@d4208000
    225   \ The Marvell EHCI can handle low and full speed devices directly,
    236   \ without needing a UHCI or OHCI companion controller
    247   ' make-port-node to handle-ls-device
    258   ' make-port-node to handle-fs-device
     9device-end
    2610
    27    : sleep  ( -- )  true to first-open?  ;
    28    : wake  ( -- )  ;
    29 end-package
     11fload ${BP}/cpu/arm/mmp2/ulpiphy.fth
    3012
    31130 0  " f0003000"  " /" begin-package  \ USB Host Controller 1 - ULPI
     
    5335\ usb-power-on is unnecessary on initial boot, as CForth turns on the
    5436\ USB power during its GPIO setup.
    55 : usb-power-on  ( -- )
     37: (usb-power-on)  ( -- )
    5638   d# 126 gpio-clr  \ OTG 5V on
    5739   d# 127 gpio-clr  \ ULPI 5V on
    5840;
    59 : reset-usb-hub  ( -- )
     41' (usb-power-on) to usb-power-on
     42
     43: (reset-usb-hub)  ( -- )
    6044   d# 146 gpio-clr  d# 10 ms  d# 146 gpio-set  \ Resets ULPI hub
    6145   ulpi-clock-on
     
    6347   ulpi-on
    6448;
    65 
    66 : init-usb  ( -- )
    67    h# 9 h# 5c pmua!  \ Enable clock to USB block
    68    reset-usb-hub
    69    init-usb-phy
    70 ;
    71 
    72 stand-init: Init USB Phy
    73 \  usb-power-on   \ The USB power is turned on early, when CForth sets up GPIOs
    74    init-usb
    75 ;
    76 
    77 d# 350 config-int usb-delay  \ Milliseconds to wait before probing hub ports
     49' (reset-usb-hub) to reset-usb-hub
    7850
    7951devalias otg  /usb@d4208000       \ USB OTG (micro) connector
     
    8153devalias o    /usb@d4208000/disk  \ Disk on USB OTG (micro) connector
    8254devalias u    /usb@f0003000/disk  \ Disk on USB-A connector
    83 
    84 \ Like $show-devs, but ignores pagination keystrokes
    85 : $nopage-show-devs  ( nodename$ -- )
    86    ['] exit? behavior >r  ['] false to exit?
    87    $show-devs
    88    r> to exit?
    89 ;
    90 
    91 \ Restrict selftest to external USB ports 1,2,3
    92 \ dev /  3 " usb-test-ports" integer-property  dend
    93 
    94 : (probe-usb2)  ( -- )
    95    " device_type" get-property  if  exit  then
    96 [ifdef] use-usb-debug-port
    97    \ I haven't figured out how to turn on the EHCI cleanly
    98    \ when the Debug Port is running
    99    dbgp-off
    100 [then]
    101    get-encoded-string  " ehci" $=  if
    102       pwd$ open-dev  ?dup  if  close-dev  then
    103    then
    104 ;
    105 : (show-usb2)  ( -- )
    106    " device_type" get-property  if  exit  then
    107    get-encoded-string  " ehci" $=  if
    108       pwd$ $nopage-show-devs
    109    then
    110 ;
    111 
    112 true value first-usb-probe?
    113 : (silent-probe-usb)  ( -- )  " /" ['] (probe-usb2) scan-subtree  ;
    114 : silent-probe-usb  ( -- )
    115    (silent-probe-usb)
    116    report-disk report-net report-keyboard
    117 ;
    118 : probe-usb  ( -- )
    119    first-usb-probe?  if
    120       false to first-usb-probe?
    121       \ Initial probe to awaken the hub
    122       (silent-probe-usb)
    123       \ A little delay to let slow devices like USB scanner wake up
    124       d# 150 ms
    125    then
    126    silent-probe-usb
    127 
    128    ." USB devices:" cr
    129    " /" ['] (show-usb2) scan-subtree
    130 
    131 ;
    132 alias p2 probe-usb
    133 
    134 0 value usb-keyboard-ih
    135 0 value otg-keyboard-ih
    136 
    137 : attach-usb-keyboard  ( -- )
    138    " usb-keyboard" expand-alias  if   ( devspec$ )
    139       drop " /usb"  comp  0=  if      ( )
    140          " usb-keyboard" open-dev to usb-keyboard-ih
    141          usb-keyboard-ih add-input
    142       then
    143    else                               ( devspec$ )
    144       2drop
    145    then
    146 
    147    " otg/keyboard" expand-alias  if   ( devspec$ )
    148       open-dev to otg-keyboard-ih
    149       otg-keyboard-ih add-input
    150    else
    151       2drop
    152    then
    153 ;
    154 
    155 : detach-usb-keyboard  ( -- )
    156    usb-keyboard-ih  if
    157       usb-keyboard-ih remove-input
    158       usb-keyboard-ih close-dev
    159       0 to usb-keyboard-ih
    160    then
    161 ;
    162 
    163 : ?usb-keyboard  ( -- )
    164    attach-usb-keyboard
    165 ;
    166 
    167 : usb-quiet  ( -- )
    168    detach-usb-keyboard
    169    " /usb@f0003000" " reset-usb" execute-device-method drop
    170    " /usb@d4208000" " reset-usb" execute-device-method drop
    171 ;
    172 
    173 : suspend-usb  ( -- )
    174    detach-usb-keyboard
    175    " /usb" " sleep" execute-device-method drop
    176 ;
    177 : has-children?   ( devspec$ -- flag )
    178    locate-device  if  false  else  child 0<>  then
    179 ;
    180 : any-usb-devices?  ( -- flag )  " /usb/hub" has-children?  ;
    181 : resume-usb  ( -- )
    182    init-usb
    183    " /usb" " wake" execute-device-method drop
    184    any-usb-devices?  if
    185       d# 2000 ms  \ USB misses devices if you probe too soon
    186    then
    187    silent-probe-usb
    188    attach-usb-keyboard
    189 ;
    190 
    191 \ Unlink every node whose phys.hi component matches port
    192 : port-match?  ( port -- flag )
    193    get-unit  if  drop false exit  then
    194    get-encoded-int =
    195 ;
    196 : rm-usb-children  ( port -- )
    197    device-context? 0=  if  drop exit  then
    198    also                             ( port )
    199    'child                           ( port prev )
    200    first-child  begin while         ( port prev )
    201       over port-match?  if          ( port prev )
    202          'peer link@  over link!    ( port prev )      \ Disconnect
    203       else                          ( port prev )
    204          drop 'peer                 ( port prev' )
    205       then                          ( port prev )
    206    next-child  repeat               ( port prev )
    207    2drop                            ( )
    208    previous definitions
    209 ;
    210 
    211 \ LICENSE_BEGIN
    212 \ Copyright (c) 2010 FirmWorks
    213 \
    214 \ Permission is hereby granted, free of charge, to any person obtaining
    215 \ a copy of this software and associated documentation files (the
    216 \ "Software"), to deal in the Software without restriction, including
    217 \ without limitation the rights to use, copy, modify, merge, publish,
    218 \ distribute, sublicense, and/or sell copies of the Software, and to
    219 \ permit persons to whom the Software is furnished to do so, subject to
    220 \ the following conditions:
    221 \
    222 \ The above copyright notice and this permission notice shall be
    223 \ included in all copies or substantial portions of the Software.
    224 \
    225 \ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    226 \ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    227 \ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    228 \ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    229 \ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    230 \ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    231 \ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    232 \
    233 \ LICENSE_END
  • cpu/arm/olpc/addrs.fth

    r2733 r3049  
    4545h#  20000 constant dropin-offset   \ Offset to dropin driver area in SPI FLASH
    4646
    47 [ifdef] use-flash-nvram
    48 h# d.0000 constant nvram-offset
    49 [then]
    50 
    51 h#  e.0000 constant mfg-data-offset     \ Offset to manufacturing data area in SPI FLASH
    52 h#  f.0000 constant mfg-data-end-offset \ Offset to end of manufacturing data area in SPI FLASH
    53 h#  f.ffd8 constant crc-offset
    54 
    55 h# 10.0000 constant /rom           \ Total size of SPI FLASH
    56 
    5747\ SRAM usage
    5848
  • cpu/arm/olpc/boardrev.fth

    r2726 r3049  
    55
    66\ Constructs a string like "B4" or "preB4" or "postB4"
    7 : model-name$  ( -- model$ )
     7: model-version$  ( -- model$ )
    88   board-revision  h# 10 /mod               ( minor major )
    99   swap  dup 8 =  if                        ( major minor )
  • cpu/arm/olpc/build-fw.fth

    r3041 r3049  
    88\ ' noop is include-hook
    99
     10: init-stuff
     11   acgr-clocks-on
     12   init-timers
     13   init-twsi
     14;
     15warning @ warning off
     16: stand-init-io
     17   stand-init-io
     18   init-stuff
     19;
     20warning !
     21
     22dev /
     23   model$  model
     24   " OLPC" encode-string  " architecture" property
     25\ The clock frequency of the root bus may be irrelevant, since the bus is internal to the SOC
     26\    d# 1,000,000,000 " clock-frequency" integer-property
     27device-end
     28
    1029fload ${BP}/cpu/arm/olpc/fbnums.fth
    1130fload ${BP}/cpu/arm/olpc/fbmsg.fth
     
    8099   decode-int nip nip  d# 1000000 / 
    81100;
    82 
    83 
    84 fload ${BP}/cpu/arm/mmp2/pmua.fth
    85 fload ${BP}/cpu/arm/mmp2/apbc.fth
    86 fload ${BP}/cpu/arm/mmp2/irq.fth
    87 fload ${BP}/cpu/arm/mmp2/timer.fth
    88 fload ${BP}/cpu/arm/mmp2/twsi.fth
    89 fload ${BP}/cpu/arm/mmp2/mfpr.fth
    90 fload ${BP}/cpu/arm/mmp2/gpio.fth
    91 
    92 : init-stuff
    93    acgr-clocks-on
    94    init-timers
    95    init-twsi
    96 ;
    97 warning @ warning off
    98 : stand-init-io
    99    stand-init-io
    100    init-stuff
    101 ;
    102 warning !
    103101
    104102fload ${BP}/cpu/arm/mmp2/watchdog.fth   \ reset-all using watchdog timer
     
    183181false constant tethered?                     \ We only support reprogramming our own FLASH
    184182
    185 [ifdef] olpc-cl3
    186 : hdd-led-off     ( -- )  ;
    187 : hdd-led-on      ( -- )  ;
    188 : hdd-led-toggle  ( -- )  ;
    189 [else]
    190 : hdd-led-off     ( -- )  d# 10 gpio-clr  ;
    191 : hdd-led-on      ( -- )  d# 10 gpio-set  ;
    192 : hdd-led-toggle  ( -- )  d# 10 gpio-pin@  if  hdd-led-off  else  hdd-led-on  then  ;
    193 [then]
    194 
    195183fload ${BP}/cpu/arm/olpc/bbedi.fth
    196184fload ${BP}/cpu/arm/olpc/edi.fth
     
    198186load-base constant flash-buf
    199187
    200 
    201 [ifdef] cl2-a1
    202 h# 10000 value /ec-flash
    203 char 3 value expected-ec-version
    204 [else]
    205 h# 8000 value /ec-flash
    206 : clx-touch?  ( -- )  board-revision h# 3a18 >=  ;
    207 \+ olpc-cl2 char 4 value expected-ec-version
    208 \+ olpc-cl3 char 5 value expected-ec-version
    209 [then]
    210 
    211 [ifndef] cl2-a1
    212 [then]
    213188fload ${BP}/cpu/arm/olpc/ecflash.fth
    214189
     
    251226end-package
    252227
    253 0 0  " d420b000"  " /" begin-package
    254    " display" name
    255    my-address my-space h# 1000 reg
    256 
    257    " /pmua" encode-phandle 1 encode-int encode+ " clocks" property
    258    d# 41 " interrupts" integer-property
    259 
    260 [ifdef] olpc-cl3
    261    fload ${BP}/cpu/arm/olpc/3.0/lcdcfg.fth
    262 [else]
    263    fload ${BP}/cpu/arm/olpc/1.75/lcdcfg.fth
     228fload ${BP}/cpu/arm/olpc/lcd.fth
     229fload ${BP}/cpu/arm/olpc/sdhci.fth
     230
     231devalias net /wlan
     232
     233fload ${BP}/dev/olpc/kb3700/spicmd.fth           \ EC SPI Command Protocol
     234
     235[ifdef] has-sp-kbd
     236fload ${BP}/cpu/arm/olpc/spcmd.fth   \ Security Processor communication protocol
     237devalias keyboard /ap-sp/keyboard
     238devalias mouse    /ap-sp/mouse
    264239[then]
    265240
    266    fload ${BP}/cpu/arm/olpc/lcd.fth
    267 [ifndef] olpc-cl3
    268    fload ${BP}/dev/olpc/dcon/mmp2dcon.fth        \ DCON control
    269 [then]
    270    defer convert-color ' noop to convert-color
    271    defer pixel*
    272    defer pixel+
    273    defer pixel!
    274 
    275    : color!  ( r g b index -- )  4drop  ;
    276    : color@  ( index -- r g b )  drop 0 0 0  ;
    277 
    278    fload ${BP}/dev/video/common/rectangle16.fth     \ Rectangular graphics
    279 
    280    depth d# 24 =  [if]
    281       code 3a+  ( adr n -- n' )
    282          pop  r0,sp
    283          inc  tos,#3
    284          add  tos,tos,r0
    285       c;
    286       code rgb888!  ( n adr -- )
    287          pop   r0,sp
    288          strb  r0,[tos]
    289          mov   r0,r0,lsr #8
    290          strb  r0,[tos,#1]
    291          mov   r0,r0,lsr #8
    292          strb  r0,[tos,#2]
    293          pop   tos,sp
    294       c;
    295       ' 3* to pixel*
    296       ' 3a+ to pixel+
    297       ' rgb888! to pixel!
    298       ' noop to convert-color
    299    [else]
    300       ' /w* to pixel*
    301       ' wa+ to pixel+
    302       ' w!  to pixel!
    303       ' argb>565-pixel to convert-color
    304    [then]
    305 
    306    : display-on
    307       init-xo-display  \ Turns on DCON etc
    308       frame-buffer-adr  hdisp vdisp * >bytes  h# ffffffff lfill
    309       init-lcd
    310    ;
    311    : map-frame-buffer  ( -- )
    312       \ We use fb-mem-va directly instead of calling map-in on the physical address
    313       \ because the physical address changes with the total memory size.  The early
    314       \ assembly language startup code establishes the mapping.
    315       fb-mem-va to frame-buffer-adr
    316    ;
    317    " display"                      device-type
    318    " ISO8859-1" encode-string    " character-set" property
    319    0 0  encode-bytes  " iso6429-1983-colors"  property
    320 
    321    \ Used as temporary storage for images by $get-image
    322    : graphmem  ( -- adr )  dimensions * pixel*  fb-mem-va +  ;
    323 
    324    : display-install  ( -- )
    325       map-frame-buffer
    326       display-on
    327       default-font set-font
    328       width  height                           ( width height )
    329       over char-width / over char-height /    ( width height rows cols )
    330       /scanline depth fb-install              ( )
    331    ;
    332 
    333    : display-remove  ( -- )  ;
    334    : display-selftest  ( -- failed? )  false  ;
    335 
    336    ' display-install  is-install
    337    ' display-remove   is-remove
    338    ' display-selftest is-selftest
    339 end-package
    340 
    341 devalias screen /display
    342    
    343 [ifdef] olpc-cl3
    344 create cp881-16  " ${BP}/ofw/termemu/cp881-16.obf" $file,
    345 ' cp881-16 to romfont
    346 [else]
    347 devalias keyboard /keyboard
    348 
    349 create 15x30pc  " ${BP}/ofw/termemu/15x30pc.psf" $file,
    350 ' 15x30pc to romfont
    351 [then]
    352 
    353 fload ${BP}/cpu/arm/olpc/sdhci.fth
    354 
    355 [ifndef] cl2-a1
    356 : boot-dev-gpio#  ( -- n )  clx-touch?  if  2  else  d# 56  then  ;
    357 fload ${BP}/cpu/arm/olpc/emmc.fth
    358 [then]
    359 
    360 devalias int /sd/disk@3
    361 devalias ext /sd/disk@1
    362 devalias net /wlan  \ XXX should report-net in case of USB Ethernet
    363 
    364 fload ${BP}/dev/olpc/kb3700/spicmd.fth           \ EC SPI Command Protocol
    365 
    366 \- olpc-cl3  fload ${BP}/cpu/arm/olpc/spcmd.fth   \ Security Processor communication protocol
    367 
    368 : wlan-reset  ( -- )  d# 58 gpio-clr  d# 20 ms  d# 58 gpio-set  ;
     241: wlan-reset  ( -- )  wlan-reset-gpio# gpio-clr  d# 20 ms  wlan-reset-gpio# gpio-set  ;
     242
     243fload ${BP}/ofw/core/fdt.fth
     244fload ${BP}/cpu/arm/linux.fth
    369245
    370246\ Create the alias unless it already exists
     
    412288
    413289fload ${BP}/cpu/arm/marvell/utmiphy.fth
    414 
    415 fload ${BP}/ofw/core/fdt.fth
    416 fload ${BP}/cpu/arm/linux.fth
    417 
    418 \+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/usb.fth
    419 \+ olpc-cl3 fload ${BP}/cpu/arm/mmp2/ulpiphy.fth
    420 \+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/usb.fth
    421 \+ olpc-cl4 fload ${BP}/cpu/arm/olpc/cl4/usb.fth
     290fload ${BP}/cpu/arm/olpc/usb.fth
    422291
    423292fload ${BP}/dev/olpc/mmp2camera/loadpkg.fth
     
    438307   stand-init
    439308   root-device
    440       model-name$   2dup model     ( name$ )
     309      model-version$   2dup model     ( name$ )
    441310      " OLPC " encode-bytes  2swap encode-string  encode+  " banner-name" property
    442311      board-revision " board-revision-int" integer-property
    443 \+ olpc-cl2  " olpc,xo-1.75" " compatible" string-property
    444 \+ olpc-cl3  " olpc,xo-3.0"  " compatible" string-property
    445 \+ olpc-cl4  " olpc,xo-cl4"  " compatible" string-property
     312      compatible$  " compatible" string-property
    446313
    447314      \ The "1-" removes the null byte
     
    494361' olpc-mapped-limit to mapped-limit
    495362
    496 \+ olpc-cl2 d#  9999 to arm-linux-machine-type  \ XO-1.75
    497 \+ olpc-cl3 d# 10000 to arm-linux-machine-type  \ XO-3
     363machine-type to arm-linux-machine-type
    498364
    499365\ Add a tag describing the linear frame buffer
     
    543409\ true to stand-init-debug?
    544410
    545 : sec-trg   ( -- )      d# 73 gpio-set  ;  \ rising edge latches SPI_WP# low
    546 : sec-trg?  ( -- bit )  d# 73 gpio-pin@  ;
     411: sec-trg   ( -- )      sec-trg-gpio# gpio-set  ;  \ rising edge latches SPI_WP# low
     412: sec-trg?  ( -- bit )  sec-trg-gpio# gpio-pin@  ;
    547413
    548414alias ec-indexed-io-off sec-trg
     
    568434;
    569435
    570 [ifdef] olpc-cl3
    571 false value rotate-button?
    572 [else]
    573 : rotate-button?  ( -- flag )  d# 15 gpio-pin@ 0=  ;
    574 [then]
     436defer rotate-button?  ' false to rotate-button?
    575437
    576438warning @  warning off
     
    633495fload ${BP}/cpu/arm/olpc/banner.fth
    634496
    635 \- olpc-cl3  devalias keyboard /ap-sp/keyboard
    636 \- olpc-cl3  devalias mouse    /ap-sp/mouse
    637 
    638497: console-start  ( -- )
    639498   install-mux-io
     
    688547code halt  ( -- )  wfi   c;
    689548
    690 \+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/switches.fth \ Lid and ebook switches
    691 \+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/switches.fth  \ Switches
    692 \+ olpc-cl4 fload ${BP}/cpu/arm/olpc/cl4/switches.fth  \ Lid and ebook switches
    693 
    694549fload ${BP}/cpu/arm/mmp2/rtc.fth       \ Internal RTC, used for wakeups
    695550
    696 \+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/leds.fth     \ LEDs
    697 \+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/leds.fth      \ LEDs
    698 \+ olpc-cl4 fload ${BP}/cpu/arm/olpc/cl4/leds.fth      \ LEDs
    699 
    700551fload ${BP}/cpu/x86/pc/olpc/via/factory.fth  \ Manufacturing tools
    701552
    702553fload ${BP}/cpu/arm/olpc/accelerometer.fth
    703 
    704 [ifndef] olpc-cl3
    705 fload ${BP}/cpu/arm/olpc/1.75/compass.fth
    706 [then]
    707 
    708 \ Suppress long memory test at final test stage
    709 dev /memory
    710 0 value old-diag-switch?
    711 : not-final-test?  ( -- flag )
    712    final-test?   if  false exit  then
    713    smt-test?  if  false exit  then
    714    old-diag-switch?
    715 ;
    716 warning @ warning off
    717 : selftest  ( -- error? )
    718    diag-switch? to old-diag-switch?
    719    not-final-test?  to diag-switch?
    720    selftest
    721    old-diag-switch? to diag-switch?
    722 ;
    723 warning !
    724 device-end
    725 
    726 \ Add suspend resume test except in final
    727 dev /switches
    728 warning @ warning off
    729 : selftest  ( -- error? )
    730    final-test?  0=  if
    731       s3-selftest  if  true exit  then
    732    then
    733    selftest
    734 ;
    735 warning !
    736 device-end
    737554
    738555\ When reprogramming this machine's SPI FLASH, rebooting the EC is unnecessary
     
    750567end-package
    751568
    752 \ it seems to be difficult to get SoC wakeups from the keypad controller,
    753 \ so we set them up as gpio, instead.
    754 [ifdef] use_mmp2_keypad_control
    755 fload ${BP}/cpu/arm/mmp2/keypad.fth
    756 [ifdef] notdef  \ CForth turns on the keypad; resetting it makes it not work
    757 stand-init: keypad
    758    keypad-on
    759    8 keypad-direct-mode
    760 ;
    761 [then]
    762 : keypad-bit  ( n keypad out-mask key-mask -- n' keypad )
    763    third invert  and  if    ( n keypad out-mask )
    764       rot or swap           ( n' keypad )
    765    else                     ( n keypad out-mask )
    766       drop                  ( n keypad )
    767    then                     ( n' keypad )
    768 ;
    769 [then]
    770 
    771569fload ${BP}/cpu/x86/pc/olpc/gamekeynames.fth
    772570
    773 [ifdef] cl2-a1
    774 : game-key@  ( -- n )
    775    0                                        ( n )
    776    d# 16 gpio-pin@ 0=  if  h#  80 or  then  \ O
    777    d# 17 gpio-pin@ 0=  if  h#  02 or  then  \ Check
    778    d# 18 gpio-pin@ 0=  if  h# 100 or  then  \ X
    779    d# 19 gpio-pin@ 0=  if  h#  01 or  then  \ Square
    780    d# 20 gpio-pin@ 0=  if  h#  40 or  then  \ Rotate
    781 ;
    782 [then]
    783 
    784 [ifdef] olpc-cl3
    785 : game-key@  ( -- n )
    786    0
    787 ;
    788 [then]
    789 
    790 [ifndef] game-key@
    791    [ifdef] use_mmp2_keypad_control
    792 : game-key@  ( -- n )
    793    0                                        ( n )
    794    d# 15 gpio-pin@ 0=  if  button-rotate or  then   ( n )
    795    scan-keypad                              ( n keypad )
    796    button-o       h# 01  keypad-bit         ( n' keypad )
    797    button-check   h# 02  keypad-bit         ( n' keypad )
    798    button-x       h# 04  keypad-bit         ( n' keypad )
    799    button-square  h# 08  keypad-bit         ( n' keypad )
    800    rocker-up      h# 10  keypad-bit         ( n' keypad )
    801    rocker-right   h# 20  keypad-bit         ( n' keypad )
    802    rocker-down    h# 40  keypad-bit         ( n' keypad )
    803    rocker-left    h# 80  keypad-bit         ( n' keypad )
    804    drop                                     ( n )
    805 ;
    806    [else]
    807 : game-key@  ( -- n )
    808    0                                        ( n )
    809    d# 15 gpio-pin@ 0=  if  button-rotate  or  then
    810    d# 16 gpio-pin@ 0=  if  button-o       or  then
    811    d# 17 gpio-pin@ 0=  if  button-check   or  then
    812    d# 18 gpio-pin@ 0=  if  button-x       or  then
    813    d# 19 gpio-pin@ 0=  if  button-square  or  then
    814    d# 20 gpio-pin@ 0=  if  rocker-up      or  then
    815    d# 21 gpio-pin@ 0=  if  rocker-right   or  then
    816    d# 22 gpio-pin@ 0=  if  rocker-down    or  then
    817    d# 23 gpio-pin@ 0=  if  rocker-left    or  then
    818 ;
    819    [then]
    820 
    821 [then]
     571defer game-key@  ' 0 to game-key@   \ Implementation will be loaded later
    822572
    823573fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth
     
    827577fload ${BP}/cpu/x86/pc/olpc/disptest.fth
    828578
    829 [ifndef] olpc-cl3
     579[ifdef] has-sp-kbd
    830580dev /ap-sp/keyboard
    831581fload ${BP}/dev/olpc/keyboard/selftest.fth   \ Keyboard diagnostic
     
    842592fload ${BP}/cpu/x86/pc/olpc/via/copynand.fth
    843593
    844 \+ olpc-cl2 fload ${BP}/cpu/arm/olpc/rm3150-touchscreen.fth    \ Touchscreen driver and diagnostic
    845 \+ olpc-cl3 fload ${BP}/cpu/arm/olpc/exc7200-touchscreen.fth    \ Touchscreen driver and diagnostic
    846 \+ olpc-cl3 fload ${BP}/dev/softkeyboard.fth                    \ On-screen keyboard
    847 \+ olpc-cl4 fload ${BP}/cpu/arm/olpc/nn-touchscreen.fth        \ Touchscreen driver and diagnostic
     594\- use-screen-kbd devalias keyboard /keyboard
     595\+ use-screen-kbd fload ${BP}/dev/softkeyboard.fth             \ On-screen keyboard
     596
    848597fload ${BP}/cpu/arm/olpc/roller.fth     \ Accelerometer test
    849598
     
    1000749;
    1001750
    1002 [ifdef] olpc-cl3
     751[ifdef] use-screen-kbd
    10037520 value screen-kbd-ih
    1004753: open-screen-keyboard  ( -- )
     
    1046795
    1047796fload ${BP}/cpu/arm/olpc/testitems.fth
    1048 \+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/testinstructions.fth
    1049 \+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/testinstructions.fth
    1050 \+ olpc-cl4 fload ${BP}/cpu/arm/olpc/cl4/testinstructions.fth
    1051797
    1052798: startup  ( -- )
     
    1081827      then
    1082828   then
    1083 \+ olpc-cl3  open-hotspot
     829\+ use-screen-kbd  open-hotspot
    1084830
    1085831   install-alarm
     
    1089835
    1090836   ['] false to interrupt-auto-boot?
    1091 \+ olpc-cl3  ?text-on
     837\+ use-screen-kbd  ?text-on
    1092838[ifdef] probe-usb
    1093839   factory-test?  if  d# 1000 ms  then  \ Extra USB probe delay in the factory
     
    1100846   interpreter-init
    1101847
    1102 \+ olpc-cl3  ?text-on
     848\+ use-screen-kbd  ?text-on
    1103849   ?diags
    1104850   ?fs-update
     
    1108854   ['] (interrupt-auto-boot?) to interrupt-auto-boot?
    1109855
    1110 \+ olpc-cl3  ?text-on
     856\+ use-screen-kbd  ?text-on
    1111857   ?usb-keyboard
    1112858
    1113859   auto-banner?  if  banner  then
    1114860
    1115 \+ olpc-cl3  ?text-on
     861\+ use-screen-kbd  ?text-on
    1116862   auto-boot
    1117 \+ olpc-cl3  close-hotspot
    1118 
    1119 \+ olpc-cl3  open-screen-keyboard  banner
     863\+ use-screen-kbd  close-hotspot
     864
     865\+ use-screen-kbd  open-screen-keyboard  banner
    1120866
    1121867   frozen? text-on? 0=  and  ( no-banner? )
     
    1149895   " devalias fsdisk //null" evaluate
    1150896;
    1151 
    1152 tag-file @ fclose  tag-file off
    1153 my-self [if]
    1154    ." WARNING: my-self is not 0" cr
    1155    bye
    1156 [then]
    1157 
    1158 .( --- Saving fw.dic ...)
    1159 " fw.dic" $save-forth cr
    1160 
    1161 fload ${BP}/cpu/arm/mmp2/rawboot.fth
    1162 
    1163 .( --- Saving fw.img --- )  cr " fw.img" $save-rom
    1164897
    1165898\ LICENSE_BEGIN
  • cpu/arm/olpc/emmc.fth

    r3032 r3049  
    4040   h# 18c2   d# 168 af!  \ eMMC_D1
    4141
    42    d# 149 gpio-set     \ Release eMMC_RST#
     42   emmc-rst-gpio# gpio-set     \ Release eMMC_RST#
    4343
    44    d# 34 gpio-set  \ This is for the case where the eMMC power is rewired to the WLAN
     44   en-wlan-pwr-gpio# gpio-set  \ This is for the case where the eMMC power is rewired to the WLAN
    4545;
    46 \ Says COMM - is RST#
    47 \ Says RESET - is CMD
    4846
    4947stand-init:
    50    boot-dev-gpio# gpio-pin@  if
     48   boot-dev-sel-gpio# gpio-pin@  if
    5149      select-emmc
    5250   else
  • cpu/arm/olpc/lcd.fth

    r2818 r3049  
     1purpose: Display driver for OLPC ARM/MMP platforms
     2\ See license at end of file
     3
     40 0  " d420b000"  " /" begin-package
     5   " display" name
     6   my-address my-space h# 1000 reg
     7
     8   " /pmua" encode-phandle 1 encode-int encode+ " clocks" property
     9   d# 41 " interrupts" integer-property
     10
     11h# 40001102 value clkdiv  \ Display Clock 1 / 2 -> 56.93 MHz
     12h# 00000700 value pmua-disp-clk-sel  \ PLL1 / 7 -> 113.86 MHz
     13
     14d#    8 value hsync  \ Sync width
     15d# 1200 value hdisp  \ Display width
     16d# 1256 value htotal \ Display + FP + Sync + BP
     17d#   24 value hbp    \ Back porch
     18
     19d#    3 value vsync  \ Sync width
     20d#  900 value vdisp  \ Display width
     21d#  912 value vtotal \ Display + FP + Sync + BP
     22d#    5 value vbp    \ Back porch
     23
     24: hfp  ( -- n )  htotal hdisp -  hsync -  hbp -  ;  \ 24
     25: vfp  ( -- n )  vtotal vdisp -  vsync -  vbp -  ;  \ 4
     26
     272 value #lanes
     282 value bytes/pixel
     29d# 16 value bpp
     30
     310 [if]  \ 24bpp parameters
     323 to #lanes
     333 to bytes/pixel
     34d# 24 to bpp
     35[then]
     36
     37: >bytes   ( pixels -- chunks )  bytes/pixel *  ;
     38: >chunks  ( pixels -- chunks )  >bytes #lanes /  ;
     39
     40alias width  hdisp
     41alias height vdisp
     42alias depth  bpp
     43width >bytes constant /scanline 
     44
     45\ \+ olpc-cl3  fload ${BP}/cpu/arm/olpc/3.0/lcdcfg.fth
    146
    247: lcd@  ( offset -- l )  lcd-pa + io@  ;
     
    228273   cursor /cursor 0  cursor-sram-write
    229274;
     275
     276   defer convert-color ' noop to convert-color
     277   defer pixel*
     278   defer pixel+
     279   defer pixel!
     280
     281   : color!  ( r g b index -- )  4drop  ;
     282   : color@  ( index -- r g b )  drop 0 0 0  ;
     283
     284   fload ${BP}/dev/video/common/rectangle16.fth     \ Rectangular graphics
     285
     286   depth d# 24 =  [if]
     287      code 3a+  ( adr n -- n' )
     288         pop  r0,sp
     289         inc  tos,#3
     290         add  tos,tos,r0
     291      c;
     292      code rgb888!  ( n adr -- )
     293         pop   r0,sp
     294         strb  r0,[tos]
     295         mov   r0,r0,lsr #8
     296         strb  r0,[tos,#1]
     297         mov   r0,r0,lsr #8
     298         strb  r0,[tos,#2]
     299         pop   tos,sp
     300      c;
     301      ' 3* to pixel*
     302      ' 3a+ to pixel+
     303      ' rgb888! to pixel!
     304      ' noop to convert-color
     305   [else]
     306      ' /w* to pixel*
     307      ' wa+ to pixel+
     308      ' w!  to pixel!
     309      ' argb>565-pixel to convert-color
     310   [then]
     311
     312   defer init-panel    ' noop to init-panel
     313   defer bright!       ' drop to bright!
     314   defer backlight-off ' noop to backlight-off
     315   defer backlight-on  ' noop to backlight-on
     316
     317   : display-on
     318      init-panel  \ Turns on DCON etc
     319      frame-buffer-adr  hdisp vdisp * >bytes  h# ffffffff lfill
     320      init-lcd
     321   ;
     322   : map-frame-buffer  ( -- )
     323      \ We use fb-mem-va directly instead of calling map-in on the physical address
     324      \ because the physical address changes with the total memory size.  The early
     325      \ assembly language startup code establishes the mapping.
     326      fb-mem-va to frame-buffer-adr
     327   ;
     328   " display"                      device-type
     329   " ISO8859-1" encode-string    " character-set" property
     330   0 0  encode-bytes  " iso6429-1983-colors"  property
     331
     332   \ Used as temporary storage for images by $get-image
     333   : graphmem  ( -- adr )  dimensions * pixel*  fb-mem-va +  ;
     334
     335   : display-install  ( -- )
     336      map-frame-buffer
     337      display-on
     338      default-font set-font
     339      width  height                           ( width height )
     340      over char-width / over char-height /    ( width height rows cols )
     341      /scanline depth fb-install              ( )
     342   ;
     343
     344   : display-remove  ( -- )  ;
     345   : display-selftest  ( -- failed? )  false  ;
     346
     347   ' display-install  is-install
     348   ' display-remove   is-remove
     349   ' display-selftest is-selftest
     350end-package
     351
     352devalias screen /display
     353   
     354[ifdef] use-small-font
     355create cp881-16  " ${BP}/ofw/termemu/cp881-16.obf" $file,
     356' cp881-16 to romfont
     357[else]
     358create 15x30pc  " ${BP}/ofw/termemu/15x30pc.psf" $file,
     359' 15x30pc to romfont
     360[then]
     361
     362\ LICENSE_BEGIN
     363\ Copyright (c) 2010 FirmWorks
     364\
     365\ Permission is hereby granted, free of charge, to any person obtaining
     366\ a copy of this software and associated documentation files (the
     367\ "Software"), to deal in the Software without restriction, including
     368\ without limitation the rights to use, copy, modify, merge, publish,
     369\ distribute, sublicense, and/or sell copies of the Software, and to
     370\ permit persons to whom the Software is furnished to do so, subject to
     371\ the following conditions:
     372\
     373\ The above copyright notice and this permission notice shall be
     374\ included in all copies or substantial portions of the Software.
     375\
     376\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     377\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     378\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     379\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     380\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     381\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     382\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     383\
     384\ LICENSE_END
  • cpu/arm/olpc/prefw.fth

    r3021 r3049  
    4343fload ${BP}/ofw/core/availpm.fth        \ Available memory list
    4444
    45 dev /
    46    " olpc,XO-1.75" model
    47    " OLPC" encode-string  " architecture" property
    48 \ The clock frequency of the root bus may be irrelevant, since the bus is internal to the SOC
    49 \    d# 1,000,000,000 " clock-frequency" integer-property
    50 device-end
    51 
    5245: (cpu-arch  ( -- adr len )
    5346   " architecture" root-phandle  get-package-property  drop
     
    230223\ fload ${BP}/ofw/gui/insticon.fth
    231224
     225\ Marvell MMP low-level stuff
     226fload ${BP}/cpu/arm/mmp2/pmua.fth
     227fload ${BP}/cpu/arm/mmp2/apbc.fth
     228fload ${BP}/cpu/arm/mmp2/irq.fth
     229fload ${BP}/cpu/arm/mmp2/timer.fth
     230fload ${BP}/cpu/arm/mmp2/twsi.fth
     231fload ${BP}/cpu/arm/mmp2/mfpr.fth
     232fload ${BP}/cpu/arm/mmp2/gpio.fth
     233
    232234\ Uninstall the diag menu from the general user interface vector
    233235\ so exiting from emacs doesn't invoke the diag menu.
  • cpu/arm/olpc/probemem.fth

    r2726 r3049  
    5757   h# 20 +loop       \ h# 20 is L1 line size
    5858
    59    h# 10000 0  do    \ Loop over sets - h# 10000 is L2 #sets
     59   l2-#sets 0  do    \ Loop over sets
    6060      0 0  do        \ Loop over ways
    6161         i j + 2+ clean&flush-d$-entry-way  \ Operate on L2 cache (2+)
  • cpu/arm/olpc/rtc.fth

    r3023 r3049  
    1616[ifdef] cl2-a1
    1717: set-address  ( -- )
    18    d# 97 to smb-clock-gpio#
    19    d# 98 to smb-data-gpio#
     18   rtc-scl-gpio# to smb-clock-gpio#
     19   rtc-sda-gpio# to smb-data-gpio#
    2020   h# d0 to smb-slave
    2121;
  • cpu/arm/olpc/sdhci.fth

    r3040 r3049  
    1818   : gpio-power-on  ( -- )
    1919      sdhci-card-power-on
    20 \ The CL3 version below actually works for CL2 >= B1
    21 \+ olpc-cl2  d# 36 slot - gpio-set
    22 \+ olpc-cl3  slot 2 =  if  d# 34 gpio-set  then
     20      slot 2 =  if  en-wlan-pwr-gpio# gpio-set  then
    2321   ;
    2422   ' gpio-power-on to card-power-on
    2523
    2624   : gpio-power-off  ( -- )
    27 \+ olpc-cl2  d# 36 slot - gpio-clr
    28 \+ olpc-cl3  slot 2 =  if  d# 34 gpio-clr  then
     25      slot 2 =  if  en-wlan-pwr-gpio# gpio-clr  then
    2926      sdhci-card-power-off
    3027   ;
    3128   ' gpio-power-off to card-power-off
    32 
    33 \+ olpc-cl2   new-device
    34 \+ olpc-cl2      1 encode-int " reg" property
    35 \+ olpc-cl2      fload ${BP}/dev/mmc/sdhci/sdmmc.fth
    36 \+ olpc-cl2      fload ${BP}/dev/mmc/sdhci/selftest.fth
    37 \+ olpc-cl2      " external" " slot-name" string-property
    38 \+ olpc-cl2   finish-device
    3929
    4030   new-device
  • cpu/arm/olpc/sound.fth

    r3023 r3049  
    228228
    229229\ Reset is unconnected on current boards
    230 \ : audio-reset  ( -- )  8 gpio-clr  ;
    231 \ : audio-unreset  ( -- )  8 gpio-set  ;
     230\ : audio-reset  ( -- )  audio-reset-gpio# gpio-clr  ;
     231\ : audio-unreset  ( -- )  audio-reset-gpio# gpio-set  ;
    232232: codec@  ( reg# -- w )  choose-smbus  1 2 twsi-get  swap bwjoin  ;
    233233: codec!  ( w reg# -- )  choose-smbus  >r wbsplit r> 3 twsi-out  ;
     
    441441: watch-dc  ( bias? -- )
    442442   to mic-bias?
    443    d# 143 gpio-set   \ DC input mode
     443   mic-ac/dc-gpio# gpio-set   \ DC input mode
    444444   h# 0400 h# 40 codec-clr
    445445   open-in
  • cpu/x86/pc/olpc/sound.fth

    r2753 r3049  
    5555;
    5656
    57 [ifndef] olpc-cl3
     57[ifndef] use-screen-kbd
    5858dev /keyboard
    59590 value waiting-up?
  • dev/olpc/dcon/mmp2dcon.fth

    r2726 r3049  
    5252
    5353: set-dcon-slave  ( -- )
    54 [ifdef] cl2-a1
    55    d# 162 to smb-clock-gpio#
    56    d# 163 to smb-data-gpio#
    57 [else]
    58    d# 161 to smb-clock-gpio#
    59    d# 110 to smb-data-gpio#
    60 [then]
     54   dcon-scl-gpio# to smb-clock-gpio#
     55   dcon-sda-gpio# to smb-data-gpio#
     56
    6157   h# 1a to smb-slave
    6258;
     
    6763: dcon!  ( word reg# -- )  set-dcon-slave  smb-word!  ;
    6864
    69 [ifdef] cl2-a1
    70 : dcon-load  ( -- )  d# 151 gpio-set  ;
    71 : dcon-unload  ( -- )  d# 151 gpio-clr  ;
    72 [else]
    73 : dcon-load  ( -- )  d# 142 gpio-set  ;
    74 : dcon-unload  ( -- )  d# 142 gpio-clr  ;
    75 [then]
     65: dcon-load  ( -- )  dcon-load-gpio# gpio-set  ;
     66: dcon-unload  ( -- )  dcon-load-gpio# gpio-clr  ;
     67
    7668\ : dcon-blnk?  ( -- flag )  ;  \ Not hooked up
    77 : dcon-stat@  ( -- n )  h# 019100 io@ 4 rshift 3 and  ;
    78 : setup-dcon-irq  ( -- )  d# 124 dup gpio-set-fer  gpio-clr-edge  ;
    79 : dcon-irq?  ( -- flag )  d# 124 gpio-edge@  ;
     69: dcon-stat@  ( -- n )  h# 019100 io@ 4 rshift 3 and  ;  \ GPIO 100..101
     70: setup-dcon-irq  ( -- )  dcon-irq-gpio# dup gpio-set-fer  gpio-clr-edge  ;
     71: dcon-irq?  ( -- flag )  dcon-irq-gpio# gpio-edge@  ;
    8072
    8173\ DCONSTAT values:  0 SCANINT  1 SCANINT_DCON  2 DISPLAYLOAD  3 MISSED
     
    152144: timeout! ( to -- )      8 dcon!  ;  \ def: h# ffff
    153145: scanint! ( si -- )      9 dcon!  ;  \ def: h# 0000
    154 : bright!  ( level -- ) d# 10 dcon! ; \ def: h# xxxF
     146: dcon-bright!  ( level -- ) d# 10 dcon! ; \ def: h# xxxF
     147' dcon-bright!  to bright!
    155148: bright@  ( -- level ) d# 10 dcon@ ;
    156149: brighter  ( -- )  bright@ 1+  h# f min  bright!  ;
    157150: dimmer    ( -- )  bright@ 1-  0 max  bright!  ;
    158151
    159 : backlight-off  ( -- )  mode@  8 invert and  mode!  ;
    160 : backlight-on   ( -- )  mode@  8 or  mode!  ;
     152: dcon-backlight-off  ( -- )  mode@  8 invert and  mode!  ;
     153' dcon-backlight-off to backlight-off
     154: dcon-backlight-on   ( -- )  mode@  8 or  mode!  ;
     155' dcon-backlight-on to backlight-on
    161156
    162157\ Color swizzle, AA, no passthrough, backlight
     
    220215: maybe-set-cmos  ( -- )  ;
    221216
    222 : init-xo-display  ( -- )
     217: init-dcon  ( -- )
    223218   smb-init
    224219
     
    227222   \ dcon-enable leaves mode set to 69 - 40:antialias, 20:swizzle, 8:backlight on, 1:passthru off
    228223;
     224' init-dcon to init-panel
     225
    229226: dcon-power-on   ( -- )  1 h# 26 ec-cmd-b!  ;
    230227: dcon-power-off  ( -- )  0 h# 26 ec-cmd-b!  ;
  • dev/olpc/kb3700/spicmd.fth

    r3023 r3049  
    4343: decode-unit  ( adr len -- phys )  push-hex  $number  if  0  then  pop-base  ;
    4444
    45 d# 155 constant cmd-gpio#
    46 d# 125 constant ack-gpio#
    47 
    4845\ Channel#(port#) Meaning
    4946\ 0              Invalid
     
    162159\ Set the direction on the ACK and CMD GPIOs
    163160: init-gpios  ( -- )
    164    cmd-gpio# gpio-dir-out
    165    ack-gpio# gpio-dir-out
    166 ;
    167 : clr-cmd  ( -- )  cmd-gpio# gpio-clr  ;
    168 : set-cmd  ( -- )  cmd-gpio# gpio-set  ;
    169 : clr-ack  ( -- )  ack-gpio# gpio-clr  ;
    170 : set-ack  ( -- )  ack-gpio# gpio-set  ;
     161   ec-spi-cmd-gpio# gpio-dir-out
     162   ec-spi-ack-gpio# gpio-dir-out
     163;
     164: clr-cmd  ( -- )  ec-spi-cmd-gpio# gpio-clr  ;
     165: set-cmd  ( -- )  ec-spi-cmd-gpio# gpio-set  ;
     166: clr-ack  ( -- )  ec-spi-ack-gpio# gpio-clr  ;
     167: set-ack  ( -- )  ec-spi-ack-gpio# gpio-set  ;
    171168: fast-ack  ( -- )  set-ack clr-ack  debug?  if  ." ACK " cr  then  ;
    172169: slow-ack  ( -- )  d# 10 ms  set-ack d# 10 ms  clr-ack  ;
  • dev/olpc/mmp2camera/platform.fth

    r2880 r3049  
    88: camera-smb-setup  ( -- )
    99   1 to smb-dly-us
    10 \+ olpc-cl2   d# 108 to smb-clock-gpio#
    11 \+ olpc-cl2   d# 109 to smb-data-gpio#
    12 \+ olpc-cl3   d#   4 to smb-clock-gpio#
    13 \+ olpc-cl3   d#   5 to smb-data-gpio#
     10   cam-scl-gpio# to smb-clock-gpio#
     11   cam-sda-gpio# to smb-data-gpio#
    1412   camera-smb-slave to smb-slave
    1513;
     
    1917
    2018: reset-sensor  ( -- )
    21 \+ olpc-cl3   d#  10 gpio-clr  1 ms  d#  10 gpio-set
    22 \+ olpc-cl2   d# 102 gpio-clr  1 ms  d# 102 gpio-set
     19   cam-rst-gpio# gpio-clr  1 ms  cam-rst-gpio# gpio-set
    2320;
    2421
    25 [ifdef] cl2-a1
    26 : sensor-power-on   ( -- )  d# 145 gpio-set  ;
    27 : sensor-power-off  ( -- )  d# 145 gpio-clr  ;
    28 [else]
    2922: sensor-power-on   ( -- )
    30    d# 150 gpio-set
    31 \+ olpc-cl2  d# 144 gpio-clr
    32 \+ olpc-cl3  d#   9 gpio-clr
     23   cam-pwr-gpio# gpio-set
     24   cam-pwrdn-gpio# gpio-clr
    3325;
    34 : sensor-power-off  ( -- )  ( d# 144 gpio-set )  d# 150 gpio-clr  ;  \ Leave low for Linux
     26: sensor-power-off  ( -- )
     27   ( cam-pwrdn-gpio# gpio-set )       \ Leave low for Linux
     28   cam-pwr-gpio# gpio-clr
     29;
    3530[then]
    3631
  • dev/olpc/spiflash/spiui.fth

    r2705 r3049  
    7575   ." Got firmware version: "
    7676   flash-buf h# f.ffc0 +  dup  h# 10  type cr  ( adr )
    77    machine-signature count comp  abort" Wrong machine signature"
     77   signature$ comp  abort" Wrong machine signature"
    7878
    7979   ?crc
     
    291291   dup /flash <>  abort" Wrong image length"      ( adr len )
    292292   2dup +  h# 40 -                                ( adr len signature-adr )
    293    machine-signature count comp  abort" Wrong machine signature"
     293   signature$ comp  abort" Wrong machine signature"
    294294                                                  ( adr len signature-adr )
    295295   ." Firmware: " h# 10 type                      ( adr len )
Note: See TracChangeset for help on using the changeset viewer.