Subversion Repositories Kolibri OS

Rev

Rev 7827 | Rev 9147 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7827 Rev 9146
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2018-2020. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2018-2021. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  AR81XX driver for KolibriOS                                    ;;
6
;;  AR81XX driver for KolibriOS                                    ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  based on alx driver from TI-OpenLink                           ;;
8
;;  based on alx driver from TI-OpenLink                           ;;
Line 22... Line 22...
22
 
22
 
23
        CURRENT_API             = 0x0200
23
        CURRENT_API             = 0x0200
24
        COMPATIBLE_API          = 0x0100
24
        COMPATIBLE_API          = 0x0100
Line 25... Line 25...
25
        API_VERSION             = (COMPATIBLE_API shl 16) + CURRENT_API
25
        API_VERSION             = (COMPATIBLE_API shl 16) + CURRENT_API
Line 26... Line 26...
26
 
26
 
27
        MAX_DEVICES             = 16
-
 
Line -... Line 27...
-
 
27
; configureable area
-
 
28
 
-
 
29
        MAX_DEVICES             = 16    ; Maximum number of devices this driver may handle
28
 
30
 
29
        __DEBUG__               = 1
31
        __DEBUG__               = 1     ; 1 = on, 0 = off
Line 30... Line 32...
30
        __DEBUG_LEVEL__         = 2
32
        __DEBUG_LEVEL__         = 2     ; 1 = verbose, 2 = errors only
Line 31... Line 33...
31
 
33
 
32
        TX_RING_SIZE            = 128             ; RING sizes must be a power of 2
34
        TX_RING_SIZE            = 128   ; Number of packets in send ring buffer
33
        RX_RING_SIZE            = 128
35
        RX_RING_SIZE            = 128   ; Number of packets in receive ring buffer
-
 
36
 
-
 
37
        RX_BUFFER_SIZE          = 1536
Line 34... Line 38...
34
 
38
 
Line 35... Line 39...
35
        RX_BUFFER_SIZE          = 1536
39
        SMB_TIMER               = 400
36
 
40
        IMT                     = 200                   ; IRQ Modulo Timer
Line 46... Line 50...
46
include '../fdo.inc'
50
include '../fdo.inc'
47
include '../netdrv.inc'
51
include '../netdrv.inc'
Line 48... Line 52...
48
 
52
 
Line -... Line 53...
-
 
53
include 'ar81xx.inc'
-
 
54
 
-
 
55
if (bsr TX_RING_SIZE)>(bsf TX_RING_SIZE)
-
 
56
  display 'TX_RING_SIZE must be a power of two'
-
 
57
  err
-
 
58
end if
49
include 'ar81xx.inc'
59
 
-
 
60
if (bsr RX_RING_SIZE)>(bsf RX_RING_SIZE)
-
 
61
  display 'RX_RING_SIZE must be a power of two'
Line -... Line 62...
-
 
62
  err
50
 
63
end if
51
; Transmit Packet Descriptor
64
 
52
 
65
; Transmit Packet Descriptor
53
struct alx_tpd
66
struct alx_tpd
54
        length          dw ?
67
        length          dw ?
55
        vlan_tag        dw ?
68
        vlan_tag        dw ?
56
        word1           dd ?
69
        word1           dd ?
Line 57... Line 70...
57
        addr_l          dd ?
70
        addr_l          dd ?
58
        addr_h          dd ?
-
 
59
ends
71
        addr_h          dd ?
60
 
72
ends
61
; Receive Return Descriptor
73
 
62
 
74
; Receive Return Descriptor
63
struct alx_rrd
75
struct alx_rrd
64
        word0           dd ?    ; IP payload cksum + number of RFDs + start index of RFD-ring
76
        word0           dd ?    ; IP payload cksum + number of RFDs + start index of RFD-ring
Line 65... Line 77...
65
        rss_hash        dd ?
77
        rss_hash        dd ?
66
        word2           dd ?    ; VLAN tag + Protocol ID + RSS Q num + RSS Hash algorithm
-
 
67
        word3           dd ?    ; Packet length + status
78
        word2           dd ?    ; VLAN tag + Protocol ID + RSS Q num + RSS Hash algorithm
68
ends
79
        word3           dd ?    ; Packet length + status
69
 
80
ends
70
; Receive Free Descriptor
81
 
Line 71... Line -...
71
 
-
 
72
struct alx_rfd
82
; Receive Free Descriptor
Line 73... Line 83...
73
        addr_l          dd ?
83
struct alx_rfd
74
        addr_h          dd ?
84
        addr_l          dd ?
75
ends
85
        addr_h          dd ?
Line 85... Line 95...
85
        irq_line        dd ?
95
        irq_line        dd ?
86
        pci_rev         dd ?
96
        pci_rev         dd ?
87
        chip_rev        dd ?
97
        chip_rev        dd ?
88
        mmio_addr       dd ?
98
        mmio_addr       dd ?
Line 89... Line -...
89
 
-
 
90
;        dma_chnl        dd ?
99
 
Line 91... Line 100...
91
        max_dma_chnl    dd ?
100
        max_dma_chnl    dd ?
92
 
101
 
Line 106... Line 115...
106
        tpd_ring_virt   rd TX_RING_SIZE
115
        tpd_ring_virt   rd TX_RING_SIZE
107
        rfd_ring_virt   rd RX_RING_SIZE
116
        rfd_ring_virt   rd RX_RING_SIZE
Line 108... Line 117...
108
 
117
 
Line 109... Line -...
109
ends
-
 
110
 
-
 
111
 
118
ends
112
 
119
 
113
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
114
;;                        ;;
121
;;                        ;;
115
;; proc START             ;;
122
;; proc START             ;;
Line 130... Line 137...
130
        xor     eax, eax
137
        xor     eax, eax
131
        ret
138
        ret
Line 132... Line 139...
132
 
139
 
Line 133... Line -...
133
endp
-
 
134
 
140
endp
135
 
141
 
136
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
142
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
137
;;                        ;;
143
;;                        ;;
138
;; proc SERVICE_PROC      ;;
144
;; proc SERVICE_PROC      ;;
Line 187... Line 193...
187
        je      .find_devicenum                         ; Device is already loaded, let's find it's device number
193
        je      .find_devicenum                         ; Device is already loaded, let's find it's device number
188
       @@:
194
       @@:
189
        add     esi, 4
195
        add     esi, 4
190
        loop    .nextdevice
196
        loop    .nextdevice
Line 191... Line -...
191
 
-
 
192
 
197
 
193
; This device doesnt have its own eth_device structure yet, lets create one
198
; This device doesnt have its own eth_device structure yet, lets create one
194
  .firstdevice:
199
  .firstdevice:
195
        cmp     [devices], MAX_DEVICES                  ; First check if the driver can handle one more card
200
        cmp     [devices], MAX_DEVICES                  ; First check if the driver can handle one more card
Line 276... Line 281...
276
        ret
281
        ret
Line 277... Line 282...
277
 
282
 
278
;------------------------------------------------------
283
;------------------------------------------------------
Line 279... Line -...
279
endp
-
 
280
 
284
endp
281
 
285
 
282
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
286
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
283
;;                                                                        ;;
287
;;                                                                        ;;
284
;;        Actual Hardware dependent code starts here                      ;;
288
;;        Actual Hardware dependent code starts here                      ;;
Line 285... Line -...
285
;;                                                                        ;;
-
 
286
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
289
;;                                                                        ;;
287
 
290
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
288
 
291
 
289
align 4
292
align 4
290
unload:
293
unload:
Line 297... Line 300...
297
        ; - Remove all allocated structures and buffers the card used
300
        ; - Remove all allocated structures and buffers the card used
Line 298... Line 301...
298
 
301
 
299
        or      eax, -1
302
        or      eax, -1
Line 300... Line -...
300
        ret
-
 
301
 
303
        ret
302
 
304
 
303
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
305
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
304
;;
306
;;
305
;;  probe: enables the device (if it really is AR81XX)
307
;;  probe: enables the device (if it really is AR81XX)
Line 309... Line 311...
309
align 4
311
align 4
310
probe:
312
probe:
311
        DEBUGF  1,"Probing\n"
313
        DEBUGF  1,"Probing\n"
Line 312... Line 314...
312
 
314
 
313
; Make the device a bus master
315
; Make the device a bus master
314
        invoke  PciRead16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
316
        invoke  PciRead16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header.command
315
        or      al, PCI_CMD_MASTER + PCI_CMD_MMIO + PCI_CMD_PIO
317
        or      al, PCI_CMD_MASTER + PCI_CMD_MMIO + PCI_CMD_PIO
316
        and     ax, not(PCI_CMD_INTX_DISABLE)
318
        and     ax, not(PCI_CMD_INTX_DISABLE)
Line 317... Line 319...
317
        invoke  PciWrite16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
319
        invoke  PciWrite16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header.command, eax
318
 
320
 
319
; get device id
321
; get device ID
Line 320... Line 322...
320
        invoke  PciRead16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.device_id
322
        invoke  PciRead16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header.device_id
321
        mov     [ebx + device.pci_did], ax
323
        mov     [ebx + device.pci_did], ax
322
 
324
 
Line 333... Line 335...
333
        mov     eax, dword[esi+4]
335
        mov     eax, dword[esi+4]
334
        mov     [ebx + device.name], eax
336
        mov     [ebx + device.name], eax
335
        DEBUGF  1, "Chip type = %s\n", eax
337
        DEBUGF  1, "Chip type = %s\n", eax
336
  .done:
338
  .done:
Line 337... Line 339...
337
 
339
 
338
; get revision id.
340
; get revision ID
339
        invoke  PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.revision_id
341
        invoke  PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header.revision_id
-
 
342
        and     eax, 0xff
340
        and     eax, 0xff
343
        DEBUGF  1,"PCI Revision: %u\n", eax
341
        mov     [ebx + device.pci_rev], eax
344
        mov     [ebx + device.pci_rev], eax
342
        shr     al, ALX_PCI_REVID_SHIFT
345
        shr     al, ALX_PCI_REVID_SHIFT
-
 
346
        mov     [ebx + device.chip_rev], eax
Line 343... Line -...
343
        mov     [ebx + device.chip_rev], eax
-
 
344
 
-
 
345
        DEBUGF  1,"Revision: %u\n", al
347
        DEBUGF  1,"ALX Revision: %u\n", eax
Line 346... Line 348...
346
 
348
 
347
;;;        call    alx_reset_pcie
349
        stdcall alx_reset_pcie
-
 
350
 
-
 
351
        mov     ecx, (ALX_PMCTRL_L0S_EN or ALX_PMCTRL_L1_EN or ALX_PMCTRL_ASPM_FCEN)
Line 348... Line 352...
348
 
352
        stdcall alx_enable_aspm
-
 
353
 
-
 
354
        stdcall alx_reset_phy
-
 
355
 
-
 
356
        stdcall alx_reset_mac
-
 
357
 
-
 
358
; Setup link to put it in a known good starting state
-
 
359
        stdcall alx_write_phy_reg, ALX_MII_DBG_ADDR, 0
-
 
360
 
-
 
361
        mov     esi, [ebx + device.mmio_addr]
-
 
362
        mov     eax, dword[esi + ALX_DRV]
-
 
363
 
-
 
364
        stdcall alx_write_phy_reg, MII_ADVERTISE, ADVERTISE_CSMA or ADVERTISE_10HALF or ADVERTISE_10FULL or ADVERTISE_100HALF or ADVERTISE_100FULL or ADVERTISE_PAUSE_CAP
-
 
365
 
-
 
366
        xor     eax, eax
-
 
367
        test    [ebx + device.pci_did], 1       ;;; FIXME: is gigabit device?
Line 349... Line 368...
349
        mov     ecx, (ALX_PMCTRL_L0S_EN or ALX_PMCTRL_L1_EN or ALX_PMCTRL_ASPM_FCEN)
368
        jz      @f
Line 350... Line 369...
350
        call    alx_enable_aspm
369
        mov     eax, ADVERTISE_1000XFULL
Line 351... Line 370...
351
 
370
  @@:
352
        call    alx_reset_phy
371
        stdcall alx_write_phy_reg, MII_CTRL1000, eax
Line 353... Line 372...
353
 
372
 
Line 354... Line 373...
354
        call    alx_reset_mac
373
        stdcall alx_write_phy_reg, MII_BMCR, BMCR_RESET or BMCR_ANENABLE or BMCR_ANRESTART
