Changeset 3255


Ignore:
Timestamp:
Aug 31, 2012, 12:57:10 AM (20 months ago)
Author:
wmb
Message:

OLPC ARM - Created a proper device-tree factoring of the OFW TWSI driver with the goal of replacing the present global version. The new version has methods in /i2c@N nodes, delegating the work to code in /packages/twsi . The global version is still present and is still used for RTC and touchscreen. The codec and accelerometer drivers have been converted over to use the new code. This resolves OLPC Trac #12072 (there was a simpler way to fix 12072, by renaming one of the accelerometer nodes, but this refactoring needed to be done eventually.)

Location:
cpu/arm
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • cpu/arm/olpc/accelerometer.fth

    r3183 r3255  
    1 hex 
    2 0 0  " "  " /twsi" begin-package 
     1dev /i2c@d4034000  \ TWSI6 
     2new-device 
     3 
    34" accelerometer" name 
     5" lis3lv02d" +compatible 
    46 
    57\ reg is set dynamically by probing to find which chip is present 
    6 \ my-address my-space encode-phys  " reg" property 
    78 
    89\ This is for the stand-alone accelerometers LIS3DHTR and LIS33DETR 
    910 
    1011\ We could call this just once in open if we had a TWSI parent node 
    11 : acc-reg@  ( reg# -- b )  1 1 " smbus-out-in" $call-parent  ; 
    12 : acc-reg!  ( b reg# -- )  2 0 " smbus-out-in" $call-parent  ; 
     12: acc-reg@  ( reg# -- b )  " byte@" $call-parent  ; 
     13: acc-reg!  ( b reg# -- )  " byte!" $call-parent  ; 
    1314: ctl1!  ( b -- )  h# 20 acc-reg!  ; 
    1415: ctl4!  ( b -- )  h# 23 acc-reg!  ; 
     
    1819: acceleration@  ( -- x y z ) 
    1920   begin  h# 27 acc-reg@  h# 08 and  until  \ wait for data available 
    20    h# 0a8 1 6 " smbus-out-in" $call-parent ( xl xh yl yh zl zh ) 
     21   h# 0a8 1 6 " bytes-out-in" $call-parent ( xl xh yl yh zl zh ) 
    2122   bwjoin wext 5 >>a     ( xl xh yl yh z ) 
    2223   >r                    ( xl xh yl yh     r: z ) 
     
    143144 
    144145: probe  ( -- ) 
    145    h# 3a 6 " set-address" $call-parent 
     146   h# 1d " set-address" $call-parent 
    146147   d# 25,000 " set-bus-speed" $call-parent \ XO-1.75 B1 lacks pullups SCL SDA 
    147148   ['] accelerometer-on catch  if 
     
    151152      d#  50 to min-x  d#  50 to min-y  d#  50 to min-z 
    152153      d# 150 to max-x  d# 150 to max-y  d# 450 to max-z 
    153       h# 19 6 encode-phys " reg" property 
     154      h# 19 1 reg 
    154155      ['] lis3dhtr-selftest to lis-selftest 
    155156   else 
     
    160161      d#  20 to min-x  d#  20 to min-y  d#  20 to min-z 
    161162      d# 400 to max-x  d# 400 to max-y  d# 400 to max-z 
    162       h# 1d 6 encode-phys " reg" property 
     163      h# 1d 1 reg 
    163164      ['] lis33de-selftest to lis-selftest 
    164165   then 
    165166; 
    166167 
    167 end-package 
     168finish-device 
     169device-end 
    168170 
    169171stand-init: Accelerometer 
  • cpu/arm/olpc/prefw.fth

    r3168 r3255  
    233233fload ${BP}/cpu/arm/mmp2/mfpr.fth 
    234234 
     235fload ${BP}/cpu/arm/mmp2/twsi-package.fth 
     236 
    235237\ Uninstall the diag menu from the general user interface vector 
    236238\ so exiting from emacs doesn't invoke the diag menu. 
  • cpu/arm/olpc/rtc.fth

    r3207 r3255  
    11purpose: Driver for external IDT1388 RTC chip on XO-1.75 
    22 
    3 0 0  " 68" " /i2c@d4031000" begin-package  \ TWSI2 
     3dev /i2c@d4031000  \ TWSI2 
     4new-device 
    45   " rtc" name 
    56   " idt,idt1338-rtc" +compatible 
    6    my-address my-space 1 reg 
     7   h# 68 1 reg 
    78 
    89[ifdef] cl2-a1 
     
    9293; 
    9394 
    94 end-package 
     95finish-device 
     96device-end 
  • cpu/arm/olpc/sound.fth

    r3238 r3255  
    1 0 0  " 1a" " /i2c@d4011000" begin-package  \ TWSI1 
     1dev /i2c@d4011000 
     2new-device 
    23   " audio-codec" name 
    34   " realtek,alc5631" +compatible 
    45   " realtek,rt5631" +compatible 
    5    my-address my-space 1 reg 
     6   h# 1a 1 reg 
    67   " rt5631-hifi" " dai-name" string-property  \ snd_soc_dai_link.codec_dai_name 
    7 end-package 
     8   : open  ( -- true )     my-unit " set-address" $call-parent  true  ; 
     9   : close  ( -- )  ; 
     10   : codec@  ( reg# -- w )  1 2 " bytes-out-in" $call-parent  swap bwjoin  ; 
     11   : codec!  ( w reg# -- )  >r wbsplit r>  3 " bytes-out" $call-parent  ; 
     12finish-device 
     13device-end 
    814 
    915: +audio  ( offset -- address ) 
     
    289295; 
    290296 
    291 [ifdef] cl2-a1 
    292 : choose-smbus  ( -- )  h# 18 1 set-twsi-target  ; 
    293 [else] 
    294 : choose-smbus  ( -- )  h# 1a 1 set-twsi-target  ; 
    295 [then] 
    296  
    297297\ Reset is unconnected on current boards 
    298298\ : audio-reset  ( -- )  audio-reset-gpio# gpio-clr  ; 
    299299\ : audio-unreset  ( -- )  audio-reset-gpio# gpio-set  ; 
    300 : codec@  ( reg# -- w )  choose-smbus  1 2 twsi-get  swap bwjoin  ; 
    301 : codec!  ( w reg# -- )  choose-smbus  >r wbsplit r> 3 twsi-out  ; 
     3000 value codec-ih 
     301: $call-codec  ( ? -- ? )  codec-ih $call-method  ; 
     302 
     303: codec@  ( reg# -- w )  " codec@" $call-codec  ; 
     304: codec!  ( w reg# -- )  " codec!" $call-codec  ; 
     305 
    302306: codec-i@  ( index# -- w )  h# 6a codec!  h# 6c codec@  ; 
    303307: codec-i!  ( w index# -- )  h# 6a codec!  h# 6c codec!  ; 
     
    636640   0 to adma-base  0 to sspa-base 
    637641; 
     642 
    6386430 value open-count 
    639644: open  ( -- flag ) 
     
    642647      my-unit           h# 100 " map-in" $call-parent to sspa-base 
    643648      audio-clock-on  if  (close) false exit  then 
     649      " /audio-codec" open-dev to codec-ih 
     650      codec-ih 0=  if  (close) false exit  then 
    644651      init-codec 
    645652   then 
     
    650657   open-count 1 =  if 
    651658      uninstall-playback-alarm  codec-off 
     659      codec-ih close-dev 
    652660      (close) 
    653661   then 
  • cpu/arm/olpc/twsi-i2c.fth

    r3234 r3255  
    11purpose: Device tree nodes for board-specific I2C buses implemented by TWSI hardware 
    22 
    3 : make-twsi-node  ( baseadr clock# irq# muxed-irq? fast? unit# -- ) 
    4    root-device 
    5    new-device 
    6       " linux,unit#" integer-property 
    7       " i2c" name 
    8       " mrvl,mmp-twsi" +compatible                    ( baseadr clock# irq# muxed-irq? fast? ) 
    9       if  0 0  " mrvl,i2c-fast-mode" property  then   ( baseadr clock# irq# muxed-irq? ) 
    10       if 
    11           " /interrupt-controller/interrupt-controller@158" encode-phandle " interrupt-parent" property 
    12       then                                            ( baseadr clock# irq# ) 
    13       " interrupts" integer-property                  ( baseadr clock# ) 
    14       " /apbc" encode-phandle rot encode-int encode+ " clocks" property 
    15  
    16       h# 1000 reg                                     ( ) 
    17       1 " #address-cells" integer-property 
    18       1 " #size-cells" integer-property 
    19       " : open true ; : close ;" evaluate 
    20       " : encode-unit  ( phys.. -- str )  push-hex (u.) pop-base  ;" evaluate 
    21       " : decode-unit  ( str -- phys.. )  push-hex  $number  if  0  then  pop-base  ;" evaluate 
    22    finish-device 
    23    device-end 
    24 ;       
     3: make-twsi-node  " ${BP}/cpu/arm/mmp2/twsi-methods.fth" included  ; 
    254 
    265\     baseadr   clk irq mux? fast? unit# 
     
    3110\ h# d4038000 d# 30   3 true  true     N make-twsi-node  \ TWSI5 
    3211  h# d4034000 d# 31   4 true  true     4 make-twsi-node  \ TWSI6 
    33  
    3412 
    3513[ifdef] soon-olpc-cl2  \ this breaks cl4-a1 boards, which ofw calls cl2. 
     
    5028end-package 
    5129[then] 
    52  
    53 0 0  " 19" " /i2c@d4034000" begin-package  \ TWSI6 
    54    " accelerometer" name 
    55    " lis3lv02d" +compatible 
    56    my-address my-space 1 reg 
    57 end-package 
Note: See TracChangeset for help on using the changeset viewer.