Author: wmb Date: Wed Aug 29 02:10:05 2012 New Revision: 3234 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3234
Log: OLPC ARM - Moved the board-specific code to create I2C device nodes into OLPC-specific files.
Added: cpu/arm/olpc/gpio-i2c.fth cpu/arm/olpc/twsi-i2c.fth Modified: cpu/arm/mmp2/gpio.fth cpu/arm/mmp2/twsi.fth cpu/arm/olpc/build-fw.fth
Modified: cpu/arm/mmp2/gpio.fth ============================================================================== --- cpu/arm/mmp2/gpio.fth Tue Aug 28 18:25:56 2012 (r3233) +++ cpu/arm/mmp2/gpio.fth Wed Aug 29 02:10:05 2012 (r3234) @@ -77,52 +77,3 @@ h# 104 make-gpio-mux-node h# 108 make-gpio-mux-node end-package - -: encode-gpio ( propval$ gpio# low? -- propval$' ) - >r >r ( propval$ r: low? gpio# ) - " /gpio" encode-phandle encode+ ( propval$' r: low? gpio# ) - r> encode-int encode+ ( propval$' r: low? ) - r> encode-int encode+ ( propval$' ) -; - -: gpio-property ( gpionum low? gpioname$ -- ) - 2>r 2>r ( r: gpioname$ gpionum low? ) - 0 0 encode-bytes ( propval$ r: gpioname$ gpionum low? ) - 2r> encode-gpio ( propval$' r: gpioname$ ) - 2r> property ( ) -; - -dev / - new-device - " camera-i2c" device-name - " i2c-gpio" +compatible - 1 " #address-cells" integer-property - 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 - finish-device - - new-device - " dcon-i2c" device-name - " i2c-gpio" +compatible - 1 " #address-cells" integer-property - 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 - finish-device -device-end
Modified: cpu/arm/mmp2/twsi.fth ============================================================================== --- cpu/arm/mmp2/twsi.fth Tue Aug 28 18:25:56 2012 (r3233) +++ cpu/arm/mmp2/twsi.fth Wed Aug 29 02:10:05 2012 (r3234) @@ -163,62 +163,6 @@ : twsi-b! ( byte reg -- ) 2 twsi-out ;
[ifdef] begin-package -: make-twsi-node ( baseadr clock# irq# muxed-irq? fast? unit# -- ) - root-device - new-device - " linux,unit#" integer-property - " i2c" name - " mrvl,mmp-twsi" +compatible ( baseadr clock# irq# muxed-irq? fast? ) - if 0 0 " mrvl,i2c-fast-mode" property then ( baseadr clock# irq# muxed-irq? ) - if - " /interrupt-controller/interrupt-controller@158" encode-phandle " interrupt-parent" property - then ( baseadr clock# irq# ) - " interrupts" integer-property ( baseadr clock# ) - " /apbc" encode-phandle rot encode-int encode+ " clocks" property - - h# 1000 reg ( ) - 1 " #address-cells" integer-property - 1 " #size-cells" integer-property - " : open true ; : close ;" evaluate - " : encode-unit ( phys.. -- str ) push-hex (u.) pop-base ;" evaluate - " : decode-unit ( str -- phys.. ) push-hex $number if 0 then pop-base ;" evaluate - finish-device - device-end -; - -\ baseadr clk irq mux? fast? unit# - h# d4011000 1 7 false true 2 make-twsi-node \ TWSI1 - h# d4031000 2 0 true true 3 make-twsi-node \ TWSI2 -\ h# d4032000 3 1 true true N make-twsi-node \ TWSI3 - h# d4033000 4 2 true true 5 make-twsi-node \ TWSI4 -\ h# d4038000 d# 30 3 true true N make-twsi-node \ TWSI5 - h# d4034000 d# 31 4 true true 4 make-twsi-node \ TWSI6 - - -[ifdef] soon-olpc-cl2 \ this breaks cl4-a1 boards, which ofw calls cl2. -0 0 " 30" " /i2c@d4033000" begin-package \ TWSI4 - " touchscreen" name - " raydium_ts" +compatible - my-address my-space 1 reg -end-package -[else] -0 0 " 50" " /i2c@d4033000" begin-package \ TWSI4 - " touchscreen" name - " zforce" +compatible - my-address my-space 1 reg - touch-rst-gpio# 1 " reset-gpios" gpio-property - touch-tck-gpio# 1 " test-gpios" gpio-property - touch-hd-gpio# 1 " hd-gpios" gpio-property - touch-int-gpio# 1 " dr-gpios" gpio-property -end-package -[then] - -0 0 " 19" " /i2c@d4034000" begin-package \ TWSI6 - " accelerometer" name - " lis3lv02d" +compatible - my-address my-space 1 reg -end-package - 0 0 " " " /" begin-package " twsi" name
Modified: cpu/arm/olpc/build-fw.fth ============================================================================== --- cpu/arm/olpc/build-fw.fth Tue Aug 28 18:25:56 2012 (r3233) +++ cpu/arm/olpc/build-fw.fth Wed Aug 29 02:10:05 2012 (r3234) @@ -102,6 +102,9 @@
fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer
+fload ${BP}/cpu/arm/olpc/gpio-i2c.fth +fload ${BP}/cpu/arm/olpc/twsi-i2c.fth + 0 0 " d4018000" " /" begin-package \ UART3 fload ${BP}/cpu/arm/mmp2/uart.fth " /apbc" encode-phandle d# 12 encode-int encode+ " clocks" property
Added: cpu/arm/olpc/gpio-i2c.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/gpio-i2c.fth Wed Aug 29 02:10:05 2012 (r3234) @@ -0,0 +1,78 @@ +purpose: Device tree nodes for I2C buses implemented with GPIOs + +: encode-gpio ( propval$ gpio# low? -- propval$' ) + >r >r ( propval$ r: low? gpio# ) + " /gpio" encode-phandle encode+ ( propval$' r: low? gpio# ) + r> encode-int encode+ ( propval$' r: low? ) + r> encode-int encode+ ( propval$' ) +; + +: gpio-property ( gpionum low? gpioname$ -- ) + 2>r 2>r ( r: gpioname$ gpionum low? ) + 0 0 encode-bytes ( propval$ r: gpioname$ gpionum low? ) + 2r> encode-gpio ( propval$' r: gpioname$ ) + 2r> property ( ) +; + +: make-sensor-node ( name$ i2c-addr -- ) + " /camera-i2c" find-device ( name$ i2c-addr ) + new-device ( name$ i2c-addr ) + 1 reg ( name$ ) + +compatible ( ) + " image-sensor" device-name + 0 0 encode-bytes + cam-pwr-gpio# 0 encode-gpio + cam-rst-gpio# 0 encode-gpio + " gpios" property + finish-device + device-end +; + +dev / + new-device + " camera-i2c" device-name + " i2c-gpio" +compatible + 1 " #address-cells" integer-property + 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 + + new-device + " image-sensor" device-name + + \ The reg and compatible properties are set by probing, based on the actual + \ image sensor encountered. For example: + \ h# 21 1 reg + \ " omnivision,ov7670" +compatible + + 0 0 encode-bytes + cam-pwr-gpio# 0 encode-gpio + cam-rst-gpio# 0 encode-gpio + " gpios" property + + finish-device + finish-device + + new-device + " dcon-i2c" device-name + " i2c-gpio" +compatible + 1 " #address-cells" integer-property + 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 + finish-device +device-end
Added: cpu/arm/olpc/twsi-i2c.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/twsi-i2c.fth Wed Aug 29 02:10:05 2012 (r3234) @@ -0,0 +1,57 @@ +purpose: Device tree nodes for board-specific I2C buses implemented by TWSI hardware + +: make-twsi-node ( baseadr clock# irq# muxed-irq? fast? unit# -- ) + root-device + new-device + " linux,unit#" integer-property + " i2c" name + " mrvl,mmp-twsi" +compatible ( baseadr clock# irq# muxed-irq? fast? ) + if 0 0 " mrvl,i2c-fast-mode" property then ( baseadr clock# irq# muxed-irq? ) + if + " /interrupt-controller/interrupt-controller@158" encode-phandle " interrupt-parent" property + then ( baseadr clock# irq# ) + " interrupts" integer-property ( baseadr clock# ) + " /apbc" encode-phandle rot encode-int encode+ " clocks" property + + h# 1000 reg ( ) + 1 " #address-cells" integer-property + 1 " #size-cells" integer-property + " : open true ; : close ;" evaluate + " : encode-unit ( phys.. -- str ) push-hex (u.) pop-base ;" evaluate + " : decode-unit ( str -- phys.. ) push-hex $number if 0 then pop-base ;" evaluate + finish-device + device-end +; + +\ baseadr clk irq mux? fast? unit# + h# d4011000 1 7 false true 2 make-twsi-node \ TWSI1 + h# d4031000 2 0 true true 3 make-twsi-node \ TWSI2 +\ h# d4032000 3 1 true true N make-twsi-node \ TWSI3 + h# d4033000 4 2 true true 5 make-twsi-node \ TWSI4 +\ h# d4038000 d# 30 3 true true N make-twsi-node \ TWSI5 + h# d4034000 d# 31 4 true true 4 make-twsi-node \ TWSI6 + + +[ifdef] soon-olpc-cl2 \ this breaks cl4-a1 boards, which ofw calls cl2. +0 0 " 30" " /i2c@d4033000" begin-package \ TWSI4 + " touchscreen" name + " raydium_ts" +compatible + my-address my-space 1 reg +end-package +[else] +0 0 " 50" " /i2c@d4033000" begin-package \ TWSI4 + " touchscreen" name + " zforce" +compatible + my-address my-space 1 reg + touch-rst-gpio# 1 " reset-gpios" gpio-property + touch-tck-gpio# 1 " test-gpios" gpio-property + touch-hd-gpio# 1 " hd-gpios" gpio-property + touch-int-gpio# 1 " dr-gpios" gpio-property +end-package +[then] + +0 0 " 19" " /i2c@d4034000" begin-package \ TWSI6 + " accelerometer" name + " lis3lv02d" +compatible + my-address my-space 1 reg +end-package
openfirmware@openfirmware.info