Line 355... Line 374...
355
 
374
 
356
        call    alx_get_perm_macaddr
-
 
357
 
-
 
358
align 4
-
 
Line 359... Line 375...
359
reset:
375
        stdcall alx_get_perm_macaddr
360
 
376
 
Line 361... Line 377...
361
        DEBUGF  1,"Resetting\n"
377
align 4
Line 362... Line 378...
362
 
378
reset:
Line 363... Line 379...
363
; alx init_sw
379
 
Line 364... Line 380...
364
 
380
        DEBUGF  1,"Resetting\n"
Line 365... Line 381...
365
        call    alx_identify_hw
381
 
366
 
382
; alx init_sw
Line 391... Line 407...
391
; Clear old interrupts
407
; Clear old interrupts
392
        mov     edi, [ebx + device.mmio_addr]
408
        mov     edi, [ebx + device.mmio_addr]
393
        mov     eax, not ALX_ISR_DIS
409
        mov     eax, not ALX_ISR_DIS
394
        mov     [edi + ALX_ISR], eax
410
        mov     [edi + ALX_ISR], eax
Line 395... Line 411...
395
 
411
 
Line 396... Line 412...
396
        call    alx_irq_enable
412
        stdcall alx_irq_enable
397
 
413
 
Line 398... Line 414...
398
; Set the mtu, kernel will be able to send now
414
; Set the MTU, kernel will be able to send now
Line 399... Line 415...
399
        mov     [ebx + device.mtu], 1514
415
        mov     [ebx + device.mtu], 1514
400
 
416
 
401
        call    alx_check_link
417
        stdcall alx_check_link
Line 402... Line -...
402
 
-
 
403
        DEBUGF  1,"Reset ok\n"
-
 
404
        xor     eax, eax
418
 
405
        ret
419
        DEBUGF  1,"Reset ok\n"
406
 
420
        xor     eax, eax
407
 
421
        ret
408
 
422
 
-
 
423
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
409
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
424
;;                                         ;;
410
;;                                         ;;
425
;; Transmit                                ;;
411
;; Transmit                                ;;
-
 
412
;;                                         ;;
-
 
413
;; In: pointer to device structure in ebx  ;;
426
;;                                         ;;
414
;;                                         ;;
-
 
415
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
427
;; In: pointer to device structure in ebx  ;;
Line 416... Line 428...
416
 
428
;; Out: eax = 0 on success                 ;;
417
;; alx_start_xmit
-
 
Line 418... Line 429...
418
;; alx_map_tx_skb
429
;;                                         ;;
419
 
430
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
420
proc transmit stdcall bufferptr
431
align 16
421
 
432
proc transmit stdcall bufferptr
422
        pushf
433
 
423
        cli
434
        spin_lock_irqsave
424
 
435
 
Line 425... Line 436...
425
        mov     esi, [bufferptr]
436
        mov     esi, [bufferptr]
426
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
437
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
427
        lea     eax, [esi + NET_BUFF.data]
438
        lea     eax, [esi + NET_BUFF.data]
428
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
439
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
Line 429... Line 440...
429
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
440
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
430
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
441
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
431
        [eax+13]:2,[eax+12]:2
442
        [eax+13]:2,[eax+12]:2
-
 
443
 
-
 
444
        cmp     [esi + NET_BUFF.length], 1514
432
 
445
        ja      .error
433
        cmp     [esi + NET_BUFF.length], 1514
446
        cmp     [esi + NET_BUFF.length], 60
434
        ja      .fail
447
        jb      .error
435
        cmp     [esi + NET_BUFF.length], 60
448
 
436
        jb      .fail
449
; Program the descriptor
Line 469... Line 482...
469
 
482
 
470
        popf
483
        popf
471
        xor     eax, eax
484
        xor     eax, eax
Line 472... Line 485...
472
        ret
485
        ret
473
 
486
 
-
 
487
  .error:
474
  .fail:
488
        DEBUGF  2, "TX packet error\n"
-
 
489
        inc     [ebx + device.packets_tx_err]
475
        DEBUGF  2,"Send failed\n"
490
        invoke  NetFree, [bufferptr]
476
        invoke  NetFree, [bufferptr]
491
 
477
        popf
492
        spin_unlock_irqrestore
Line 478... Line 493...
478
        or      eax, -1
493
        or      eax, -1
-
 
494
        ret
-
 
495
 
-
 
496
  .overrun:
Line -... Line 497...
-
 
497
        DEBUGF  2, "TX overrun\n"
-
 
498
        inc     [ebx + device.packets_tx_ovr]
-
 
499
        invoke  NetFree, [bufferptr]
Line -... Line 500...
-
 
500
 
Line 479... Line 501...
479
        ret
501
        spin_unlock_irqrestore
480
 
502
        or      eax, -1
481
endp
503
        ret
482
 
504
 
483
 
505
endp
484
 
-
 
485
;;;;;;;;;;;;;;;;;;;;;;;
506
 
486
;;                   ;;
507
;;;;;;;;;;;;;;;;;;;;;;;
Line 487... Line 508...
487
;; Interrupt handler ;;
508
;;                   ;;
Line -... Line 509...
-
 
509
;; Interrupt handler ;;
488
;;                   ;;
510
;;                   ;;
Line 489... Line 511...
489
;;;;;;;;;;;;;;;;;;;;;;;
511
;;;;;;;;;;;;;;;;;;;;;;;
Line 490... Line -...
490
 
-
 
491
align 4
-
 
492
int_handler:
-
 
493
 
-
 
494
        push    ebx esi edi
-
 
495
 
-
 
496
        DEBUGF  1,"int\n"
512
align 16
497
 
513
int_handler:
498
; Find pointer of device wich made IRQ occur
514
 
499
 
515
        push    ebx esi edi
500
        mov     ecx, [devices]
-
 
501
        test    ecx, ecx
-
 
502
        jz      .nothing
-
 
503
        mov     esi, device_list
-
 
504
  .nextdevice:
-
 
505
        mov     ebx, [esi]
-
 
506
        mov     edi, [ebx + device.mmio_addr]
-
 
507
        mov     eax, [edi + ALX_ISR]
-
 
508
        test    eax, eax
-
 
509
        jnz     .got_it
-
 
510
  .continue:
-
 
Line 511... Line -...
511
        add     esi, 4
-
 
512
        dec     ecx
516
 
513
        jnz     .nextdevice
517
        mov     ebx, [esp+4*4]
514
  .nothing:
518
        DEBUGF  1,"INT for 0x%x\n", ebx
Line 515... Line 519...
515
        pop     edi esi ebx
519
 
516
        xor     eax, eax
520
; TODO? if we are paranoid, we can check that the value from ebx is present in the current device_list
517
 
521
 
518
        ret                             ; If no device was found, abort
522
        mov     edi, [ebx + device.mmio_addr]
519
 
523
        mov     eax, [edi + ALX_ISR]
520
; At this point, test for all possible reasons, and handle accordingly
524
        test    eax, eax
521
 
525
        jz      .nothing
Line 522... Line 526...
522
  .got_it:
526
 
523
        or      eax, ALX_ISR_DIS
527
        or      eax, ALX_ISR_DIS
524
        mov     [edi + ALX_ISR], eax    ; ACK interrupt
528
        mov     [edi + ALX_ISR], eax    ; ACK interrupt
525
        DEBUGF  1,"Device: %x Status: %x\n", ebx, eax
529
        DEBUGF  1,"Status: %x\n", eax
526
 
530
 
527
        test    eax, ALX_ISR_TX_Q0
531
        test    eax, ALX_ISR_TX_Q0
Line 528... Line 532...
528
        jz      .no_tx
532
        jz      .no_tx
529
        DEBUGF  1,"TX interrupt\n"
533
        DEBUGF  1,"TX interrupt\n"
530
        pusha
534
        pusha
531
        call    alx_clean_tx_irq
535
        stdcall alx_clean_tx_irq
532
        popa
536
        popa
533
  .no_tx:
537
  .no_tx:
534
 
538
 
535
        test    eax, ALX_ISR_RX_Q0
539
        test    eax, ALX_ISR_RX_Q0
Line 536... Line 540...
536
        jz      .no_rx
540
        jz      .no_rx
537
        DEBUGF  1,"RX interrupt\n"
541
        DEBUGF  1,"RX interrupt\n"
538
        pusha
542
        pusha
-
 
543
        stdcall alx_clean_rx_irq
-
 
544
        popa
-
 
545
 
539
        call    alx_clean_rx_irq
546
  .no_rx:
Line -... Line 547...
-
 
547
        test    eax, ALX_ISR_PHY
-
 
548
        jz      .no_phy
-
 
549
        DEBUGF  1,"PHY interrupt\n"
Line 540... Line 550...
540
        popa
550
        pusha
-
 
551
; TODO: queue link check and disable this interrupt cause meanwhile??
541
 
552
        stdcall alx_check_link
-
 
553
        popa
-
 
554
 
-
 
555
  .no_phy:
Line 542... Line 556...
542
  .no_rx:
556
        mov     dword[edi + ALX_ISR], 0
543
        test    eax, ALX_ISR_PHY
557
        pop     edi esi ebx
Line 544... Line 558...
544
        jz      .no_phy
558
        xor     eax, eax
Line 573... Line 587...
573
 
587
 
574
        xor     eax, eax
588
        xor     eax, eax
575
        dec     eax
589
        dec     eax
Line -... Line 590...
-
 
590
        ret
-
 
591
 
-
 
592
  .alc:
-
 
593
        mov     [ebx + device.max_dma_chnl], 2
-
 
594
        xor     eax, eax
-
 
595
        ret
Line -... Line 596...
-
 
596
 
Line 576... Line 597...
576
        ret
597
endp
-
 
598
 
-
 
599
proc udelay stdcall microseconds
-
 
600
 
-
 
601
; FIXME
-
 
602
 
-
 
603
        push    esi ecx edx
-
 
604
        xor     esi, esi
-
 
605
        inc     esi
-
 
606
        invoke  Sleep
-
 
607
        pop     edx ecx esi
-
 
608
 
-
 
609
        ret
-
 
610
 
-
 
611
endp
-
 
612
 
-
 
613
proc alx_reset_pcie stdcall
-
 
614
 
-
 
615
        DEBUGF  1,"alx_reset_pcie\n"
-
 
616
 
-
 
617
; Make the device a bus master
-
 
618
        invoke  PciRead16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
-
 
619
        or      al, PCI_CMD_MASTER or PCI_CMD_MMIO or PCI_CMD_PIO
-
 
620
        and     ax, not(PCI_CMD_INTX_DISABLE)
-
 
621
        invoke  PciWrite16, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
-
 
622
 
-
 
623
; Clear any powersaving setting
-
 
624
        invoke  PciWrite16, [ebx + device.pci_bus], [ebx + device.pci_dev], 0x44, 0x0000        ;; FIXME
-
 
625
 
-
 
626
; Mask some pcie error bits
-
 
627
        mov     esi, [ebx + device.mmio_addr]
-
 
628
        mov     eax, [esi + ALX_UE_SVRT]
-
 
629
        and     eax, not(ALX_UE_SVRT_DLPROTERR or ALX_UE_SVRT_FCPROTERR)
-
 
630
        mov     [esi + ALX_UE_SVRT], eax
-
 
631
 
-
 
632
; pclk
-
 
633
        mov     eax, [esi + ALX_MASTER]
-
 
634
        or      eax, ALX_MASTER_WAKEN_25M
-
 
635
        and     eax, not (ALX_MASTER_PCLKSEL_SRDS)
-
 
636
        cmp     [ebx + device.chip_rev], ALX_REV_A1
-
 
637
        ja      @f
-
 
638
        test    [ebx + device.pci_rev], ALX_PCI_REVID_WITH_CR
-
 
639
        jz      @f
-
 
640
        or      eax, ALX_MASTER_PCLKSEL_SRDS
-
 
641
  @@:
-
 
642
        mov     [esi + ALX_MASTER], eax
-
 
643
 
-
 
644
        xor     eax, eax
577
 
645
        ret
Line 578... Line 646...
578
 
646
 
579
 
647
endp
Line 580... Line 648...
580
align 16
648
 
Line 589... Line 657...
589
 
657
 
590
        DEBUGF  1,"Cleaning TX desc %u buffer 0x%x\n", eax, [ebx + device.tpd_ring_virt + eax*4]
