Author: wmb
Date: Thu Dec 6 22:15:34 2012
New Revision: 3475
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3475
Log:
EDID decoder - (a) Fixed crash due to typo of " for ." (b) Fixed spurious + in audio decoding.
Modified:
dev/edid.fth
Modified: dev/edid.fth
==============================================================================
--- dev/edid.fth Thu Dec 6 08:03:54 2012 (r3474)
+++ dev/edid.fth Thu Dec 6 22:15:34 2012 (r3475)
@@ -141,21 +141,21 @@
\ Audio sample rates
: .cea-freqs ( n -- )
- peel-bit if ." 32" then ?.+
- peel-bit if ." 44" then ?.+
- peel-bit if ." 48" then ?.+
- peel-bit if ." 88" then ?.+
- peel-bit if ." 96" then ?.+
- peel-bit if ." 176" then ?.+
- peel-bit if ." 192" then drop
- ." kHz"
+ peel-bit if ." 32" ?.+ then
+ peel-bit if ." 44" ?.+ then
+ peel-bit if ." 48" ?.+ then
+ peel-bit if ." 88" ?.+ then
+ peel-bit if ." 96" ?.+ then
+ peel-bit if ." 176" ?.+ then
+ peel-bit if ." 192" then
+ ." kHz" drop
;
\ Audio sample widths
: .cea-bits ( n -- )
- peel-bit if ." 16" then ?.+
- peel-bit if ." 20" then ?.+
- peel-bit if ." 24" then drop
- ." bits"
+ peel-bit if ." 16" ?.+ then
+ peel-bit if ." 20" ?.+ then
+ peel-bit if ." 24" then
+ ." bits" drop
;
string-array format-names
@@ -284,13 +284,13 @@
\ rest is history.
: .cea-speaker ( offset size -- )
drop cea@
- peel-bit if " Front_L+R " then \ Stereo
- peel-bit if " LFE " then \ Subwoofer makes 2.1
- peel-bit if " Front_Center " then \ Center fill makes 3.1
- peel-bit if " Rear_L+R " then \ Ambience makes 5.1
- peel-bit if " Rear_Center " then \ 7.1 ...
- peel-bit if " Front_Center_L+R " then \ How many speakers do they want to sell you?
- peel-bit if " Rear_Center_L+R " then \ How can you live without twelve speakers?
+ peel-bit if ." Front_L+R " then \ Stereo
+ peel-bit if ." LFE " then \ Subwoofer makes 2.1
+ peel-bit if ." Front_Center " then \ Center fill makes 3.1
+ peel-bit if ." Rear_L+R " then \ Ambience makes 5.1
+ peel-bit if ." Rear_Center " then \ 7.1 ...
+ peel-bit if ." Front_Center_L+R " then \ How many speakers do they want to sell you?
+ peel-bit if ." Rear_Center_L+R " then \ How can you live without twelve speakers?
drop
;
Author: quozl
Date: Wed Dec 5 09:02:09 2012
New Revision: 3471
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3471
Log:
usbserial - FTDI232 driver for OLPC serial adapters
Modified:
dev/usb2/device/serial/common.fth
dev/usb2/device/serial/ftdi.fth
dev/usb2/device/serial/uart.fth
dev/usb2/device/serial/usbserial.bth
dev/usb2/device/serial/vendor.fth
Modified: dev/usb2/device/serial/common.fth
==============================================================================
--- dev/usb2/device/serial/common.fth Wed Dec 5 04:44:52 2012 (r3470)
+++ dev/usb2/device/serial/common.fth Wed Dec 5 09:02:09 2012 (r3471)
@@ -107,6 +107,29 @@
;
' generic-rpoll to rpoll
+[ifndef] /string
+: /string ( adr len cnt -- adr' len' ) tuck - -rot + swap ;
+[then]
+
+: generic-read-bytes ( adr len -- #read ) \ -2 for none available right now
+ rpoll
+ dup 0= if nip exit then ( adr len )
+ read-q deque? 0= if ( adr len )
+ 2drop ( )
+ lost-carrier? if -1 false to lost-carrier? else -2 then
+ ( -2:none | -1:down )
+ exit
+ then ( adr len char )
+ over >r ( adr len char r: len )
+ begin ( adr len char r: len )
+ 2 pick c! ( adr len r: len )
+ 1 /string ( adr' len' )
+ dup 0= if 2drop r> exit then ( adr' len' )
+ read-q deque? 0= until ( adr len r: len )
+ nip r> swap - ( actual )
+;
+' generic-read-bytes to read-bytes
+
: generic-write-bytes ( adr len -- actual )
swap >r ( len ) ( R: adr )
/outbuf /mod ( rem #loop )
Modified: dev/usb2/device/serial/ftdi.fth
==============================================================================
--- dev/usb2/device/serial/ftdi.fth Wed Dec 5 04:44:52 2012 (r3470)
+++ dev/usb2/device/serial/ftdi.fth Wed Dec 5 09:02:09 2012 (r3471)
@@ -20,10 +20,14 @@
: ftdi-flush-rx ( -- ) 0 1 ftdi-set ;
: ftdi-flush-tx ( -- ) 0 2 ftdi-set ;
+[ifndef] rounded-/
+: rounded-/ swap 2* swap / dup 1 and + 2/ ;
+[then]
+
: ftdi-baud ( baud -- )
\ There are some high bits for fractional divisors that we don't use
d# 48000000 swap rounded-/ ( divisor )
- 0 swap 3 ftdi-set
+ 4 rshift 3 ftdi-set
;
: ftdi-modem-ctl ( code -- ) 1 ftdi-set ;
@@ -69,4 +73,73 @@
\ If there is any real data, it will be returned in bytes 2, ...
\ If there is no data, 2-byte status messages are sent every 40 ms.
+: ftdi-rpoll ( -- )
+ bulk-in? if drop restart-bulk-in exit then \ USB error; restart
+ ?dup if
+ 2 ?do
+ inbuf i ca+ c@ read-q enque
+ loop
+ restart-bulk-in
+ then
+;
+
\ Data is transmitted on bulk endpoint 2, verbatim.
+
+: ftdi-rts-dtr-off ( -- )
+ ftdi-rts-off
+ ftdi-dtr-off
+;
+
+: ftdi-rts-dtr-on ( -- )
+ ftdi-rts-on
+ ftdi-dtr-on
+;
+
+: ftdi-set-baud ( -- )
+ d# 115200 ftdi-baud
+ ftdi-rts-dtr-on
+ ftdi-8n1
+ ftdi-flow-none
+;
+
+: ftdi-inituart ( -- )
+ ftdi-set-baud
+;
+
+
+: init-ftdi ( -- )
+ ['] ftdi-rts-dtr-off to rts-dtr-off
+ ['] ftdi-rts-dtr-on to rts-dtr-on
+ ['] ftdi-rpoll to rpoll
+ ['] ftdi-inituart to inituart
+;
+
+: init ( -- )
+ init
+ vid pid uart-ftdi? if init-ftdi then
+;
+
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2012 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Modified: dev/usb2/device/serial/uart.fth
==============================================================================
--- dev/usb2/device/serial/uart.fth Wed Dec 5 04:44:52 2012 (r3470)
+++ dev/usb2/device/serial/uart.fth Wed Dec 5 09:02:09 2012 (r3471)
@@ -11,8 +11,6 @@
variable refcount 0 refcount !
-: /string ( adr len cnt -- adr' len' ) tuck - -rot + swap ;
-
\ Don't do this until someone calls read. That makes the device
\ work as a console, with separate input and output instances
0 value read-started?
@@ -32,21 +30,7 @@
\ no more characters are immediately available.
: read ( adr len -- #read ) \ -2 for none available right now
?start-reading
- rpoll
- dup 0= if nip exit then ( adr len )
- read-q deque? 0= if ( adr len )
- 2drop ( )
- lost-carrier? if -1 false to lost-carrier? else -2 then
- ( -2:none | -1:down )
- exit
- then ( adr len char )
- over >r ( adr len char r: len )
- begin ( adr len char r: len )
- 2 pick c! ( adr len r: len )
- 1 /string ( adr' len' )
- dup 0= if 2drop r> exit then ( adr' len' )
- read-q deque? 0= until ( adr len r: len )
- nip r> swap - ( actual )
+ read-bytes
;
: write ( adr len -- actual ) dup if write-bytes else nip then ;
Modified: dev/usb2/device/serial/usbserial.bth
==============================================================================
--- dev/usb2/device/serial/usbserial.bth Wed Dec 5 04:44:52 2012 (r3470)
+++ dev/usb2/device/serial/usbserial.bth Wed Dec 5 09:02:09 2012 (r3471)
@@ -16,6 +16,7 @@
fload ${BP}/dev/usb2/device/serial/belkin.fth \ Belkin device routines
fload ${BP}/dev/usb2/device/serial/mct_u232.fth \ MCT U232 device routines
fload ${BP}/dev/usb2/device/serial/pl2303.fth \ PL2303 device routines
+fload ${BP}/dev/usb2/device/serial/ftdi.fth \ FTDI device routines
fload ${BP}/dev/usb2/device/serial/uart.fth \ USB uart driver
end0
Modified: dev/usb2/device/serial/vendor.fth
==============================================================================
--- dev/usb2/device/serial/vendor.fth Wed Dec 5 04:44:52 2012 (r3470)
+++ dev/usb2/device/serial/vendor.fth Wed Dec 5 09:02:09 2012 (r3471)
@@ -7,6 +7,10 @@
525 w, 127a w, \ Ajays USB 2.0 Debug Cable
here swap - constant /uart-generic-list
+create uart-ftdi-list here
+ 403 w, 6001 w, \ FT232
+here swap - constant /uart-ftdi-list
+
create uart-pl2303-list here
557 w, 2008 w, \ ATEN, IOGear
67b w, 2303 w, \ PL2303
@@ -33,6 +37,9 @@
uart-generic-list /uart-generic-list find-vendor-product?
;
+: uart-ftdi? ( vid pid -- flag )
+ uart-ftdi-list /uart-ftdi-list find-vendor-product?
+;
: uart-pl2303? ( vid pid -- flag )
uart-pl2303-list /uart-pl2303-list find-vendor-product?
@@ -47,7 +54,8 @@
;
: usb-uart? ( vid pid -- flag )
- 2dup uart-pl2303? if 2drop true exit then
+ 2dup uart-ftdi? if 2drop true exit then
+ 2dup uart-pl2303? if 2drop true exit then
\ Not debugged yet...
\ 2dup uart-mct? if 2drop true exit then
2dup uart-belkin? if 2drop true exit then