Changeset 3260


Ignore:
Timestamp:
Aug 31, 2012, 12:22:06 AM (3 years ago)
Author:
wmb
Message:

OLPC ARM - Converted the MMP2 DCON driver to call it's I2C parent bus for I2C services, instead of using the bit-banged SMBUS driver directly. Also added I2C methods to the parent node for the image sensor, paving the way for later conversion of that driver.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpu/arm/olpc/build-fw.fth

    r3259 r3260  
    102102fload ${BP}/cpu/arm/mmp2/watchdog.fth   \ reset-all using watchdog timer
    103103
     104fload ${BP}/cpu/arm/olpc/smbus.fth         \ Bit-banged SMBUS (I2C) using GPIOs
     105
    104106fload ${BP}/cpu/arm/olpc/gpio-i2c.fth
    105107fload ${BP}/cpu/arm/olpc/twsi-i2c.fth
     
    134136
    135137\needs md5init  fload ${BP}/ofw/ppp/md5.fth                \ MD5 hash
    136 
    137 fload ${BP}/cpu/arm/olpc/smbus.fth         \ Bit-banged SMBUS (I2C) using GPIOs
    138138
    139139fload ${BP}/dev/olpc/spiflash/flashif.fth  \ Generic FLASH interface
  • cpu/arm/olpc/gpio-i2c.fth

    r3234 r3260  
    3737      : encode-unit  ( phys.. -- str )  push-hex (u.) pop-base  ;
    3838      : decode-unit  ( str -- phys.. )  push-hex  $number  if  0  then  pop-base  ;
    39       : open  ( -- flag )  true  ;
    40       : close  ( -- )  ;
    4139     
    4240      0 0 encode-bytes
     
    4442          cam-scl-gpio# 0 encode-gpio
    4543      " gpios" property
     44
     45      0 instance value slave-address
     46      : set-address  ( slave -- )  to slave-address  ;
     47      : smb-setup
     48         1 to smb-dly-us cam-scl-gpio# to smb-clock-gpio#
     49         cam-sda-gpio# to smb-data-gpio#
     50         slave-address to smb-slave
     51      ;
     52      \ Since this I2C bus is dedicated to the DCON, we save space by
     53      \ implementing only the methods that the DCON uses
     54      : reg-b@  ( reg# -- b )  smb-setup smb-byte@  ;
     55      : reg-b!  ( b reg# -- )  smb-setup smb-byte!  ;
     56      : open  ( -- flag )  true  ;
     57      : close  ( -- )  ;
    4658
    4759      new-device
     
    5769            cam-rst-gpio# 0 encode-gpio
    5870         " gpios" property
    59 
    6071      finish-device
    6172   finish-device
     
    6879      : encode-unit  ( phys.. -- str )  push-hex (u.) pop-base  ;
    6980      : decode-unit  ( str -- phys.. )  push-hex  $number  if  0  then  pop-base  ;
    70       : open  ( -- flag )  true  ;
    71       : close  ( -- )  ;
    7281
    7382      0 0 encode-bytes
     
    7584         dcon-scl-gpio# 0 encode-gpio
    7685      " gpios" property
     86
     87      0 instance value slave-address
     88      : set-address  ( slave -- )  to slave-address  ;
     89      : smb-setup  ( -- )
     90         dcon-scl-gpio# to smb-clock-gpio#
     91         dcon-sda-gpio# to smb-data-gpio#
     92         slave-address to smb-slave
     93      ;
     94
     95      \ Since this I2C bus is dedicated to the DCON, we save space by
     96      \ implementing only the methods that the DCON uses
     97
     98      : reg-w@  ( reg# -- w )  smb-setup smb-word@  ;
     99      : reg-w!  ( w reg# -- )  smb-setup smb-word!  ;
     100
     101      : bus-reset  ( -- )  smb-setup smb-stop 1 ms  smb-off  1 ms  smb-on  ;
     102      : bus-init  ( -- )  smb-setup  smb-on  smb-pulses  ;
     103
     104      : open  ( -- flag )  true  ;
     105      : close  ( -- )  ;
    77106   finish-device
    78107device-end
  • dev/olpc/dcon/mmp2dcon.fth

    r3197 r3260  
    5454\ h# 8000 constant DM_SELFTEST
    5555
    56 : set-dcon-slave  ( -- )
    57    dcon-scl-gpio# to smb-clock-gpio#
    58    dcon-sda-gpio# to smb-data-gpio#
    59 
    60    h# 0d to smb-slave
    61 ;
    62 
    63 : smb-init    ( -- )  set-dcon-slave  smb-on  smb-pulses  ;
    64 : smb-reset   ( -- )  smb-stop 1 ms  smb-off  1 ms  smb-on   ;
    65 
    66 : dcon@  ( reg# -- word )  set-dcon-slave  smb-word@  ;
    67 : dcon!  ( word reg# -- )  set-dcon-slave  smb-word!  ;
     56: bus-init  ( -- )  " bus-init" $call-parent  ;
     57: bus-reset  ( -- )  " bus-reset" $call-parent  ;
     58
     59: dcon@  ( reg# -- word )  " reg-w@" $call-parent  ;
     60: dcon!  ( word reg# -- )  " reg-w!" $call-parent  ;
    6861
    6962: dcon-load  ( -- )  dcon-load-gpio# gpio-set  ;
     
    135128
    136129: try-dcon!  ( w reg# -- )
    137    ['] dcon!  catch  if  2drop  smb-reset  then
     130   ['] dcon!  catch  if  2drop  bus-reset  then
    138131;
    139132
     
    172165
    173166\ Setup so it can be called by execute-device-method
    174 : dcon-off  ( -- )  smb-init  h# 12 ['] mode!  catch  if  drop  then  ;
     167: dcon-off  ( -- )  bus-init  h# 12 ['] mode!  catch  if  drop  then  ;
    175168
    176169: dcon2?  ( -- flag )
     
    179172         h# dc02 =  unloop exit
    180173      then                         ( x )
    181       drop   d# 50 ms  smb-init    ( )
     174      drop   d# 50 ms  bus-init    ( )
    182175   loop
    183176   false
     
    218211[ifdef] old-way
    219212: init-dcon  ( -- )
    220    smb-init
     213   bus-init
    221214
    222215\ Unnecessary because CForth has already done it
     
    227220[else]
    228221: open  ( -- flag )
    229    smb-init
     222   my-unit " set-address" $call-parent
     223   bus-init
    230224\ Unnecessary because CForth has already done it
    231225\   dcon-load  dcon-enable  ( maybe-set-cmos )
Note: See TracChangeset for help on using the changeset viewer.