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