658
        DEBUGF  1,"Cleaning TX desc %u buffer 0x%x\n", eax, [ebx + device.tpd_ring_virt + eax*4]
591
        push    eax ecx
659
        push    eax ecx
592
        invoke  NetFree, [ebx + device.tpd_ring_virt + eax*4]
660
        invoke  NetFree, [ebx + device.tpd_ring_virt + eax*4]
-
 
661
        pop     ecx eax
Line 593... Line 662...
593
        pop     ecx eax
662
        mov     [ebx + device.tpd_ring_virt + eax*4], 0
594
 
663
 
595
        inc     eax
664
        inc     eax
596
        and     eax, TX_RING_SIZE-1
665
        and     eax, TX_RING_SIZE-1
597
        jmp     .loop
666
        jmp     .loop
Line 598... Line 667...
598
  .done:
667
  .done:
Line -... Line 668...
-
 
668
        mov     [ebx + device.txq_read_idx], eax
Line 599... Line -...
599
        mov     [ebx + device.txq_read_idx], eax
-
 
600
 
669
 
Line 601... Line 670...
601
        ret
670
        ret
602
 
671
 
603
 
672
endp
604
align 16
673
 
Line 645... Line 714...
645
; Allocate new descriptor
714
; Allocate new descriptor
646
        push    esi ecx edx
715
        push    esi ecx edx
647
        invoke  NetAlloc, RX_BUFFER_SIZE+NET_BUFF.data
716
        invoke  NetAlloc, RX_BUFFER_SIZE+NET_BUFF.data
648
        pop     edx ecx esi
717
        pop     edx ecx esi
649
        test    eax, eax
718
        test    eax, eax
650
;        jz      .out_of_mem
719
        jz      .rx_overrun
651
        mov     [ebx + device.rfd_ring_virt + ecx], eax
720
        mov     [ebx + device.rfd_ring_virt + ecx], eax
652
        add     eax, NET_BUFF.data
721
        add     eax, NET_BUFF.data
653
        invoke  GetPhysAddr
722
        invoke  GetPhysAddr
654
        mov     dword[ebx + device.rfd_ring + ecx*2], eax
723
        mov     dword[ebx + device.rfd_ring + ecx*2], eax
Line 663... Line 732...
663
        shr     ecx, 2
732
        shr     ecx, 2
664
        inc     ecx
733
        inc     ecx
665
        and     ecx, RX_RING_SIZE-1
734
        and     ecx, RX_RING_SIZE-1
666
        jmp     .loop
735
        jmp     .loop
Line -... Line 736...
-
 
736
 
-
 
737
  .rx_overrun:
-
 
738
        DEBUGF  2,"RX FIFO overrun\n"
-
 
739
        inc     [ebx + device.packets_rx_ovr]
-
 
740
        shr     ecx, 2
-
 
741
        inc     ecx
-
 
742
        and     ecx, RX_RING_SIZE-1
-
 
743
        jmp     .loop
667
 
744
 
668
  .done:
745
  .done:
669
        shr     ecx, 2
746
        shr     ecx, 2
Line 670... Line 747...
670
        mov     [ebx + device.rxq_read_idx], ecx
747
        mov     [ebx + device.rxq_read_idx], ecx
671
 
748
 
672
; Update producer index
749
; Update producer index
Line 673... Line 750...
673
        mov     esi, [ebx + device.mmio_addr]
750
        mov     esi, [ebx + device.mmio_addr]
Line -... Line 751...
-
 
751
        mov     [esi + ALX_RFD_PIDX], cx
Line 674... Line -...
674
        mov     [esi + ALX_RFD_PIDX], cx
-
 
675
 
752
 
676
        ret
753
        ret
Line 677... Line 754...
677
 
754
 
Line 678... Line 755...
678
 
755
endp
679
align 16
-
 
680
; ecx = additional bit flags (ALX_PMCTRL_L0S_EN, ALX_PMCTRL_L1_EN, ALX_PMCTRL_ASPM_FCEN)
-
 
681
alx_enable_aspm:
-
 
682
 
-
 
Line 683... Line -...
683
        DEBUGF  1,"alx_enable_aspm (0x%x)\n", ecx
-
 
684
 
-
 
685
        mov     esi, [ebx + device.mmio_addr]
-
 
686
        mov     eax, dword[esi + ALX_PMCTRL]
756
 
687
 
-
 
688
        and     eax, not(ALX_PMCTRL_LCKDET_TIMER_MASK shl ALX_PMCTRL_LCKDET_TIMER_SHIFT)
-
 
689
        or      eax, (ALX_PMCTRL_LCKDET_TIMER_DEF shl ALX_PMCTRL_LCKDET_TIMER_SHIFT)
-
 
690
 
-
 
691
        or      eax, (ALX_PMCTRL_RCVR_WT_1US or ALX_PMCTRL_L1_CLKSW_EN or ALX_PMCTRL_L1_SRDSRX_PWD)
757
; IN: ecx = additional bit flags (ALX_PMCTRL_L0S_EN, ALX_PMCTRL_L1_EN, ALX_PMCTRL_ASPM_FCEN)
Line 692... Line 758...
692
 
758
proc alx_enable_aspm stdcall
693
        and     eax, not(ALX_PMCTRL_L1REQ_TO_MASK shl ALX_PMCTRL_L1REQ_TO_SHIFT)
759
 
694
        or      eax, (ALX_PMCTRL_L1REG_TO_DEF shl ALX_PMCTRL_L1REQ_TO_SHIFT)
760
        DEBUGF  1,"alx_enable_aspm (0x%x)\n", ecx
695
 
761
 
696
        and     eax, not(ALX_PMCTRL_L1_TIMER_MASK shl ALX_PMCTRL_L1_TIMER_SHIFT)
762
        mov     esi, [ebx + device.mmio_addr]
697
        or      eax, (ALX_PMCTRL_L1_TIMER_16US shl ALX_PMCTRL_L1_TIMER_SHIFT)
763
 
Line -... Line 764...
-
 
764
        cmp     [ebx + device.pci_did], ALX_DEV_ID_AR8131
-
 
765
        je      .alc_l1c
-
 
766
 
-
 
767
        cmp     [ebx + device.chip_rev], ALX_REV_A1
-
 
768
        ja      @f
-
 
769
        test    [ebx + device.pci_rev], ALX_PCI_REVID_WITH_CR
-
 
770
        jz      @f
-
 
771
        or      ecx, ALX_PMCTRL_L1_SRDS_EN or ALX_PMCTRL_L1_SRDSPLL_EN
-
 
772
  @@:
-
 
773
 
-
 
774
        mov     eax, dword[esi + ALX_PMCTRL]
-
 
775
        and     eax, not((ALX_PMCTRL_LCKDET_TIMER_MASK shl ALX_PMCTRL_LCKDET_TIMER_SHIFT) or \
-
 
776
                         (ALX_PMCTRL_L1REQ_TO_MASK shl ALX_PMCTRL_L1REQ_TO_SHIFT) or \
-
 
777
                         (ALX_PMCTRL_L1_TIMER_MASK shl ALX_PMCTRL_L1_TIMER_SHIFT) or \
-
 
778
                         ALX_PMCTRL_L1_SRDS_EN or \
-
 
779
                         ALX_PMCTRL_L1_SRDSPLL_EN or \
-
 
780
                         ALX_PMCTRL_L1_BUFSRX_EN or \
-
 
781
                         ALX_PMCTRL_SADLY_EN or \
698
 
782
                         ALX_PMCTRL_HOTRST_WTEN or \
699
        and     eax, not(ALX_PMCTRL_L1_SRDS_EN  or ALX_PMCTRL_L1_SRDSPLL_EN or ALX_PMCTRL_L1_BUFSRX_EN or ALX_PMCTRL_SADLY_EN or ALX_PMCTRL_HOTRST_WTEN or ALX_PMCTRL_L0S_EN  or ALX_PMCTRL_L1_EN  or ALX_PMCTRL_ASPM_FCEN  or ALX_PMCTRL_TXL1_AFTER_L0S  or ALX_PMCTRL_RXL1_AFTER_L0S)
783
                         ALX_PMCTRL_L0S_EN or \
Line 700... Line 784...
700
 
784
                         ALX_PMCTRL_L1_EN or \
Line 701... Line 785...
701
        cmp     [ebx + device.chip_rev], ALX_REV_A1
785
                         ALX_PMCTRL_ASPM_FCEN or \
-
 
786
                         ALX_PMCTRL_TXL1_AFTER_L0S or \
-
 
787
                         ALX_PMCTRL_RXL1_AFTER_L0S)
-
 
788
        or      eax, (ALX_PMCTRL_LCKDET_TIMER_DEF shl ALX_PMCTRL_LCKDET_TIMER_SHIFT) or \
-
 
789
                     (ALX_PMCTRL_RCVR_WT_1US or ALX_PMCTRL_L1_CLKSW_EN or ALX_PMCTRL_L1_SRDSRX_PWD) or \
-
 
790
                     (ALX_PMCTRL_L1REG_TO_DEF shl ALX_PMCTRL_L1REQ_TO_SHIFT) or \
-
 
791
                     (ALX_PMCTRL_L1_TIMER_16US shl ALX_PMCTRL_L1_TIMER_SHIFT)
-
 
792
        or      eax, ecx
-
 
793
        mov     dword[esi + ALX_PMCTRL], eax
-
 
794
 
-
 
795
        ret
-
 
796
 
-
 
797
  .alc_l1c:
-
 
798
 
-
 
799
        DEBUGF  1, "aspm for L1C\n"
-
 
800
 
-
 
801
        mov     esi, [ebx + device.mmio_addr]
-
 
802
        mov     eax, dword[esi + ALX_PMCTRL]
-
 
803
 
-
 
804
        and     eax, not(ALX_PMCTRL_L0S_EN or ALX_PMCTRL_L1_EN or ALX_PMCTRL_ASPM_FCEN)
-
 
805
        or      eax, (ALX_PMCTRL_LCKDET_TIMER_DEF shl ALX_PMCTRL_LCKDET_TIMER_SHIFT) ;\
-
 
806
                ;     or (0 shl ALX_PMCTRL_L1_TIMER_SHIFT)
-
 
807
 
-
 
808
        or      eax, ecx
-
 
809
 
-
 
810
;;; FIXME if(linkon)
702
        ja      @f
811
 
Line 703... Line 812...
703
        test    [ebx + device.pci_rev], 1
812
        or      eax, (ALX_PMCTRL_L1_SRDS_EN or ALX_PMCTRL_L1_SRDSPLL_EN or ALX_PMCTRL_L1_BUFSRX_EN)
Line 704... Line 813...
704
        jz      @f
813
        and     eax, not(ALX_PMCTRL_L1_SRDSRX_PWD or ALX_PMCTRL_L1_CLKSW_EN or ALX_PMCTRL_L0S_EN or ALX_PMCTRL_L1_EN)
705
        or      eax, ALX_PMCTRL_L1_SRDS_EN or ALX_PMCTRL_L1_SRDSPLL_EN
814
 
706
  @@:
815
;;
707
 
816
 
708
        or      eax, ecx
817
        mov     dword[esi + ALX_PMCTRL], eax
Line 709... Line 818...
709
        mov     dword[esi + ALX_PMCTRL], eax
818
 
Line 710... Line 819...
710
 
819
        ret
711
        ret
820
 
Line 712... Line 821...
712
 
821
endp
713
align 16
822
 
714
alx_reset_mac:
823
proc alx_reset_mac stdcall
715
 
824
 
716
        DEBUGF  1, "reset mac\n"
825
        DEBUGF  1, "reset mac\n"
717
 
826
 
718
; disable all interrupts, RXQ/TXQ
827
; disable all interrupts, RXQ/TXQ
-
 
828
        mov     esi, [ebx + device.mmio_addr]
-
 
829
        mov     dword[esi + ALX_MSIX_MASK], 0xffffffff
719
        mov     esi, [ebx + device.mmio_addr]
830
        mov     dword[esi + ALX_IMR], 0x0
720
        mov     dword[esi + ALX_MSIX_MASK], 0xffffffff
831
        mov     dword[esi + ALX_ISR], ALX_ISR_DIS
721
        mov     dword[esi + ALX_IMR], 0x0
832
 
Line 722... Line 833...
722
        mov     dword[esi + ALX_ISR], ALX_ISR_DIS
