pandora: defconfig: update
[pandora-kernel.git] / 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 = 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         DEBUG("ft1000_hw:ft1000_reset_card: call dsp_reload\n");
654         dsp_reload(ft1000dev);
655
656         DEBUG("dsp reload successful\n");
657
658         mdelay(10);
659
660         /* Initialize DSP heartbeat area */
661         ft1000_write_dpram16(ft1000dev, FT1000_MAG_HI_HO, ho_mag,
662                              FT1000_MAG_HI_HO_INDX);
663         ft1000_read_dpram16(ft1000dev, FT1000_MAG_HI_HO, (u8 *) &tempword,
664                             FT1000_MAG_HI_HO_INDX);
665         DEBUG("ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n", tempword);
666
667         info->CardReady = 1;
668
669         info->fCondResetPend = 0;
670
671         return TRUE;
672 }
673
674 static const struct net_device_ops ftnet_ops =
675 {
676         .ndo_open = &ft1000_open,
677         .ndo_stop = &ft1000_close,
678         .ndo_start_xmit = &ft1000_start_xmit,
679         .ndo_get_stats = &ft1000_netdev_stats,
680 };
681
682
683 //---------------------------------------------------------------------------
684 // Function:    init_ft1000_netdev
685 //
686 // Parameters:  ft1000dev  - device structure
687 //
688 //
689 // Returns:     STATUS_SUCCESS - success
690 //              STATUS_FAILURE - failure
691 //
692 // Description: This function initialize the network device
693 //
694 // Notes:
695 //
696 //---------------------------------------------------------------------------
697 int init_ft1000_netdev(struct ft1000_device *ft1000dev)
698 {
699         struct net_device *netdev;
700         struct ft1000_info *pInfo = NULL;
701         struct dpram_blk *pdpram_blk;
702         int i, ret_val;
703         struct list_head *cur, *tmp;
704         char card_nr[2];
705         unsigned long gCardIndex = 0;
706
707         DEBUG("Enter init_ft1000_netdev...\n");
708
709         netdev = alloc_etherdev(sizeof(struct ft1000_info));
710         if (!netdev) {
711                 DEBUG("init_ft1000_netdev: can not allocate network device\n");
712                 return -ENOMEM;
713         }
714
715         pInfo = netdev_priv(netdev);
716
717         memset(pInfo, 0, sizeof(struct ft1000_info));
718
719         dev_alloc_name(netdev, netdev->name);
720
721         DEBUG("init_ft1000_netdev: network device name is %s\n", netdev->name);
722
723         if (strncmp(netdev->name, "eth", 3) == 0) {
724                 card_nr[0] = netdev->name[3];
725                 card_nr[1] = '\0';
726                 ret_val = strict_strtoul(card_nr, 10, &gCardIndex);
727                 if (ret_val) {
728                         printk(KERN_ERR "Can't parse netdev\n");
729                         goto err_net;
730                 }
731
732                 pInfo->CardNumber = gCardIndex;
733                 DEBUG("card number = %d\n", pInfo->CardNumber);
734         } else {
735                 printk(KERN_ERR "ft1000: Invalid device name\n");
736                 ret_val = -ENXIO;
737                 goto err_net;
738         }
739
740         memset(&pInfo->stats, 0, sizeof(struct net_device_stats));
741
742         spin_lock_init(&pInfo->dpram_lock);
743         pInfo->pFt1000Dev = ft1000dev;
744         pInfo->DrvErrNum = 0;
745         pInfo->registered = 1;
746         pInfo->ft1000_reset = ft1000_reset;
747         pInfo->mediastate = 0;
748         pInfo->fifo_cnt = 0;
749         pInfo->DeviceCreated = FALSE;
750         pInfo->CardReady = 0;
751         pInfo->DSP_TIME[0] = 0;
752         pInfo->DSP_TIME[1] = 0;
753         pInfo->DSP_TIME[2] = 0;
754         pInfo->DSP_TIME[3] = 0;
755         pInfo->fAppMsgPend = 0;
756         pInfo->fCondResetPend = 0;
757         pInfo->usbboot = 0;
758         pInfo->dspalive = 0;
759         memset(&pInfo->tempbuf[0], 0, sizeof(pInfo->tempbuf));
760
761         INIT_LIST_HEAD(&pInfo->prov_list);
762
763         INIT_LIST_HEAD(&pInfo->nodes.list);
764
765         netdev->netdev_ops = &ftnet_ops;
766
767         ft1000dev->net = netdev;
768
769         DEBUG("Initialize free_buff_lock and freercvpool\n");
770         spin_lock_init(&free_buff_lock);
771
772         /* initialize a list of buffers to be use for queuing
773          * up receive command data
774          */
775         INIT_LIST_HEAD(&freercvpool);
776
777         /* create list of free buffers */
778         for (i = 0; i < NUM_OF_FREE_BUFFERS; i++) {
779                 /* Get memory for DPRAM_DATA link list */
780                 pdpram_blk = kmalloc(sizeof(struct dpram_blk), GFP_KERNEL);
781                 if (pdpram_blk == NULL) {
782                         ret_val = -ENOMEM;
783                         goto err_free;
784                 }
785                 /* Get a block of memory to store command data */
786                 pdpram_blk->pbuffer = kmalloc(MAX_CMD_SQSIZE, GFP_KERNEL);
787                 if (pdpram_blk->pbuffer == NULL) {
788                         ret_val = -ENOMEM;
789                         kfree(pdpram_blk);
790                         goto err_free;
791                 }
792                 /* link provisioning data */
793                 list_add_tail(&pdpram_blk->list, &freercvpool);
794         }
795         numofmsgbuf = NUM_OF_FREE_BUFFERS;
796
797         return 0;
798
799 err_free:
800         list_for_each_safe(cur, tmp, &freercvpool) {
801                 pdpram_blk = list_entry(cur, struct dpram_blk, list);
802                 list_del(&pdpram_blk->list);
803                 kfree(pdpram_blk->pbuffer);
804                 kfree(pdpram_blk);
805         }
806 err_net:
807         free_netdev(netdev);
808         return ret_val;
809 }
810
811 //---------------------------------------------------------------------------
812 // Function:    reg_ft1000_netdev
813 //
814 // Parameters:  ft1000dev  - device structure
815 //
816 //
817 // Returns:     STATUS_SUCCESS - success
818 //              STATUS_FAILURE - failure
819 //
820 // Description: This function register the network driver
821 //
822 // Notes:
823 //
824 //---------------------------------------------------------------------------
825 int reg_ft1000_netdev(struct ft1000_device *ft1000dev,
826                       struct usb_interface *intf)
827 {
828         struct net_device *netdev;
829         struct ft1000_info *pInfo;
830         int rc;
831
832         netdev = ft1000dev->net;
833         pInfo = netdev_priv(ft1000dev->net);
834         DEBUG("Enter reg_ft1000_netdev...\n");
835
836         ft1000_read_register(ft1000dev, &pInfo->AsicID, FT1000_REG_ASIC_ID);
837
838         usb_set_intfdata(intf, pInfo);
839         SET_NETDEV_DEV(netdev, &intf->dev);
840
841         rc = register_netdev(netdev);
842         if (rc) {
843                 DEBUG("reg_ft1000_netdev: could not register network device\n");
844                 free_netdev(netdev);
845                 return rc;
846         }
847
848         ft1000_create_dev(ft1000dev);
849
850         DEBUG("reg_ft1000_netdev returned\n");
851
852         pInfo->CardReady = 1;
853
854         return 0;
855 }
856
857 static int ft1000_reset(struct net_device *dev)
858 {
859         ft1000_reset_card(dev);
860         return 0;
861 }
862
863 //---------------------------------------------------------------------------
864 // Function:    ft1000_usb_transmit_complete
865 //
866 // Parameters:  urb  - transmitted usb urb
867 //
868 //
869 // Returns:     none
870 //
871 // Description: This is the callback function when a urb is transmitted
872 //
873 // Notes:
874 //
875 //---------------------------------------------------------------------------
876 static void ft1000_usb_transmit_complete(struct urb *urb)
877 {
878
879         struct ft1000_device *ft1000dev = urb->context;
880
881         if (urb->status)
882                 pr_err("%s: TX status %d\n", ft1000dev->net->name, urb->status);
883
884         netif_wake_queue(ft1000dev->net);
885 }
886
887 //---------------------------------------------------------------------------
888 //
889 // Function:   ft1000_copy_down_pkt
890 // Description: This function will take an ethernet packet and convert it to
891 //             a Flarion packet prior to sending it to the ASIC Downlink
892 //             FIFO.
893 // Input:
894 //     dev    - device structure
895 //     packet - address of ethernet packet
896 //     len    - length of IP packet
897 // Output:
898 //     status - FAILURE
899 //              SUCCESS
900 //
901 //---------------------------------------------------------------------------
902 static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
903 {
904         struct ft1000_info *pInfo = netdev_priv(netdev);
905         struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev;
906
907         int count, ret;
908         u8 *t;
909         struct pseudo_hdr hdr;
910
911         if (!pInfo->CardReady) {
912                 DEBUG("ft1000_copy_down_pkt::Card Not Ready\n");
913                 return -ENODEV;
914         }
915
916         count = sizeof(struct pseudo_hdr) + len;
917         if (count > MAX_BUF_SIZE) {
918                 DEBUG("Error:ft1000_copy_down_pkt:Message Size Overflow!\n");
919                 DEBUG("size = %d\n", count);
920                 return -EINVAL;
921         }
922
923         if (count % 4)
924                 count = count + (4 - (count % 4));
925
926         memset(&hdr, 0, sizeof(struct pseudo_hdr));
927
928         hdr.length = ntohs(count);
929         hdr.source = 0x10;
930         hdr.destination = 0x20;
931         hdr.portdest = 0x20;
932         hdr.portsrc = 0x10;
933         hdr.sh_str_id = 0x91;
934         hdr.control = 0x00;
935
936         hdr.checksum = hdr.length ^ hdr.source ^ hdr.destination ^
937             hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control;
938
939         memcpy(&pFt1000Dev->tx_buf[0], &hdr, sizeof(hdr));
940         memcpy(&(pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)]), packet, len);
941
942         netif_stop_queue(netdev);
943
944         usb_fill_bulk_urb(pFt1000Dev->tx_urb,
945                           pFt1000Dev->dev,
946                           usb_sndbulkpipe(pFt1000Dev->dev,
947                                           pFt1000Dev->bulk_out_endpointAddr),
948                           pFt1000Dev->tx_buf, count,
949                           ft1000_usb_transmit_complete, (void *)pFt1000Dev);
950
951         t = (u8 *) pFt1000Dev->tx_urb->transfer_buffer;
952
953         ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC);
954
955         if (ret) {
956                 DEBUG("ft1000 failed tx_urb %d\n", ret);
957                 return ret;
958         } else {
959                 pInfo->stats.tx_packets++;
960                 pInfo->stats.tx_bytes += (len + 14);
961         }
962
963         return 0;
964 }
965
966
967 //---------------------------------------------------------------------------
968 // Function:    ft1000_start_xmit
969 //
970 // Parameters:  skb - socket buffer to be sent
971 //              dev - network device
972 //
973 //
974 // Returns:     none
975 //
976 // Description: transmit a ethernet packet
977 //
978 // Notes:
979 //
980 //---------------------------------------------------------------------------
981 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
982 {
983         struct ft1000_info *pInfo = netdev_priv(dev);
984         struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev;
985         u8 *pdata;
986         int maxlen, pipe;
987
988         if (skb == NULL) {
989                 DEBUG("ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n");
990                 return NETDEV_TX_OK;
991         }
992
993         if (pFt1000Dev->status & FT1000_STATUS_CLOSING) {
994                 DEBUG("network driver is closed, return\n");
995                 goto err;
996         }
997
998         pipe =
999             usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr);
1000         maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe));
1001
1002         pdata = (u8 *) skb->data;
1003
1004         if (pInfo->mediastate == 0) {
1005                 /* Drop packet is mediastate is down */
1006                 DEBUG("ft1000_hw:ft1000_start_xmit:mediastate is down\n");
1007                 goto err;
1008         }
1009
1010         if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) {
1011                 /* Drop packet which has invalid size */
1012                 DEBUG("ft1000_hw:ft1000_start_xmit:invalid ethernet length\n");
1013                 goto err;
1014         }
1015
1016         ft1000_copy_down_pkt(dev, (pdata + ENET_HEADER_SIZE - 2),
1017                              skb->len - ENET_HEADER_SIZE + 2);
1018
1019 err:
1020         dev_kfree_skb(skb);
1021
1022         return NETDEV_TX_OK;
1023 }
1024
1025
1026 //---------------------------------------------------------------------------
1027 //
1028 // Function:   ft1000_copy_up_pkt
1029 // Description: This function will take a packet from the FIFO up link and
1030 //             convert it into an ethernet packet and deliver it to the IP stack
1031 // Input:
1032 //     urb - the receiving usb urb
1033 //
1034 // Output:
1035 //     status - FAILURE
1036 //              SUCCESS
1037 //
1038 //---------------------------------------------------------------------------
1039 static int ft1000_copy_up_pkt(struct urb *urb)
1040 {
1041         struct ft1000_info *info = urb->context;
1042         struct ft1000_device *ft1000dev = info->pFt1000Dev;
1043         struct net_device *net = ft1000dev->net;
1044
1045         u16 tempword;
1046         u16 len;
1047         u16 lena;
1048         struct sk_buff *skb;
1049         u16 i;
1050         u8 *pbuffer = NULL;
1051         u8 *ptemp = NULL;
1052         u16 *chksum;
1053
1054         if (ft1000dev->status & FT1000_STATUS_CLOSING) {
1055                 DEBUG("network driver is closed, return\n");
1056                 return STATUS_SUCCESS;
1057         }
1058         // Read length
1059         len = urb->transfer_buffer_length;
1060         lena = urb->actual_length;
1061
1062         chksum = (u16 *) ft1000dev->rx_buf;
1063
1064         tempword = *chksum++;
1065         for (i = 1; i < 7; i++)
1066                 tempword ^= *chksum++;
1067
1068         if (tempword != *chksum) {
1069                 info->stats.rx_errors++;
1070                 ft1000_submit_rx_urb(info);
1071                 return STATUS_FAILURE;
1072         }
1073
1074         skb = dev_alloc_skb(len + 12 + 2);
1075
1076         if (skb == NULL) {
1077                 DEBUG("ft1000_copy_up_pkt: No Network buffers available\n");
1078                 info->stats.rx_errors++;
1079                 ft1000_submit_rx_urb(info);
1080                 return STATUS_FAILURE;
1081         }
1082
1083         pbuffer = (u8 *) skb_put(skb, len + 12);
1084
1085         /* subtract the number of bytes read already */
1086         ptemp = pbuffer;
1087
1088         /* fake MAC address */
1089         *pbuffer++ = net->dev_addr[0];
1090         *pbuffer++ = net->dev_addr[1];
1091         *pbuffer++ = net->dev_addr[2];
1092         *pbuffer++ = net->dev_addr[3];
1093         *pbuffer++ = net->dev_addr[4];
1094         *pbuffer++ = net->dev_addr[5];
1095         *pbuffer++ = 0x00;
1096         *pbuffer++ = 0x07;
1097         *pbuffer++ = 0x35;
1098         *pbuffer++ = 0xff;
1099         *pbuffer++ = 0xff;
1100         *pbuffer++ = 0xfe;
1101
1102         memcpy(pbuffer, ft1000dev->rx_buf + sizeof(struct pseudo_hdr),
1103                len - sizeof(struct pseudo_hdr));
1104
1105         skb->dev = net;
1106
1107         skb->protocol = eth_type_trans(skb, net);
1108         skb->ip_summed = CHECKSUM_UNNECESSARY;
1109         netif_rx(skb);
1110
1111         info->stats.rx_packets++;
1112         /* Add on 12 bytes for MAC address which was removed */
1113         info->stats.rx_bytes += (lena + 12);
1114
1115         ft1000_submit_rx_urb(info);
1116
1117         return SUCCESS;
1118 }
1119
1120
1121 //---------------------------------------------------------------------------
1122 //
1123 // Function:   ft1000_submit_rx_urb
1124 // Description: the receiving function of the network driver
1125 //
1126 // Input:
1127 //     info - a private structure contains the device information
1128 //
1129 // Output:
1130 //     status - FAILURE
1131 //              SUCCESS
1132 //
1133 //---------------------------------------------------------------------------
1134 static int ft1000_submit_rx_urb(struct ft1000_info *info)
1135 {
1136         int result;
1137         struct ft1000_device *pFt1000Dev = info->pFt1000Dev;
1138
1139         if (pFt1000Dev->status & FT1000_STATUS_CLOSING) {
1140                 DEBUG("network driver is closed, return\n");
1141                 return -ENODEV;
1142         }
1143
1144         usb_fill_bulk_urb(pFt1000Dev->rx_urb,
1145                           pFt1000Dev->dev,
1146                           usb_rcvbulkpipe(pFt1000Dev->dev,
1147                                           pFt1000Dev->bulk_in_endpointAddr),
1148                           pFt1000Dev->rx_buf, MAX_BUF_SIZE,
1149                           (usb_complete_t) ft1000_copy_up_pkt, info);
1150
1151         result = usb_submit_urb(pFt1000Dev->rx_urb, GFP_ATOMIC);
1152
1153         if (result) {
1154                 pr_err("ft1000_submit_rx_urb: submitting rx_urb %d failed\n",
1155                        result);
1156                 return result;
1157         }
1158
1159         return 0;
1160 }
1161
1162
1163 //---------------------------------------------------------------------------
1164 // Function:    ft1000_open
1165 //
1166 // Parameters:
1167 //              dev - network device
1168 //
1169 //
1170 // Returns:     none
1171 //
1172 // Description: open the network driver
1173 //
1174 // Notes:
1175 //
1176 //---------------------------------------------------------------------------
1177 static int ft1000_open(struct net_device *dev)
1178 {
1179         struct ft1000_info *pInfo = netdev_priv(dev);
1180         struct timeval tv;
1181         int ret;
1182
1183         DEBUG("ft1000_open is called for card %d\n", pInfo->CardNumber);
1184
1185         pInfo->stats.rx_bytes = 0;
1186         pInfo->stats.tx_bytes = 0;
1187         pInfo->stats.rx_packets = 0;
1188         pInfo->stats.tx_packets = 0;
1189         do_gettimeofday(&tv);
1190         pInfo->ConTm = tv.tv_sec;
1191         pInfo->ProgConStat = 0;
1192
1193         netif_start_queue(dev);
1194
1195         netif_carrier_on(dev);
1196
1197         ret = ft1000_submit_rx_urb(pInfo);
1198
1199         return ret;
1200 }
1201
1202 //---------------------------------------------------------------------------
1203 // Function:    ft1000_close
1204 //
1205 // Parameters:
1206 //              net - network device
1207 //
1208 //
1209 // Returns:     none
1210 //
1211 // Description: close the network driver
1212 //
1213 // Notes:
1214 //
1215 //---------------------------------------------------------------------------
1216 int ft1000_close(struct net_device *net)
1217 {
1218         struct ft1000_info *pInfo = netdev_priv(net);
1219         struct ft1000_device *ft1000dev = pInfo->pFt1000Dev;
1220
1221         ft1000dev->status |= FT1000_STATUS_CLOSING;
1222
1223         DEBUG("ft1000_close: pInfo=%p, ft1000dev=%p\n", pInfo, ft1000dev);
1224         netif_carrier_off(net);
1225         netif_stop_queue(net);
1226         ft1000dev->status &= ~FT1000_STATUS_CLOSING;
1227
1228         pInfo->ProgConStat = 0xff;
1229
1230         return 0;
1231 }
1232
1233 static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev)
1234 {
1235         struct ft1000_info *info = netdev_priv(dev);
1236
1237         return &(info->stats);
1238 }
1239
1240
1241 //---------------------------------------------------------------------------
1242 //
1243 // Function:   ft1000_chkcard
1244 // Description: This function will check if the device is presently available on
1245 //             the system.
1246 // Input:
1247 //     dev    - device structure
1248 // Output:
1249 //     status - FALSE (device is not present)
1250 //              TRUE  (device is present)
1251 //
1252 //---------------------------------------------------------------------------
1253 static int ft1000_chkcard(struct ft1000_device *dev)
1254 {
1255         u16 tempword;
1256         u16 status;
1257         struct ft1000_info *info = netdev_priv(dev->net);
1258
1259         if (info->fCondResetPend) {
1260                 DEBUG
1261                     ("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n");
1262                 return TRUE;
1263         }
1264         /* Mask register is used to check for device presence since it is never
1265          * set to zero.
1266          */
1267         status = ft1000_read_register(dev, &tempword, FT1000_REG_SUP_IMASK);
1268         if (tempword == 0) {
1269                 DEBUG
1270                     ("ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");
1271                 return FALSE;
1272         }
1273         /* The system will return the value of 0xffff for the version register
1274          * if the device is not present.
1275          */
1276         status = ft1000_read_register(dev, &tempword, FT1000_REG_ASIC_ID);
1277         if (tempword != 0x1b01) {
1278                 dev->status |= FT1000_STATUS_CLOSING;
1279                 DEBUG
1280                     ("ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n");
1281                 return FALSE;
1282         }
1283         return TRUE;
1284 }
1285
1286 //---------------------------------------------------------------------------
1287 //
1288 // Function:   ft1000_receive_cmd
1289 // Description: This function will read a message from the dpram area.
1290 // Input:
1291 //    dev - network device structure
1292 //    pbuffer - caller supply address to buffer
1293 //    pnxtph - pointer to next pseudo header
1294 // Output:
1295 //   Status = 0 (unsuccessful)
1296 //          = 1 (successful)
1297 //
1298 //---------------------------------------------------------------------------
1299 static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer,
1300                                int maxsz, u16 *pnxtph)
1301 {
1302         u16 size, ret;
1303         u16 *ppseudohdr;
1304         int i;
1305         u16 tempword;
1306
1307         ret =
1308             ft1000_read_dpram16(dev, FT1000_MAG_PH_LEN, (u8 *) &size,
1309                                 FT1000_MAG_PH_LEN_INDX);
1310         size = ntohs(size) + PSEUDOSZ;
1311         if (size > maxsz) {
1312                 DEBUG("FT1000:ft1000_receive_cmd:Invalid command length = %d\n",
1313                       size);
1314                 return FALSE;
1315         } else {
1316                 ppseudohdr = (u16 *) pbuffer;
1317                 ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE,
1318                                       FT1000_REG_DPRAM_ADDR);
1319                 ret =
1320                     ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH);
1321                 pbuffer++;
1322                 ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE + 1,
1323                                       FT1000_REG_DPRAM_ADDR);
1324                 for (i = 0; i <= (size >> 2); i++) {
1325                         ret =
1326                             ft1000_read_register(dev, pbuffer,
1327                                                  FT1000_REG_MAG_DPDATAL);
1328                         pbuffer++;
1329                         ret =
1330                             ft1000_read_register(dev, pbuffer,
1331                                                  FT1000_REG_MAG_DPDATAH);
1332                         pbuffer++;
1333                 }
1334                 /* copy odd aligned word */
1335                 ret =
1336                     ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAL);
1337
1338                 pbuffer++;
1339                 ret =
1340                     ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH);
1341
1342                 pbuffer++;
1343                 if (size & 0x0001) {
1344                         /* copy odd byte from fifo */
1345                         ret =
1346                             ft1000_read_register(dev, &tempword,
1347                                                  FT1000_REG_DPRAM_DATA);
1348                         *pbuffer = ntohs(tempword);
1349                 }
1350                 /* Check if pseudo header checksum is good
1351                  * Calculate pseudo header checksum
1352                  */
1353                 tempword = *ppseudohdr++;
1354                 for (i = 1; i < 7; i++)
1355                         tempword ^= *ppseudohdr++;
1356
1357                 if ((tempword != *ppseudohdr))
1358                         return FALSE;
1359
1360                 return TRUE;
1361         }
1362 }
1363
1364 static int ft1000_dsp_prov(void *arg)
1365 {
1366         struct ft1000_device *dev = (struct ft1000_device *)arg;
1367         struct ft1000_info *info = netdev_priv(dev->net);
1368         u16 tempword;
1369         u16 len;
1370         u16 i = 0;
1371         struct prov_record *ptr;
1372         struct pseudo_hdr *ppseudo_hdr;
1373         u16 *pmsg;
1374         u16 status;
1375         u16 TempShortBuf[256];
1376
1377         DEBUG("*** DspProv Entered\n");
1378
1379         while (list_empty(&info->prov_list) == 0) {
1380                 DEBUG("DSP Provisioning List Entry\n");
1381
1382                 /* Check if doorbell is available */
1383                 DEBUG("check if doorbell is cleared\n");
1384                 status =
1385                     ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL);
1386                 if (status) {
1387                         DEBUG("ft1000_dsp_prov::ft1000_read_register error\n");
1388                         break;
1389                 }
1390
1391                 while (tempword & FT1000_DB_DPRAM_TX) {
1392                         mdelay(10);
1393                         i++;
1394                         if (i == 10) {
1395                                 DEBUG("FT1000:ft1000_dsp_prov:message drop\n");
1396                                 return STATUS_FAILURE;
1397                         }
1398                         ft1000_read_register(dev, &tempword,
1399                                              FT1000_REG_DOORBELL);
1400                 }
1401
1402                 if (!(tempword & FT1000_DB_DPRAM_TX)) {
1403                         DEBUG("*** Provision Data Sent to DSP\n");
1404
1405                         /* Send provisioning data */
1406                         ptr =
1407                             list_entry(info->prov_list.next, struct prov_record,
1408                                        list);
1409                         len = *(u16 *) ptr->pprov_data;
1410                         len = htons(len);
1411                         len += PSEUDOSZ;
1412
1413                         pmsg = (u16 *) ptr->pprov_data;
1414                         ppseudo_hdr = (struct pseudo_hdr *)pmsg;
1415                         /* Insert slow queue sequence number */
1416                         ppseudo_hdr->seq_num = info->squeseqnum++;
1417                         ppseudo_hdr->portsrc = 0;
1418                         /* Calculate new checksum */
1419                         ppseudo_hdr->checksum = *pmsg++;
1420                         for (i = 1; i < 7; i++) {
1421                                 ppseudo_hdr->checksum ^= *pmsg++;
1422                         }
1423
1424                         TempShortBuf[0] = 0;
1425                         TempShortBuf[1] = htons(len);
1426                         memcpy(&TempShortBuf[2], ppseudo_hdr, len);
1427
1428                         status =
1429                             ft1000_write_dpram32(dev, 0,
1430                                                  (u8 *) &TempShortBuf[0],
1431                                                  (unsigned short)(len + 2));
1432                         status =
1433                             ft1000_write_register(dev, FT1000_DB_DPRAM_TX,
1434                                                   FT1000_REG_DOORBELL);
1435
1436                         list_del(&ptr->list);
1437                         kfree(ptr->pprov_data);
1438                         kfree(ptr);
1439                 }
1440                 msleep(10);
1441         }
1442
1443         DEBUG("DSP Provisioning List Entry finished\n");
1444
1445         msleep(100);
1446
1447         info->fProvComplete = 1;
1448         info->CardReady = 1;
1449
1450         return STATUS_SUCCESS;
1451 }
1452
1453 static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
1454 {
1455         struct ft1000_info *info = netdev_priv(dev->net);
1456         u16 msgtype;
1457         u16 tempword;
1458         struct media_msg *pmediamsg;
1459         struct dsp_init_msg *pdspinitmsg;
1460         struct drv_msg *pdrvmsg;
1461         u16 i;
1462         struct pseudo_hdr *ppseudo_hdr;
1463         u16 *pmsg;
1464         u16 status;
1465         union {
1466                 u8 byte[2];
1467                 u16 wrd;
1468         } convert;
1469
1470         char *cmdbuffer = kmalloc(1600, GFP_KERNEL);
1471         if (!cmdbuffer)
1472                 return STATUS_FAILURE;
1473
1474         status = ft1000_read_dpram32(dev, 0x200, cmdbuffer, size);
1475
1476 #ifdef JDEBUG
1477         DEBUG("ft1000_proc_drvmsg:cmdbuffer\n");
1478         for (i = 0; i < size; i += 5) {
1479                 if ((i + 5) < size)
1480                         DEBUG("0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", cmdbuffer[i],
1481                               cmdbuffer[i + 1], cmdbuffer[i + 2],
1482                               cmdbuffer[i + 3], cmdbuffer[i + 4]);
1483                 else {
1484                         for (j = i; j < size; j++)
1485                                 DEBUG("0x%x ", cmdbuffer[j]);
1486                         DEBUG("\n");
1487                         break;
1488                 }
1489         }
1490 #endif
1491         pdrvmsg = (struct drv_msg *)&cmdbuffer[2];
1492         msgtype = ntohs(pdrvmsg->type);
1493         DEBUG("ft1000_proc_drvmsg:Command message type = 0x%x\n", msgtype);
1494         switch (msgtype) {
1495         case MEDIA_STATE:{
1496                         DEBUG
1497                             ("ft1000_proc_drvmsg:Command message type = MEDIA_STATE");
1498
1499                         pmediamsg = (struct media_msg *)&cmdbuffer[0];
1500                         if (info->ProgConStat != 0xFF) {
1501                                 if (pmediamsg->state) {
1502                                         DEBUG("Media is up\n");
1503                                         if (info->mediastate == 0) {
1504                                                 if (info->NetDevRegDone) {
1505                                                         netif_wake_queue(dev->
1506                                                                          net);
1507                                                 }
1508                                                 info->mediastate = 1;
1509                                         }
1510                                 } else {
1511                                         DEBUG("Media is down\n");
1512                                         if (info->mediastate == 1) {
1513                                                 info->mediastate = 0;
1514                                                 if (info->NetDevRegDone) {
1515                                                 }
1516                                                 info->ConTm = 0;
1517                                         }
1518                                 }
1519                         } else {
1520                                 DEBUG("Media is down\n");
1521                                 if (info->mediastate == 1) {
1522                                         info->mediastate = 0;
1523                                         info->ConTm = 0;
1524                                 }
1525                         }
1526                         break;
1527                 }
1528         case DSP_INIT_MSG:{
1529                         DEBUG
1530                             ("ft1000_proc_drvmsg:Command message type = DSP_INIT_MSG");
1531
1532                         pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[2];
1533                         memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ);
1534                         DEBUG("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n",
1535                               info->DspVer[0], info->DspVer[1], info->DspVer[2],
1536                               info->DspVer[3]);
1537                         memcpy(info->HwSerNum, pdspinitmsg->HwSerNum,
1538                                HWSERNUMSZ);
1539                         memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ);
1540                         memcpy(info->eui64, pdspinitmsg->eui64, EUISZ);
1541                         DEBUG("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n",
1542                               info->eui64[0], info->eui64[1], info->eui64[2],
1543                               info->eui64[3], info->eui64[4], info->eui64[5],
1544                               info->eui64[6], info->eui64[7]);
1545                         dev->net->dev_addr[0] = info->eui64[0];
1546                         dev->net->dev_addr[1] = info->eui64[1];
1547                         dev->net->dev_addr[2] = info->eui64[2];
1548                         dev->net->dev_addr[3] = info->eui64[5];
1549                         dev->net->dev_addr[4] = info->eui64[6];
1550                         dev->net->dev_addr[5] = info->eui64[7];
1551
1552                         if (ntohs(pdspinitmsg->length) ==
1553                             (sizeof(struct dsp_init_msg) - 20)) {
1554                                 memcpy(info->ProductMode,
1555                                        pdspinitmsg->ProductMode, MODESZ);
1556                                 memcpy(info->RfCalVer, pdspinitmsg->RfCalVer,
1557                                        CALVERSZ);
1558                                 memcpy(info->RfCalDate, pdspinitmsg->RfCalDate,
1559                                        CALDATESZ);
1560                                 DEBUG("RFCalVer = 0x%2x 0x%2x\n",
1561                                       info->RfCalVer[0], info->RfCalVer[1]);
1562                         }
1563                         break;
1564                 }
1565         case DSP_PROVISION:{
1566                         DEBUG
1567                             ("ft1000_proc_drvmsg:Command message type = DSP_PROVISION\n");
1568
1569                         /* kick off dspprov routine to start provisioning
1570                          * Send provisioning data to DSP
1571                          */
1572                         if (list_empty(&info->prov_list) == 0) {
1573                                 info->fProvComplete = 0;
1574                                 status = ft1000_dsp_prov(dev);
1575                                 if (status != STATUS_SUCCESS)
1576                                         goto out;
1577                         } else {
1578                                 info->fProvComplete = 1;
1579                                 status =
1580                                     ft1000_write_register(dev, FT1000_DB_HB,
1581                                                           FT1000_REG_DOORBELL);
1582                                 DEBUG
1583                                     ("FT1000:drivermsg:No more DSP provisioning data in dsp image\n");
1584                         }
1585                         DEBUG("ft1000_proc_drvmsg:DSP PROVISION is done\n");
1586                         break;
1587                 }
1588         case DSP_STORE_INFO:{
1589                         DEBUG
1590                             ("ft1000_proc_drvmsg:Command message type = DSP_STORE_INFO");
1591
1592                         DEBUG("FT1000:drivermsg:Got DSP_STORE_INFO\n");
1593                         tempword = ntohs(pdrvmsg->length);
1594                         info->DSPInfoBlklen = tempword;
1595                         if (tempword < (MAX_DSP_SESS_REC - 4)) {
1596                                 pmsg = (u16 *) &pdrvmsg->data[0];
1597                                 for (i = 0; i < ((tempword + 1) / 2); i++) {
1598                                         DEBUG
1599                                             ("FT1000:drivermsg:dsp info data = 0x%x\n",
1600                                              *pmsg);
1601                                         info->DSPInfoBlk[i + 10] = *pmsg++;
1602                                 }
1603                         } else {
1604                                 info->DSPInfoBlklen = 0;
1605                         }
1606                         break;
1607                 }
1608         case DSP_GET_INFO:{
1609                         DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n");
1610                         /* copy dsp info block to dsp */
1611                         info->DrvMsgPend = 1;
1612                         /* allow any outstanding ioctl to finish */
1613                         mdelay(10);
1614                         status =
1615                             ft1000_read_register(dev, &tempword,
1616                                                  FT1000_REG_DOORBELL);
1617                         if (tempword & FT1000_DB_DPRAM_TX) {
1618                                 mdelay(10);
1619                                 status =
1620                                     ft1000_read_register(dev, &tempword,
1621                                                          FT1000_REG_DOORBELL);
1622                                 if (tempword & FT1000_DB_DPRAM_TX) {
1623                                         mdelay(10);
1624                                         status =
1625                                             ft1000_read_register(dev, &tempword,
1626                                                                  FT1000_REG_DOORBELL);
1627                                         if (tempword & FT1000_DB_DPRAM_TX)
1628                                                 break;
1629                                 }
1630                         }
1631                         /* Put message into Slow Queue
1632                          * Form Pseudo header
1633                          */
1634                         pmsg = (u16 *) info->DSPInfoBlk;
1635                         *pmsg++ = 0;
1636                         *pmsg++ =
1637                             htons(info->DSPInfoBlklen + 20 +
1638                                   info->DSPInfoBlklen);
1639                         ppseudo_hdr =
1640                             (struct pseudo_hdr *)(u16 *) &info->DSPInfoBlk[2];
1641                         ppseudo_hdr->length =
1642                             htons(info->DSPInfoBlklen + 4 +
1643                                   info->DSPInfoBlklen);
1644                         ppseudo_hdr->source = 0x10;
1645                         ppseudo_hdr->destination = 0x20;
1646                         ppseudo_hdr->portdest = 0;
1647                         ppseudo_hdr->portsrc = 0;
1648                         ppseudo_hdr->sh_str_id = 0;
1649                         ppseudo_hdr->control = 0;
1650                         ppseudo_hdr->rsvd1 = 0;
1651                         ppseudo_hdr->rsvd2 = 0;
1652                         ppseudo_hdr->qos_class = 0;
1653                         /* Insert slow queue sequence number */
1654                         ppseudo_hdr->seq_num = info->squeseqnum++;
1655                         /* Insert application id */
1656                         ppseudo_hdr->portsrc = 0;
1657                         /* Calculate new checksum */
1658                         ppseudo_hdr->checksum = *pmsg++;
1659                         for (i = 1; i < 7; i++)
1660                                 ppseudo_hdr->checksum ^= *pmsg++;
1661
1662                         info->DSPInfoBlk[10] = 0x7200;
1663                         info->DSPInfoBlk[11] = htons(info->DSPInfoBlklen);
1664                         status =
1665                             ft1000_write_dpram32(dev, 0,
1666                                                  (u8 *) &info->DSPInfoBlk[0],
1667                                                  (unsigned short)(info->
1668                                                                   DSPInfoBlklen
1669                                                                   + 22));
1670                         status =
1671                             ft1000_write_register(dev, FT1000_DB_DPRAM_TX,
1672                                                   FT1000_REG_DOORBELL);
1673                         info->DrvMsgPend = 0;
1674
1675                         break;
1676                 }
1677
1678         case GET_DRV_ERR_RPT_MSG:{
1679                         DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n");
1680                         /* copy driver error message to dsp */
1681                         info->DrvMsgPend = 1;
1682                         /* allow any outstanding ioctl to finish */
1683                         mdelay(10);
1684                         status =
1685                             ft1000_read_register(dev, &tempword,
1686                                                  FT1000_REG_DOORBELL);
1687                         if (tempword & FT1000_DB_DPRAM_TX) {
1688                                 mdelay(10);
1689                                 status =
1690                                     ft1000_read_register(dev, &tempword,
1691                                                          FT1000_REG_DOORBELL);
1692                                 if (tempword & FT1000_DB_DPRAM_TX)
1693                                         mdelay(10);
1694                         }
1695
1696                         if ((tempword & FT1000_DB_DPRAM_TX) == 0) {
1697                                 /* Put message into Slow Queue
1698                                  * Form Pseudo header
1699                                  */
1700                                 pmsg = (u16 *) &tempbuffer[0];
1701                                 ppseudo_hdr = (struct pseudo_hdr *)pmsg;
1702                                 ppseudo_hdr->length = htons(0x0012);
1703                                 ppseudo_hdr->source = 0x10;
1704                                 ppseudo_hdr->destination = 0x20;
1705                                 ppseudo_hdr->portdest = 0;
1706                                 ppseudo_hdr->portsrc = 0;
1707                                 ppseudo_hdr->sh_str_id = 0;
1708                                 ppseudo_hdr->control = 0;
1709                                 ppseudo_hdr->rsvd1 = 0;
1710                                 ppseudo_hdr->rsvd2 = 0;
1711                                 ppseudo_hdr->qos_class = 0;
1712                                 /* Insert slow queue sequence number */
1713                                 ppseudo_hdr->seq_num = info->squeseqnum++;
1714                                 /* Insert application id */
1715                                 ppseudo_hdr->portsrc = 0;
1716                                 /* Calculate new checksum */
1717                                 ppseudo_hdr->checksum = *pmsg++;
1718                                 for (i = 1; i < 7; i++)
1719                                         ppseudo_hdr->checksum ^= *pmsg++;
1720
1721                                 pmsg = (u16 *) &tempbuffer[16];
1722                                 *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG);
1723                                 *pmsg++ = htons(0x000e);
1724                                 *pmsg++ = htons(info->DSP_TIME[0]);
1725                                 *pmsg++ = htons(info->DSP_TIME[1]);
1726                                 *pmsg++ = htons(info->DSP_TIME[2]);
1727                                 *pmsg++ = htons(info->DSP_TIME[3]);
1728                                 convert.byte[0] = info->DspVer[0];
1729                                 convert.byte[1] = info->DspVer[1];
1730                                 *pmsg++ = convert.wrd;
1731                                 convert.byte[0] = info->DspVer[2];
1732                                 convert.byte[1] = info->DspVer[3];
1733                                 *pmsg++ = convert.wrd;
1734                                 *pmsg++ = htons(info->DrvErrNum);
1735
1736                                 card_send_command(dev,
1737                                                  (unsigned char *)&tempbuffer[0],
1738                                                  (u16) (0x0012 + PSEUDOSZ));
1739                                 info->DrvErrNum = 0;
1740                         }
1741                         info->DrvMsgPend = 0;
1742
1743                         break;
1744                 }
1745
1746         default:
1747                 break;
1748         }
1749
1750         status = STATUS_SUCCESS;
1751 out:
1752         kfree(cmdbuffer);
1753         DEBUG("return from ft1000_proc_drvmsg\n");
1754         return status;
1755 }
1756
1757 int ft1000_poll(void* dev_id) {
1758
1759     struct ft1000_device *dev = (struct ft1000_device *)dev_id;
1760         struct ft1000_info *info = netdev_priv(dev->net);
1761
1762     u16 tempword;
1763     u16 status;
1764     u16 size;
1765     int i;
1766     u16 data;
1767     u16 modulo;
1768     u16 portid;
1769     u16 nxtph;
1770         struct dpram_blk *pdpram_blk;
1771         struct pseudo_hdr *ppseudo_hdr;
1772     unsigned long flags;
1773
1774     if (ft1000_chkcard(dev) == FALSE) {
1775         DEBUG("ft1000_poll::ft1000_chkcard: failed\n");
1776         return STATUS_FAILURE;
1777     }
1778
1779     status = ft1000_read_register (dev, &tempword, FT1000_REG_DOORBELL);
1780
1781     if ( !status )
1782     {
1783
1784         if (tempword & FT1000_DB_DPRAM_RX) {
1785
1786             status = ft1000_read_dpram16(dev, 0x200, (u8 *)&data, 0);
1787             size = ntohs(data) + 16 + 2;
1788             if (size % 4) {
1789                 modulo = 4 - (size % 4);
1790                 size = size + modulo;
1791             }
1792             status = ft1000_read_dpram16(dev, 0x201, (u8 *)&portid, 1);
1793             portid &= 0xff;
1794
1795             if (size < MAX_CMD_SQSIZE) {
1796                 switch (portid)
1797                 {
1798                     case DRIVERID:
1799                         DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n");
1800
1801                         status = ft1000_proc_drvmsg (dev, size);
1802                         if (status != STATUS_SUCCESS )
1803                             return status;
1804                         break;
1805                     case DSPBCMSGID:
1806                         // This is a dsp broadcast message
1807                         // Check which application has registered for dsp broadcast messages
1808
1809                         for (i=0; i<MAX_NUM_APP; i++) {
1810                            if ( (info->app_info[i].DspBCMsgFlag) && (info->app_info[i].fileobject) &&
1811                                          (info->app_info[i].NumOfMsg < MAX_MSG_LIMIT)  )
1812                            {
1813                                nxtph = FT1000_DPRAM_RX_BASE + 2;
1814                                pdpram_blk = ft1000_get_buffer (&freercvpool);
1815                                if (pdpram_blk != NULL) {
1816                                    if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) {
1817                                         ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer;
1818                                        // Put message into the appropriate application block
1819                                        info->app_info[i].nRxMsg++;
1820                                        spin_lock_irqsave(&free_buff_lock, flags);
1821                                        list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist);
1822                                        info->app_info[i].NumOfMsg++;
1823                                        spin_unlock_irqrestore(&free_buff_lock, flags);
1824                                        wake_up_interruptible(&info->app_info[i].wait_dpram_msg);
1825                                    }
1826                                    else {
1827                                        info->app_info[i].nRxMsgMiss++;
1828                                        // Put memory back to free pool
1829                                        ft1000_free_buffer(pdpram_blk, &freercvpool);
1830                                        DEBUG("pdpram_blk::ft1000_get_buffer NULL\n");
1831                                    }
1832                                }
1833                                else {
1834                                    DEBUG("Out of memory in free receive command pool\n");
1835                                    info->app_info[i].nRxMsgMiss++;
1836                                }
1837                            }
1838                         }
1839                         break;
1840                     default:
1841                         pdpram_blk = ft1000_get_buffer (&freercvpool);
1842
1843                         if (pdpram_blk != NULL) {
1844                            if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) {
1845                                 ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer;
1846                                // Search for correct application block
1847                                for (i=0; i<MAX_NUM_APP; i++) {
1848                                    if (info->app_info[i].app_id == ppseudo_hdr->portdest) {
1849                                        break;
1850                                    }
1851                                }
1852
1853                                if (i == MAX_NUM_APP) {
1854                                    DEBUG("FT1000:ft1000_parse_dpram_msg: No application matching id = %d\n", ppseudo_hdr->portdest);
1855                                    // Put memory back to free pool
1856                                    ft1000_free_buffer(pdpram_blk, &freercvpool);
1857                                }
1858                                else {
1859                                    if (info->app_info[i].NumOfMsg > MAX_MSG_LIMIT) {
1860                                        // Put memory back to free pool
1861                                        ft1000_free_buffer(pdpram_blk, &freercvpool);
1862                                    }
1863                                    else {
1864                                        info->app_info[i].nRxMsg++;
1865                                        // Put message into the appropriate application block
1866                                        list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist);
1867                                        info->app_info[i].NumOfMsg++;
1868                                    }
1869                                }
1870                            }
1871                            else {
1872                                // Put memory back to free pool
1873                                ft1000_free_buffer(pdpram_blk, &freercvpool);
1874                            }
1875                         }
1876                         else {
1877                             DEBUG("Out of memory in free receive command pool\n");
1878                         }
1879                         break;
1880                 }
1881             }
1882             else {
1883                 DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size);
1884             }
1885             status = ft1000_write_register (dev, FT1000_DB_DPRAM_RX, FT1000_REG_DOORBELL);
1886         }
1887         else if (tempword & FT1000_DSP_ASIC_RESET) {
1888
1889             // Let's reset the ASIC from the Host side as well
1890             status = ft1000_write_register (dev, ASIC_RESET_BIT, FT1000_REG_RESET);
1891             status = ft1000_read_register (dev, &tempword, FT1000_REG_RESET);
1892             i = 0;
1893             while (tempword & ASIC_RESET_BIT) {
1894                 status = ft1000_read_register (dev, &tempword, FT1000_REG_RESET);
1895                 msleep(10);
1896                 i++;
1897                 if (i==100)
1898                     break;
1899             }
1900             if (i==100) {
1901                 DEBUG("Unable to reset ASIC\n");
1902                 return STATUS_SUCCESS;
1903             }
1904             msleep(10);
1905             // Program WMARK register
1906             status = ft1000_write_register (dev, 0x600, FT1000_REG_MAG_WATERMARK);
1907             // clear ASIC reset doorbell
1908             status = ft1000_write_register (dev, FT1000_DSP_ASIC_RESET, FT1000_REG_DOORBELL);
1909             msleep(10);
1910         }
1911         else if (tempword & FT1000_ASIC_RESET_REQ) {
1912             DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_ASIC_RESET_REQ\n");
1913
1914             // clear ASIC reset request from DSP
1915             status = ft1000_write_register (dev, FT1000_ASIC_RESET_REQ, FT1000_REG_DOORBELL);
1916             status = ft1000_write_register (dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL);
1917             // copy dsp session record from Adapter block
1918             status = ft1000_write_dpram32 (dev, 0, (u8 *)&info->DSPSess.Rec[0], 1024);
1919             // Program WMARK register
1920             status = ft1000_write_register (dev, 0x600, FT1000_REG_MAG_WATERMARK);
1921             // ring doorbell to tell DSP that ASIC is out of reset
1922             status = ft1000_write_register (dev, FT1000_ASIC_RESET_DSP, FT1000_REG_DOORBELL);
1923         }
1924         else if (tempword & FT1000_DB_COND_RESET) {
1925             DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DB_COND_RESET\n");
1926
1927             if (info->fAppMsgPend == 0) {
1928                // Reset ASIC and DSP
1929
1930                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER0, (u8 *)&(info->DSP_TIME[0]), FT1000_MAG_DSP_TIMER0_INDX);
1931                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER1, (u8 *)&(info->DSP_TIME[1]), FT1000_MAG_DSP_TIMER1_INDX);
1932                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER2, (u8 *)&(info->DSP_TIME[2]), FT1000_MAG_DSP_TIMER2_INDX);
1933                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER3, (u8 *)&(info->DSP_TIME[3]), FT1000_MAG_DSP_TIMER3_INDX);
1934                 info->CardReady = 0;
1935                 info->DrvErrNum = DSP_CONDRESET_INFO;
1936                 DEBUG("ft1000_hw:DSP conditional reset requested\n");
1937                 info->ft1000_reset(dev->net);
1938             }
1939             else {
1940                 info->fProvComplete = 0;
1941                 info->fCondResetPend = 1;
1942             }
1943
1944             ft1000_write_register(dev, FT1000_DB_COND_RESET, FT1000_REG_DOORBELL);
1945         }
1946
1947     }
1948
1949     return STATUS_SUCCESS;
1950
1951 }