Author: wmb Date: Wed Mar 6 19:42:03 2013 New Revision: 3591 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3591
Log: OLPC - WLAN driver - fixed build problem on XO-1 introduced by recent changes to support Bluetooth.
Added: dev/mmc/sdhci/mv8686/libertas-interface.fth Modified: dev/libertas.fth dev/mmc/sdhci/mv8686/loadpkg.fth dev/usb2/device/wlan/fw8388.fth dev/usb2/device/wlan/usb8388.bth dev/usb2/device/wlan/usb8388.fth
Modified: dev/libertas.fth ============================================================================== --- dev/libertas.fth Wed Mar 6 19:09:26 2013 (r3590) +++ dev/libertas.fth Wed Mar 6 19:42:03 2013 (r3591) @@ -47,10 +47,10 @@ \ Override as necessary
: init-buf ( -- ) - outbuf 0= if /outbuf " alloc-buffer" $call-parent to outbuf then + outbuf 0= if /outbuf alloc-buffer to outbuf then ; : free-buf ( -- ) - outbuf if outbuf /outbuf " free-buffer" $call-parent 0 to outbuf then + outbuf if outbuf /outbuf free-buffer 0 to outbuf then ;
\ ======================================================================= @@ -175,7 +175,7 @@ drop
: outbuf-out ( -- error? ) - outbuf dup >fw-len le-w@ " cmd-out" $call-parent + outbuf dup >fw-len le-w@ cmd-out ;
@@ -608,9 +608,9 @@ ;
: check-for-rx ( -- ) - " got-packet?" $call-parent if ( error | buf len type 0 ) + got-packet? if ( error | buf len type 0 ) 0= if process-rx then ( ) - " recycle-packet" $call-parent ( ) + recycle-packet ( ) then ( ) ;
@@ -697,8 +697,10 @@ \ =========================================================================
: reset-wlan ( -- ) +\ XXX wlan-reset evaluate + driver-is-not-ready - " reset-host-bus" $call-parent + reset-host-bus ; : sleep ( -- ) reset-wlan ; : wake ( -- ) ; @@ -712,8 +714,15 @@ respbuf >fw-data false ;
+\ Sometimes get-hw-spec fails the first time after +\ the driver is reopened with the firmware still active. +\ This has been seen with the 8388 USB version. +: retry-get-hw-spec ( -- true | adr false ) + get-hw-spec dup if drop get-hw-spec then +; + : set-fw-params ( -- ) - get-hw-spec 0= if ( adr ) + retry-get-hw-spec 0= if ( adr )
\ is 802.11n capable? dup d# 34 + le-l@ h# 800 and if @@ -1231,7 +1240,7 @@ drop d# 1000 ms \ retry while busy repeat ( adr len scan-adr scan-len err? r: chan ) r> drop ( adr len scan-adr scan-len err? ) - if 4drop false exit then ( adr len scan-adr scan-len ) + if 2drop 2drop false exit then ( adr len scan-adr scan-len ) rot min >r ( adr scan-adr r: actual ) swap r@ move ( r: actual ) r> ( actual ) @@ -1799,7 +1808,7 @@ mac-adr$ mac-adr$ broadcast-mac$ 0 h# c0 set-802.11-header h# 0002 0 +pkt-data le-w! \ Reason code: auth no longer valid packet-buf /802.11-header 2 + wrap-802.11 ( adr len ) - " data-out" $call-parent + data-out r> set-tx-ctrl ;
@@ -2127,17 +2136,15 @@ repeat drop ;
-\ Maybe handle this in parent's close method -: release-bus-resources ( -- ) " release-bus-resources" $call-parent ; - : open ( -- ok? ) my-args parse-args + set-parent-channel " " set-ssid \ Instance buffers aren't necessarily initially 0 - my-space " set-address" $call-parent \ Set SDIO function number if necessary opencount @ 0= if init-buf + setup-transport if free-buf false exit then ds-ready to driver-state - " multifunction?" $call-parent if init-function then + multifunction? if init-function then ?make-mac-address-property if release-bus-resources free-buf false exit then set-fw-params my-args " supplicant" $open-package to supplicant-ih @@ -2169,7 +2176,7 @@ ['] 2drop to ?process-eapol mac-off supplicant-ih ?dup if close-package 0 to supplicant-ih then - " multifunction?" $call-parent if shutdown-function then + multifunction? if shutdown-function then release-bus-resources driver-is-not-ready then @@ -2180,16 +2187,16 @@ : write-force ( adr len -- actual ) tuck ( actual adr len ) wrap-ethernet ( actual adr' len' ) - " data-out" $call-parent ( actual ) + data-out ( actual ) ;
: read-force ( adr len -- actual ) - " got-packet?" $call-parent 0= if ( adr len ) + got-packet? 0= if ( adr len ) 2drop -2 exit then ( adr len [ error | buf actual type 0 ] )
if \ receive error ( adr len ) - " recycle-packet" $call-parent ( adr len ) + recycle-packet ( adr len ) 2drop -1 exit then ( adr len buf actual type )
@@ -2202,7 +2209,7 @@ 2drop -2 \ No data then ( actual )
- " recycle-packet" $call-parent ( actual ) + recycle-packet ( actual ) ;
0 instance value /packet @@ -2235,7 +2242,7 @@ " "(01 08 02 04 0b 16 0c 12 18 24 32 04 30 48 e0 ec)" ( tags-adr tags-len ) tuck 6 +pkt-data swap move ( tags-size ) packet-buf swap /802.11-header + 6 + wrap-802.11 ( adr len ) - " data-out" $call-parent + data-out ;
: authenticate-reply ( -- ) @@ -2245,7 +2252,7 @@ 0 4 +pkt-data le-w! \ Status - okay
packet-buf /802.11-header 6 + wrap-802.11 ( adr len ) - " data-out" $call-parent + data-out ;
defer handle-data ' noop is handle-data @@ -2292,7 +2299,7 @@ packet-buf swap /802.11-header + 6 + wrap-802.11 ( len padr plen ) begin backlog 8 >= while process-mgmt-frame repeat backlog 1+ to backlog - " data-out" " $call-parent ( len ) + data-out ( len ) throttle ;
Added: dev/mmc/sdhci/mv8686/libertas-interface.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ dev/mmc/sdhci/mv8686/libertas-interface.fth Wed Mar 6 19:42:03 2013 (r3591) @@ -0,0 +1,14 @@ +: alloc-buffer ( len -- adr ) " alloc-buffer" $call-parent ; +: free-buffer ( adr len -- ) " free-buffer" $call-parent ; +: cmd-out ( adr len -- ) " cmd-out" $call-parent ; +: data-out ( adr len -- ) " data-out" $call-parent ; +: got-packet? ( -- false | error true | buf len type 0 true ) " got-packet?" $call-parent ; +: recycle-packet ( -- ) " recycle-packet" $call-parent ; +: reset-host-bus ( -- ) " reset-host-bus" $call-parent ; +: data-out ( adr len -- ) " data-out" $call-parent ; +: release-bus-resources ( -- ) " release-bus-resources" $call-parent ; +: multifunction? ( -- flag ) " multifunction?" $call-parent ; +: set-parent-channel ( -- ) my-space " set-address" $call-parent ; +: setup-transport ( -- error? ) false ; \ Done by parent + +\ : x-cmd-out ( adr len -- ) /fw-transport + cmd-out ;
Modified: dev/mmc/sdhci/mv8686/loadpkg.fth ============================================================================== --- dev/mmc/sdhci/mv8686/loadpkg.fth Wed Mar 6 19:09:26 2013 (r3590) +++ dev/mmc/sdhci/mv8686/loadpkg.fth Wed Mar 6 19:42:03 2013 (r3591) @@ -13,6 +13,7 @@ new-device 1 to my-space my-space 1 reg +fload ${BP}/dev/mmc/sdhci/mv8686/libertas-interface.fth \ Marvell "Libertas" common code fload ${BP}/dev/libertas.fth \ Marvell "Libertas" common code finish-device
Modified: dev/usb2/device/wlan/fw8388.fth ============================================================================== --- dev/usb2/device/wlan/fw8388.fth Wed Mar 6 19:09:26 2013 (r3590) +++ dev/usb2/device/wlan/fw8388.fth Wed Mar 6 19:42:03 2013 (r3591) @@ -84,11 +84,11 @@
: wait-cmd-fw-dl-ack ( -- acked? ) d# 100 0 do ( ) - got-packet? if ( error | buf len type 0 ) + bulk-in-ready? if ( error | buf len type 0 ) if ( ) false ( acked? ) - else ( buf len type ) - drop cmd-fw-dl-ok? ( acked? ) + else ( buf len ) + cmd-fw-dl-ok? ( acked? ) then ( acked? ) recycle-packet ( acked? ) unloop exit @@ -99,12 +99,12 @@ ;
: download-fw-init ( -- ) - fw-buf /boot-cmd erase - boot-magic fw-buf >boot-magic le-l! - cmd-fw-dl fw-buf >boot-cmd c! + outbuf /boot-cmd erase + boot-magic outbuf >boot-magic le-l! + cmd-fw-dl outbuf >boot-cmd c!
5 0 do - fw-buf /boot-cmd packet-out drop + outbuf /boot-cmd packet-out drop wait-cmd-fw-dl-ack if leave then loop ; @@ -118,8 +118,8 @@
: wait-fw-dl-ack ( -- ) d# 500 0 do ( ) - got-packet? if ( error | buf len tupe 0 ) - 0= if drop process-dl-resp then ( ) + bulk-in-ready? if ( error | buf len 0 ) + 0= if process-dl-resp then ( ) recycle-packet ( ) leave then ( ) @@ -130,11 +130,11 @@ : (download-fw) ( adr len -- ) bounds begin ( end start ) dl-seq++ \ Increment sequence number - dup fw-buf /dl-header move \ Move header to outbuf - dl-seq fw-buf >dl-seq le-l! \ Add sequence number to outbuf - dup /dl-header + fw-buf >dl-data 2 pick >dl-len le-l@ dup >r move - \ Move payload to fw-buf - fw-buf r@ /dl-header + 4 + packet-out drop + dup outbuf /dl-header move \ Move header to outbuf + dl-seq outbuf >dl-seq le-l! \ Add sequence number to outbuf + dup /dl-header + outbuf >dl-data 2 pick >dl-len le-l@ dup >r move + \ Move payload to outbuf + outbuf r@ /dl-header + 4 + packet-out drop \ Send command wait-fw-dl-ack \ Wait for ACK r> + /dl-header + \ Advance pointer @@ -180,11 +180,16 @@ ;
: load-all-fw ( -- error? ) - d# 2048 dma-alloc to fw-buf + fw-loaded? if false exit then wlan-fw find-fw ( adr len ) - dup if download-fw else 2drop true then - fw-buf d# 2048 dma-free + dup if download-fw else 2drop true then ( error? ) + dup 0= to fw-loaded? ( error? ) ; +: (setup-transport) ( -- error? ) + setup-bus-io ?dup if exit then + load-all-fw dup if release-bus-resources then ( error? ) +; +' (setup-transport) to setup-transport
\ LICENSE_BEGIN \ Copyright (c) 2007 FirmWorks
Modified: dev/usb2/device/wlan/usb8388.bth ============================================================================== --- dev/usb2/device/wlan/usb8388.bth Wed Mar 6 19:09:26 2013 (r3590) +++ dev/usb2/device/wlan/usb8388.bth Wed Mar 6 19:42:03 2013 (r3591) @@ -13,8 +13,8 @@ fload ${BP}/dev/usb2/device/common.fth \ USB device driver common routines fload ${BP}/dev/usb2/device/wlan/common.fth \ Ethernet common variables and routines fload ${BP}/dev/usb2/device/wlan/usb8388.fth \ USB I/O interface for Marvell 8388 -fload ${BP}/dev/usb2/device/wlan/fw8388.fth \ Marvell firmware download for USB fload ${BP}/dev/libertas.fth \ Marvell "Libertas" common code +fload ${BP}/dev/usb2/device/wlan/fw8388.fth \ Marvell firmware download for USB \ fload ${BP}/dev/usb2/device/wlan/wlan.fth \ External interface methods
end0
Modified: dev/usb2/device/wlan/usb8388.fth ============================================================================== --- dev/usb2/device/wlan/usb8388.fth Wed Mar 6 19:09:26 2013 (r3590) +++ dev/usb2/device/wlan/usb8388.fth Wed Mar 6 19:42:03 2013 (r3591) @@ -70,6 +70,7 @@ ?dup 0= if ( dadr dlen ) decode-header 0 ( dadr dlen type 0 ) then ( error | buf len 0 ) + true else ( ) false ( false ) then ( false | error true | buf len 0 true ) @@ -95,7 +96,8 @@
: release-bus-resources ( -- ) end-bulk-in end-out-ring ;
-: reset-host-bus ( -- ) " wlan-reset" evaluate ; +false value fw-loaded? +: reset-host-bus ( -- ) " wlan-reset" evaluate false to fw-loaded? ;
0 value vid 0 value pid @@ -108,8 +110,13 @@ ;
init -XXX need open and close methods and open needs to call setup-bus-io -XXX need alloc-buffer and free-buffer method + +: open ( -- okay? ) setup-bus-io 0= ; +: close ( -- ) ; +: alloc-buffer ( len -- adr ) /fw-transport + dma-alloc /fw-transport + ; +: free-buffer ( adr len -- ) /fw-transport negate /string dma-free ; + +defer setup-transport ( -- error? ) ' true to setup-transport
\ LICENSE_BEGIN \ Copyright (c) 2009 FirmWorks
openfirmware@openfirmware.info