833
        stdcall alx_stop_mac
723
 
834
 
724
        call    alx_stop_mac
835
; mac reset workaround
725
 
836
        mov     dword[esi + ALX_RFD_PIDX], 1
Line 726... Line 837...
726
; mac reset workaround
837
 
727
        mov     dword[esi + ALX_RFD_PIDX], 1
-
 
728
 
838
; disable l0s/l1 before MAC reset on some chips
729
; disable l0s/l1 before mac reset on some chips
-
 
730
        cmp     [ebx + device.chip_rev], ALX_REV_A1
-
 
731
        ja      @f
-
 
Line 732... Line 839...
732
        test    [ebx + device.pci_rev], 1       ; Card reader function? FIXME: according register definitions, this should be bit 1 ISO 0
839
        cmp     [ebx + device.chip_rev], ALX_REV_A1
733
        jz      @f
840
        ja      @f
734
        mov     eax, [esi + ALX_PMCTRL]
841
        test    [ebx + device.pci_rev], ALX_PCI_REVID_WITH_CR
735
        mov     edx, eax
842
        jz      @f
736
        and     eax, not(ALX_PMCTRL_L1_EN or ALX_PMCTRL_L0S_EN)
843
        mov     eax, [esi + ALX_PMCTRL]
-
 
844
        mov     edx, eax
-
 
845
        test    eax, ALX_PMCTRL_L1_EN or ALX_PMCTRL_L0S_EN
-
 
846
        jz      @f
737
        mov     [esi + ALX_PMCTRL], eax
847
        and     eax, not(ALX_PMCTRL_L1_EN or ALX_PMCTRL_L0S_EN)
738
  @@:
848
        mov     [esi + ALX_PMCTRL], eax
739
 
849
  @@:
740
; reset whole mac safely
850
 
-
 
851
; reset whole MAC safely
741
        mov     eax, [esi + ALX_MASTER]
852
        mov     eax, [esi + ALX_MASTER]
742
        or      eax, ALX_MASTER_DMA_MAC_RST + ALX_MASTER_OOB_DIS
853
        or      eax, ALX_MASTER_DMA_MAC_RST or ALX_MASTER_OOB_DIS
743
        mov     [esi + ALX_MASTER], eax
854
        mov     [esi + ALX_MASTER], eax
744
 
855
 
-
 
856
; make sure it's real idle
-
 
857
        stdcall udelay, 10
-
 
858
 
745
; make sure it's real idle
859
        mov     ecx, ALX_DMA_MAC_RST_TO ; timeout
746
        push    esi ecx edx
860
  .loop1:
747
        xor     esi, esi
861
        mov     eax, dword[esi + ALX_RFD_PIDX]
748
        inc     esi
862
        test    eax, eax
Line 749... Line 863...
749
        invoke  Sleep           ; FIXME
863
        jz      @f
750
        pop     edx ecx esi
864
 
751
 
865
        stdcall udelay, 10
752
        mov     ecx, ALX_DMA_MAC_RST_TO
866
 
753
  .loop1:
867
        dec     ecx
754
        mov     eax, dword[esi + ALX_RFD_PIDX]
868
        jnz     .loop1
755
        test    eax, eax
869
        jmp     .error
756
        jz      @f
-
 
757
        dec     ecx
870
  @@:
758
        jnz     .loop1
871
 
Line 759... Line 872...
759
        jmp     .error
872
  .loop2:
Line 760... Line 873...
760
  @@:
873
        mov     eax, dword[esi + ALX_MASTER]
Line 761... Line 874...
761
  .loop2:
874
        test    eax, ALX_MASTER_DMA_MAC_RST
762
        mov     eax, dword[esi + ALX_MASTER]
875
        jz      @f
Line 794... Line 907...
794
        ja      @f
907
        ja      @f
795
        and     eax, not ALX_MISC_ISO_EN
908
        and     eax, not ALX_MISC_ISO_EN
796
  @@:
909
  @@:
797
        mov     [esi + ALX_MISC], eax
910
        mov     [esi + ALX_MISC], eax
Line 798... Line -...
798
 
-
 
799
        push    esi
911
 
800
        xor     esi, esi
-
 
801
        inc     esi
-
 
802
        invoke  Sleep           ;; FIXME: udelay(20);
-
 
Line 803... Line 912...
803
        pop     esi
912
        stdcall udelay, 20
804
 
913
 
805
; driver control speed/duplex, hash-alg
914
; driver control speed/duplex, hash-alg
Line -... Line 915...
-
 
915
        mov     eax, [ebx + device.rx_ctrl]
806
        mov     eax, [ebx + device.rx_ctrl]
916
        mov     [esi + ALX_MAC_CTRL], eax
807
        mov     [esi + ALX_MAC_CTRL], eax
917
 
808
 
918
; clk sw
Line 809... Line 919...
809
        mov     eax, dword[esi + ALX_SERDES]
919
        mov     eax, dword[esi + ALX_SERDES]
Line 818... Line 928...
818
        DEBUGF  1, "error\n"
928
        DEBUGF  1, "error\n"
819
        xor     eax, eax
929
        xor     eax, eax
820
        dec     eax
930
        dec     eax
821
        ret
931
        ret
Line -... Line 932...
-
 
932
 
Line 822... Line -...
822
 
-
 
823
 
933
endp
Line 824... Line 934...
824
align 16
934
 
Line 825... Line 935...
825
alx_reset_phy:
935
proc alx_reset_phy stdcall
Line -... Line 936...
-
 
936
 
-
 
937
        DEBUGF  1, "Reset phy\n"
-
 
938
 
-
 
939
        mov     esi, [ebx + device.mmio_addr]
-
 
940
 
-
 
941
        mov     eax, dword [esi + ALX_PHY_CTRL]
-
 
942
        DEBUGF 1, "read ALX_PHY_CTRL = %x\n", eax
-
 
943
        and     eax, not (ALX_PHY_CTRL_DSPRST_OUT or ALX_PHY_CTRL_IDDQ or ALX_PHY_CTRL_GATE_25M or ALX_PHY_CTRL_POWER_DOWN or ALX_PHY_CTRL_CLS)
-
 
944
        or      eax, ALX_PHY_CTRL_RST_ANALOG
-
 
945
        or      eax, ALX_PHY_CTRL_HIB_PULSE or ALX_PHY_CTRL_HIB_EN ; assume pws is enabled
-
 
946
 
-
 
947
        DEBUGF 1, "write ALX_PHY_CTRL = %x\n", eax
-
 
948
        mov     [esi + ALX_PHY_CTRL], eax
-
 
949
 
-
 
950
        stdcall udelay, 5
-
 
951
 
-
 
952
        or      eax, ALX_PHY_CTRL_DSPRST_OUT
-
 
953
        mov     [esi + ALX_PHY_CTRL], eax
-
 
954
 
-
 
955
        stdcall udelay, 10
-
 
956
 
-
 
957
        or      eax, ALX_PHY_CTRL_DSPRST_OUT
-
 
958
        DEBUGF 1, "write ALX_PHY_CTRL = %x\n", eax
-
 
959
        mov     dword [esi + ALX_PHY_CTRL], eax
-
 
960
 
-
 
961
        stdcall udelay, 800
-
 
962
 
-
 
963
; PHY power saving & hibernate
-
 
964
        stdcall alx_write_phy_dbg, ALX_MIIDBG_LEGCYPS, ALX_LEGCYPS_DEF
-
 
965
        stdcall alx_write_phy_dbg, ALX_MIIDBG_SYSMODCTRL, ALX_SYSMODCTRL_IECHOADJ_DEF
-
 
966
        stdcall alx_write_phy_ext, ALX_MIIEXT_PCS, ALX_MIIEXT_VDRVBIAS, ALX_VDRVBIAS_DEF
-
 
967
 
-
 
968
; EEE advertisement
826
 
969
        mov     eax, [esi + ALX_LPI_CTRL]
-
 
970
        and     eax, not (ALX_LPI_CTRL_EN)
-
 
971
        mov     [esi + ALX_LPI_CTRL], eax
-
 
972
        stdcall alx_write_phy_ext, ALX_MIIEXT_ANEG, ALX_MIIEXT_LOCAL_EEEADV, 0
-
 
973
 
-
 
974
; PHY power saving
-
 
975
        stdcall alx_write_phy_dbg, ALX_MIIDBG_TST10BTCFG, ALX_TST10BTCFG_DEF
-
 
976
        stdcall alx_write_phy_dbg, ALX_MIIDBG_SRDSYSMOD, ALX_SRDSYSMOD_DEF
-
 
977
        stdcall alx_write_phy_dbg, ALX_MIIDBG_TST100BTCFG, ALX_TST100BTCFG_DEF
-
 
978
        stdcall alx_write_phy_dbg, ALX_MIIDBG_ANACTRL, ALX_ANACTRL_DEF
-
 
979
        stdcall alx_read_phy_dbg, ALX_MIIDBG_GREENCFG2
Line -... Line 980...
-
 
980
        and     eax, not ALX_GREENCFG2_GATE_DFSE_EN
-
 
981
        stdcall alx_write_phy_dbg, ALX_MIIDBG_GREENCFG2, eax
827
        DEBUGF  1, "Reset phy\n"
982
; rtl8139c, 120m issue */
828
 
983
        stdcall alx_write_phy_ext, ALX_MIIEXT_ANEG, ALX_MIIEXT_NLP78, ALX_MIIEXT_NLP78_120M_DEF
829
        mov     esi, [ebx + device.mmio_addr]
984
        stdcall alx_write_phy_ext, ALX_MIIEXT_ANEG, ALX_MIIEXT_S3DIG10, ALX_MIIEXT_S3DIG10_DEF
830
 
985
 
Line 831... Line 986...
831
;; TODO
986
; TODO: link patch ?
832
 
987
 
833
; set phy interrupt mask
988
; set PHY interrupt mask
Line 843... Line 998...
843
        DEBUGF  1, "error\n"
998
        DEBUGF  1, "error\n"
844
        xor     eax, eax
999
        xor     eax, eax
845
        dec     eax
1000
        dec     eax
846
        ret
1001
        ret
Line -... Line 1002...
-
 
1002
 
Line 847... Line -...
847
 
-
 
848
 
1003
endp
849
;align 16
-
 
850
;alx_enable_osc:
-
 
851
;
-
 
852
;        mov     esi, [ebx + device.mmio_addr]
-
 
853
;
-
 
854
;; rising edge
-
 
855
;        mov     eax, dword[esi + ALX_MISC]
-
 
856
;        and     eax, not ALX_MISC_INTNLOSC_OPEN
-
 
857
;        mov     dword[esi + ALX_MISC], eax
-
 
858
;        or      eax, ALX_MISC_INTNLOSC_OPEN
-
 
859
;        mov     dword[esi + ALX_MISC], eax
-
 
Line -... Line 1004...
-
 
1004
 
Line -... Line 1005...
-
 
1005
proc alx_set_macaddr stdcall
-
 
1006
 
-
 
1007
        mov     esi, [ebx + device.mmio_addr]
-
 
1008
 
-
 
1009
        mov     eax, dword[ebx + device.mac+2]
-
 
1010
        bswap   eax
-
 
1011
        mov     [esi + ALX_STAD0], eax
-
 
1012
        mov     ax, word[ebx + device.mac]
-
 
1013
        xchg    al, ah
-
 
1014
        mov     [esi + ALX_STAD1], ax
-
 
1015
 
-
 
1016
 
-
 
1017
        ret
-
 
1018
endp
-
 
1019
 
860
;
1020
proc alx_enable_osc stdcall
-
 
1021
 
-
 
1022
        mov     esi, [ebx + device.mmio_addr]
-
 
1023
 
-
 
1024
; rising edge
-
 
1025
        mov     eax, dword[esi + ALX_MISC]
-
 
1026
        and     eax, not ALX_MISC_INTNLOSC_OPEN
-
 
1027
        mov     dword[esi + ALX_MISC], eax
-
 
1028
        or      eax, ALX_MISC_INTNLOSC_OPEN
-
 
1029
        mov     dword[esi + ALX_MISC], eax
-
 
1030
 
861
;        ret
1031
        ret
Line 862... Line 1032...
862
 
1032
 
Line 863... Line 1033...
863
 
1033
endp
864
align 16
1034
 
Line 874... Line 1044...
874
 
1044
 
