Changeset 3569
- Timestamp:
- Feb 25, 2013 9:34:36 AM (3 months ago)
- Location:
- dev
- Files:
-
- 1 added
- 11 edited
-
bluetooth (added)
-
libertas.fth (modified) (33 diffs)
-
mmc/sdhci/mv8686/common.fth (modified) (2 diffs)
-
mmc/sdhci/mv8686/fw8686.fth (modified) (7 diffs)
-
mmc/sdhci/mv8686/loadpkg.fth (modified) (1 diff)
-
mmc/sdhci/mv8686/mv8686.fth (modified) (5 diffs)
-
mmc/sdhci/mv8686/sdio.fth (modified) (12 diffs)
-
mmc/sdhci/sdhci.fth (modified) (1 diff)
-
usb2/device/wlan/fw8388.fth (modified) (5 diffs)
-
usb2/device/wlan/usb8388.bth (modified) (1 diff)
-
usb2/device/wlan/usb8388.fth (modified) (6 diffs)
-
usb2/device/wlan/wlan.fth (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dev/libertas.fth
r3560 r3569 4 4 headers 5 5 hex 6 7 false instance value debug? 8 9 : debug-on ( -- ) true to debug? ; 10 : vdump ( adr len -- ) debug? if " dump" evaluate else 2drop then ; 11 12 create mac-adr 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 13 6 constant /mac-adr 14 : mac-adr$ ( -- adr len ) mac-adr /mac-adr ; 15 16 : max-frame-size ( -- size ) d# 1514 ; 17 18 external 19 defer get-mac-address ( -- adr len ) ' mac-adr$ to get-mac-address 20 headers 21 6 22 7 23 \ **************** WPA and WPA2 are not functional yet ****************** … … 22 38 : .ssids ( adr len -- ) " .ssids" $call-supplicant ; 23 39 24 defer load-all-fw ( -- error? ) ' false to load-all-fw25 40 defer ?process-eapol ['] 2drop to ?process-eapol 26 41 … … 33 48 34 49 : init-buf ( -- ) 35 outbuf 0= if /outbuf dma-allocto outbuf then50 outbuf 0= if /outbuf " alloc-buffer" $call-parent to outbuf then 36 51 ; 37 52 : free-buf ( -- ) 38 outbuf if outbuf /outbuf dma-free0 to outbuf then53 outbuf if outbuf /outbuf " free-buffer" $call-parent 0 to outbuf then 39 54 ; 40 55 … … 144 159 headers 145 160 146 : marvel-link-up? ( -- flag ) driver-state ds-ready > ; 147 148 ' marvel-link-up? to link-up? 161 : link-up? ( -- flag ) driver-state ds-ready > ; 149 162 150 163 \ ========================================================================= … … 153 166 154 167 struct 155 /fw-transport +156 168 2 field >fw-cmd \ Start of command header 157 169 2 field >fw-len … … 159 171 2 field >fw-result 160 172 dup constant /fw-cmd 161 dup /fw-transport -constant /fw-cmd-hdr \ Command header len (less /fw-transport)173 dup constant /fw-cmd-hdr \ Command header len (less /fw-transport) 162 174 0 field >fw-data \ Command payload starts here 163 175 drop 164 176 165 177 : outbuf-out ( -- error? ) 166 outbuf dup >fw-len le-w@ /fw-transport + cmd-out178 outbuf dup >fw-len le-w@ " cmd-out" $call-parent 167 179 ; 168 180 … … 192 204 193 205 struct 194 /fw-transport +195 206 4 field >tx-stat 196 207 4 field >tx-ctrl … … 212 223 213 224 struct 214 /fw-transport +215 225 1 field >tx14-bsstype 216 226 1 field >tx14-bss# … … 242 252 tuck outbuf >tx-pkt-no-mesh swap move ( len ) 243 253 244 /tx-hdr-no-mesh /fw-transport -outbuf >tx-offset le-l! ( len ) \ Offset from >tx-stat field254 /tx-hdr-no-mesh outbuf >tx-offset le-l! ( len ) \ Offset from >tx-stat field 245 255 tx-ctrl outbuf >tx-ctrl le-l! ( len ) 246 256 … … 254 264 tuck outbuf >tx-pkt swap move ( len ) 255 265 256 /tx-hdr /fw-transport - outbuf >tx-offset le-l!( len ) \ Offset from >tx-stat field266 /tx-hdr outbuf >tx-offset le-l! ( len ) \ Offset from >tx-stat field 257 267 tx-ctrl outbuf >tx-ctrl le-l! ( len ) 258 268 … … 271 281 tuck outbuf >tx14-pkt swap move ( len ) 272 282 273 /tx14-hdr /fw-transport - outbuf >tx14-offset le-w!( len ) \ Offset from >tx14-bsstype field283 /tx14-hdr outbuf >tx14-offset le-w! ( len ) \ Offset from >tx14-bsstype field 274 284 tx-ctrl outbuf >tx14-ctrl le-l! ( len ) 275 285 … … 288 298 \ Receive packet descriptor 289 299 struct 290 /fw-transport +291 300 2 field >rx-stat 292 301 1 field >rx-snr … … 311 320 312 321 struct 313 /fw-transport +314 322 1 field >rx14-bsstype 315 323 1 field >rx14-bss# … … 359 367 360 368 \ Go to the payload, skipping the descriptor header 361 dup dup >rx-offset le-l@ + /fw-transport +( adr data-adr )369 dup dup >rx-offset le-l@ + ( adr data-adr ) 362 370 swap >rx-len le-w@ ( data-adr data-len ) 363 371 … … 375 383 \ Go to the payload, skipping the descriptor header 376 384 >r ( r: adr ) 377 r@ r@ >rx14-offset le-w@ + /fw-transport +( data-adr r: adr )385 r@ r@ >rx14-offset le-w@ + ( data-adr r: adr ) 378 386 r@ >rx14-len le-w@ ( data-adr data-len r: adr ) 379 387 … … 506 514 resp-wait-short to resp-wait ( len cmd ) 507 515 outbuf /outbuf erase ( len cmd ) 508 outbuf /fw-transport + to x 0 to /x( len cmd )516 outbuf to x 0 to /x ( len cmd ) 509 517 ( len cmd ) +xw \ fw-cmd ( len ) 510 518 /fw-cmd-hdr + +xw \ fw-len ( ) … … 531 539 0 value debug-tx-feedback? 532 540 : process-ind ( adr len -- ) 533 drop 534 true to got-indicator? 535 4 + le-l@ dup to last-event541 drop ( adr ) 542 true to got-indicator? ( adr ) 543 le-l@ dup to last-event ( event-code ) 536 544 dup h# 10000 u>= if ( event-code ) 537 545 \ TX feedback from thin firmware … … 591 599 ; 592 600 593 : process-rx ( adr len -- ) 594 over packet-type case 595 \ Encoding must agree with packet-type 601 : process-rx ( adr len type -- ) 602 case 596 603 0 of process-request endof \ Response & request 597 604 1 of process-data endof \ Data … … 602 609 603 610 : check-for-rx ( -- ) 604 got-packet? if ( error | buf len0 )605 0= if 2dup vdump process-rxthen ( )606 recycle-packet ( )611 " got-packet?" $call-parent if ( error | buf len type 0 ) 612 0= if process-rx then ( ) 613 " recycle-packet" $call-parent ( ) 607 614 then ( ) 608 615 ; … … 691 698 692 699 : reset-wlan ( -- ) 693 " wlan-reset" evaluate694 700 driver-is-not-ready 695 reset-host-bus701 " reset-host-bus" $call-parent 696 702 ; 697 703 : sleep ( -- ) reset-wlan ; … … 1693 1699 driver-state ds-disconnected and if do-associate drop then 1694 1700 ; 1695 ' ?reassociate to start-nic1696 1701 1697 1702 : disassociate ( mac$ -- ) … … 1795 1800 h# 0002 0 +pkt-data le-w! \ Reason code: auth no longer valid 1796 1801 packet-buf /802.11-header 2 + wrap-802.11 ( adr len ) 1797 data-out1802 " data-out" $call-parent 1798 1803 r> set-tx-ctrl 1799 1804 ; … … 2101 2106 ; 2102 2107 2103 : ?load-fw ( -- error? )2104 driver-state ds-not-ready = if2105 load-all-fw if2106 ." Failed to download firmware" cr2107 true exit2108 then2109 ds-ready to driver-state2110 then2111 multifunction? if init-function then2112 ?make-mac-address-property2113 ;2114 2115 2108 false instance value use-promiscuous? 2116 2109 … … 2135 2128 ; 2136 2129 2130 \ Maybe handle this in parent's close method 2131 : release-bus-resources ( -- ) " release-bus-resources" $call-parent ; 2132 2137 2133 : open ( -- ok? ) 2138 2134 my-args parse-args 2139 set-parent-channel2140 2135 " " set-ssid \ Instance buffers aren't necessarily initially 0 2136 my-space " set-address" $call-parent \ Set SDIO function number if necessary 2141 2137 opencount @ 0= if 2142 2138 init-buf 2143 d river-is-not-ready2144 /inbuf /outbuf setup-bus-io if free-buf false exitthen2145 ? load-fwif release-bus-resources free-buf false exit then2139 ds-ready to driver-state 2140 " multifunction?" $call-parent if init-function then 2141 ?make-mac-address-property if release-bus-resources free-buf false exit then 2146 2142 set-fw-params 2147 2143 my-args " supplicant" $open-package to supplicant-ih … … 2153 2149 do-associate 0= if free-buf false exit then 2154 2150 then 2155 start-nic2151 ?reassociate 2156 2152 then 2157 2153 then … … 2172 2168 link-up? if target-mac$ deauthenticate then 2173 2169 ['] 2drop to ?process-eapol 2174 stop-nic2175 2170 mac-off 2176 2171 supplicant-ih ?dup if close-package 0 to supplicant-ih then 2177 multifunction?if shutdown-function then2172 " multifunction?" $call-parent if shutdown-function then 2178 2173 release-bus-resources 2179 2174 driver-is-not-ready … … 2186 2181 tuck ( actual adr len ) 2187 2182 wrap-ethernet ( actual adr' len' ) 2188 data-out( actual )2183 " data-out" $call-parent ( actual ) 2189 2184 ; 2190 2185 2191 2186 : read-force ( adr len -- actual ) 2192 got-packet? 0= if( adr len )2187 " got-packet?" $call-parent 0= if ( adr len ) 2193 2188 2drop -2 exit 2194 then ( adr len [ error | buf actual 0 ] )2189 then ( adr len [ error | buf actual type 0 ] ) 2195 2190 2196 2191 if \ receive error ( adr len ) 2197 recycle-packet( adr len )2192 " recycle-packet" $call-parent ( adr len ) 2198 2193 2drop -1 exit 2199 then ( adr len buf actual )2200 2201 false to got-data? ( adr len buf actual )2194 then ( adr len buf actual type ) 2195 2196 false to got-data? ( adr len buf actual type ) 2202 2197 process-rx ( adr len ) 2203 2198 … … 2208 2203 then ( actual ) 2209 2204 2210 recycle-packet( actual )2205 " recycle-packet" $call-parent ( actual ) 2211 2206 ; 2212 2207 … … 2241 2236 tuck 6 +pkt-data swap move ( tags-size ) 2242 2237 packet-buf swap /802.11-header + 6 + wrap-802.11 ( adr len ) 2243 data-out2238 " data-out" $call-parent 2244 2239 ; 2245 2240 … … 2251 2246 2252 2247 packet-buf /802.11-header 6 + wrap-802.11 ( adr len ) 2253 data-out2248 " data-out" $call-parent 2254 2249 ; 2255 2250 … … 2298 2293 begin backlog 8 >= while process-mgmt-frame repeat 2299 2294 backlog 1+ to backlog 2300 data-out( len )2295 " data-out" " $call-parent ( len ) 2301 2296 throttle 2302 2297 ; … … 2340 2335 then ( adr ihandle|0 ) 2341 2336 2342 dup 0= if ." Can't open obp-tftp support package" stop-nicabort then2337 dup 0= if ." Can't open obp-tftp support package" abort then 2343 2338 ( adr ihandle ) 2344 2339 … … 2349 2344 ; 2350 2345 2351 : reset ( -- flag ) reset-nic;2346 : reset ( -- flag ) true ; 2352 2347 2353 2348 : do-disassociate ( -- ) -
dev/mmc/sdhci/mv8686/common.fth
r3336 r3569 29 29 : /string ( adr len cnt -- adr+n len-n ) tuck - -rot + swap ; 30 30 31 create mac-adr 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c,32 6 constant /mac-adr33 : mac-adr$ ( -- adr len ) mac-adr /mac-adr ;34 35 31 : null$ ( -- adr len ) " " ; 36 32 … … 58 54 : vldump ( adr len -- ) debug? if " ldump" evaluate else 2drop then ; 59 55 : vtype ( adr len -- ) debug? if type cr else 2drop then ; 60 61 62 defer link-up? ( -- up? ) ' true to link-up?63 defer reset-nic ( -- ) ' noop to reset-nic64 defer start-nic ( -- ) ' noop to start-nic65 defer stop-nic ( -- ) ' noop to stop-nic66 67 external68 defer get-mac-address ( -- adr len ) ' mac-adr$ to get-mac-address69 headers70 71 : max-frame-size ( -- size ) d# 1514 ;72 73 : property-or-abort ( name$ -- n )74 2dup get-my-property if ( name$ )75 ." Can't find property " type cr stop-nic abort76 then ( name$ value$ )77 2swap 2drop decode-int nip nip ( n )78 ;79 56 80 57 : find-fw ( $ -- adr len ) -
dev/mmc/sdhci/mv8686/fw8686.fth
r3487 r3569 6 6 \ Firmware download data structures 7 7 \ ======================================================================= 8 9 0 value fw-buf 8 10 9 11 h# fedc constant FIRMWARE_READY … … 22 24 0 value dn-retry 23 25 24 : fw-dn-blksz ( -- blksz ) host-f1-rd-base-0-reg 1 sdio-reg-w@ ;26 : fw-dn-blksz ( -- blksz ) host-f1-rd-base-0-reg sdio-w@ ; 25 27 : wait-for-fw-dn-blksz ( -- blksz ) 26 28 \ Wait for the first non-zero value … … 42 44 begin 43 45 fw-len dn-idx - fw-tx-len min ( len ) 44 fw-adr dn-idx + outbuf 2 pick move ( len )45 outbuf over sdio-fw! <> if46 4 config-reg 1 sdio-reg! \ FN1 CFG = write iomem fail46 fw-adr dn-idx + fw-buf 2 pick move ( len ) 47 fw-buf over sdio-fw! <> if 48 4 config-reg sdio-b! \ FN1 CFG = write iomem fail 47 49 then 48 50 sdio-poll-dl-ready 0= if ." Download fw died" cr true exit then … … 74 76 75 77 mv8787? if 76 2 config-reg 1 sdio-reg! \ Host power up78 2 config-reg sdio-b! \ Host power up 77 79 then 78 80 false … … 85 87 sdio-poll-dl-ready 0= if true exit then 86 88 fw-len dn-idx - /fw-tx min ( len ) 87 dup outbuf le-l! ( len )88 fw-adr dn-idx + outbuf 4 + 2 pick move ( len )89 dup fw-buf le-l! ( len ) 90 fw-adr dn-idx + fw-buf 4 + 2 pick move ( len ) 89 91 dn-idx over + to dn-idx ( len ) 90 outbuf swap 4 + sdio-fw! drop ( )92 fw-buf swap 4 + sdio-fw! drop ( ) 91 93 dn-idx fw-len >= until 92 94 \ Write last EOF data 93 outbuf fw-blksz erase94 outbuf fw-blksz sdio-fw! drop95 fw-buf fw-blksz erase 96 fw-buf fw-blksz sdio-fw! drop 95 97 false 96 98 ; … … 102 104 ; 103 105 104 : load-sdio-fw ( -- error? ) 106 : free-fw-buf ( -- ) fw-buf d# 2048 dma-free ; 107 : load-all-fw ( -- error? ) 108 d# 2048 dma-alloc to fw-buf 105 109 helper? if 106 110 wlan-helper find-fw dup if ( adr len ) 107 111 2dup download-helper ( adr len error? ) 108 112 -rot free-mem ( error? ) 109 if true exit then ( )113 if free-fw-buf true exit then ( ) 110 114 else ( adr len ) 111 115 2drop ( ) … … 119 123 2drop true ( error? ) 120 124 then ( error? ) 125 free-fw-buf ( error? ) 121 126 ; 122 ' load-sdio-fw to load-all-fw 127 128 false value fw-active? 129 : set-address ( function# -- ) 130 init-function 131 fw-active? 0= if 132 load-all-fw if 133 ." Marvell WLAN module firmware load failed" cr 134 abort 135 then 136 true to fw-active? 137 then 138 mv8787? if 139 card-rx-unit-reg sdio-b@ to rx-shift 140 then 141 ; 142 : reset-host-bus ( -- ) " wlan-reset" evaluate false to fw-active? ; 143 144 0 value open-count 145 : open ( -- flag ) 146 set-parent-channel 147 open-count if 148 true 149 else 150 setup-bus-io 0= 151 then ( okay? ) 152 dup if open-count 1+ to open-count then 153 ; 154 : close ( -- ) 155 open-count 1 = if false to fw-active? then 156 open-count 1- 0 max to open-count 157 ; 123 158 124 159 \ LICENSE_BEGIN -
dev/mmc/sdhci/mv8686/loadpkg.fth
r2004 r3569 1 " sdio" name 1 2 fload ${BP}/dev/mmc/sdhci/mv8686/common.fth \ Ethernet common variables and routines 2 3 fload ${BP}/dev/mmc/sdhci/mv8686/ring.fth \ Receive ring management 3 4 fload ${BP}/dev/mmc/sdhci/mv8686/sdio.fth \ SDIO interface routines 4 5 fload ${BP}/dev/mmc/sdhci/mv8686/mv8686.fth \ SDIO I/O interface for Marvell 8686 6 fload ${BP}/dev/mmc/sdhci/mv8686/fw8686.fth \ Marvell firmware download for SDIO 7 8 1 " #size-cells" integer-property 9 1 " #address-cells" integer-property 10 : decode-unit ( adr len -- phys ) push-hex $number if 0 then pop-base ; 11 : encode-unit ( phys -- adr len ) push-hex (u.) pop-base ; 12 13 new-device 14 1 to my-space 15 my-space 1 reg 5 16 fload ${BP}/dev/libertas.fth \ Marvell "Libertas" common code 6 fload ${BP}/dev/mmc/sdhci/mv8686/fw8686.fth \ Marvell firmware download for SDIO 7 \ fload ${BP}/dev/mmc/sdhci/mv8686/wlan.fth \ External interface methods 17 finish-device 18 19 new-device 20 2 to my-space 21 my-space 1 reg 22 " bluetooth" name 23 fload ${BP}/dev/bluetooth/marvell-hci.fth \ Bluetooth driver 24 finish-device -
dev/mmc/sdhci/mv8686/mv8686.fth
r3337 r3569 4 4 headers 5 5 hex 6 7 0 0 encode-bytes " fullmac" property8 6 9 7 \ ======================================================================= … … 30 28 constant /fw-transport 31 29 32 : packet-type ( adr -- type ) 33 >fw-type le-w@ case 34 CMD_TYPE_CMD of 0 endof 35 CMD_TYPE_DATA of 1 endof 36 CMD_TYPE_EVENT of 2 endof 37 endcase 30 : bt-packet-len&type ( adr -- len type ) 31 /fw-transport - dup le-l@ h# ffffff and /fw-transport - swap 3 + c@ 38 32 ; 39 33 40 34 : cmd-out ( adr len -- error? ) 41 read-poll 35 /fw-transport negate /string ( adr' len' ) 36 read-poll ( len ) 42 37 2dup swap >fw-plen le-w! ( len ) 43 38 CMD_TYPE_CMD 2 pick >fw-type le-w! ( len ) 44 45 2dup vdump ( adr len )46 39 packet-out ( error? ) 47 40 ; 48 41 49 42 : data-out ( adr len -- ) 50 read-poll 43 /fw-transport negate /string ( adr' len' ) 44 read-poll ( adr len ) 51 45 2dup swap >fw-plen le-w! ( adr len ) 52 46 CMD_TYPE_DATA 2 pick >fw-type le-w! ( adr len ) … … 54 48 ; 55 49 56 : got-packet? ( -- false | error true | buf len 0 true ) 57 read-poll ( ) 50 : decode-header ( buf len -- dadr dlen 8686-type ) 51 drop ( buf ) 52 dup /fw-transport + swap ( dadr buf ) 53 dup >fw-plen le-w@ swap ( dadr dlen ) 54 >fw-type le-w@ case 55 CMD_TYPE_CMD of 0 endof 56 CMD_TYPE_DATA of 1 endof 57 CMD_TYPE_EVENT of 2 endof 58 endcase ( dadr dlen 8686-type ) 59 ; 60 : got-packet? ( -- false | error true | buf len type 0 true ) 61 read-poll ( ) 58 62 59 get-queued? if ( buf len ) 60 0 true ( buf len 0 true ) 61 else ( ) 62 false ( false ) 63 get-queued? if ( buf len ) 64 decode-header ( dadr dlen type ) 65 0 true ( buf len 0 true ) 66 else ( ) 67 false ( false ) 68 then 69 ; 70 : decode-bt-header ( buf len -- dadr dlen type ) 71 drop ( buf ) 72 \ SDIO specific header - length: byte[2:0], type: byte[3] 73 \ (HCI_COMMAND = 1, ACL_DATA = 2, SCO_DATA = 3, EVENT=4, 0xFE = Vendor) 74 dup /fw-transport + swap ( dadr buf ) 75 dup le-l@ h# ffffff and swap ( dadr dlen buf ) 76 3 + c@ ( dadr dlen type ) 77 ; 78 79 : got-bt-packet? ( -- false | dadr dlen type true ) 80 read-poll ( ) 81 82 get-queued? if ( buf len ) 83 decode-bt-header true ( dadr dlen type true ) 84 else ( ) 85 false ( false ) 63 86 then 64 87 ; … … 67 90 0 value rca \ Relative card address 68 91 69 : set-parent-channel ( -- ) rca my-unit set-address;92 : set-parent-channel ( -- ) rca my-unit " set-address" $call-parent ; 70 93 71 94 : release-bus-resources ( -- ) drain-queue detach-card ; … … 76 99 77 100 : make-my-properties ( -- ) 78 get-addressdup to rca101 " get-address" $call-parent dup to rca 79 102 encode-int " assigned-address" property 80 103 ; 81 104 82 : setup-bus-io ( /inbuf /outbuf -- error? ) 83 2drop 105 : setup-bus-io ( -- error? ) 84 106 init-queue 85 107 ?attach-card 0= if ." Failed to attach card" cr true exit then 86 108 make-my-properties 87 init-device88 109 false 89 110 ; 90 111 91 : reset-host-bus ( -- ) ; 112 : alloc-buffer ( len -- adr ) /fw-transport + dma-alloc ; 113 : free-buffer ( adr len -- ) /fw-transport negate /string dma-free ; 92 114 93 115 \ LICENSE_BEGIN -
dev/mmc/sdhci/mv8686/sdio.fth
r3487 r3569 5 5 headers 6 6 7 : sdio-reg@ ( reg# function# -- value ) " sdio-reg@" $call-parent ; 8 : sdio-reg! ( value reg# function# -- ) " sdio-reg!" $call-parent ; 9 : sdio-reg-w@ ( reg# function# -- w.value ) 10 2dup sdio-reg@ -rot ( low reg# function# ) 11 swap 1+ swap sdio-reg@ ( low high ) 12 bwjoin ( w.value ) 13 ; 14 : sdio-w@ ( reg# -- w.value ) 1 sdio-reg-w@ ; 7 0 instance value function# 8 0 instance value rx-shift 9 10 : sdio-b@ ( reg# function# -- value ) function# " sdio-reg@" $call-parent ; 11 : sdio-b! ( value reg# function# -- ) function# " sdio-reg!" $call-parent ; 12 : sdio-w@ ( reg# -- w.value ) 13 dup sdio-b@ ( reg# low ) 14 swap 1+ sdio-b@ ( low high ) 15 bwjoin ( w.value ) 16 ; 15 17 16 18 false instance value multifunction? … … 27 29 : set-default-fw$ ( adr len -- ) to fw-name-len to fw-name-adr ; 28 30 29 0 value ioport31 0 instance value ioport 30 32 d# 256 constant blksz \ Block size for data tx/rx 31 33 d# 256 constant fw-blksz … … 51 53 h# 60 constant card-fw-status0-reg 52 54 \ h# 61 constant card-fw-status1-reg 53 \h# 62 constant card-rx-len-reg54 \h# 63 constant card-rx-unit-reg55 h# 62 constant card-rx-len-reg 56 h# 63 constant card-rx-unit-reg 55 57 h# 78 constant ioport-reg 56 58 … … 68 70 69 71 : mv8686-rx-ready? ( -- len ) 70 host-intstatus-reg 1 sdio-reg@72 host-intstatus-reg sdio-b@ 71 73 dup 0= if exit then 72 dup invert 3 and host-intstatus-reg 1 sdio-reg! \ Clear UP_LD bit74 dup invert 3 and host-intstatus-reg sdio-b! \ Clear UP_LD bit 73 75 1 and if 74 76 sdio-fw-status@ … … 107 109 then 108 110 ; 111 109 112 0 instance value rx-port# 110 113 0 instance value wr-bitmap 111 114 0 instance value rd-bitmap 115 : bt-update-bitmaps ( -- len ) 116 card-status-reg sdio-b@ 117 dup 1 and if 1 to wr-bitmap then 118 2 and if 1 to rd-bitmap then 119 ; 120 : mv8787-bt-rx-ready? ( -- len ) 121 rd-bitmap if ( ) 122 0 to rd-bitmap ( ) 123 card-rx-len-reg sdio-b@ rx-shift lshift ( len ) 124 \ XXX round up to multiple of blocksize ? Maybe sdhci already does it 125 else ( ) 126 bt-update-bitmaps ( ) 127 0 ( len ) 128 then ( len ) 129 ; 130 112 131 : update-bitmaps ( -- ) 113 host-intstatus-reg 1 sdio-reg@132 host-intstatus-reg sdio-b@ 114 133 dup 2 and if wr-bitmap-reg sdio-w@ to wr-bitmap then 115 134 1 and if rd-bitmap-reg sdio-w@ to rd-bitmap then 116 135 ; 117 : mv8787- rx-ready? ( -- len )136 : mv8787-wlan-rx-ready? ( -- len ) 118 137 rd-bitmap dup if ( bitmap ) 119 138 d# 16 0 do ( bitmap ) … … 129 148 update-bitmaps ( 0 ) 130 149 then 150 ; 151 : mv8787-rx-ready? ( -- len ) 152 function# 1 = if mv8787-wlan-rx-ready? else mv8787-bt-rx-ready? then 131 153 ; 132 154 … … 169 191 h# 60 to card-fw-status0-reg 170 192 \ h# 61 to card-fw-status1-reg 171 \h# 62 to card-rx-len-reg172 \h# 63 to card-rx-unit-reg193 h# 62 to card-rx-len-reg 194 h# 63 to card-rx-unit-reg 173 195 h# 78 to ioport-reg 174 196 d# 256 to blksz … … 184 206 ; 185 207 208 : set-block-size ( n -- ) to blksz ; 209 186 210 : set-version ( -- error? ) 187 211 " sdio-card-id" $call-parent case … … 196 220 : roundup-blksz ( n -- n' ) blksz 1- + blksz / blksz * ; 197 221 198 : set-address ( rca slot -- ) " set-address" $call-parent ;199 222 : get-address ( -- rca ) " get-address" $call-parent ; 200 223 : attach-card ( -- ok? ) " attach-sdio-card" $call-parent ; … … 203 226 : sdio-poll-dl-ready ( -- ready? ) 204 227 false d# 100 0 do 205 card-status-reg 1 sdio-reg@228 card-status-reg sdio-b@ 206 229 h# 9 tuck and = if drop true leave then 207 230 d# 100 usec … … 211 234 212 235 : sdio-fw! ( adr len -- actual ) 213 >r >r ioport 1 true r> r> fw-blksz false " r/w-ioblocks" $call-parent 214 ; 215 216 : init-device ( -- ) 217 ioport-reg 3 bounds do i 1 sdio-reg@ loop \ Read the IO port 236 >r >r ioport function# true r> r> fw-blksz false " r/w-ioblocks" $call-parent 237 ; 238 239 : init-function ( function# -- ) 240 0 to function# ( function# ) 241 242 1 over lshift 2 sdio-b! ( function# ) \ Enable IO function 243 1 over lshift 1 or 4 sdio-b! ( function# ) \ Enable interrupts for function and card 244 245 7 sdio-b@ h# 20 or 7 sdio-b! ( function# ) \ Enable async interrupt mode 246 247 to function# 248 249 ioport-reg 3 bounds do i sdio-b@ loop \ Read the IO port 218 250 0 bljoin to ioport 219 220 7 0 sdio-reg@ h# 20 or 7 0 sdio-reg! \ Enable async interrupt mode221 222 2 2 0 sdio-reg! \ Enable IO function 1 (2 = 1 << 1)223 3 4 0 sdio-reg! \ Enable interrupts (1) for function 1 (1 << 1)224 251 225 252 mv8787? if 226 253 \ Set host interrupt reset to "read to clear" 227 host-int-rsr-reg 1 sdio-reg@ h# 3f or host-int-rsr-reg 1 sdio-reg!254 host-int-rsr-reg sdio-b@ h# 3f or host-int-rsr-reg sdio-b! 228 255 229 256 \ Set Dnld/upld to "auto reset" 230 card-misc-cfg-reg 1 sdio-reg@ h# 10 or card-misc-cfg-reg 1 sdio-reg!257 card-misc-cfg-reg sdio-b@ h# 10 or card-misc-cfg-reg sdio-b! 231 258 then 232 259 \ Newer revisions of the 8787 firmware empirically require that this … … 234 261 \ 8686 firmware, appear to be content with it either here or after 235 262 \ firmware startup. 236 3 host-int-mask-reg 1 sdio-reg! \ Enable upload (1) and download (2)263 3 host-int-mask-reg sdio-b! \ Enable upload (1) and download (2) 237 264 ; 238 265 239 266 : sdio-blocks@ ( adr len -- actual ) 240 267 >r >r 241 rx-port# ioport + 1true r> r> blksz true " r/w-ioblocks" $call-parent ( actual )268 rx-port# ioport + function# true r> r> blksz true " r/w-ioblocks" $call-parent ( actual ) 242 269 ; 243 270 244 271 \ : sdio-blocks! ( adr len -- actual ) 245 \ >r >r x-get-write-port ioport + 1true r> r> blksz false " r/w-ioblocks" $call-parent272 \ >r >r x-get-write-port ioport + function# true r> r> blksz false " r/w-ioblocks" $call-parent 246 273 \ ; 247 274 248 \ 1 is the function number249 275 : (sdio-blocks!) ( adr len port# -- actual ) 250 ioport + -rot ( port# adr len )251 1 true 2swap( port# function# inc? adr len )276 ioport + -rot ( port# adr len ) 277 function# true 2swap ( port# function# inc? adr len ) 252 278 blksz false " r/w-ioblocks" $call-parent 253 279 ; 280 : sdio-blocks! ( adr len -- actual ) 0 (sdio-blocks!) ; 254 281 255 282 \ 0 is the control port number -
dev/mmc/sdhci/sdhci.fth
r3337 r3569 1091 1091 dup h# ff <> 1092 1092 while ( offset tuple-code ) 1093 \ Another potentially interesting tuple s sih# 15 from which1093 \ Another potentially interesting tuple is h# 15 from which 1094 1094 \ you can get strings naming the product. 1095 1095 case -
dev/usb2/device/wlan/fw8388.fth
r1735 r3569 85 85 : wait-cmd-fw-dl-ack ( -- acked? ) 86 86 d# 100 0 do ( ) 87 got-packet? if ( error | buf len 0 )87 got-packet? if ( error | buf len type 0 ) 88 88 if ( ) 89 89 false ( acked? ) 90 else ( buf len )91 cmd-fw-dl-ok? ( acked? )90 else ( buf len type ) 91 drop cmd-fw-dl-ok? ( acked? ) 92 92 then ( acked? ) 93 93 recycle-packet ( acked? ) … … 100 100 101 101 : download-fw-init ( -- ) 102 outbuf /boot-cmd erase103 boot-magic outbuf >boot-magic le-l!104 cmd-fw-dl outbuf >boot-cmd c!102 fw-buf /boot-cmd erase 103 boot-magic fw-buf >boot-magic le-l! 104 cmd-fw-dl fw-buf >boot-cmd c! 105 105 106 106 5 0 do 107 outbuf /boot-cmd packet-out drop107 fw-buf /boot-cmd packet-out drop 108 108 wait-cmd-fw-dl-ack if leave then 109 109 loop … … 119 119 : wait-fw-dl-ack ( -- ) 120 120 d# 500 0 do ( ) 121 got-packet? if ( error | buf len 0 )122 0= if process-dl-resp then ( )121 got-packet? if ( error | buf len tupe 0 ) 122 0= if drop process-dl-resp then ( ) 123 123 recycle-packet ( ) 124 124 leave … … 131 131 bounds begin ( end start ) 132 132 dl-seq++ \ Increment sequence number 133 dup outbuf /dl-header move \ Move header to outbuf134 dl-seq outbuf >dl-seq le-l! \ Add sequence number to outbuf135 dup /dl-header + outbuf >dl-data 2 pick >dl-len le-l@ dup >r move136 \ Move payload to outbuf137 outbuf r@ /dl-header + 4 + packet-out drop133 dup fw-buf /dl-header move \ Move header to outbuf 134 dl-seq fw-buf >dl-seq le-l! \ Add sequence number to outbuf 135 dup /dl-header + fw-buf >dl-data 2 pick >dl-len le-l@ dup >r move 136 \ Move payload to fw-buf 137 fw-buf r@ /dl-header + 4 + packet-out drop 138 138 \ Send command 139 139 wait-fw-dl-ack \ Wait for ACK … … 180 180 ; 181 181 182 : load-8388-fw ( -- error? ) 182 : load-all-fw ( -- error? ) 183 d# 2048 dma-alloc to fw-buf 183 184 wlan-fw find-fw ( adr len ) 184 185 dup if download-fw else 2drop true then 185 ; 186 187 ' load-8388-fw to load-all-fw 186 fw-buf d# 2048 dma-free 187 ; 188 188 189 189 \ LICENSE_BEGIN -
dev/usb2/device/wlan/usb8388.bth
r1179 r3569 14 14 fload ${BP}/dev/usb2/device/wlan/common.fth \ Ethernet common variables and routines 15 15 fload ${BP}/dev/usb2/device/wlan/usb8388.fth \ USB I/O interface for Marvell 8388 16 fload ${BP}/dev/usb2/device/wlan/fw8388.fth \ Marvell firmware download for USB 16 17 fload ${BP}/dev/libertas.fth \ Marvell "Libertas" common code 17 18 \ fload ${BP}/dev/usb2/device/wlan/wlan.fth \ External interface methods 18 fload ${BP}/dev/usb2/device/wlan/fw8388.fth \ Marvell firmware download for USB19 19 20 20 end0 -
dev/usb2/device/wlan/usb8388.fth
r3448 r3569 43 43 44 44 : cmd-out ( adr len -- error? ) 45 /fw-transport negate /string ( adr' len' ) 45 46 TYPE_USB_REQUEST 2 pick >fw-transport le-l! ( adr len ) 46 47 2dup vdump ( adr len ) … … 49 50 50 51 : data-out ( adr len -- ) 52 /fw-transport negate /string ( adr' len' ) 51 53 TYPE_USB_DATA 2 pick >fw-transport le-l! ( adr len ) 52 54 packet-out-async 53 55 ; 54 56 55 \ Translate the USB/8388 type codes into more abstract codes, which 56 \ happen to be the codes used by the 8686 57 : packet-type ( adr -- type ) 58 >fw-transport le-l@ case 57 \ Translate the USB/8388 type codes into uniform code numbers 58 : decode-header ( buf len -- dadr dlen type ) 59 over le-l@ >r ( buf len r: usb-type ) 60 /fw-transport /string ( dadr dlen r: usb-type ) 61 r> case 59 62 TYPE_USB_REQUEST of 0 endof 60 63 TYPE_USB_DATA of 1 endof 61 64 TYPE_USB_INDICATION of 2 endof 62 endcase 65 endcase ( dadr dlen type ) 63 66 ; 64 67 65 : got-packet? ( -- false | error true | buf len 0 true ) bulk-in-ready? ; 68 : got-packet? ( -- false | error true | buf len type 0 true ) 69 bulk-in-ready? if ( error | buf len 0 ) 70 ?dup 0= if ( dadr dlen ) 71 decode-header 0 ( dadr dlen type 0 ) 72 then ( error | buf len 0 ) 73 else ( ) 74 false ( false ) 75 then ( false | error true | buf len 0 true ) 76 ; 66 77 : recycle-packet ( -- ) restart-bulk-in ; 67 78 … … 70 81 : set-parent-channel ( -- ) set-device device set-target ; 71 82 72 : setup-bus-io ( /inbuf /outbuf-- error? )83 : setup-bus-io ( -- error? ) 73 84 reset? if 74 85 configuration set-config if … … 78 89 bulk-in-pipe bulk-out-pipe reset-bulk-toggles 79 90 then 80 4 bulk-out-pipe " begin-out-ring" $call-parent ( /inbuf )81 h# 40 bulk-in-pipe " begin-in-ring" $call-parent91 d# 2048 4 bulk-out-pipe " begin-out-ring" $call-parent 92 d# 2048 h# 40 bulk-in-pipe " begin-in-ring" $call-parent 82 93 false 83 94 ; … … 85 96 : release-bus-resources ( -- ) end-bulk-in end-out-ring ; 86 97 87 : reset-host-bus ( -- ) ;98 : reset-host-bus ( -- ) " wlan-reset" evaluate ; 88 99 89 100 0 value vid … … 98 109 99 110 init 111 XXX need open and close methods and open needs to call setup-bus-io 112 XXX need alloc-buffer and free-buffer method 100 113 101 114 \ LICENSE_BEGIN -
dev/usb2/device/wlan/wlan.fth
r1704 r3569 125 125 got-packet? 0= if ( adr len ) 126 126 2drop -2 exit 127 then ( adr len [ error | buf actual 0 ] )127 then ( adr len [ error | buf actual type 0 ] ) 128 128 129 129 if \ receive error ( adr len ) 130 130 recycle-packet ( adr len ) 131 131 2drop -1 exit 132 then ( adr len buf actual )133 134 false to got-data? ( adr len buf actual )132 then ( adr len buf actual type ) 133 134 false to got-data? ( adr len buf actual type ) 135 135 process-rx ( adr len ) 136 136 recycle-packet ( adr len )
Note: See TracChangeset
for help on using the changeset viewer.
