Author: wmb Date: 2009-04-02 20:27:04 +0200 (Thu, 02 Apr 2009) New Revision: 1134
Modified: dev/usb2/device/serial/uart.fth dev/usb2/device/serial/vendor.fth dev/usb2/hcd/ehci/ehci.fth dev/usb2/hcd/hcd.fth Log: Added Ajays USB debug device support to USB serial driver.
Modified: dev/usb2/device/serial/uart.fth =================================================================== --- dev/usb2/device/serial/uart.fth 2009-04-02 18:26:16 UTC (rev 1133) +++ dev/usb2/device/serial/uart.fth 2009-04-02 18:27:04 UTC (rev 1134) @@ -13,6 +13,16 @@
: /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? +: ?start-reading ( -- ) + read-started? if exit then + read-q init-q + inbuf /bulk-in-pipe bulk-in-pipe begin-bulk-in + true to read-started? +; + external
: install-abort ( -- ) ['] poll-tty d# 100 alarm ; \ Check for break @@ -21,6 +31,7 @@ \ Read at most "len" characters into the buffer at adr, stopping when \ 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 ) @@ -43,9 +54,8 @@ : open ( -- flag ) device set-target refcount @ 0= if - init-buf read-q init-q + init-buf inituart rts-dtr-on - inbuf /bulk-in-pipe bulk-in-pipe begin-bulk-in then refcount @ 1+ refcount ! true
Modified: dev/usb2/device/serial/vendor.fth =================================================================== --- dev/usb2/device/serial/vendor.fth 2009-04-02 18:26:16 UTC (rev 1133) +++ dev/usb2/device/serial/vendor.fth 2009-04-02 18:27:04 UTC (rev 1134) @@ -3,6 +3,10 @@ headers hex
+create uart-generic-list here + 525 w, 127a w, \ Ajays USB 2.0 Debug Cable +here swap - constant /uart-generic-list + create uart-pl2303-list here 557 w, 2008 w, \ ATEN, IOGear 67b w, 2303 w, \ PL2303 @@ -25,6 +29,11 @@ 921 w, 1000 w, \ GoHubs single port here swap - constant /uart-belkin-list
+: uart-generic? ( vid pid -- flag ) + uart-generic-list /uart-generic-list find-vendor-product? +; + + : uart-pl2303? ( vid pid -- flag ) uart-pl2303-list /uart-pl2303-list find-vendor-product? ; @@ -41,5 +50,7 @@ 2dup uart-pl2303? if 2drop true exit then \ Not debugged yet... \ 2dup uart-mct? if 2drop true exit then - uart-belkin? + 2dup uart-belkin? if 2drop true exit then + 2dup uart-generic? if 2drop true exit then + 2drop false ;
Modified: dev/usb2/hcd/ehci/ehci.fth =================================================================== --- dev/usb2/hcd/ehci/ehci.fth 2009-04-02 18:26:16 UTC (rev 1133) +++ dev/usb2/hcd/ehci/ehci.fth 2009-04-02 18:27:04 UTC (rev 1134) @@ -27,7 +27,8 @@ 0 0 my-space h# 0200.0010 + /regs map-in to ehci-reg ; : unmap-regs ( -- ) - 4 my-w@ 7 invert and 4 my-w! + \ Don't disable because somebody else might be using the controller. + \ 4 my-w@ 7 invert and 4 my-w! ehci-reg /regs map-out 0 to ehci-reg ;
@@ -97,6 +98,32 @@ doorbell-wait ;
+0 value dbgp-offset +0 value dbgp-bar + +: find-dbgp-regs ( -- ) + h# 34 my-l@ ( capability-ptr ) + begin dup while ( cap-offset ) + dup my-b@ h# 0a = if ( cfg-adr ) + 2+ my-w@ ( dbgp-ptr ) + dup h# 1fff and to dbgp-offset ( ) + d# 13 rshift 7 and 1- /l* h# 10 + to dbgp-bar + exit + then ( cfg-adr ) + 1+ my-b@ ( cap-offset' ) + repeat ( cap-offset ) + drop +; +: debug-port-active? ( -- flag ) + hcsparams@ h# f0.0000 and 0= if false exit then + find-dbgp-regs + dbgp-offset 0= if false exit then + \ We should take dbgp-bar into account, but for now we + \ just assume it's the same BAR as for the main registers. + dbgp-offset ehci-reg@ + h# 1000.0000 and 0<> +; + external
: start-usb ( -- ) @@ -113,7 +140,8 @@ ;
: reset-usb ( -- ) - ehci-reg dup 0= if map-regs then + ehci-reg dup 0= if map-regs then ( reg ) + debug-port-active? if drop exit then \ Don't kill the debug port! usbcmd@ 2 or 1 invert and usbcmd! \ HCReset d# 10 0 do usbcmd@ 2 and 0= ?leave
Modified: dev/usb2/hcd/hcd.fth =================================================================== --- dev/usb2/hcd/hcd.fth 2009-04-02 18:26:16 UTC (rev 1133) +++ dev/usb2/hcd/hcd.fth 2009-04-02 18:27:04 UTC (rev 1134) @@ -57,6 +57,9 @@ \ Common routines \ ---------------------------------------------------------------------------
+: my-b@ ( offset -- b ) my-space + " config-b@" $call-parent ; +: my-b! ( b offset -- ) my-space + " config-b!" $call-parent ; + : my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ; : my-w! ( w offset -- ) my-space + " config-w!" $call-parent ;