875
; clk from chipset may be unstable 1s after de-assert of
1045
; clk from chipset may be unstable 1s after de-assert of
876
; PERST, driver need re-calibrate before enter Sleep for WoL
1046
; PERST, driver need re-calibrate before enter Sleep for WoL
877
        mov     eax, dword[esi + ALX_MISC]
1047
        mov     eax, dword[esi + ALX_MISC]
878
        cmp     [ebx + device.chip_rev], ALX_REV_B0
1048
        cmp     [ebx + device.chip_rev], ALX_REV_B0
Line 879... Line 1049...
879
        jb      .rev_a
1049
        jb      .rev_A
880
 
1050
 
881
; restore over current protection def-val, this val could be reset by MAC-RST
1051
; restore over current protection def-val, this val could be reset by MAC-RST
882
        and     eax, not (ALX_MISC_PSW_OCP_MASK shl ALX_MISC_PSW_OCP_SHIFT)
1052
        and     eax, not (ALX_MISC_PSW_OCP_MASK shl ALX_MISC_PSW_OCP_SHIFT)
Line 892... Line 1062...
892
        and     eax, not ALX_MSIC2_CALB_START
1062
        and     eax, not ALX_MSIC2_CALB_START
893
        mov     dword[esi + ALX_MSIC2], eax
1063
        mov     dword[esi + ALX_MSIC2], eax
894
        or      eax, ALX_MSIC2_CALB_START
1064
        or      eax, ALX_MSIC2_CALB_START
895
        mov     dword[esi + ALX_MSIC2], eax
1065
        mov     dword[esi + ALX_MSIC2], eax
Line 896... Line -...
896
 
-
 
897
        push    esi ecx
1066
 
898
        xor     esi, esi
-
 
899
        inc     esi
-
 
900
        invoke  Sleep           ;; FIXME: udelay(20)
-
 
Line 901... Line 1067...
901
        pop     ecx esi
1067
        stdcall udelay, 20
Line 902... Line 1068...
902
 
1068
 
Line 903... Line 1069...
903
        ret
1069
        ret
904
 
1070
 
905
  .rev_a:
1071
  .rev_A:
906
 
1072
 
907
;  disable isolate for rev A devices
1073
;  disable isolate for rev A devices
908
        and     eax, not ( ALX_MISC_ISO_EN)
1074
        and     eax, not (ALX_MISC_ISO_EN)
Line 909... Line -...
909
        or      eax, ALX_MISC_INTNLOSC_OPEN
-
 
910
        mov     dword[esi + ALX_MISC], eax
1075
        or      eax, ALX_MISC_INTNLOSC_OPEN
911
        and     eax, not ALX_MISC_INTNLOSC_OPEN
-
 
912
        mov     dword[esi + ALX_MISC], eax
-
 
913
 
-
 
Line 914... Line 1076...
914
        push    esi ecx
1076
        mov     dword[esi + ALX_MISC], eax
Line 915... Line 1077...
915
        xor     esi, esi
1077
        and     eax, not ALX_MISC_INTNLOSC_OPEN
-
 
1078
        mov     dword[esi + ALX_MISC], eax
916
        inc     esi
1079
 
Line 917... Line 1080...
917
        invoke  Sleep           ;; FIXME: udelay(20)
1080
        stdcall udelay, 20
918
        pop     ecx esi
1081
 
919
 
1082
        ret
920
        ret
1083
 
Line 942... Line 1105...
942
        cmp     dword[ebx + device.mac], 0xffffffff
1105
        cmp     dword[ebx + device.mac], 0xffffffff
943
        jne     @f
1106
        jne     @f
944
        cmp     word[ebx + device.mac + 4], 0xffff
1107
        cmp     word[ebx + device.mac + 4], 0xffff
945
        je      .invalid
1108
        je      .invalid
946
  @@:
1109
  @@:
-
 
1110
        test    byte[ebx + device.mac + 5], 0x01        ; Multicast
947
; TODO: check if it's not a multicast
1111
        jnz     .invalid
-
 
1112
  @@:
948
        xor     eax, eax
1113
        xor     eax, eax
949
        ret
1114
        ret
Line 950... Line 1115...
950
 
1115
 
951
  .invalid:
1116
  .invalid:
952
        DEBUGF  1, "Invalid MAC!\n"
1117
        DEBUGF  1, "Invalid MAC!\n"
953
        xor     eax, eax
1118
        xor     eax, eax
954
        inc     eax
1119
        inc     eax
Line -... Line 1120...
-
 
1120
        ret
Line 955... Line -...
955
        ret
-
 
956
 
1121
 
Line 957... Line 1122...
957
 
1122
endp
958
align 16
1123
 
959
alx_get_perm_macaddr:
1124
proc alx_get_perm_macaddr stdcall
960
 
1125
 
Line 961... Line 1126...
961
; try to get it from register first
1126
; try to get it from register first
962
        call    alx_read_macaddr
1127
        stdcall alx_read_macaddr
Line 999... Line 1164...
999
        invoke  Sleep
1164
        invoke  Sleep
1000
        pop     ecx esi
1165
        pop     ecx esi
1001
        jmp     .loop2
1166
        jmp     .loop2
1002
  @@:
1167
  @@:
Line 1003... Line 1168...
1003
 
1168
 
1004
        call    alx_read_macaddr
1169
        stdcall alx_read_macaddr
1005
        test    eax, eax
1170
        test    eax, eax
Line 1006... Line 1171...
1006
        jz      .done
1171
        jz      .done
1007
 
1172
 
Line 1046... Line 1211...
1046
        invoke  Sleep
1211
        invoke  Sleep
1047
        pop     ecx edx esi
1212
        pop     ecx edx esi
1048
        jmp     .loop4
1213
        jmp     .loop4
1049
  @@:
1214
  @@:
Line 1050... Line 1215...
1050
 
1215
 
1051
        call    alx_read_macaddr
1216
        stdcall alx_read_macaddr
1052
        test    eax, eax
1217
        test    eax, eax
Line 1053... Line 1218...
1053
        jz      .done
1218
        jz      .done
1054
 
1219
 
Line 1061... Line 1226...
1061
  .done:
1226
  .done:
1062
        DEBUGF  1, "MAC OK\n"
1227
        DEBUGF  1, "MAC OK\n"
1063
        xor     eax, eax
1228
        xor     eax, eax
1064
        ret
1229
        ret
Line 1065... Line 1230...
1065
 
1230
 
-
 
1231
endp
1066
align 16
1232
 
Line 1067... Line 1233...
1067
alx_stop_mac:
1233
proc alx_stop_mac stdcall
Line 1068... Line 1234...
1068
 
1234
 
Line 1076... Line 1242...
1076
 
1242
 
1077
        mov     eax, dword[esi + ALX_TXQ0]
1243
        mov     eax, dword[esi + ALX_TXQ0]
1078
        and     eax, not ALX_TXQ0_EN
1244
        and     eax, not ALX_TXQ0_EN
Line 1079... Line -...
1079
        mov     dword[esi + ALX_TXQ0], eax
-
 
1080
 
1245
        mov     dword[esi + ALX_TXQ0], eax
1081
        push    esi
-
 
1082
        xor     esi, esi
-
 
1083
        inc     esi
-
 
Line 1084... Line 1246...
1084
        invoke  Sleep   ; FIME: udelay(40)
1246
 
1085
        pop     esi
1247
        stdcall udelay, 40
1086
 
1248
 
1087
        mov     eax, [ebx + device.rx_ctrl]
1249
        mov     eax, [ebx + device.rx_ctrl]
Line 1093... Line 1255...
1093
  .loop:
1255
  .loop:
1094
        mov     eax, [esi + ALX_MAC_STS]
1256
        mov     eax, [esi + ALX_MAC_STS]
1095
        test    eax, ALX_MAC_STS_IDLE
1257
        test    eax, ALX_MAC_STS_IDLE
1096
        jz      .done
1258
        jz      .done
Line 1097... Line -...
1097
 
-
 
1098
        push    esi
1259
 
1099
        xor     esi, esi
-
 
1100
        inc     esi
-
 
1101
        invoke  Sleep   ; FIME: udelay(10)
-
 
Line 1102... Line 1260...
1102
        pop     esi
1260
        stdcall udelay, 10
1103
 
1261
 
Line 1104... Line 1262...
1104
        dec     ecx
1262
        dec     ecx
Line 1112... Line 1270...
1112
  .done:
1270
  .done:
1113
        DEBUGF  1,"alx_stop_mac ok\n"
1271
        DEBUGF  1,"alx_stop_mac ok\n"
1114
        xor     eax, eax
1272
        xor     eax, eax
1115
        ret
1273
        ret
Line -... Line 1274...
-
 
1274
 
Line 1116... Line -...
1116
 
-
 
1117
 
1275
endp
Line 1118... Line 1276...
1118
align 16
1276
 
Line 1119... Line 1277...
1119
alx_start_mac:
1277
proc alx_start_mac stdcall
Line 1131... Line 1289...
1131
        mov     dword[esi + ALX_TXQ0], eax
1289
        mov     dword[esi + ALX_TXQ0], eax
Line 1132... Line 1290...
1132
 
1290
 
1133
        mov     eax, [ebx + device.rx_ctrl]
1291
        mov     eax, [ebx + device.rx_ctrl]
1134
        or      eax, ALX_MAC_CTRL_TX_EN or ALX_MAC_CTRL_RX_EN
1292
        or      eax, ALX_MAC_CTRL_TX_EN or ALX_MAC_CTRL_RX_EN
1135
        and     eax, not ALX_MAC_CTRL_FULLD
1293
        and     eax, not ALX_MAC_CTRL_FULLD
1136
        test    [ebx + device.state], ETH_LINK_FD
1294
        test    [ebx + device.state], ETH_LINK_FULL_DUPLEX
1137
        jz      @f
1295
        jz      .no_fd
1138
        or      eax, ALX_MAC_CTRL_FULLD
1296
        or      eax, ALX_MAC_CTRL_FULLD
1139
  @@:
1297
  .no_fd:
1140
        and     eax, not (ALX_MAC_CTRL_SPEED_MASK shl ALX_MAC_CTRL_SPEED_SHIFT)
1298
        and     eax, not (ALX_MAC_CTRL_SPEED_MASK shl ALX_MAC_CTRL_SPEED_SHIFT)
-
 
1299
        mov     ecx, [ebx + device.state]
-
 
1300
        and     ecx, ETH_LINK_SPEED_MASK
1141
        test    [ebx + device.state], ETH_LINK_1G
1301
        cmp     ecx, ETH_LINK_SPEED_1G
1142
        jz      .10_100
1302
        jne      .10_100
1143
        or      eax, (ALX_MAC_CTRL_SPEED_1000 shl ALX_MAC_CTRL_SPEED_SHIFT)
-
 
1144
 
-
 
1145
        mov     [ebx + device.rx_ctrl], eax
-
 
1146
        mov     [esi + ALX_MAC_CTRL], eax
-
 
1147
 
1303
        or      eax, (ALX_MAC_CTRL_SPEED_1000 shl ALX_MAC_CTRL_SPEED_SHIFT)
Line 1148... Line 1304...
1148
        ret
1304
        jmp     .done
1149
 
1305
 
Line -... Line 1306...
-
 
1306
  .10_100:
-
 
1307
        or      eax, (ALX_MAC_CTRL_SPEED_10_100 shl ALX_MAC_CTRL_SPEED_SHIFT)
1150
  .10_100:
1308
 
1151
        or      eax, (ALX_MAC_CTRL_SPEED_10_100 shl ALX_MAC_CTRL_SPEED_SHIFT)
1309
  .done:
Line 1152... Line 1310...
1152
 
1310
        DEBUGF  1,"mac ctrl=0x%x\n", eax
Line -... Line 1311...
-
 
1311
        mov     [ebx + device.rx_ctrl], eax
Line 1153... Line -...
1153
        mov     [ebx + device.rx_ctrl], eax
-
 
1154
        mov     [esi + ALX_MAC_CTRL], eax
-
 
1155
 
1312
        mov     [esi + ALX_MAC_CTRL], eax
Line 1156... Line 1313...
1156
        ret
1313
 
Line 1157... Line 1314...
1157
 
1314
        ret
Line 1198... Line 1355...
1198
 
1355
 
Line 1199... Line 1356...
1199
        xor     eax, eax
1356
        xor     eax, eax
Line -... Line 1357...
-
 
