]> Pileus Git - ~andy/linux/blob - drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
staging: ft1000: Remove unused variable ASICResetNum.
[~andy/linux] / drivers / staging / ft1000 / ft1000-usb / ft1000_hw.c
1 //=====================================================
2 // CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved.
3 //
4 //
5 // This file is part of Express Card USB Driver
6 //
7 // $Id:
8 //====================================================
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/netdevice.h>
13 #include <linux/etherdevice.h>
14 #include <linux/usb.h>
15 #include "ft1000_usb.h"
16 #include <linux/types.h>
17
18 #define HARLEY_READ_REGISTER     0x0
19 #define HARLEY_WRITE_REGISTER    0x01
20 #define HARLEY_READ_DPRAM_32     0x02
21 #define HARLEY_READ_DPRAM_LOW    0x03
22 #define HARLEY_READ_DPRAM_HIGH   0x04
23 #define HARLEY_WRITE_DPRAM_32    0x05
24 #define HARLEY_WRITE_DPRAM_LOW   0x06
25 #define HARLEY_WRITE_DPRAM_HIGH  0x07
26
27 #define HARLEY_READ_OPERATION    0xc1
28 #define HARLEY_WRITE_OPERATION   0x41
29
30 //#define JDEBUG
31
32 static int ft1000_reset(struct net_device *ft1000dev);
33 static int ft1000_submit_rx_urb(struct ft1000_info *info);
34 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev);
35 static int ft1000_open (struct net_device *dev);
36 static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev);
37 static int ft1000_chkcard (struct ft1000_device *dev);
38
39 static u8 tempbuffer[1600];
40
41 #define MAX_RCV_LOOP   100
42
43 //---------------------------------------------------------------------------
44 // Function:    ft1000_control
45 //
46 // Parameters:  ft1000_device  - device structure
47 //              pipe - usb control message pipe
48 //              request - control request
49 //              requesttype - control message request type
50 //              value - value to be written or 0
51 //              index - register index
52 //              data - data buffer to hold the read/write values
53 //              size - data size
54 //              timeout - control message time out value
55 //
56 // Returns:     STATUS_SUCCESS - success
57 //              STATUS_FAILURE - failure
58 //
59 // Description: This function sends a control message via USB interface synchronously
60 //
61 // Notes:
62 //
63 //---------------------------------------------------------------------------
64 static int ft1000_control(struct ft1000_device *ft1000dev, unsigned int pipe,
65                           u8 request, u8 requesttype, u16 value, u16 index,
66                           void *data, u16 size, int timeout)
67 {
68         u16 ret;
69
70         if ((ft1000dev == NULL) || (ft1000dev->dev == NULL)) {
71                 DEBUG("ft1000dev or ft1000dev->dev == NULL, failure\n");
72                 return -ENODEV;
73         }
74
75         ret = usb_control_msg(ft1000dev->dev, pipe, request, requesttype,
76                               value, index, data, size, LARGE_TIMEOUT);
77
78         if (ret > 0)
79                 ret = 0;
80
81         return ret;
82 }
83
84 //---------------------------------------------------------------------------
85 // Function:    ft1000_read_register
86 //
87 // Parameters:  ft1000_device  - device structure
88 //              Data - data buffer to hold the value read
89 //              nRegIndex - register index
90 //
91 // Returns:     STATUS_SUCCESS - success
92 //              STATUS_FAILURE - failure
93 //
94 // Description: This function returns the value in a register
95 //
96 // Notes:
97 //
98 //---------------------------------------------------------------------------
99
100 int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data,
101                          u16 nRegIndx)
102 {
103         int ret = STATUS_SUCCESS;
104
105         ret = ft1000_control(ft1000dev,
106                              usb_rcvctrlpipe(ft1000dev->dev, 0),
107                              HARLEY_READ_REGISTER,
108                              HARLEY_READ_OPERATION,
109                              0,
110                              nRegIndx,
111                              Data,
112                              2,
113                              LARGE_TIMEOUT);
114
115         return ret;
116 }
117
118 //---------------------------------------------------------------------------
119 // Function:    ft1000_write_register
120 //
121 // Parameters:  ft1000_device  - device structure
122 //              value - value to write into a register
123 //              nRegIndex - register index
124 //
125 // Returns:     STATUS_SUCCESS - success
126 //              STATUS_FAILURE - failure
127 //
128 // Description: This function writes the value in a register
129 //
130 // Notes:
131 //
132 //---------------------------------------------------------------------------
133 int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value,
134                           u16 nRegIndx)
135 {
136         int ret = STATUS_SUCCESS;
137
138         ret = ft1000_control(ft1000dev,
139                              usb_sndctrlpipe(ft1000dev->dev, 0),
140                              HARLEY_WRITE_REGISTER,
141                              HARLEY_WRITE_OPERATION,
142                              value,
143                              nRegIndx,
144                              NULL,
145                              0,
146                              LARGE_TIMEOUT);
147
148         return ret;
149 }
150
151 //---------------------------------------------------------------------------
152 // Function:    ft1000_read_dpram32
153 //
154 // Parameters:  ft1000_device  - device structure
155 //              indx - starting address to read
156 //              buffer - data buffer to hold the data read
157 //              cnt - number of byte read from DPRAM
158 //
159 // Returns:     STATUS_SUCCESS - success
160 //              STATUS_FAILURE - failure
161 //
162 // Description: This function read a number of bytes from DPRAM
163 //
164 // Notes:
165 //
166 //---------------------------------------------------------------------------
167
168 int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
169                         u16 cnt)
170 {
171         int ret = STATUS_SUCCESS;
172
173         ret = ft1000_control(ft1000dev,
174                              usb_rcvctrlpipe(ft1000dev->dev, 0),
175                              HARLEY_READ_DPRAM_32,
176                              HARLEY_READ_OPERATION,
177                              0,
178                              indx,
179                              buffer,
180                              cnt,
181                              LARGE_TIMEOUT);
182
183         return ret;
184 }
185
186 //---------------------------------------------------------------------------
187 // Function:    ft1000_write_dpram32
188 //
189 // Parameters:  ft1000_device  - device structure
190 //              indx - starting address to write the data
191 //              buffer - data buffer to write into DPRAM
192 //              cnt - number of bytes to write
193 //
194 // Returns:     STATUS_SUCCESS - success
195 //              STATUS_FAILURE - failure
196 //
197 // Description: This function writes into DPRAM a number of bytes
198 //
199 // Notes:
200 //
201 //---------------------------------------------------------------------------
202 int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
203                          u16 cnt)
204 {
205         int ret = STATUS_SUCCESS;
206
207         if (cnt % 4)
208                 cnt += cnt - (cnt % 4);
209
210         ret = ft1000_control(ft1000dev,
211                              usb_sndctrlpipe(ft1000dev->dev, 0),
212                              HARLEY_WRITE_DPRAM_32,
213                              HARLEY_WRITE_OPERATION,
214                              0,
215                              indx,
216                              buffer,
217                              cnt,
218                              LARGE_TIMEOUT);
219
220         return ret;
221 }
222
223 //---------------------------------------------------------------------------
224 // Function:    ft1000_read_dpram16
225 //
226 // Parameters:  ft1000_device  - device structure
227 //              indx - starting address to read
228 //              buffer - data buffer to hold the data read
229 //              hightlow - high or low 16 bit word
230 //
231 // Returns:     STATUS_SUCCESS - success
232 //              STATUS_FAILURE - failure
233 //
234 // Description: This function read 16 bits from DPRAM
235 //
236 // Notes:
237 //
238 //---------------------------------------------------------------------------
239 int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
240                         u8 highlow)
241 {
242         int ret = STATUS_SUCCESS;
243         u8 request;
244
245         if (highlow == 0)
246                 request = HARLEY_READ_DPRAM_LOW;
247         else
248                 request = HARLEY_READ_DPRAM_HIGH;
249
250         ret = ft1000_control(ft1000dev,
251                              usb_rcvctrlpipe(ft1000dev->dev, 0),
252                              request,
253                              HARLEY_READ_OPERATION,
254                              0,
255                              indx,
256                              buffer,
257                              2,
258                              LARGE_TIMEOUT);
259
260         return ret;
261 }
262
263 //---------------------------------------------------------------------------
264 // Function:    ft1000_write_dpram16
265 //
266 // Parameters:  ft1000_device  - device structure
267 //              indx - starting address to write the data
268 //              value - 16bits value to write
269 //              hightlow - high or low 16 bit word
270 //
271 // Returns:     STATUS_SUCCESS - success
272 //              STATUS_FAILURE - failure
273 //
274 // Description: This function writes into DPRAM a number of bytes
275 //
276 // Notes:
277 //
278 //---------------------------------------------------------------------------
279 int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u8 highlow)
280 {
281         int ret = STATUS_SUCCESS;
282         u8 request;
283
284         if (highlow == 0)
285                 request = HARLEY_WRITE_DPRAM_LOW;
286         else
287                 request = HARLEY_WRITE_DPRAM_HIGH;
288
289         ret = ft1000_control(ft1000dev,
290                              usb_sndctrlpipe(ft1000dev->dev, 0),
291                              request,
292                              HARLEY_WRITE_OPERATION,
293                              value,
294                              indx,
295                              NULL,
296                              0,
297                              LARGE_TIMEOUT);
298
299         return ret;
300 }
301
302 //---------------------------------------------------------------------------
303 // Function:    fix_ft1000_read_dpram32
304 //
305 // Parameters:  ft1000_device  - device structure
306 //              indx - starting address to read
307 //              buffer - data buffer to hold the data read
308 //
309 //
310 // Returns:     STATUS_SUCCESS - success
311 //              STATUS_FAILURE - failure
312 //
313 // Description: This function read DPRAM 4 words at a time
314 //
315 // Notes:
316 //
317 //---------------------------------------------------------------------------
318 int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx,
319                             u8 *buffer)
320 {
321         u8 buf[16];
322         u16 pos;
323         int ret = STATUS_SUCCESS;
324
325         pos = (indx / 4) * 4;
326         ret = ft1000_read_dpram32(ft1000dev, pos, buf, 16);
327
328         if (ret == STATUS_SUCCESS) {
329                 pos = (indx % 4) * 4;
330                 *buffer++ = buf[pos++];
331                 *buffer++ = buf[pos++];
332                 *buffer++ = buf[pos++];
333                 *buffer++ = buf[pos++];
334         } else {
335                 DEBUG("fix_ft1000_read_dpram32: DPRAM32 Read failed\n");
336                 *buffer++ = 0;
337                 *buffer++ = 0;
338                 *buffer++ = 0;
339                 *buffer++ = 0;
340         }
341
342         return ret;
343 }
344
345
346 //---------------------------------------------------------------------------
347 // Function:    fix_ft1000_write_dpram32
348 //
349 // Parameters:  ft1000_device  - device structure
350 //              indx - starting address to write
351 //              buffer - data buffer to write
352 //
353 //
354 // Returns:     STATUS_SUCCESS - success
355 //              STATUS_FAILURE - failure
356 //
357 // Description: This function write to DPRAM 4 words at a time
358 //
359 // Notes:
360 //
361 //---------------------------------------------------------------------------
362 int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer)
363 {
364         u16 pos1;
365         u16 pos2;
366         u16 i;
367         u8 buf[32];
368         u8 resultbuffer[32];
369         u8 *pdata;
370         int ret  = STATUS_SUCCESS;
371
372         pos1 = (indx / 4) * 4;
373         pdata = buffer;
374         ret = ft1000_read_dpram32(ft1000dev, pos1, buf, 16);
375
376         if (ret == STATUS_SUCCESS) {
377                 pos2 = (indx % 4)*4;
378                 buf[pos2++] = *buffer++;
379                 buf[pos2++] = *buffer++;
380                 buf[pos2++] = *buffer++;
381                 buf[pos2++] = *buffer++;
382                 ret = ft1000_write_dpram32(ft1000dev, pos1, buf, 16);
383         } else {
384                 DEBUG("fix_ft1000_write_dpram32: DPRAM32 Read failed\n");
385                 return ret;
386         }
387
388         ret = ft1000_read_dpram32(ft1000dev, pos1, (u8 *)&resultbuffer[0], 16);
389
390         if (ret == STATUS_SUCCESS) {
391                 buffer = pdata;
392                 for (i = 0; i < 16; i++) {
393                         if (buf[i] != resultbuffer[i])
394                                 ret = STATUS_FAILURE;
395                 }
396         }
397
398         if (ret == STATUS_FAILURE) {
399                 ret = ft1000_write_dpram32(ft1000dev, pos1,
400                                            (u8 *)&tempbuffer[0], 16);
401                 ret = ft1000_read_dpram32(ft1000dev, pos1,
402                                           (u8 *)&resultbuffer[0], 16);
403                 if (ret == STATUS_SUCCESS) {
404                         buffer = pdata;
405                         for (i = 0; i < 16; i++) {
406                                 if (tempbuffer[i] != resultbuffer[i]) {
407                                         ret = STATUS_FAILURE;
408                                         DEBUG("%s Failed to write\n",
409                                               __func__);
410                                 }
411                         }
412                 }
413         }
414
415         return ret;
416 }
417
418
419 //------------------------------------------------------------------------
420 //
421 //  Function:   card_reset_dsp
422 //
423 //  Synopsis:   This function is called to reset or activate the DSP
424 //
425 //  Arguments:  value                  - reset or activate
426 //
427 //  Returns:    None
428 //-----------------------------------------------------------------------
429 static void card_reset_dsp(struct ft1000_device *ft1000dev, bool value)
430 {
431         u16 status = STATUS_SUCCESS;
432         u16 tempword;
433
434         status = ft1000_write_register(ft1000dev, HOST_INTF_BE,
435                                         FT1000_REG_SUP_CTRL);
436         status = ft1000_read_register(ft1000dev, &tempword,
437                                       FT1000_REG_SUP_CTRL);
438
439         if (value) {
440                 DEBUG("Reset DSP\n");
441                 status = ft1000_read_register(ft1000dev, &tempword,
442                                               FT1000_REG_RESET);
443                 tempword |= DSP_RESET_BIT;
444                 status = ft1000_write_register(ft1000dev, tempword,
445                                                FT1000_REG_RESET);
446         } else {
447                 DEBUG("Activate DSP\n");
448                 status = ft1000_read_register(ft1000dev, &tempword,
449                                               FT1000_REG_RESET);
450                 tempword |= DSP_ENCRYPTED;
451                 tempword &= ~DSP_UNENCRYPTED;
452                 status = ft1000_write_register(ft1000dev, tempword,
453                                                FT1000_REG_RESET);
454                 status = ft1000_read_register(ft1000dev, &tempword,
455                                               FT1000_REG_RESET);
456                 tempword &= ~EFUSE_MEM_DISABLE;
457                 tempword &= ~DSP_RESET_BIT;
458                 status = ft1000_write_register(ft1000dev, tempword,
459                                                FT1000_REG_RESET);
460                 status = ft1000_read_register(ft1000dev, &tempword,
461                                               FT1000_REG_RESET);
462         }
463 }
464
465 //---------------------------------------------------------------------------
466 // Function:    card_send_command
467 //
468 // Parameters:  ft1000_device  - device structure
469 //              ptempbuffer - command buffer
470 //              size - command buffer size
471 //
472 // Returns:     STATUS_SUCCESS - success
473 //              STATUS_FAILURE - failure
474 //
475 // Description: This function sends a command to ASIC
476 //
477 // Notes:
478 //
479 //---------------------------------------------------------------------------
480 void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer,
481                        int size)
482 {
483         unsigned short temp;
484         unsigned char *commandbuf;
485
486         DEBUG("card_send_command: enter card_send_command... size=%d\n", size);
487
488         commandbuf = (unsigned char *)kmalloc(size + 2, GFP_KERNEL);
489         memcpy((void *)commandbuf + 2, (void *)ptempbuffer, size);
490
491         ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);
492
493         if (temp & 0x0100)
494                 msleep(10);
495
496         /* check for odd word */
497         size = size + 2;
498
499         /* Must force to be 32 bit aligned */
500         if (size % 4)
501                 size += 4 - (size % 4);
502
503         ft1000_write_dpram32(ft1000dev, 0, commandbuf, size);
504         msleep(1);
505         ft1000_write_register(ft1000dev, FT1000_DB_DPRAM_TX,
506                               FT1000_REG_DOORBELL);
507         msleep(1);
508
509         ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);
510
511         if ((temp & 0x0100) == 0) {
512                 //DEBUG("card_send_command: Message sent\n");
513         }
514
515 }
516
517 //--------------------------------------------------------------------------
518 //
519 //  Function:   dsp_reload
520 //
521 //  Synopsis:   This function is called to load or reload the DSP
522 //
523 //  Arguments:  ft1000dev - device structure
524 //
525 //  Returns:    None
526 //-----------------------------------------------------------------------
527 int dsp_reload(struct ft1000_device *ft1000dev)
528 {
529         u16 status;
530         u16 tempword;
531         u32 templong;
532
533         struct ft1000_info *pft1000info;
534
535         pft1000info = netdev_priv(ft1000dev->net);
536
537         pft1000info->CardReady = 0;
538
539         /* Program Interrupt Mask register */
540         status = ft1000_write_register(ft1000dev, 0xffff, FT1000_REG_SUP_IMASK);
541
542         status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET);
543         tempword |= ASIC_RESET_BIT;
544         status = ft1000_write_register(ft1000dev, tempword, FT1000_REG_RESET);
545         msleep(1000);
546         status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET);
547         DEBUG("Reset Register = 0x%x\n", tempword);
548
549         /* Toggle DSP reset */
550         card_reset_dsp(ft1000dev, 1);
551         msleep(1000);
552         card_reset_dsp(ft1000dev, 0);
553         msleep(1000);
554
555         status =
556             ft1000_write_register(ft1000dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL);
557
558         /* Let's check for FEFE */
559         status =
560             ft1000_read_dpram32(ft1000dev, FT1000_MAG_DPRAM_FEFE_INDX,
561                                 (u8 *) &templong, 4);
562         DEBUG("templong (fefe) = 0x%8x\n", templong);
563
564         /* call codeloader */
565         status = scram_dnldr(ft1000dev, pFileStart, FileLength);
566
567         if (status != STATUS_SUCCESS)
568                 return -EIO;
569
570         msleep(1000);
571
572         DEBUG("dsp_reload returned\n");
573
574         return 0;
575 }
576
577 //---------------------------------------------------------------------------
578 //
579 // Function:   ft1000_reset_asic
580 // Description: This function will call the Card Service function to reset the
581 //             ASIC.
582 // Input:
583 //     dev    - device structure
584 // Output:
585 //     none
586 //
587 //---------------------------------------------------------------------------
588 static void ft1000_reset_asic(struct net_device *dev)
589 {
590         struct ft1000_info *info = netdev_priv(dev);
591         struct ft1000_device *ft1000dev = info->pFt1000Dev;
592         u16 tempword;
593
594         DEBUG("ft1000_hw:ft1000_reset_asic called\n");
595
596         /* Let's use the register provided by the Magnemite ASIC to reset the
597          * ASIC and DSP.
598          */
599         ft1000_write_register(ft1000dev, (DSP_RESET_BIT | ASIC_RESET_BIT),
600                               FT1000_REG_RESET);
601
602         mdelay(1);
603
604         /* set watermark to -1 in order to not generate an interrrupt */
605         ft1000_write_register(ft1000dev, 0xffff, FT1000_REG_MAG_WATERMARK);
606
607         /* clear interrupts */
608         ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_ISR);
609         DEBUG("ft1000_hw: interrupt status register = 0x%x\n", tempword);
610         ft1000_write_register(ft1000dev, tempword, FT1000_REG_SUP_ISR);
611         ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_ISR);
612         DEBUG("ft1000_hw: interrupt status register = 0x%x\n", tempword);
613 }
614
615
616 //---------------------------------------------------------------------------
617 //
618 // Function:   ft1000_reset_card
619 // Description: This function will reset the card
620 // Input:
621 //     dev    - device structure
622 // Output:
623 //     status - FALSE (card reset fail)
624 //              TRUE  (card reset successful)
625 //
626 //---------------------------------------------------------------------------
627 static int ft1000_reset_card(struct net_device *dev)
628 {
629         struct ft1000_info *info = netdev_priv(dev);
630         struct ft1000_device *ft1000dev = info->pFt1000Dev;
631         u16 tempword;
632         struct prov_record *ptr;
633
634         DEBUG("ft1000_hw:ft1000_reset_card called.....\n");
635
636         info->fCondResetPend = 1;
637         info->CardReady = 0;
638         info->fProvComplete = 0;
639
640         /* Make sure we free any memory reserve for provisioning */
641         while (list_empty(&info->prov_list) == 0) {
642                 DEBUG("ft1000_reset_card:deleting provisioning record\n");
643                 ptr =
644                     list_entry(info->prov_list.next, struct prov_record, list);
645                 list_del(&ptr->list);
646                 kfree(ptr->pprov_data);
647                 kfree(ptr);
648         }
649
650         DEBUG("ft1000_hw:ft1000_reset_card: reset asic\n");
651         ft1000_reset_asic(dev);
652
653         info->DSPResetNum++;
654
655         DEBUG("ft1000_hw:ft1000_reset_card: call dsp_reload\n");
656         dsp_reload(ft1000dev);
657
658         DEBUG("dsp reload successful\n");
659
660         mdelay(10);
661
662         /* Initialize DSP heartbeat area */
663         ft1000_write_dpram16(ft1000dev, FT1000_MAG_HI_HO, ho_mag,
664                              FT1000_MAG_HI_HO_INDX);
665         ft1000_read_dpram16(ft1000dev, FT1000_MAG_HI_HO, (u8 *) &tempword,
666                             FT1000_MAG_HI_HO_INDX);
667         DEBUG("ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n", tempword);
668
669         info->CardReady = 1;
670
671         info->fCondResetPend = 0;
672
673         return TRUE;
674 }
675
676 #ifdef HAVE_NET_DEVICE_OPS
677 static const struct net_device_ops ftnet_ops =
678 {
679         .ndo_open = &ft1000_open,
680         .ndo_stop = &ft1000_close,
681         .ndo_start_xmit = &ft1000_start_xmit,
682         .ndo_get_stats = &ft1000_netdev_stats,
683 };
684 #endif
685
686
687 //---------------------------------------------------------------------------
688 // Function:    init_ft1000_netdev
689 //
690 // Parameters:  ft1000dev  - device structure
691 //
692 //
693 // Returns:     STATUS_SUCCESS - success
694 //              STATUS_FAILURE - failure
695 //
696 // Description: This function initialize the network device
697 //
698 // Notes:
699 //
700 //---------------------------------------------------------------------------
701 int init_ft1000_netdev(struct ft1000_device *ft1000dev)
702 {
703         struct net_device *netdev;
704         struct ft1000_info *pInfo = NULL;
705         struct dpram_blk *pdpram_blk;
706         int i, ret_val;
707         struct list_head *cur, *tmp;
708         char card_nr[2];
709         unsigned long gCardIndex = 0;
710
711         DEBUG("Enter init_ft1000_netdev...\n");
712
713         netdev = alloc_etherdev(sizeof(struct ft1000_info));
714         if (!netdev) {
715                 DEBUG("init_ft1000_netdev: can not allocate network device\n");
716                 return -ENOMEM;
717         }
718
719         pInfo = netdev_priv(netdev);
720
721         memset(pInfo, 0, sizeof(struct ft1000_info));
722
723         dev_alloc_name(netdev, netdev->name);
724
725         DEBUG("init_ft1000_netdev: network device name is %s\n", netdev->name);
726
727         if (strncmp(netdev->name, "eth", 3) == 0) {
728                 card_nr[0] = netdev->name[3];
729                 card_nr[1] = '\0';
730                 ret_val = strict_strtoul(card_nr, 10, &gCardIndex);
731                 if (ret_val) {
732                         printk(KERN_ERR "Can't parse netdev\n");
733                         goto err_net;
734                 }
735
736                 pInfo->CardNumber = gCardIndex;
737                 DEBUG("card number = %d\n", pInfo->CardNumber);
738         } else {
739                 printk(KERN_ERR "ft1000: Invalid device name\n");
740                 ret_val = -ENXIO;
741                 goto err_net;
742         }
743
744         memset(&pInfo->stats, 0, sizeof(struct net_device_stats));
745
746         spin_lock_init(&pInfo->dpram_lock);
747         pInfo->pFt1000Dev = ft1000dev;
748         pInfo->DrvErrNum = 0;
749         pInfo->registered = 1;
750         pInfo->ft1000_reset = ft1000_reset;
751         pInfo->mediastate = 0;
752         pInfo->fifo_cnt = 0;
753         pInfo->DeviceCreated = FALSE;
754         pInfo->CurrentInterruptEnableMask = ISR_DEFAULT_MASK;
755         pInfo->InterruptsEnabled = FALSE;
756         pInfo->CardReady = 0;
757         pInfo->DSP_TIME[0] = 0;
758         pInfo->DSP_TIME[1] = 0;
759         pInfo->DSP_TIME[2] = 0;
760         pInfo->DSP_TIME[3] = 0;
761         pInfo->fAppMsgPend = 0;
762         pInfo->fCondResetPend = 0;
763         pInfo->usbboot = 0;
764         pInfo->dspalive = 0;
765         memset(&pInfo->tempbuf[0], 0, sizeof(pInfo->tempbuf));
766
767         INIT_LIST_HEAD(&pInfo->prov_list);
768
769         INIT_LIST_HEAD(&pInfo->nodes.list);
770
771 #ifdef HAVE_NET_DEVICE_OPS
772         netdev->netdev_ops = &ftnet_ops;
773 #else
774         netdev->hard_start_xmit = &ft1000_start_xmit;
775         netdev->get_stats = &ft1000_netdev_stats;
776         netdev->open = &ft1000_open;
777         netdev->stop = &ft1000_close;
778 #endif
779
780         ft1000dev->net = netdev;
781
782         DEBUG("Initialize free_buff_lock and freercvpool\n");
783         spin_lock_init(&free_buff_lock);
784
785         /* initialize a list of buffers to be use for queuing
786          * up receive command data
787          */
788         INIT_LIST_HEAD(&freercvpool);
789
790         /* create list of free buffers */
791         for (i = 0; i < NUM_OF_FREE_BUFFERS; i++) {
792                 /* Get memory for DPRAM_DATA link list */
793                 pdpram_blk = kmalloc(sizeof(struct dpram_blk), GFP_KERNEL);
794                 if (pdpram_blk == NULL) {
795                         ret_val = -ENOMEM;
796                         goto err_free;
797                 }
798                 /* Get a block of memory to store command data */
799                 pdpram_blk->pbuffer = kmalloc(MAX_CMD_SQSIZE, GFP_KERNEL);
800                 if (pdpram_blk->pbuffer == NULL) {
801                         ret_val = -ENOMEM;
802                         kfree(pdpram_blk);
803                         goto err_free;
804                 }
805                 /* link provisioning data */
806                 list_add_tail(&pdpram_blk->list, &freercvpool);
807         }
808         numofmsgbuf = NUM_OF_FREE_BUFFERS;
809
810         return 0;
811
812 err_free:
813         list_for_each_safe(cur, tmp, &freercvpool) {
814                 pdpram_blk = list_entry(cur, struct dpram_blk, list);
815                 list_del(&pdpram_blk->list);
816                 kfree(pdpram_blk->pbuffer);
817                 kfree(pdpram_blk);
818         }
819 err_net:
820         free_netdev(netdev);
821         return ret_val;
822 }
823
824 //---------------------------------------------------------------------------
825 // Function:    reg_ft1000_netdev
826 //
827 // Parameters:  ft1000dev  - device structure
828 //
829 //
830 // Returns:     STATUS_SUCCESS - success
831 //              STATUS_FAILURE - failure
832 //
833 // Description: This function register the network driver
834 //
835 // Notes:
836 //
837 //---------------------------------------------------------------------------
838 int reg_ft1000_netdev(struct ft1000_device *ft1000dev,
839                       struct usb_interface *intf)
840 {
841         struct net_device *netdev;
842         struct ft1000_info *pInfo;
843         int rc;
844
845         netdev = ft1000dev->net;
846         pInfo = netdev_priv(ft1000dev->net);
847         DEBUG("Enter reg_ft1000_netdev...\n");
848
849         ft1000_read_register(ft1000dev, &pInfo->AsicID, FT1000_REG_ASIC_ID);
850
851         usb_set_intfdata(intf, pInfo);
852         SET_NETDEV_DEV(netdev, &intf->dev);
853
854         rc = register_netdev(netdev);
855         if (rc) {
856                 DEBUG("reg_ft1000_netdev: could not register network device\n");
857                 free_netdev(netdev);
858                 return rc;
859         }
860
861         ft1000_create_dev(ft1000dev);
862
863         DEBUG("reg_ft1000_netdev returned\n");
864
865         pInfo->CardReady = 1;
866
867         return 0;
868 }
869
870 static int ft1000_reset(struct net_device *dev)
871 {
872         ft1000_reset_card(dev);
873         return 0;
874 }
875
876 //---------------------------------------------------------------------------
877 // Function:    ft1000_usb_transmit_complete
878 //
879 // Parameters:  urb  - transmitted usb urb
880 //
881 //
882 // Returns:     none
883 //
884 // Description: This is the callback function when a urb is transmitted
885 //
886 // Notes:
887 //
888 //---------------------------------------------------------------------------
889 static void ft1000_usb_transmit_complete(struct urb *urb)
890 {
891
892         struct ft1000_device *ft1000dev = urb->context;
893
894         if (urb->status)
895                 pr_err("%s: TX status %d\n", ft1000dev->net->name, urb->status);
896
897         netif_wake_queue(ft1000dev->net);
898 }
899
900 //---------------------------------------------------------------------------
901 //
902 // Function:   ft1000_copy_down_pkt
903 // Description: This function will take an ethernet packet and convert it to
904 //             a Flarion packet prior to sending it to the ASIC Downlink
905 //             FIFO.
906 // Input:
907 //     dev    - device structure
908 //     packet - address of ethernet packet
909 //     len    - length of IP packet
910 // Output:
911 //     status - FAILURE
912 //              SUCCESS
913 //
914 //---------------------------------------------------------------------------
915 static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
916 {
917         struct ft1000_info *pInfo = netdev_priv(netdev);
918         struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev;
919
920         int count, ret;
921         u8 *t;
922         struct pseudo_hdr hdr;
923
924         if (!pInfo->CardReady) {
925                 DEBUG("ft1000_copy_down_pkt::Card Not Ready\n");
926                 return -ENODEV;
927         }
928
929         count = sizeof(struct pseudo_hdr) + len;
930         if (count > MAX_BUF_SIZE) {
931                 DEBUG("Error:ft1000_copy_down_pkt:Message Size Overflow!\n");
932                 DEBUG("size = %d\n", count);
933                 return -EINVAL;
934         }
935
936         if (count % 4)
937                 count = count + (4 - (count % 4));
938
939         memset(&hdr, 0, sizeof(struct pseudo_hdr));
940
941         hdr.length = ntohs(count);
942         hdr.source = 0x10;
943         hdr.destination = 0x20;
944         hdr.portdest = 0x20;
945         hdr.portsrc = 0x10;
946         hdr.sh_str_id = 0x91;
947         hdr.control = 0x00;
948
949         hdr.checksum = hdr.length ^ hdr.source ^ hdr.destination ^
950             hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control;
951
952         memcpy(&pFt1000Dev->tx_buf[0], &hdr, sizeof(hdr));
953         memcpy(&(pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)]), packet, len);
954
955         netif_stop_queue(netdev);
956
957         usb_fill_bulk_urb(pFt1000Dev->tx_urb,
958                           pFt1000Dev->dev,
959                           usb_sndbulkpipe(pFt1000Dev->dev,
960                                           pFt1000Dev->bulk_out_endpointAddr),
961                           pFt1000Dev->tx_buf, count,
962                           ft1000_usb_transmit_complete, (void *)pFt1000Dev);
963
964         t = (u8 *) pFt1000Dev->tx_urb->transfer_buffer;
965
966         ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC);
967
968         if (ret) {
969                 DEBUG("ft1000 failed tx_urb %d\n", ret);
970                 return ret;
971         } else {
972                 pInfo->stats.tx_packets++;
973                 pInfo->stats.tx_bytes += (len + 14);
974         }
975
976         return 0;
977 }
978
979
980 //---------------------------------------------------------------------------
981 // Function:    ft1000_start_xmit
982 //
983 // Parameters:  skb - socket buffer to be sent
984 //              dev - network device
985 //
986 //
987 // Returns:     none
988 //
989 // Description: transmit a ethernet packet
990 //
991 // Notes:
992 //
993 //---------------------------------------------------------------------------
994 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
995 {
996         struct ft1000_info *pInfo = netdev_priv(dev);
997         struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev;
998         u8 *pdata;
999         int maxlen, pipe;
1000
1001         if (skb == NULL) {
1002                 DEBUG("ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n");
1003                 return NETDEV_TX_OK;
1004         }
1005
1006         if (pFt1000Dev->status & FT1000_STATUS_CLOSING) {
1007                 DEBUG("network driver is closed, return\n");
1008                 goto err;
1009         }
1010
1011         pipe =
1012             usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr);
1013         maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe));
1014
1015         pdata = (u8 *) skb->data;
1016
1017         if (pInfo->mediastate == 0) {
1018                 /* Drop packet is mediastate is down */
1019                 DEBUG("ft1000_hw:ft1000_start_xmit:mediastate is down\n");
1020                 goto err;
1021         }
1022
1023         if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) {
1024                 /* Drop packet which has invalid size */
1025                 DEBUG("ft1000_hw:ft1000_start_xmit:invalid ethernet length\n");
1026                 goto err;
1027         }
1028
1029         ft1000_copy_down_pkt(dev, (pdata + ENET_HEADER_SIZE - 2),
1030                              skb->len - ENET_HEADER_SIZE + 2);
1031
1032 err:
1033         dev_kfree_skb(skb);
1034
1035         return NETDEV_TX_OK;
1036 }
1037
1038
1039 //---------------------------------------------------------------------------
1040 //
1041 // Function:   ft1000_copy_up_pkt
1042 // Description: This function will take a packet from the FIFO up link and
1043 //             convert it into an ethernet packet and deliver it to the IP stack
1044 // Input:
1045 //     urb - the receiving usb urb
1046 //
1047 // Output:
1048 //     status - FAILURE
1049 //              SUCCESS
1050 //
1051 //---------------------------------------------------------------------------
1052 static int ft1000_copy_up_pkt(struct urb *urb)
1053 {
1054         struct ft1000_info *info = urb->context;
1055         struct ft1000_device *ft1000dev = info->pFt1000Dev;
1056         struct net_device *net = ft1000dev->net;
1057
1058         u16 tempword;
1059         u16 len;
1060         u16 lena;
1061         struct sk_buff *skb;
1062         u16 i;
1063         u8 *pbuffer = NULL;
1064         u8 *ptemp = NULL;
1065         u16 *chksum;
1066
1067         if (ft1000dev->status & FT1000_STATUS_CLOSING) {
1068                 DEBUG("network driver is closed, return\n");
1069                 return STATUS_SUCCESS;
1070         }
1071         // Read length
1072         len = urb->transfer_buffer_length;
1073         lena = urb->actual_length;
1074
1075         chksum = (u16 *) ft1000dev->rx_buf;
1076
1077         tempword = *chksum++;
1078         for (i = 1; i < 7; i++)
1079                 tempword ^= *chksum++;
1080
1081         if (tempword != *chksum) {
1082                 info->stats.rx_errors++;
1083                 ft1000_submit_rx_urb(info);
1084                 return STATUS_FAILURE;
1085         }
1086
1087         skb = dev_alloc_skb(len + 12 + 2);
1088
1089         if (skb == NULL) {
1090                 DEBUG("ft1000_copy_up_pkt: No Network buffers available\n");
1091                 info->stats.rx_errors++;
1092                 ft1000_submit_rx_urb(info);
1093                 return STATUS_FAILURE;
1094         }
1095
1096         pbuffer = (u8 *) skb_put(skb, len + 12);
1097
1098         /* subtract the number of bytes read already */
1099         ptemp = pbuffer;
1100
1101         /* fake MAC address */
1102         *pbuffer++ = net->dev_addr[0];
1103         *pbuffer++ = net->dev_addr[1];
1104         *pbuffer++ = net->dev_addr[2];
1105         *pbuffer++ = net->dev_addr[3];
1106         *pbuffer++ = net->dev_addr[4];
1107         *pbuffer++ = net->dev_addr[5];
1108         *pbuffer++ = 0x00;
1109         *pbuffer++ = 0x07;
1110         *pbuffer++ = 0x35;
1111         *pbuffer++ = 0xff;
1112         *pbuffer++ = 0xff;
1113         *pbuffer++ = 0xfe;
1114
1115         memcpy(pbuffer, ft1000dev->rx_buf + sizeof(struct pseudo_hdr),
1116                len - sizeof(struct pseudo_hdr));
1117
1118         skb->dev = net;
1119
1120         skb->protocol = eth_type_trans(skb, net);
1121         skb->ip_summed = CHECKSUM_UNNECESSARY;
1122         netif_rx(skb);
1123
1124         info->stats.rx_packets++;
1125         /* Add on 12 bytes for MAC address which was removed */
1126         info->stats.rx_bytes += (lena + 12);
1127
1128         ft1000_submit_rx_urb(info);
1129
1130         return SUCCESS;
1131 }
1132
1133
1134 //---------------------------------------------------------------------------
1135 //
1136 // Function:   ft1000_submit_rx_urb
1137 // Description: the receiving function of the network driver
1138 //
1139 // Input:
1140 //     info - a private structure contains the device information
1141 //
1142 // Output:
1143 //     status - FAILURE
1144 //              SUCCESS
1145 //
1146 //---------------------------------------------------------------------------
1147 static int ft1000_submit_rx_urb(struct ft1000_info *info)
1148 {
1149         int result;
1150         struct ft1000_device *pFt1000Dev = info->pFt1000Dev;
1151
1152         if (pFt1000Dev->status & FT1000_STATUS_CLOSING) {
1153                 DEBUG("network driver is closed, return\n");
1154                 return -ENODEV;
1155         }
1156
1157         usb_fill_bulk_urb(pFt1000Dev->rx_urb,
1158                           pFt1000Dev->dev,
1159                           usb_rcvbulkpipe(pFt1000Dev->dev,
1160                                           pFt1000Dev->bulk_in_endpointAddr),
1161                           pFt1000Dev->rx_buf, MAX_BUF_SIZE,
1162                           (usb_complete_t) ft1000_copy_up_pkt, info);
1163
1164         result = usb_submit_urb(pFt1000Dev->rx_urb, GFP_ATOMIC);
1165
1166         if (result) {
1167                 pr_err("ft1000_submit_rx_urb: submitting rx_urb %d failed\n",
1168                        result);
1169                 return result;
1170         }
1171
1172         return 0;
1173 }
1174
1175
1176 //---------------------------------------------------------------------------
1177 // Function:    ft1000_open
1178 //
1179 // Parameters:
1180 //              dev - network device
1181 //
1182 //
1183 // Returns:     none
1184 //
1185 // Description: open the network driver
1186 //
1187 // Notes:
1188 //
1189 //---------------------------------------------------------------------------
1190 static int ft1000_open(struct net_device *dev)
1191 {
1192         struct ft1000_info *pInfo = netdev_priv(dev);
1193         struct timeval tv;
1194         int ret;
1195
1196         DEBUG("ft1000_open is called for card %d\n", pInfo->CardNumber);
1197
1198         pInfo->stats.rx_bytes = 0;
1199         pInfo->stats.tx_bytes = 0;
1200         pInfo->stats.rx_packets = 0;
1201         pInfo->stats.tx_packets = 0;
1202         do_gettimeofday(&tv);
1203         pInfo->ConTm = tv.tv_sec;
1204         pInfo->ProgConStat = 0;
1205
1206         netif_start_queue(dev);
1207
1208         netif_carrier_on(dev);
1209
1210         ret = ft1000_submit_rx_urb(pInfo);
1211
1212         return ret;
1213 }
1214
1215 //---------------------------------------------------------------------------
1216 // Function:    ft1000_close
1217 //
1218 // Parameters:
1219 //              net - network device
1220 //
1221 //
1222 // Returns:     none
1223 //
1224 // Description: close the network driver
1225 //
1226 // Notes:
1227 //
1228 //---------------------------------------------------------------------------
1229 int ft1000_close(struct net_device *net)
1230 {
1231         struct ft1000_info *pInfo = netdev_priv(net);
1232         struct ft1000_device *ft1000dev = pInfo->pFt1000Dev;
1233
1234         ft1000dev->status |= FT1000_STATUS_CLOSING;
1235
1236         DEBUG("ft1000_close: pInfo=%p, ft1000dev=%p\n", pInfo, ft1000dev);
1237         netif_carrier_off(net);
1238         netif_stop_queue(net);
1239         ft1000dev->status &= ~FT1000_STATUS_CLOSING;
1240
1241         pInfo->ProgConStat = 0xff;
1242
1243         return 0;
1244 }
1245
1246 static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev)
1247 {
1248         struct ft1000_info *info = netdev_priv(dev);
1249
1250         return &(info->stats);
1251 }
1252
1253
1254 //---------------------------------------------------------------------------
1255 //
1256 // Function:   ft1000_chkcard
1257 // Description: This function will check if the device is presently available on
1258 //             the system.
1259 // Input:
1260 //     dev    - device structure
1261 // Output:
1262 //     status - FALSE (device is not present)
1263 //              TRUE  (device is present)
1264 //
1265 //---------------------------------------------------------------------------
1266 static int ft1000_chkcard(struct ft1000_device *dev)
1267 {
1268         u16 tempword;
1269         u16 status;
1270         struct ft1000_info *info = netdev_priv(dev->net);
1271
1272         if (info->fCondResetPend) {
1273                 DEBUG
1274                     ("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n");
1275                 return TRUE;
1276         }
1277         /* Mask register is used to check for device presence since it is never
1278          * set to zero.
1279          */
1280         status = ft1000_read_register(dev, &tempword, FT1000_REG_SUP_IMASK);
1281         if (tempword == 0) {
1282                 DEBUG
1283                     ("ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");
1284                 return FALSE;
1285         }
1286         /* The system will return the value of 0xffff for the version register
1287          * if the device is not present.
1288          */
1289         status = ft1000_read_register(dev, &tempword, FT1000_REG_ASIC_ID);
1290         if (tempword != 0x1b01) {
1291                 dev->status |= FT1000_STATUS_CLOSING;
1292                 DEBUG
1293                     ("ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n");
1294                 return FALSE;
1295         }
1296         return TRUE;
1297 }
1298
1299 //---------------------------------------------------------------------------
1300 //
1301 // Function:   ft1000_receive_cmd
1302 // Description: This function will read a message from the dpram area.
1303 // Input:
1304 //    dev - network device structure
1305 //    pbuffer - caller supply address to buffer
1306 //    pnxtph - pointer to next pseudo header
1307 // Output:
1308 //   Status = 0 (unsuccessful)
1309 //          = 1 (successful)
1310 //
1311 //---------------------------------------------------------------------------
1312 static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer,
1313                                int maxsz, u16 *pnxtph)
1314 {
1315         u16 size, ret;
1316         u16 *ppseudohdr;
1317         int i;
1318         u16 tempword;
1319
1320         ret =
1321             ft1000_read_dpram16(dev, FT1000_MAG_PH_LEN, (u8 *) &size,
1322                                 FT1000_MAG_PH_LEN_INDX);
1323         size = ntohs(size) + PSEUDOSZ;
1324         if (size > maxsz) {
1325                 DEBUG("FT1000:ft1000_receive_cmd:Invalid command length = %d\n",
1326                       size);
1327                 return FALSE;
1328         } else {
1329                 ppseudohdr = (u16 *) pbuffer;
1330                 ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE,
1331                                       FT1000_REG_DPRAM_ADDR);
1332                 ret =
1333                     ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH);
1334                 pbuffer++;
1335                 ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE + 1,
1336                                       FT1000_REG_DPRAM_ADDR);
1337                 for (i = 0; i <= (size >> 2); i++) {
1338                         ret =
1339                             ft1000_read_register(dev, pbuffer,
1340                                                  FT1000_REG_MAG_DPDATAL);
1341                         pbuffer++;
1342                         ret =
1343                             ft1000_read_register(dev, pbuffer,
1344                                                  FT1000_REG_MAG_DPDATAH);
1345                         pbuffer++;
1346                 }
1347                 /* copy odd aligned word */
1348                 ret =
1349                     ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAL);
1350
1351                 pbuffer++;
1352                 ret =
1353                     ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH);
1354
1355                 pbuffer++;
1356                 if (size & 0x0001) {
1357                         /* copy odd byte from fifo */
1358                         ret =
1359                             ft1000_read_register(dev, &tempword,
1360                                                  FT1000_REG_DPRAM_DATA);
1361                         *pbuffer = ntohs(tempword);
1362                 }
1363                 /* Check if pseudo header checksum is good
1364                  * Calculate pseudo header checksum
1365                  */
1366                 tempword = *ppseudohdr++;
1367                 for (i = 1; i < 7; i++)
1368                         tempword ^= *ppseudohdr++;
1369
1370                 if ((tempword != *ppseudohdr))
1371                         return FALSE;
1372
1373                 return TRUE;
1374         }
1375 }
1376
1377 static int ft1000_dsp_prov(void *arg)
1378 {
1379         struct ft1000_device *dev = (struct ft1000_device *)arg;
1380         struct ft1000_info *info = netdev_priv(dev->net);
1381         u16 tempword;
1382         u16 len;
1383         u16 i = 0;
1384         struct prov_record *ptr;
1385         struct pseudo_hdr *ppseudo_hdr;
1386         u16 *pmsg;
1387         u16 status;
1388         u16 TempShortBuf[256];
1389
1390         DEBUG("*** DspProv Entered\n");
1391
1392         while (list_empty(&info->prov_list) == 0) {
1393                 DEBUG("DSP Provisioning List Entry\n");
1394
1395                 /* Check if doorbell is available */
1396                 DEBUG("check if doorbell is cleared\n");
1397                 status =
1398                     ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL);
1399                 if (status) {
1400                         DEBUG("ft1000_dsp_prov::ft1000_read_register error\n");
1401                         break;
1402                 }
1403
1404                 while (tempword & FT1000_DB_DPRAM_TX) {
1405                         mdelay(10);
1406                         i++;
1407                         if (i == 10) {
1408                                 DEBUG("FT1000:ft1000_dsp_prov:message drop\n");
1409                                 return STATUS_FAILURE;
1410                         }
1411                         ft1000_read_register(dev, &tempword,
1412                                              FT1000_REG_DOORBELL);
1413                 }
1414
1415                 if (!(tempword & FT1000_DB_DPRAM_TX)) {
1416                         DEBUG("*** Provision Data Sent to DSP\n");
1417
1418                         /* Send provisioning data */
1419                         ptr =
1420                             list_entry(info->prov_list.next, struct prov_record,
1421                                        list);
1422                         len = *(u16 *) ptr->pprov_data;
1423                         len = htons(len);
1424                         len += PSEUDOSZ;
1425
1426                         pmsg = (u16 *) ptr->pprov_data;
1427                         ppseudo_hdr = (struct pseudo_hdr *)pmsg;
1428                         /* Insert slow queue sequence number */
1429                         ppseudo_hdr->seq_num = info->squeseqnum++;
1430                         ppseudo_hdr->portsrc = 0;
1431                         /* Calculate new checksum */
1432                         ppseudo_hdr->checksum = *pmsg++;
1433                         for (i = 1; i < 7; i++) {
1434                                 ppseudo_hdr->checksum ^= *pmsg++;
1435                         }
1436
1437                         TempShortBuf[0] = 0;
1438                         TempShortBuf[1] = htons(len);
1439                         memcpy(&TempShortBuf[2], ppseudo_hdr, len);
1440
1441                         status =
1442                             ft1000_write_dpram32(dev, 0,
1443                                                  (u8 *) &TempShortBuf[0],
1444                                                  (unsigned short)(len + 2));
1445                         status =
1446                             ft1000_write_register(dev, FT1000_DB_DPRAM_TX,
1447                                                   FT1000_REG_DOORBELL);
1448
1449                         list_del(&ptr->list);
1450                         kfree(ptr->pprov_data);
1451                         kfree(ptr);
1452                 }
1453                 msleep(10);
1454         }
1455
1456         DEBUG("DSP Provisioning List Entry finished\n");
1457
1458         msleep(100);
1459
1460         info->fProvComplete = 1;
1461         info->CardReady = 1;
1462
1463         return STATUS_SUCCESS;
1464 }
1465
1466 static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
1467 {
1468         struct ft1000_info *info = netdev_priv(dev->net);
1469         u16 msgtype;
1470         u16 tempword;
1471         struct media_msg *pmediamsg;
1472         struct dsp_init_msg *pdspinitmsg;
1473         struct drv_msg *pdrvmsg;
1474         u16 i;
1475         struct pseudo_hdr *ppseudo_hdr;
1476         u16 *pmsg;
1477         u16 status;
1478         union {
1479                 u8 byte[2];
1480                 u16 wrd;
1481         } convert;
1482
1483         char *cmdbuffer = kmalloc(1600, GFP_KERNEL);
1484         if (!cmdbuffer)
1485                 return STATUS_FAILURE;
1486
1487         status = ft1000_read_dpram32(dev, 0x200, cmdbuffer, size);
1488
1489 #ifdef JDEBUG
1490         DEBUG("ft1000_proc_drvmsg:cmdbuffer\n");
1491         for (i = 0; i < size; i += 5) {
1492                 if ((i + 5) < size)
1493                         DEBUG("0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", cmdbuffer[i],
1494                               cmdbuffer[i + 1], cmdbuffer[i + 2],
1495                               cmdbuffer[i + 3], cmdbuffer[i + 4]);
1496                 else {
1497                         for (j = i; j < size; j++)
1498                                 DEBUG("0x%x ", cmdbuffer[j]);
1499                         DEBUG("\n");
1500                         break;
1501                 }
1502         }
1503 #endif
1504         pdrvmsg = (struct drv_msg *)&cmdbuffer[2];
1505         msgtype = ntohs(pdrvmsg->type);
1506         DEBUG("ft1000_proc_drvmsg:Command message type = 0x%x\n", msgtype);
1507         switch (msgtype) {
1508         case MEDIA_STATE:{
1509                         DEBUG
1510                             ("ft1000_proc_drvmsg:Command message type = MEDIA_STATE");
1511
1512                         pmediamsg = (struct media_msg *)&cmdbuffer[0];
1513                         if (info->ProgConStat != 0xFF) {
1514                                 if (pmediamsg->state) {
1515                                         DEBUG("Media is up\n");
1516                                         if (info->mediastate == 0) {
1517                                                 if (info->NetDevRegDone) {
1518                                                         netif_wake_queue(dev->
1519                                                                          net);
1520                                                 }
1521                                                 info->mediastate = 1;
1522                                         }
1523                                 } else {
1524                                         DEBUG("Media is down\n");
1525                                         if (info->mediastate == 1) {
1526                                                 info->mediastate = 0;
1527                                                 if (info->NetDevRegDone) {
1528                                                 }
1529                                                 info->ConTm = 0;
1530                                         }
1531                                 }
1532                         } else {
1533                                 DEBUG("Media is down\n");
1534                                 if (info->mediastate == 1) {
1535                                         info->mediastate = 0;
1536                                         info->ConTm = 0;
1537                                 }
1538                         }
1539                         break;
1540                 }
1541         case DSP_INIT_MSG:{
1542                         DEBUG
1543                             ("ft1000_proc_drvmsg:Command message type = DSP_INIT_MSG");
1544
1545                         pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[2];
1546                         memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ);
1547                         DEBUG("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n",
1548                               info->DspVer[0], info->DspVer[1], info->DspVer[2],
1549                               info->DspVer[3]);
1550                         memcpy(info->HwSerNum, pdspinitmsg->HwSerNum,
1551                                HWSERNUMSZ);
1552                         memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ);
1553                         memcpy(info->eui64, pdspinitmsg->eui64, EUISZ);
1554                         DEBUG("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n",
1555                               info->eui64[0], info->eui64[1], info->eui64[2],
1556                               info->eui64[3], info->eui64[4], info->eui64[5],
1557                               info->eui64[6], info->eui64[7]);
1558                         dev->net->dev_addr[0] = info->eui64[0];
1559                         dev->net->dev_addr[1] = info->eui64[1];
1560                         dev->net->dev_addr[2] = info->eui64[2];
1561                         dev->net->dev_addr[3] = info->eui64[5];
1562                         dev->net->dev_addr[4] = info->eui64[6];
1563                         dev->net->dev_addr[5] = info->eui64[7];
1564
1565                         if (ntohs(pdspinitmsg->length) ==
1566                             (sizeof(struct dsp_init_msg) - 20)) {
1567                                 memcpy(info->ProductMode,
1568                                        pdspinitmsg->ProductMode, MODESZ);
1569                                 memcpy(info->RfCalVer, pdspinitmsg->RfCalVer,
1570                                        CALVERSZ);
1571                                 memcpy(info->RfCalDate, pdspinitmsg->RfCalDate,
1572                                        CALDATESZ);
1573                                 DEBUG("RFCalVer = 0x%2x 0x%2x\n",
1574                                       info->RfCalVer[0], info->RfCalVer[1]);
1575                         }
1576                         break;
1577                 }
1578         case DSP_PROVISION:{
1579                         DEBUG
1580                             ("ft1000_proc_drvmsg:Command message type = DSP_PROVISION\n");
1581
1582                         /* kick off dspprov routine to start provisioning
1583                          * Send provisioning data to DSP
1584                          */
1585                         if (list_empty(&info->prov_list) == 0) {
1586                                 info->fProvComplete = 0;
1587                                 status = ft1000_dsp_prov(dev);
1588                                 if (status != STATUS_SUCCESS)
1589                                         goto out;
1590                         } else {
1591                                 info->fProvComplete = 1;
1592                                 status =
1593                                     ft1000_write_register(dev, FT1000_DB_HB,
1594                                                           FT1000_REG_DOORBELL);
1595                                 DEBUG
1596                                     ("FT1000:drivermsg:No more DSP provisioning data in dsp image\n");
1597                         }
1598                         DEBUG("ft1000_proc_drvmsg:DSP PROVISION is done\n");
1599                         break;
1600                 }
1601         case DSP_STORE_INFO:{
1602                         DEBUG
1603                             ("ft1000_proc_drvmsg:Command message type = DSP_STORE_INFO");
1604
1605                         DEBUG("FT1000:drivermsg:Got DSP_STORE_INFO\n");
1606                         tempword = ntohs(pdrvmsg->length);
1607                         info->DSPInfoBlklen = tempword;
1608                         if (tempword < (MAX_DSP_SESS_REC - 4)) {
1609                                 pmsg = (u16 *) &pdrvmsg->data[0];
1610                                 for (i = 0; i < ((tempword + 1) / 2); i++) {
1611                                         DEBUG
1612                                             ("FT1000:drivermsg:dsp info data = 0x%x\n",
1613                                              *pmsg);
1614                                         info->DSPInfoBlk[i + 10] = *pmsg++;
1615                                 }
1616                         } else {
1617                                 info->DSPInfoBlklen = 0;
1618                         }
1619                         break;
1620                 }
1621         case DSP_GET_INFO:{
1622                         DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n");
1623                         /* copy dsp info block to dsp */
1624                         info->DrvMsgPend = 1;
1625                         /* allow any outstanding ioctl to finish */
1626                         mdelay(10);
1627                         status =
1628                             ft1000_read_register(dev, &tempword,
1629                                                  FT1000_REG_DOORBELL);
1630                         if (tempword & FT1000_DB_DPRAM_TX) {
1631                                 mdelay(10);
1632                                 status =
1633                                     ft1000_read_register(dev, &tempword,
1634                                                          FT1000_REG_DOORBELL);
1635                                 if (tempword & FT1000_DB_DPRAM_TX) {
1636                                         mdelay(10);
1637                                         status =
1638                                             ft1000_read_register(dev, &tempword,
1639                                                                  FT1000_REG_DOORBELL);
1640                                         if (tempword & FT1000_DB_DPRAM_TX)
1641                                                 break;
1642                                 }
1643                         }
1644                         /* Put message into Slow Queue
1645                          * Form Pseudo header
1646                          */
1647                         pmsg = (u16 *) info->DSPInfoBlk;
1648                         *pmsg++ = 0;
1649                         *pmsg++ =
1650                             htons(info->DSPInfoBlklen + 20 +
1651                                   info->DSPInfoBlklen);
1652                         ppseudo_hdr =
1653                             (struct pseudo_hdr *)(u16 *) &info->DSPInfoBlk[2];
1654                         ppseudo_hdr->length =
1655                             htons(info->DSPInfoBlklen + 4 +
1656                                   info->DSPInfoBlklen);
1657                         ppseudo_hdr->source = 0x10;
1658                         ppseudo_hdr->destination = 0x20;
1659                         ppseudo_hdr->portdest = 0;
1660                         ppseudo_hdr->portsrc = 0;
1661                         ppseudo_hdr->sh_str_id = 0;
1662                         ppseudo_hdr->control = 0;
1663                         ppseudo_hdr->rsvd1 = 0;
1664                         ppseudo_hdr->rsvd2 = 0;
1665                         ppseudo_hdr->qos_class = 0;
1666                         /* Insert slow queue sequence number */
1667                         ppseudo_hdr->seq_num = info->squeseqnum++;
1668                         /* Insert application id */
1669                         ppseudo_hdr->portsrc = 0;
1670                         /* Calculate new checksum */
1671                         ppseudo_hdr->checksum = *pmsg++;
1672                         for (i = 1; i < 7; i++)
1673                                 ppseudo_hdr->checksum ^= *pmsg++;
1674
1675                         info->DSPInfoBlk[10] = 0x7200;
1676                         info->DSPInfoBlk[11] = htons(info->DSPInfoBlklen);
1677                         status =
1678                             ft1000_write_dpram32(dev, 0,
1679                                                  (u8 *) &info->DSPInfoBlk[0],
1680                                                  (unsigned short)(info->
1681                                                                   DSPInfoBlklen
1682                                                                   + 22));
1683                         status =
1684                             ft1000_write_register(dev, FT1000_DB_DPRAM_TX,
1685                                                   FT1000_REG_DOORBELL);
1686                         info->DrvMsgPend = 0;
1687
1688                         break;
1689                 }
1690
1691         case GET_DRV_ERR_RPT_MSG:{
1692                         DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n");
1693                         /* copy driver error message to dsp */
1694                         info->DrvMsgPend = 1;
1695                         /* allow any outstanding ioctl to finish */
1696                         mdelay(10);
1697                         status =
1698                             ft1000_read_register(dev, &tempword,
1699                                                  FT1000_REG_DOORBELL);
1700                         if (tempword & FT1000_DB_DPRAM_TX) {
1701                                 mdelay(10);
1702                                 status =
1703                                     ft1000_read_register(dev, &tempword,
1704                                                          FT1000_REG_DOORBELL);
1705                                 if (tempword & FT1000_DB_DPRAM_TX)
1706                                         mdelay(10);
1707                         }
1708
1709                         if ((tempword & FT1000_DB_DPRAM_TX) == 0) {
1710                                 /* Put message into Slow Queue
1711                                  * Form Pseudo header
1712                                  */
1713                                 pmsg = (u16 *) &tempbuffer[0];
1714                                 ppseudo_hdr = (struct pseudo_hdr *)pmsg;
1715                                 ppseudo_hdr->length = htons(0x0012);
1716                                 ppseudo_hdr->source = 0x10;
1717                                 ppseudo_hdr->destination = 0x20;
1718                                 ppseudo_hdr->portdest = 0;
1719                                 ppseudo_hdr->portsrc = 0;
1720                                 ppseudo_hdr->sh_str_id = 0;
1721                                 ppseudo_hdr->control = 0;
1722                                 ppseudo_hdr->rsvd1 = 0;
1723                                 ppseudo_hdr->rsvd2 = 0;
1724                                 ppseudo_hdr->qos_class = 0;
1725                                 /* Insert slow queue sequence number */
1726                                 ppseudo_hdr->seq_num = info->squeseqnum++;
1727                                 /* Insert application id */
1728                                 ppseudo_hdr->portsrc = 0;
1729                                 /* Calculate new checksum */
1730                                 ppseudo_hdr->checksum = *pmsg++;
1731                                 for (i = 1; i < 7; i++)
1732                                         ppseudo_hdr->checksum ^= *pmsg++;
1733
1734                                 pmsg = (u16 *) &tempbuffer[16];
1735                                 *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG);
1736                                 *pmsg++ = htons(0x000e);
1737                                 *pmsg++ = htons(info->DSP_TIME[0]);
1738                                 *pmsg++ = htons(info->DSP_TIME[1]);
1739                                 *pmsg++ = htons(info->DSP_TIME[2]);
1740                                 *pmsg++ = htons(info->DSP_TIME[3]);
1741                                 convert.byte[0] = info->DspVer[0];
1742                                 convert.byte[1] = info->DspVer[1];
1743                                 *pmsg++ = convert.wrd;
1744                                 convert.byte[0] = info->DspVer[2];
1745                                 convert.byte[1] = info->DspVer[3];
1746                                 *pmsg++ = convert.wrd;
1747                                 *pmsg++ = htons(info->DrvErrNum);
1748
1749                                 card_send_command(dev,
1750                                                  (unsigned char *)&tempbuffer[0],
1751                                                  (u16) (0x0012 + PSEUDOSZ));
1752                                 info->DrvErrNum = 0;
1753                         }
1754                         info->DrvMsgPend = 0;
1755
1756                         break;
1757                 }
1758
1759         default:
1760                 break;
1761         }
1762
1763         status = STATUS_SUCCESS;
1764 out:
1765         kfree(cmdbuffer);
1766         DEBUG("return from ft1000_proc_drvmsg\n");
1767         return status;
1768 }
1769
1770 int ft1000_poll(void* dev_id) {
1771
1772     struct ft1000_device *dev = (struct ft1000_device *)dev_id;
1773         struct ft1000_info *info = netdev_priv(dev->net);
1774
1775     u16 tempword;
1776     u16 status;
1777     u16 size;
1778     int i;
1779     u16 data;
1780     u16 modulo;
1781     u16 portid;
1782     u16 nxtph;
1783         struct dpram_blk *pdpram_blk;
1784         struct pseudo_hdr *ppseudo_hdr;
1785     unsigned long flags;
1786
1787     if (ft1000_chkcard(dev) == FALSE) {
1788         DEBUG("ft1000_poll::ft1000_chkcard: failed\n");
1789         return STATUS_FAILURE;
1790     }
1791
1792     status = ft1000_read_register (dev, &tempword, FT1000_REG_DOORBELL);
1793
1794     if ( !status )
1795     {
1796
1797         if (tempword & FT1000_DB_DPRAM_RX) {
1798
1799             status = ft1000_read_dpram16(dev, 0x200, (u8 *)&data, 0);
1800             size = ntohs(data) + 16 + 2;
1801             if (size % 4) {
1802                 modulo = 4 - (size % 4);
1803                 size = size + modulo;
1804             }
1805             status = ft1000_read_dpram16(dev, 0x201, (u8 *)&portid, 1);
1806             portid &= 0xff;
1807
1808             if (size < MAX_CMD_SQSIZE) {
1809                 switch (portid)
1810                 {
1811                     case DRIVERID:
1812                         DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n");
1813
1814                         status = ft1000_proc_drvmsg (dev, size);
1815                         if (status != STATUS_SUCCESS )
1816                             return status;
1817                         break;
1818                     case DSPBCMSGID:
1819                         // This is a dsp broadcast message
1820                         // Check which application has registered for dsp broadcast messages
1821
1822                         for (i=0; i<MAX_NUM_APP; i++) {
1823                            if ( (info->app_info[i].DspBCMsgFlag) && (info->app_info[i].fileobject) &&
1824                                          (info->app_info[i].NumOfMsg < MAX_MSG_LIMIT)  )
1825                            {
1826                                nxtph = FT1000_DPRAM_RX_BASE + 2;
1827                                pdpram_blk = ft1000_get_buffer (&freercvpool);
1828                                if (pdpram_blk != NULL) {
1829                                    if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) {
1830                                         ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer;
1831                                        // Put message into the appropriate application block
1832                                        info->app_info[i].nRxMsg++;
1833                                        spin_lock_irqsave(&free_buff_lock, flags);
1834                                        list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist);
1835                                        info->app_info[i].NumOfMsg++;
1836                                        spin_unlock_irqrestore(&free_buff_lock, flags);
1837                                        wake_up_interruptible(&info->app_info[i].wait_dpram_msg);
1838                                    }
1839                                    else {
1840                                        info->app_info[i].nRxMsgMiss++;
1841                                        // Put memory back to free pool
1842                                        ft1000_free_buffer(pdpram_blk, &freercvpool);
1843                                        DEBUG("pdpram_blk::ft1000_get_buffer NULL\n");
1844                                    }
1845                                }
1846                                else {
1847                                    DEBUG("Out of memory in free receive command pool\n");
1848                                    info->app_info[i].nRxMsgMiss++;
1849                                }
1850                            }
1851                         }
1852                         break;
1853                     default:
1854                         pdpram_blk = ft1000_get_buffer (&freercvpool);
1855
1856                         if (pdpram_blk != NULL) {
1857                            if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) {
1858                                 ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer;
1859                                // Search for correct application block
1860                                for (i=0; i<MAX_NUM_APP; i++) {
1861                                    if (info->app_info[i].app_id == ppseudo_hdr->portdest) {
1862                                        break;
1863                                    }
1864                                }
1865
1866                                if (i == MAX_NUM_APP) {
1867                                    DEBUG("FT1000:ft1000_parse_dpram_msg: No application matching id = %d\n", ppseudo_hdr->portdest);
1868                                    // Put memory back to free pool
1869                                    ft1000_free_buffer(pdpram_blk, &freercvpool);
1870                                }
1871                                else {
1872                                    if (info->app_info[i].NumOfMsg > MAX_MSG_LIMIT) {
1873                                        // Put memory back to free pool
1874                                        ft1000_free_buffer(pdpram_blk, &freercvpool);
1875                                    }
1876                                    else {
1877                                        info->app_info[i].nRxMsg++;
1878                                        // Put message into the appropriate application block
1879                                        list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist);
1880                                        info->app_info[i].NumOfMsg++;
1881                                    }
1882                                }
1883                            }
1884                            else {
1885                                // Put memory back to free pool
1886                                ft1000_free_buffer(pdpram_blk, &freercvpool);
1887                            }
1888                         }
1889                         else {
1890                             DEBUG("Out of memory in free receive command pool\n");
1891                         }
1892                         break;
1893                 }
1894             }
1895             else {
1896                 DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size);
1897             }
1898             status = ft1000_write_register (dev, FT1000_DB_DPRAM_RX, FT1000_REG_DOORBELL);
1899         }
1900         else if (tempword & FT1000_DSP_ASIC_RESET) {
1901
1902             // Let's reset the ASIC from the Host side as well
1903             status = ft1000_write_register (dev, ASIC_RESET_BIT, FT1000_REG_RESET);
1904             status = ft1000_read_register (dev, &tempword, FT1000_REG_RESET);
1905             i = 0;
1906             while (tempword & ASIC_RESET_BIT) {
1907                 status = ft1000_read_register (dev, &tempword, FT1000_REG_RESET);
1908                 msleep(10);
1909                 i++;
1910                 if (i==100)
1911                     break;
1912             }
1913             if (i==100) {
1914                 DEBUG("Unable to reset ASIC\n");
1915                 return STATUS_SUCCESS;
1916             }
1917             msleep(10);
1918             // Program WMARK register
1919             status = ft1000_write_register (dev, 0x600, FT1000_REG_MAG_WATERMARK);
1920             // clear ASIC reset doorbell
1921             status = ft1000_write_register (dev, FT1000_DSP_ASIC_RESET, FT1000_REG_DOORBELL);
1922             msleep(10);
1923         }
1924         else if (tempword & FT1000_ASIC_RESET_REQ) {
1925             DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_ASIC_RESET_REQ\n");
1926
1927             // clear ASIC reset request from DSP
1928             status = ft1000_write_register (dev, FT1000_ASIC_RESET_REQ, FT1000_REG_DOORBELL);
1929             status = ft1000_write_register (dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL);
1930             // copy dsp session record from Adapter block
1931             status = ft1000_write_dpram32 (dev, 0, (u8 *)&info->DSPSess.Rec[0], 1024);
1932             // Program WMARK register
1933             status = ft1000_write_register (dev, 0x600, FT1000_REG_MAG_WATERMARK);
1934             // ring doorbell to tell DSP that ASIC is out of reset
1935             status = ft1000_write_register (dev, FT1000_ASIC_RESET_DSP, FT1000_REG_DOORBELL);
1936         }
1937         else if (tempword & FT1000_DB_COND_RESET) {
1938             DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DB_COND_RESET\n");
1939
1940             if (info->fAppMsgPend == 0) {
1941                // Reset ASIC and DSP
1942
1943                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER0, (u8 *)&(info->DSP_TIME[0]), FT1000_MAG_DSP_TIMER0_INDX);
1944                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER1, (u8 *)&(info->DSP_TIME[1]), FT1000_MAG_DSP_TIMER1_INDX);
1945                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER2, (u8 *)&(info->DSP_TIME[2]), FT1000_MAG_DSP_TIMER2_INDX);
1946                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER3, (u8 *)&(info->DSP_TIME[3]), FT1000_MAG_DSP_TIMER3_INDX);
1947                 info->CardReady = 0;
1948                 info->DrvErrNum = DSP_CONDRESET_INFO;
1949                 DEBUG("ft1000_hw:DSP conditional reset requested\n");
1950                 info->ft1000_reset(dev->net);
1951             }
1952             else {
1953                 info->fProvComplete = 0;
1954                 info->fCondResetPend = 1;
1955             }
1956
1957             ft1000_write_register(dev, FT1000_DB_COND_RESET, FT1000_REG_DOORBELL);
1958         }
1959
1960     }
1961
1962     return STATUS_SUCCESS;
1963
1964 }