Changeset 3260
- Timestamp:
- Aug 31, 2012 2:22:06 AM (9 months ago)
- Files:
-
- 3 edited
-
cpu/arm/olpc/build-fw.fth (modified) (2 diffs)
-
cpu/arm/olpc/gpio-i2c.fth (modified) (5 diffs)
-
dev/olpc/dcon/mmp2dcon.fth (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cpu/arm/olpc/build-fw.fth
r3259 r3260 102 102 fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer 103 103 104 fload ${BP}/cpu/arm/olpc/smbus.fth \ Bit-banged SMBUS (I2C) using GPIOs 105 104 106 fload ${BP}/cpu/arm/olpc/gpio-i2c.fth 105 107 fload ${BP}/cpu/arm/olpc/twsi-i2c.fth … … 134 136 135 137 \needs md5init fload ${BP}/ofw/ppp/md5.fth \ MD5 hash 136 137 fload ${BP}/cpu/arm/olpc/smbus.fth \ Bit-banged SMBUS (I2C) using GPIOs138 138 139 139 fload ${BP}/dev/olpc/spiflash/flashif.fth \ Generic FLASH interface -
cpu/arm/olpc/gpio-i2c.fth
r3234 r3260 37 37 : encode-unit ( phys.. -- str ) push-hex (u.) pop-base ; 38 38 : decode-unit ( str -- phys.. ) push-hex $number if 0 then pop-base ; 39 : open ( -- flag ) true ;40 : close ( -- ) ;41 39 42 40 0 0 encode-bytes … … 44 42 cam-scl-gpio# 0 encode-gpio 45 43 " 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 ( -- ) ; 46 58 47 59 new-device … … 57 69 cam-rst-gpio# 0 encode-gpio 58 70 " gpios" property 59 60 71 finish-device 61 72 finish-device … … 68 79 : encode-unit ( phys.. -- str ) push-hex (u.) pop-base ; 69 80 : decode-unit ( str -- phys.. ) push-hex $number if 0 then pop-base ; 70 : open ( -- flag ) true ;71 : close ( -- ) ;72 81 73 82 0 0 encode-bytes … … 75 84 dcon-scl-gpio# 0 encode-gpio 76 85 " 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 ( -- ) ; 77 106 finish-device 78 107 device-end -
dev/olpc/dcon/mmp2dcon.fth
r3197 r3260 54 54 \ h# 8000 constant DM_SELFTEST 55 55 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 ; 68 61 69 62 : dcon-load ( -- ) dcon-load-gpio# gpio-set ; … … 135 128 136 129 : try-dcon! ( w reg# -- ) 137 ['] dcon! catch if 2drop smb-reset then130 ['] dcon! catch if 2drop bus-reset then 138 131 ; 139 132 … … 172 165 173 166 \ 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 ; 175 168 176 169 : dcon2? ( -- flag ) … … 179 172 h# dc02 = unloop exit 180 173 then ( x ) 181 drop d# 50 ms smb-init ( )174 drop d# 50 ms bus-init ( ) 182 175 loop 183 176 false … … 218 211 [ifdef] old-way 219 212 : init-dcon ( -- ) 220 smb-init213 bus-init 221 214 222 215 \ Unnecessary because CForth has already done it … … 227 220 [else] 228 221 : open ( -- flag ) 229 smb-init 222 my-unit " set-address" $call-parent 223 bus-init 230 224 \ Unnecessary because CForth has already done it 231 225 \ dcon-load dcon-enable ( maybe-set-cmos )
Note: See TracChangeset
for help on using the changeset viewer.