1357
 
Line 1200... Line -...
1200
 
-
 
1201
        ret
-
 
1202
 
-
 
1203
 
-
 
1204
align 16
-
 
1205
alx_alloc_descriptors:
-
 
1206
 
-
 
1207
        DEBUGF  1,"alx_alloc_descriptors\n"
-
 
1208
 
-
 
1209
; physical tx/rx ring descriptors
-
 
1210
 
-
 
1211
;        alx->descmem.size = sizeof.tx_desc * TX_RING_SIZE + sizeof.rx_desc * RX_RING_SIZE + sizeof(struct alx_rfd) * RX_RING_SIZE;
-
 
1212
;        alx->descmem.virt = dma_zalloc_coherent(&alx->hw.pdev->dev, alx->descmem.size, &alx->descmem.dma, GFP_KERNEL);
-
 
1213
;        if (!alx->descmem.virt)
-
 
1214
;                goto out_free;
-
 
1215
;
-
 
1216
;        alx->txq.tpd = (void *)alx->descmem.virt;
-
 
1217
;        alx->txq.tpd_dma = alx->descmem.dma;
-
 
1218
 
-
 
1219
; alignment requirement for next block
-
 
1220
;        BUILD_BUG_ON(tx_desc.sizeof % 8);
-
 
1221
;
-
 
1222
;        alx->rxq.rrd = (void *)((u8 *)alx->descmem.virt + tx_desc.sizeof * TX_RING_SIZE);
-
 
1223
;        alx->rxq.rrd_dma = alx->descmem.dma + sizeof.tx_desc * TX_RING_SIZE;
-
 
1224
;
-
 
1225
; alignment requirement for next block
-
 
1226
;        BUILD_BUG_ON(rx_desc.sizeof % 8);
-
 
1227
;
-
 
1228
;        alx->rxq.rfd = (void *)((u8 *)alx->descmem.virt + sizeof.tx_desx * TX_RING_SIZE + sizeof.rx_desc * RX_RING_SIZE);
-
 
1229
;        alx->rxq.rfd_dma = alx->descmem.dma + sizeof.tx_desc * TX_RING_SIZE + sizeof.rx_desc * RX_RING_SIZE;
-
 
1230
 
-
 
1231
        xor     eax, eax
-
 
1232
        ret
1358
        ret
Line 1233... Line 1359...
1233
 
1359
 
Line 1234... Line -...
1234
 
-
 
1235
align 16
-
 
1236
alx_alloc_rings:
-
 
1237
 
-
 
1238
        DEBUGF  1,"alx_alloc_rings\n"
1360
endp
1239
 
1361
 
1240
        call    alx_alloc_descriptors
1362
proc alx_alloc_rings stdcall
Line 1241... Line -...
1241
        test    eax, eax
-
 
1242
        jnz     .ret_err
-
 
1243
 
1363
 
Line -... Line 1364...
-
 
1364
        DEBUGF  1,"alx_alloc_rings\n"
Line 1244... Line -...
1244
        and     [ebx + device.int_mask], not ALX_ISR_ALL_QUEUES
-
 
1245
        or      [ebx + device.int_mask], ALX_ISR_TX_Q0 or ALX_ISR_RX_Q0
1365
 
Line 1246... Line 1366...
1246
;        netif_napi_add(alx->dev, &alx->napi, alx_poll, 64);
1366
        and     [ebx + device.int_mask], not ALX_ISR_ALL_QUEUES
Line 1247... Line 1367...
1247
 
1367
        or      [ebx + device.int_mask], ALX_ISR_TX_Q0 or ALX_ISR_RX_Q0
1248
        call    alx_reinit_rings
1368
        stdcall alx_reinit_rings
1249
  .ret_err:
1369
 
Line 1250... Line 1370...
1250
        ret
1370
        ret
Line -... Line 1371...
-
 
1371
 
Line 1251... Line -...
1251
 
-
 
1252
 
1372
endp
Line 1253... Line 1373...
1253
align 16
1373
 
Line 1254... Line 1374...
1254
alx_reinit_rings:
1374
proc alx_reinit_rings stdcall
1255
 
1375
 
Line 1301... Line 1421...
1301
  .none:
1421
  .none:
1302
        xor     eax, eax
1422
        xor     eax, eax
Line 1303... Line 1423...
1303
 
1423
 
Line -... Line 1424...
-
 
1424
        ret
Line 1304... Line -...
1304
        ret
-
 
1305
 
1425
 
Line 1306... Line 1426...
1306
 
1426
endp
Line 1307... Line 1427...
1307
align 16
1427
 
1308
alx_free_rx_ring:
1428
proc alx_free_rx_ring stdcall
Line 1327... Line 1447...
1327
        cmp     ecx, RX_RING_SIZE
1447
        cmp     ecx, RX_RING_SIZE
1328
        jb      .loop
1448
        jb      .loop
Line 1329... Line 1449...
1329
 
1449
 
Line -... Line 1450...
-
 
1450
        ret
Line 1330... Line -...
1330
        ret
-
 
1331
 
1451
 
Line 1332... Line 1452...
1332
 
1452
endp
Line 1333... Line 1453...
1333
align 16
1453
 
1334
alx_configure:
1454
proc alx_configure stdcall
1335
 
1455
 
Line 1336... Line 1456...
1336
        DEBUGF  1,"alx_configure\n"
1456
        DEBUGF  1,"alx_configure\n"
1337
 
1457
 
1338
        call    alx_configure_basic
1458
        stdcall alx_configure_basic
Line 1339... Line 1459...
1339
        call    alx_disable_rss
1459
        stdcall alx_disable_rss
1340
        call    __alx_set_rx_mode
1460
        call    alx_set_rx_mode
Line -... Line 1461...
-
 
1461
 
Line 1341... Line -...
1341
 
-
 
1342
        mov     esi, [ebx + device.mmio_addr]
1462
        mov     esi, [ebx + device.mmio_addr]
Line 1343... Line 1463...
1343
        mov     eax, [ebx + device.rx_ctrl]
1463
        mov     eax, [ebx + device.rx_ctrl]
Line 1344... Line 1464...
1344
        mov     [esi + ALX_MAC_CTRL], eax
1464
        mov     [esi + ALX_MAC_CTRL], eax
1345
 
1465
 
1346
        xor     eax, eax
1466
        xor     eax, eax
1347
        ret
1467
        ret
Line 1348... Line 1468...
1348
 
1468
 
Line 1349... Line 1469...
1349
 
1469
endp
Line 1350... Line 1470...
1350
align 16
1470
 
-
 
1471
proc alx_irq_enable stdcall
1351
alx_irq_enable:
1472
 
Line 1352... Line 1473...
1352
 
1473
        DEBUGF  1,"alx_irq_enable\n"
Line 1353... Line 1474...
1353
        DEBUGF  1,"alx_irq_enable\n"
1474
 
1354
 
1475
        mov     esi, [ebx + device.mmio_addr]
1355
        mov     esi, [ebx + device.mmio_addr]
1476
        mov     dword[esi + ALX_ISR], 0
Line 1356... Line 1477...
1356
        mov     dword[esi + ALX_ISR], 0
1477
        mov     eax, [ebx + device.int_mask]
Line 1357... Line 1478...
1357
        mov     eax, [ebx + device.int_mask]
1478
        mov     [esi + ALX_IMR], eax
Line -... Line 1479...
-
 
1479
 
Line 1358... Line -...
1358
        mov     [esi + ALX_IMR], eax
-
 
1359
 
1480
        stdcall alx_post_write
Line 1360... Line 1481...
1360
        call    alx_post_write
1481
 
1361
 
1482
        ret
1362
        ret
1483
 
1363
 
1484
endp
Line 1364... Line 1485...
1364
align 16
1485
 
Line -... Line 1486...
-
 
1486
proc alx_irq_disable stdcall
Line 1365... Line -...
1365
alx_irq_disable:
-
 
1366
 
1487
 
Line 1367... Line 1488...
1367
        DEBUGF  1,"alx_irq_disable\n"
1488
        DEBUGF  1,"alx_irq_disable\n"
Line 1368... Line 1489...
1368
 
1489
 
Line 1369... Line 1490...
1369
        mov     esi, [ebx + device.mmio_addr]
1490
        mov     esi, [ebx + device.mmio_addr]
Line 1370... Line 1491...
1370
        mov     dword[esi + ALX_ISR], ALX_ISR_DIS
1491
        mov     dword[esi + ALX_ISR], ALX_ISR_DIS
Line 1371... Line 1492...
1371
        mov     dword[esi + ALX_IMR], 0
1492
        mov     dword[esi + ALX_IMR], 0
1372
 
-
 
1373
        call    alx_post_write
1493
 
1374
 
1494
        stdcall alx_post_write
1375
        ret
1495
 
1376
 
1496
        ret
Line 1377... Line 1497...
1377
 
1497
 
Line -... Line 1498...
-
 
1498
endp
1378
align 16
1499
 
1379
alx_post_write:
1500
proc alx_post_write stdcall
1380
 
1501
 
Line -... Line 1502...
-
 
1502
        push    eax
1381
        push    eax
1503
        mov     esi, [ebx + device.mmio_addr]
Line 1382... Line 1504...
1382
        mov     esi, [ebx + device.mmio_addr]
1504
        mov     eax, [esi]
1383
        mov     eax, [esi]
1505
        pop     eax
Line 1384... Line 1506...
1384
        pop     eax
1506
 
1385
 
1507
        ret
1386
        ret
1508
 
Line 1435... Line 1557...
1435
 
1557
 
1436
        test    [ebx + device.pci_did], 1       ;;; FIXME: is gigabit device?
1558
        test    [ebx + device.pci_did], 1       ;;; FIXME: is gigabit device?
1437
        jz      @f
1559
        jz      @f
1438
        or      eax, ALX_RXQ0_ASPM_THRESH_100M shl ALX_RXQ0_ASPM_THRESH_SHIFT
1560
        or      eax, ALX_RXQ0_ASPM_THRESH_100M shl ALX_RXQ0_ASPM_THRESH_SHIFT
1439
  @@:
1561
  @@:
-
 
1562
        mov     [esi + ALX_RXQ0], eax
-
 
1563
 
-
 
1564
; DMA
Line 1440... Line -...
1440
        mov     dword[esi + ALX_RXQ0], eax
-
 
1441
 
1565
        max_payload equ 2               ;;;; FIXME
1442
; TODO: DMA
1566
 
1443
;        mov     eax, [esi + ALX_DMA]    ; read and ignore?
-
 
1444
;        mov     eax, [ebx + device.dma_chnl]
-
 
1445
;        dec     eax
1567
        mov     eax, [esi + ALX_DMA]            ; Read and ignore?
1446
;        shl     eax, ALX_DMA_RCHNL_SEL_SHIFT
1568
        ; Pre-B0 devices have 2 DMA channels
1447
;        or      eax, (ALX_DMA_RORDER_MODE_OUT shl ALX_DMA_RORDER_MODE_SHIFT) \
1569
        mov     eax, (ALX_DMA_RORDER_MODE_OUT shl ALX_DMA_RORDER_MODE_SHIFT) \
1448
;                or ALX_DMA_RREQ_PRI_DATA \
1570
                or ALX_DMA_RREQ_PRI_DATA \
1449
;                or (max_payload shl ALX_DMA_RREQ_BLEN_SHIFT ) \
1571
                or (max_payload shl ALX_DMA_RREQ_BLEN_SHIFT) \
1450
;                or (ALX_DMA_WDLY_CNT_DEF shl ALX_DMA_WDLY_CNT_SHIFT ) \
1572
                or (ALX_DMA_WDLY_CNT_DEF shl ALX_DMA_WDLY_CNT_SHIFT ) \
Line -... Line 1573...
-
 
1573
                or (ALX_DMA_RDLY_CNT_DEF shl ALX_DMA_RDLY_CNT_SHIFT ) \
-
 
1574
                or ((2-1) shl ALX_DMA_RCHNL_SEL_SHIFT)
-
 
1575
 
-
 
1576
        cmp     [ebx + device.chip_rev], ALX_REV_B0
-
 
1577
        jb      @f
-
 
1578
        ; B0 and newer have 4 DMA channels
-
 
1579
        mov     eax, (ALX_DMA_RORDER_MODE_OUT shl ALX_DMA_RORDER_MODE_SHIFT) \
-
 
