Author: wmb Date: Fri Aug 31 02:22:06 2012 New Revision: 3260 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3260
Log: 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.
Modified: cpu/arm/olpc/build-fw.fth cpu/arm/olpc/gpio-i2c.fth dev/olpc/dcon/mmp2dcon.fth
Modified: cpu/arm/olpc/build-fw.fth ============================================================================== --- cpu/arm/olpc/build-fw.fth Fri Aug 31 01:52:44 2012 (r3259) +++ cpu/arm/olpc/build-fw.fth Fri Aug 31 02:22:06 2012 (r3260) @@ -101,6 +101,8 @@
fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer
+fload ${BP}/cpu/arm/olpc/smbus.fth \ Bit-banged SMBUS (I2C) using GPIOs + fload ${BP}/cpu/arm/olpc/gpio-i2c.fth fload ${BP}/cpu/arm/olpc/twsi-i2c.fth
@@ -134,8 +136,6 @@
\needs md5init fload ${BP}/ofw/ppp/md5.fth \ MD5 hash
-fload ${BP}/cpu/arm/olpc/smbus.fth \ Bit-banged SMBUS (I2C) using GPIOs - fload ${BP}/dev/olpc/spiflash/flashif.fth \ Generic FLASH interface
fload ${BP}/dev/olpc/spiflash/spiif.fth \ Generic low-level SPI bus access
Modified: cpu/arm/olpc/gpio-i2c.fth ============================================================================== --- cpu/arm/olpc/gpio-i2c.fth Fri Aug 31 01:52:44 2012 (r3259) +++ cpu/arm/olpc/gpio-i2c.fth Fri Aug 31 02:22:06 2012 (r3260) @@ -36,14 +36,26 @@ 1 " #size-cells" integer-property : encode-unit ( phys.. -- str ) push-hex (u.) pop-base ; : decode-unit ( str -- phys.. ) push-hex $number if 0 then pop-base ; - : open ( -- flag ) true ; - : close ( -- ) ;
0 0 encode-bytes cam-sda-gpio# 0 encode-gpio cam-scl-gpio# 0 encode-gpio " gpios" property
+ 0 instance value slave-address + : set-address ( slave -- ) to slave-address ; + : smb-setup + 1 to smb-dly-us cam-scl-gpio# to smb-clock-gpio# + cam-sda-gpio# to smb-data-gpio# + slave-address to smb-slave + ; + \ Since this I2C bus is dedicated to the DCON, we save space by + \ implementing only the methods that the DCON uses + : reg-b@ ( reg# -- b ) smb-setup smb-byte@ ; + : reg-b! ( b reg# -- ) smb-setup smb-byte! ; + : open ( -- flag ) true ; + : close ( -- ) ; + new-device " image-sensor" device-name
@@ -56,7 +68,6 @@ cam-pwr-gpio# 0 encode-gpio cam-rst-gpio# 0 encode-gpio " gpios" property - finish-device finish-device
@@ -67,12 +78,30 @@ 1 " #size-cells" integer-property : encode-unit ( phys.. -- str ) push-hex (u.) pop-base ; : decode-unit ( str -- phys.. ) push-hex $number if 0 then pop-base ; - : open ( -- flag ) true ; - : close ( -- ) ;
0 0 encode-bytes dcon-sda-gpio# 0 encode-gpio dcon-scl-gpio# 0 encode-gpio " gpios" property + + 0 instance value slave-address + : set-address ( slave -- ) to slave-address ; + : smb-setup ( -- ) + dcon-scl-gpio# to smb-clock-gpio# + dcon-sda-gpio# to smb-data-gpio# + slave-address to smb-slave + ; + + \ Since this I2C bus is dedicated to the DCON, we save space by + \ implementing only the methods that the DCON uses + + : reg-w@ ( reg# -- w ) smb-setup smb-word@ ; + : reg-w! ( w reg# -- ) smb-setup smb-word! ; + + : bus-reset ( -- ) smb-setup smb-stop 1 ms smb-off 1 ms smb-on ; + : bus-init ( -- ) smb-setup smb-on smb-pulses ; + + : open ( -- flag ) true ; + : close ( -- ) ; finish-device device-end
Modified: dev/olpc/dcon/mmp2dcon.fth ============================================================================== --- dev/olpc/dcon/mmp2dcon.fth Fri Aug 31 01:52:44 2012 (r3259) +++ dev/olpc/dcon/mmp2dcon.fth Fri Aug 31 02:22:06 2012 (r3260) @@ -53,18 +53,11 @@ \ h# 4000 constant DM_DEBUG \ h# 8000 constant DM_SELFTEST
-: set-dcon-slave ( -- ) - dcon-scl-gpio# to smb-clock-gpio# - dcon-sda-gpio# to smb-data-gpio# +: bus-init ( -- ) " bus-init" $call-parent ; +: bus-reset ( -- ) " bus-reset" $call-parent ;
- h# 0d to smb-slave -; - -: smb-init ( -- ) set-dcon-slave smb-on smb-pulses ; -: smb-reset ( -- ) smb-stop 1 ms smb-off 1 ms smb-on ; - -: dcon@ ( reg# -- word ) set-dcon-slave smb-word@ ; -: dcon! ( word reg# -- ) set-dcon-slave smb-word! ; +: dcon@ ( reg# -- word ) " reg-w@" $call-parent ; +: dcon! ( word reg# -- ) " reg-w!" $call-parent ;
: dcon-load ( -- ) dcon-load-gpio# gpio-set ; : dcon-unload ( -- ) dcon-load-gpio# gpio-clr ; @@ -134,7 +127,7 @@ \ gx_configure_tft(info);
: try-dcon! ( w reg# -- ) - ['] dcon! catch if 2drop smb-reset then + ['] dcon! catch if 2drop bus-reset then ;
: mode@ ( -- mode ) 1 dcon@ ; @@ -171,14 +164,14 @@ ;
\ Setup so it can be called by execute-device-method -: dcon-off ( -- ) smb-init h# 12 ['] mode! catch if drop then ; +: dcon-off ( -- ) bus-init h# 12 ['] mode! catch if drop then ;
: dcon2? ( -- flag ) 5 0 do 0 ['] dcon@ catch 0= if ( x ) h# dc02 = unloop exit then ( x ) - drop d# 50 ms smb-init ( ) + drop d# 50 ms bus-init ( ) loop false ; @@ -217,7 +210,7 @@
[ifdef] old-way : init-dcon ( -- ) - smb-init + bus-init
\ Unnecessary because CForth has already done it \ dcon-load dcon-enable ( maybe-set-cmos ) @@ -226,7 +219,8 @@ ' init-dcon to init-panel [else] : open ( -- flag ) - smb-init + my-unit " set-address" $call-parent + bus-init \ Unnecessary because CForth has already done it \ dcon-load dcon-enable ( maybe-set-cmos ) \ dcon-enable leaves mode set to 69 - 40:antialias, 20:swizzle, 8:backlight on, 1:passthru off