1580
                or ALX_DMA_RREQ_PRI_DATA \
-
 
1581
                or (max_payload shl ALX_DMA_RREQ_BLEN_SHIFT) \
-
 
1582
                or (ALX_DMA_WDLY_CNT_DEF shl ALX_DMA_WDLY_CNT_SHIFT ) \
-
 
1583
                or (ALX_DMA_RDLY_CNT_DEF shl ALX_DMA_RDLY_CNT_SHIFT ) \
Line 1451... Line 1584...
1451
;                or (ALX_DMA_RDLY_CNT_DEF shl ALX_DMA_RDLY_CNT_SHIFT )
1584
                or ((4-1) shl ALX_DMA_RCHNL_SEL_SHIFT)
1452
;        mov     [esi + ALX_DMA], eax
1585
  @@:
1453
 
1586
        mov     [esi + ALX_DMA], eax
1454
 
1587
 
Line 1460... Line 1593...
1460
                 or (4 shl ALX_WRR_PRI3_SHIFT)
1593
                 or (4 shl ALX_WRR_PRI3_SHIFT)
1461
        mov      [esi + ALX_WRR], eax
1594
        mov      [esi + ALX_WRR], eax
Line 1462... Line 1595...
1462
 
1595
 
Line -... Line 1596...
-
 
1596
        ret
Line 1463... Line -...
1463
        ret
-
 
1464
 
1597
 
Line 1465... Line 1598...
1465
 
1598
endp
Line 1466... Line 1599...
1466
align 16
1599
 
Line 1474... Line 1607...
1474
        and     eax, not (ALX_RXQ0_RSS_HASH_EN)
1607
        and     eax, not (ALX_RXQ0_RSS_HASH_EN)
1475
        mov     [esi + ALX_RXQ0] , eax
1608
        mov     [esi + ALX_RXQ0] , eax
Line 1476... Line 1609...
1476
 
1609
 
Line 1477... Line 1610...
1477
        ret
1610
        ret
-
 
1611
 
1478
 
1612
endp
Line 1479... Line 1613...
1479
align 16
1613
 
Line 1480... Line 1614...
1480
__alx_set_rx_mode:
1614
proc alx_set_rx_mode stdcall
Line -... Line 1615...
-
 
1615
 
-
 
1616
        DEBUGF  1,"__alx_set_rx_mode\n"
1481
 
1617
 
1482
        DEBUGF  1,"__alx_set_rx_mode\n"
1618
        mov     esi, [ebx + device.mmio_addr]
1483
 
1619
 
1484
        mov     esi, [ebx + device.mmio_addr]
1620
; TODO: proper multicast
1485
 
1621
 
1486
;        if (!(netdev->flags & IFF_ALLMULTI)) {
1622
;        if (!(netdev->flags & IFF_ALLMULTI)) {
1487
;                netdev_for_each_mc_addr(ha, netdev)
1623
;                netdev_for_each_mc_addr(ha, netdev)
Line 1488... Line 1624...
1488
;                        alx_add_mc_addr(hw, ha->addr, mc_hash);
1624
;                        alx_add_mc_addr(hw, ha->addr, mc_hash);
1489
;
1625
;
1490
;                alx_write_mem32(hw, ALX_HASH_TBL0, mc_hash[0]);
1626
;                alx_write_mem32(hw, ALX_HASH_TBL0, mc_hash[0]);
1491
;                alx_write_mem32(hw, ALX_HASH_TBL1, mc_hash[1]);
1627
;                alx_write_mem32(hw, ALX_HASH_TBL1, mc_hash[1]);
Line 1492... Line 1628...
1492
;        }
1628
;        }
Line -... Line 1629...
-
 
1629
 
Line 1493... Line -...
1493
 
-
 
1494
        mov     eax, [ebx + device.rx_ctrl]
1630
        mov     eax, [ebx + device.rx_ctrl]
Line 1495... Line 1631...
1495
        or      eax, ALX_MAC_CTRL_PROMISC_EN or ALX_MAC_CTRL_MULTIALL_EN
1631
        or      eax, ALX_MAC_CTRL_PROMISC_EN or ALX_MAC_CTRL_MULTIALL_EN        ; FIXME: dont force promiscous mode..
Line 1496... Line 1632...
1496
        mov     [ebx + device.rx_ctrl], eax
1632
        mov     [ebx + device.rx_ctrl], eax
Line 1497... Line 1633...
1497
        mov     dword[esi + ALX_MAC_CTRL], eax
1633
        mov     dword[esi + ALX_MAC_CTRL], eax
1498
 
1634
 
1499
        ret
1635
        ret
Line 1500... Line 1636...
1500
 
1636
 
Line 1522... Line 1658...
1522
        je      .no_change
1658
        je      .no_change
Line 1523... Line 1659...
1523
 
1659
 
1524
        cmp     [ebx + device.state], ETH_LINK_DOWN
1660
        cmp     [ebx + device.state], ETH_LINK_DOWN
Line 1525... Line 1661...
1525
        je      .link_down
1661
        je      .link_down
1526
 
1662
 
1527
        call    alx_post_phy_link
1663
        stdcall alx_post_phy_link
1528
        mov     ecx, (ALX_PMCTRL_L0S_EN or ALX_PMCTRL_L1_EN or ALX_PMCTRL_ASPM_FCEN)
1664
        mov     ecx, (ALX_PMCTRL_L0S_EN or ALX_PMCTRL_L1_EN or ALX_PMCTRL_ASPM_FCEN)
Line 1529... Line 1665...
1529
        call    alx_enable_aspm
1665
        stdcall alx_enable_aspm
Line 1530... Line 1666...
1530
        call    alx_start_mac
1666
        stdcall alx_start_mac
Line 1539... Line 1675...
1539
        ret
1675
        ret
Line 1540... Line 1676...
1540
 
1676
 
1541
  .link_down:
1677
  .link_down:
Line 1542... Line 1678...
1542
; Link is now down
1678
; Link is now down
1543
 
1679
 
1544
        call    alx_reset_mac
1680
        stdcall alx_reset_mac
Line 1545... Line 1681...
1545
        test    eax, eax
1681
        test    eax, eax
Line 1546... Line 1682...
1546
        jnz     .reset
1682
        jnz     .reset
1547
 
1683
 
1548
        call    alx_irq_disable
1684
        stdcall alx_irq_disable
1549
 
1685
 
Line 1550... Line 1686...
1550
; MAC reset causes all HW settings to be lost, restore all
1686
; MAC reset causes all HW settings to be lost, restore all
1551
        call    alx_reinit_rings
1687
        stdcall alx_reinit_rings
1552
        test    eax, eax
1688
        test    eax, eax
1553
        jnz     .reset
1689
        jnz     .reset
1554
 
1690
 
Line 1555... Line 1691...
1555
        call    alx_configure
1691
        stdcall alx_configure
Line 1556... Line 1692...
1556
        mov     ecx, (ALX_PMCTRL_L1_EN or ALX_PMCTRL_ASPM_FCEN)
1692
        mov     ecx, (ALX_PMCTRL_L1_EN or ALX_PMCTRL_ASPM_FCEN)
Line 1557... Line 1693...
1557
        call    alx_enable_aspm
1693
        stdcall alx_enable_aspm
1558
        call    alx_post_phy_link
1694
        stdcall alx_post_phy_link
1559
        call    alx_irq_enable
1695
        stdcall alx_irq_enable
Line 1560... Line 1696...
1560
 
1696
 
Line -... Line 1697...
-
 
1697
        invoke  NetLinkChanged
-
 
1698
 
-
 
1699
        ret
Line 1561... Line -...
1561
        invoke  NetLinkChanged
-
 
1562
 
1700
 
Line 1563... Line 1701...
1563
        ret
1701
  .reset:
1564
 
1702
        DEBUGF  1, "alx_schedule_reset\n"
Line 1565... Line 1703...
1565
  .reset:
1703
;;;        stdcall alx_schedule_reset
1566
        DEBUGF  1, "alx_schedule_reset"
1704
 
Line 1567... Line -...
1567
;;;        call    alx_schedule_reset
-
 
-
 
1705
        ret
-
 
1706
 
1568
 
1707
endp
1569
        ret
1708
 
1570
 
1709
proc alx_post_phy_link stdcall
Line 1571... Line 1710...
1571
 
1710
 
1572
align 16
1711
        DEBUGF  1, "alx_post_phy_link\n"
Line 1573... Line 1712...
1573
alx_post_phy_link:
1712
 
Line 1574... Line 1713...
1574
 
1713
        cmp     [ebx + device.chip_rev], ALX_REV_B0
Line -... Line 1714...
-
 
1714
        ja      .done
Line 1575... Line -...
1575
        cmp     [ebx + device.chip_rev], ALX_REV_B0
-
 
1576
        ja      .done
1715
 
Line -... Line 1716...
-
 
1716
        cmp     [ebx + device.state], ETH_LINK_UNKNOWN
1577
 
1717
        jae     @f
Line 1578... Line 1718...
1578
        cmp     [ebx + device.state], ETH_LINK_UNKNOWN
1718
 
Line -... Line 1719...
-
 
1719
; TODO: vendor hocus-pocus to tune the PHY according the detected cable length
Line 1579... Line -...
1579
        jae     @f
-
 
1580
 
1720
        stdcall alx_write_phy_dbg, ALX_MIIDBG_AZ_ANADECT, ALX_AZ_ANADECT_DEF
Line 1581... Line 1721...
1581
; TODO
1721
        stdcall alx_read_phy_ext, ALX_MIIEXT_AFE, ALX_MIIEXT_ANEG
Line 1582... Line 1722...
1582
;        stdcall alx_read_phy_ext, ALX_MIIEXT_AFE, ALX_MIIEXT_ANEG
1722
        and     eax, not (ALX_AFE_10BT_100M_TH)
1583
;        and     eax, not (ALX_AFE_10BT_100M_TH)
1723
        stdcall alx_write_phy_ext, ALX_MIIEXT_AFE, ALX_MIIEXT_ANEG, eax
Line 1584... Line 1724...
1584
;        stdcall alx_write_phy_ext, ALX_MIIEXT_AFE, ALX_MIIEXT_ANEG, eax
1724
 
Line 1585... Line 1725...
1585
 
1725
        ret
1586
        ret
1726
  @@:
1587
  @@:
1727
 
1588
 
1728
  .done:
1589
  .done:
1729
 
1590
 
1730
        ret
1591
        ret
1731
 
1592
 
1732
endp
1593
 
1733
 
Line 1594... Line 1734...
1594
align 16
1734
proc alx_clear_phy_intr stdcall
Line 1595... Line 1735...
1595
alx_clear_phy_intr:
1735
 
1596
 
1736
        DEBUGF  1,"alx_clear_phy_intr\n"
1597
        stdcall alx_read_phy_reg, 0, ALX_MII_ISR
1737
        stdcall alx_read_phy_reg, ALX_MII_ISR
1598
 
1738
 
1599
        ret
1739
        ret
Line 1600... Line 1740...
1600
 
1740
 
1601
 
1741
endp
1602
align 16
1742
 
1603
alx_get_phy_link:
1743
proc alx_get_phy_link stdcall
1604
 
1744
 
1605
        DEBUGF  1,"alx_get_phy_link\n"
1745
        DEBUGF  1,"alx_get_phy_link\n"
Line 1606... Line 1746...
1606
 
1746
 
1607
        stdcall alx_read_phy_reg, 0, MII_BMSR
1747
        stdcall alx_read_phy_reg, MII_BMSR
1608
        stdcall alx_read_phy_reg, 0, MII_BMSR
1748
        stdcall alx_read_phy_reg, MII_BMSR
1609
 
1749
 
1610
        mov     [ebx + device.state], ETH_LINK_DOWN
1750
        mov     [ebx + device.state], ETH_LINK_DOWN
1611
 
1751
 
Line 1612... Line 1752...
1612
        test    ax, BMSR_LSTATUS
1752
        test    ax, BMSR_LSTATUS
1613
        jnz     @f
1753
        jnz     @f
1614
        DEBUGF  1,"link is down\n"
1754
        DEBUGF  1,"link is down\n"
1615
        xor     eax, eax
1755
        xor     eax, eax
1616
        ret
1756
        ret
1617
  @@:
1757
  @@:
Line 1618... Line 1758...
1618
        stdcall alx_read_phy_reg, 0, ALX_MII_GIGA_PSSR
1758
        stdcall alx_read_phy_reg, ALX_MII_GIGA_PSSR
1619
        test    ax, ALX_GIGA_PSSR_SPD_DPLX_RESOLVED
1759
        test    ax, ALX_GIGA_PSSR_SPD_DPLX_RESOLVED
1620
        jz      .wrong_speed
1760
        jz      .wrong_speed
Line 1657... Line 1797...
1657
        DEBUGF  1,"wrong speed\n"
1797
        DEBUGF  1,"wrong speed\n"
1658
        xor     eax, eax
1798
        xor     eax, eax
1659
        dec     eax
1799
        dec     eax
1660
        ret
1800
        ret
Line -... Line 1801...
-
 
1801
 
Line -... Line 1802...
-
 
1802
endp
Line -... Line 1803...
-
 
1803
 
Line 1661... Line -...
1661
 
-
 
1662
 
-
 
1663
 
-
 
1664
 
-
 
1665
align 16
-
 
1666
proc  alx_read_phy_reg stdcall, phy_addr:dword, reg:dword
1804
proc alx_read_phy_reg stdcall, reg:dword
Line 1667... Line 1805...
1667
 
1805
 
Line 1668... Line 1806...
1668
; FIXME: Only internal PHY for now, fixed clock
1806
; FIXME: fixed clock
1669
 
1807
 
Line 1680... Line 1818...
1680
  .loop:
1818
  .loop:
1681
        mov     eax, dword[esi + ALX_MDIO]
1819
        mov     eax, dword[esi + ALX_MDIO]
1682
        test    eax, ALX_MDIO_BUSY
1820
        test    eax, ALX_MDIO_BUSY
1683
        jz      .ready
1821
        jz      .ready
Line 1684... Line -...
1684
 
-
 
1685
        push    esi ecx
1822
 
1686
        xor     esi, esi
-
 
1687
        inc     esi
-
 
1688
        invoke  Sleep           ;; FIXME: udelay(10)
-
 
Line 1689... Line 1823...
1689
        pop     ecx esi
1823
        stdcall udelay, 10
1690
 
1824
 
Line 1691... Line 1825...
1691
        dec     ecx
1825
        dec     ecx
1692
        jnz     .loop
1826
        jnz     .loop
1693
 
1827
 
1694
        DEBUGF  1,"PHY read timeout!\n"
1828
        DEBUGF  1,"alx_read_phy_reg read timeout!\n"
Line 1695... Line 1829...
1695
        xor     eax, eax
1829
        xor     eax, eax
1696
        dec     eax
1830
        dec     eax
1697
        ret
1831
        ret
Line 1698... Line 1832...
1698
 
1832
 
Line 1699... Line 1833...
1699
  .ready:
1833
  .ready:
Line 1700... Line 1834...
1700
;        shr     eax, ALX_MDIO_DATA_SHIFT
1834
;        shr     eax, ALX_MDIO_DATA_SHIFT
Line -... Line 1835...
-
 
1835
        and     eax, ALX_MDIO_DATA_MASK
Line -... Line 1836...
-
 
1836
 
Line -... Line 1837...
-
 
1837
        DEBUGF  1,"alx_read_phy_reg data=0x%x\n", eax:4
Line -... Line 1838...
-
 
1838
 
-
 
1839
        ret
-
 
1840
 
-
 
1841
endp
-
 
1842
 
-
 
1843
proc  alx_read_phy_ext stdcall, dev:dword, reg:dword
-
 
1844
 
-
 
1845
; FIXME: fixed clock
-
 
1846
 
-
 
1847
        DEBUGF  1,"alx_read_phy_ext dev=0x%x reg=0x%x\n", [dev]:4, [reg]:4
-
 
1848
 
-
 
1849
        mov     esi, [ebx + device.mmio_addr]
1701
        and     eax, ALX_MDIO_DATA_MASK
1850
 
1702
 
1851
        mov     eax, [dev]
-
 
1852
        shl     eax, ALX_MDIO_EXTN_DEVAD_SHIFT
-
 
1853
        mov     ax, word[reg]
-
 
1854
;        shl     eax, ALX_MDIO_EXTN_REG_SHIFT
-
 
1855
        mov     dword[esi + ALX_MDIO_EXTN], eax
Line -... Line 1856...
-
 
1856
 
1703
        DEBUGF  1,"PHY read, val=0x%x\n", eax:4
1857
        mov     eax, ALX_MDIO_SPRES_PRMBL or (ALX_MDIO_CLK_SEL_25MD4 shl ALX_MDIO_CLK_SEL_SHIFT) or ALX_MDIO_START or ALX_MDIO_OP_READ or ALX_MDIO_MODE_EXT
Line -... Line 1858...
-
 
1858
        mov     dword[esi + ALX_MDIO], eax
-
 
1859
 
-
 
1860
        mov     ecx, ALX_MDIO_MAX_AC_TO
-
 
1861
  .loop:
-
 
1862
        mov     eax, dword[esi + ALX_MDIO]
-
 
1863
        test    eax, ALX_MDIO_BUSY
-
 
1864
        jz      .ready
-
 
1865
 
-
 
1866
        stdcall udelay, 10
-
 
1867
 
-
 
1868
        dec     ecx
-
 
1869
        jnz     .loop
-
 
1870
 
-
 
1871
        DEBUGF  1,"alx_read_phy_ext read timeout!\n"
-
 
1872
        xor     eax, eax
-
 
1873
        dec     eax
-
 
1874
        ret
-
 
1875
 
-
 
1876
  .ready:
1704
 
1877
;        shr     eax, ALX_MDIO_DATA_SHIFT
Line 1705... Line 1878...
1705
        ret
1878
        and     eax, ALX_MDIO_DATA_MASK
Line 1706... Line 1879...
1706
 
1879
 
1707
endp
1880
        DEBUGF  1,"alx_read_phy_ext data=0x%x\n", eax:4
Line 1728... Line 1901...
1728
  .loop:
1901
  .loop:
1729
        mov     eax, dword[esi + ALX_MDIO]
1902
        mov     eax, dword[esi + ALX_MDIO]
1730
        test    eax, ALX_MDIO_BUSY
1903
        test    eax, ALX_MDIO_BUSY
1731
        jz      .ready
1904
        jz      .ready
Line 1732... Line -...
1732
 
-
 
1733
        push    esi ecx
1905
 
1734
        xor     esi, esi
-
 
1735
        inc     esi
-
 
1736
        invoke  Sleep           ;; FIXME: udelay(10)
-
 
Line 1737... Line 1906...
1737
        pop     ecx esi
1906
        stdcall udelay, 10
1738
 
1907
 
Line 1739... Line 1908...
1739
        dec     ecx
1908
        dec     ecx
1740
        jnz     .loop
1909
        jnz     .loop
1741
 
1910
 
1742
        DEBUGF  1,"PHY write timeout!\n"
1911
        DEBUGF  1,"alx_write_phy_reg timeout!\n"
Line 1743... Line 1912...
1743
        xor     eax, eax
1912
        xor     eax, eax
-
 
1913
        dec     eax
-
 
1914
        ret
-
 
1915
 
-
 
1916
  .ready:
-
 
1917
        DEBUGF  1,"alx_write_phy_reg OK\n"
-
 
1918
        xor     eax, eax
-
 
1919
 
-
 
1920
        ret
-
 
1921
endp
-
 
1922
 
-
 
1923
proc  alx_write_phy_dbg stdcall, reg:dword, val:dword
-
 
1924
 
-
 
1925
        DEBUGF  1,"alx_write_phy_dbg\n"
-
 
1926
 
-
 
1927
        stdcall alx_write_phy_reg, ALX_MII_DBG_ADDR, [reg]
-
 
1928
        test    eax, eax
-
 
1929
        jnz     @f
-
 
1930
        stdcall alx_write_phy_reg, ALX_MII_DBG_DATA, [val]
-
 
1931
 
-
 
1932
        ret
-
 
1933
  @@:
-
 
1934
        DEBUGF  1,"alx_write_phy_dbg ERROR\n"
-
 
1935
 
-
 
1936
        ret
-
 
1937
 
-
 
1938
endp
-
 
1939
 
-
 
1940
proc  alx_read_phy_dbg stdcall, reg:dword
-
 
1941
 
-
 
1942
        DEBUGF  1,"alx_read_phy_dbg\n"
-
 
1943
 
-
 
1944
        stdcall alx_write_phy_reg, ALX_MII_DBG_ADDR, [reg]
-
 
1945
        test    eax, eax
-
 
1946
        jnz     @f
-
 
1947
        stdcall alx_read_phy_reg, ALX_MII_DBG_DATA
-
 
1948
 
-
 
1949
        ret
-
 
1950
  @@:
-
 
1951
        DEBUGF  1,"alx_read_phy_dbg ERROR\n"
-
 
1952
 
-
 
1953
        ret
-
 
1954
 
-
 
1955
endp
-
 
1956
 
-
 
1957
proc  alx_write_phy_ext stdcall, dev:dword, reg:dword, val:dword
-
 
1958
 
-
 
1959
; FIXME: fixed clock
-
 
1960
 
-
 
1961
        DEBUGF  1,"alx_write_phy_ext dev=0x%x reg=0x%x, data=0x%x\n", [dev]:4, [reg]:4, [val]:4
-
 
1962
 
-
 
1963
        mov     esi, [ebx + device.mmio_addr]
-
 
1964
 
-
 
1965
        mov     eax, [dev]
-
 
1966
        shl     eax, ALX_MDIO_EXTN_DEVAD_SHIFT
-
 
1967
        mov     ax, word[reg]
-
 
1968
;        shl     eax, ALX_MDIO_EXTN_REG_SHIFT
-
 
1969
        mov     dword[esi + ALX_MDIO_EXTN], eax
-
 
1970
 
-
 
1971
        movzx   eax, word[val]                   ; data must be in 16 lower bits :)
-
 
1972
        or      eax, ALX_MDIO_SPRES_PRMBL or (ALX_MDIO_CLK_SEL_25MD4 shl ALX_MDIO_CLK_SEL_SHIFT) or ALX_MDIO_START or ALX_MDIO_MODE_EXT
-
 
1973
        mov     dword[esi + ALX_MDIO], eax
-
 
1974
 
-
 
1975
        mov     ecx, ALX_MDIO_MAX_AC_TO
-
 
1976
  .loop:
-
 
1977
        mov     eax, dword[esi + ALX_MDIO]
-
 
1978
        test    eax, ALX_MDIO_BUSY
-
 
1979
        jz      .ready
-
 
1980
 
-
 
1981
        stdcall udelay, 10
-
 
1982
 
-
 
1983
        dec     ecx
-
 
1984
        jnz     .loop
-
 
1985
 
-
 
1986
        DEBUGF  1,"alx_write_phy_ext timeout!\n"
-
 
1987
        xor     eax, eax
1744
        dec     eax
1988
        dec     eax
1745
        ret
1989
        ret
Line 1746... Line 1990...
1746
 
1990
 
1747
  .ready:
1991
  .ready:
Line 1748... Line -...
1748
        DEBUGF  1,"PHY write OK\n"
-
 
1749
        xor     eax, eax
1992
        DEBUGF  1,"alx_write_phy_ext OK\n"
Line 1750... Line 1993...
1750
 
1993
        xor     eax, eax
Line 1751... Line 1994...
1751
        ret
1994
 
Line 1761... Line 2004...
1761
; Only legacy interrupts supported for now.
2004
; Only legacy interrupts supported for now.
1762
        mov     dword[esi + ALX_MSI_RETRANS_TIMER], 0
2005
        mov     dword[esi + ALX_MSI_RETRANS_TIMER], 0
Line 1763... Line 2006...
1763
 
2006
 
Line 1764... Line -...
1764
        ret
-
 
1765
 
2007
        ret
Line 1766... Line 2008...
1766
 
2008
 
1767
; End of code
2009
; End of code
Line 1768... Line 2010...
1768
 
2010
 
Line 1769... Line 2011...
1769
data fixups
2011
data fixups
Line 1770... Line -...
1770
end data
-
 
1771
 
2012
end data
1772
include '../peimport.inc'
2013
 
1773
 
2014
include '../peimport.inc'
1774
my_service      db 'AR81XX',0                    ; max 16 chars include zero
2015
 
1775
 
2016
my_service      db 'AR81XX',0                    ; max 16 chars include zero