1 /*---------------------------------------------------------------------------
2 FT1000 driver for Flarion Flash OFDM NIC Device
4 Copyright (C) 2002 Flarion Technologies, All rights reserved.
5 Copyright (C) 2006 Patrik Ostrihon, All rights reserved.
6 Copyright (C) 2006 ProWeb Consulting, a.s, All rights reserved.
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your option) any
11 later version. This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details. You should have received a copy of the GNU General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc., 59 Temple Place -
17 Suite 330, Boston, MA 02111-1307, USA.
18 -----------------------------------------------------------------------------*/
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/proc_fs.h>
24 #include <linux/sched.h>
25 #include <linux/ptrace.h>
26 #include <linux/slab.h>
27 #include <linux/string.h>
28 #include <linux/timer.h>
29 #include <linux/interrupt.h>
32 #include <asm/bitops.h>
34 #include <linux/netdevice.h>
35 #include <linux/etherdevice.h>
36 #include <linux/skbuff.h>
37 #include <linux/if_arp.h>
38 #include <linux/ioport.h>
39 #include <linux/wait.h>
40 #include <linux/vmalloc.h>
42 #include <linux/firmware.h>
43 #include <linux/ethtool.h>
45 #include <pcmcia/cistpl.h>
46 #include <pcmcia/cisreg.h>
47 #include <pcmcia/ds.h>
50 #define DEBUG(n, args...) printk(KERN_DEBUG args);
52 #define DEBUG(n, args...)
55 #include <linux/delay.h>
58 static const struct firmware *fw_entry;
60 static void ft1000_hbchk(u_long data);
61 static struct timer_list poll_timer = {
62 .function = ft1000_hbchk
65 static u16 cmdbuffer[1024];
66 static u8 tempbuffer[1600];
67 static u8 ft1000_card_present = 0;
68 static u8 flarion_ft1000_cnt = 0;
70 static irqreturn_t ft1000_interrupt(int irq, void *dev_id);
71 static void ft1000_enable_interrupts(struct net_device *dev);
72 static void ft1000_disable_interrupts(struct net_device *dev);
77 ("Support for Flarion Flash OFDM NIC Device. Support for PCMCIA when used with ft1000_cs.");
78 MODULE_LICENSE("GPL");
79 MODULE_SUPPORTED_DEVICE("FT1000");
81 #define MAX_RCV_LOOP 100
83 //---------------------------------------------------------------------------
85 // Function: ft1000_read_fifo_len
86 // Description: This function will read the ASIC Uplink FIFO status register
87 // which will return the number of bytes remaining in the Uplink FIFO.
88 // Sixteen bytes are subtracted to make sure that the ASIC does not
89 // reach its threshold.
91 // dev - network device structure
93 // value - number of bytes available in the ASIC Uplink FIFO.
95 //---------------------------------------------------------------------------
96 static inline u16 ft1000_read_fifo_len(struct net_device *dev)
98 struct ft1000_info *info = netdev_priv(dev);
100 if (info->AsicID == ELECTRABUZZ_ID)
101 return (ft1000_read_reg(dev, FT1000_REG_UFIFO_STAT) - 16);
103 return (ft1000_read_reg(dev, FT1000_REG_MAG_UFSR) - 16);
106 //---------------------------------------------------------------------------
108 // Function: ft1000_read_dpram
109 // Description: This function will read the specific area of dpram
110 // (Electrabuzz ASIC only)
112 // dev - device structure
113 // offset - index of dpram
115 // value - value of dpram
117 //---------------------------------------------------------------------------
118 u16 ft1000_read_dpram(struct net_device *dev, int offset)
120 struct ft1000_info *info = netdev_priv(dev);
124 // Provide mutual exclusive access while reading ASIC registers.
125 spin_lock_irqsave(&info->dpram_lock, flags);
126 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
127 data = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
128 spin_unlock_irqrestore(&info->dpram_lock, flags);
133 //---------------------------------------------------------------------------
135 // Function: ft1000_write_dpram
136 // Description: This function will write to a specific area of dpram
137 // (Electrabuzz ASIC only)
139 // dev - device structure
140 // offset - index of dpram
141 // value - value to write
145 //---------------------------------------------------------------------------
146 static inline void ft1000_write_dpram(struct net_device *dev,
147 int offset, u16 value)
149 struct ft1000_info *info = netdev_priv(dev);
152 // Provide mutual exclusive access while reading ASIC registers.
153 spin_lock_irqsave(&info->dpram_lock, flags);
154 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
155 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, value);
156 spin_unlock_irqrestore(&info->dpram_lock, flags);
159 //---------------------------------------------------------------------------
161 // Function: ft1000_read_dpram_mag_16
162 // Description: This function will read the specific area of dpram
163 // (Magnemite ASIC only)
165 // dev - device structure
166 // offset - index of dpram
168 // value - value of dpram
170 //---------------------------------------------------------------------------
171 u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index)
173 struct ft1000_info *info = netdev_priv(dev);
177 // Provide mutual exclusive access while reading ASIC registers.
178 spin_lock_irqsave(&info->dpram_lock, flags);
179 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
180 // check if we want to read upper or lower 32-bit word
182 data = ft1000_read_reg(dev, FT1000_REG_MAG_DPDATAL);
184 data = ft1000_read_reg(dev, FT1000_REG_MAG_DPDATAH);
186 spin_unlock_irqrestore(&info->dpram_lock, flags);
191 //---------------------------------------------------------------------------
193 // Function: ft1000_write_dpram_mag_16
194 // Description: This function will write to a specific area of dpram
195 // (Magnemite ASIC only)
197 // dev - device structure
198 // offset - index of dpram
199 // value - value to write
203 //---------------------------------------------------------------------------
204 static inline void ft1000_write_dpram_mag_16(struct net_device *dev,
205 int offset, u16 value, int Index)
207 struct ft1000_info *info = netdev_priv(dev);
210 // Provide mutual exclusive access while reading ASIC registers.
211 spin_lock_irqsave(&info->dpram_lock, flags);
212 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
214 ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAL, value);
216 ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAH, value);
218 spin_unlock_irqrestore(&info->dpram_lock, flags);
221 //---------------------------------------------------------------------------
223 // Function: ft1000_read_dpram_mag_32
224 // Description: This function will read the specific area of dpram
225 // (Magnemite ASIC only)
227 // dev - device structure
228 // offset - index of dpram
230 // value - value of dpram
232 //---------------------------------------------------------------------------
233 u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset)
235 struct ft1000_info *info = netdev_priv(dev);
239 // Provide mutual exclusive access while reading ASIC registers.
240 spin_lock_irqsave(&info->dpram_lock, flags);
241 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
242 data = inl(dev->base_addr + FT1000_REG_MAG_DPDATAL);
243 spin_unlock_irqrestore(&info->dpram_lock, flags);
248 //---------------------------------------------------------------------------
250 // Function: ft1000_write_dpram_mag_32
251 // Description: This function will write to a specific area of dpram
252 // (Magnemite ASIC only)
254 // dev - device structure
255 // offset - index of dpram
256 // value - value to write
260 //---------------------------------------------------------------------------
261 void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value)
263 struct ft1000_info *info = netdev_priv(dev);
266 // Provide mutual exclusive access while reading ASIC registers.
267 spin_lock_irqsave(&info->dpram_lock, flags);
268 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
269 outl(value, dev->base_addr + FT1000_REG_MAG_DPDATAL);
270 spin_unlock_irqrestore(&info->dpram_lock, flags);
273 //---------------------------------------------------------------------------
275 // Function: ft1000_enable_interrupts
276 // Description: This function will enable interrupts base on the current interrupt mask.
278 // dev - device structure
282 //---------------------------------------------------------------------------
283 static void ft1000_enable_interrupts(struct net_device *dev)
287 DEBUG(1, "ft1000_hw:ft1000_enable_interrupts()\n");
288 ft1000_write_reg(dev, FT1000_REG_SUP_IMASK, ISR_DEFAULT_MASK);
289 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);
291 "ft1000_hw:ft1000_enable_interrupts:current interrupt enable mask = 0x%x\n",
295 //---------------------------------------------------------------------------
297 // Function: ft1000_disable_interrupts
298 // Description: This function will disable all interrupts.
300 // dev - device structure
304 //---------------------------------------------------------------------------
305 static void ft1000_disable_interrupts(struct net_device *dev)
309 DEBUG(1, "ft1000_hw: ft1000_disable_interrupts()\n");
310 ft1000_write_reg(dev, FT1000_REG_SUP_IMASK, ISR_MASK_ALL);
311 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);
313 "ft1000_hw:ft1000_disable_interrupts:current interrupt enable mask = 0x%x\n",
317 //---------------------------------------------------------------------------
319 // Function: ft1000_reset_asic
320 // Description: This function will call the Card Service function to reset the
323 // dev - device structure
327 //---------------------------------------------------------------------------
328 static void ft1000_reset_asic(struct net_device *dev)
330 struct ft1000_info *info = netdev_priv(dev);
331 struct ft1000_pcmcia *pcmcia = info->priv;
334 DEBUG(1, "ft1000_hw:ft1000_reset_asic called\n");
336 (*info->ft1000_reset) (pcmcia->link);
338 // Let's use the register provided by the Magnemite ASIC to reset the
340 if (info->AsicID == MAGNEMITE_ID) {
341 ft1000_write_reg(dev, FT1000_REG_RESET,
342 (DSP_RESET_BIT | ASIC_RESET_BIT));
345 if (info->AsicID == ELECTRABUZZ_ID) {
346 // set watermark to -1 in order to not generate an interrupt
347 ft1000_write_reg(dev, FT1000_REG_WATERMARK, 0xffff);
349 // set watermark to -1 in order to not generate an interrupt
350 ft1000_write_reg(dev, FT1000_REG_MAG_WATERMARK, 0xffff);
353 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
354 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
355 ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
356 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
357 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
361 //---------------------------------------------------------------------------
363 // Function: ft1000_reset_card
364 // Description: This function will reset the card
366 // dev - device structure
368 // status - false (card reset fail)
369 // true (card reset successful)
371 //---------------------------------------------------------------------------
372 static int ft1000_reset_card(struct net_device *dev)
374 struct ft1000_info *info = netdev_priv(dev);
378 struct prov_record *ptr;
380 DEBUG(1, "ft1000_hw:ft1000_reset_card called.....\n");
383 info->ProgConStat = 0;
384 info->squeseqnum = 0;
385 ft1000_disable_interrupts(dev);
387 // del_timer(&poll_timer);
389 // Make sure we free any memory reserve for provisioning
390 while (list_empty(&info->prov_list) == 0) {
392 "ft1000_hw:ft1000_reset_card:deleting provisioning record\n");
393 ptr = list_entry(info->prov_list.next, struct prov_record, list);
394 list_del(&ptr->list);
395 kfree(ptr->pprov_data);
399 if (info->AsicID == ELECTRABUZZ_ID) {
400 DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting DSP\n");
401 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
404 "ft1000_hw:ft1000_reset_card:resetting ASIC and DSP\n");
405 ft1000_write_reg(dev, FT1000_REG_RESET,
406 (DSP_RESET_BIT | ASIC_RESET_BIT));
409 // Copy DSP session record into info block if this is not a coldstart
410 if (ft1000_card_present == 1) {
411 spin_lock_irqsave(&info->dpram_lock, flags);
412 if (info->AsicID == ELECTRABUZZ_ID) {
413 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
414 FT1000_DPRAM_RX_BASE);
415 for (i = 0; i < MAX_DSP_SESS_REC; i++) {
416 info->DSPSess.Rec[i] =
418 FT1000_REG_DPRAM_DATA);
421 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
422 FT1000_DPRAM_MAG_RX_BASE);
423 for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) {
424 info->DSPSess.MagRec[i] =
425 inl(dev->base_addr + FT1000_REG_MAG_DPDATA);
428 spin_unlock_irqrestore(&info->dpram_lock, flags);
431 DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting ASIC\n");
434 ft1000_reset_asic(dev);
436 DEBUG(1, "ft1000_hw:ft1000_reset_card:downloading dsp image\n");
438 if (info->AsicID == MAGNEMITE_ID) {
439 // Put dsp in reset and take ASIC out of reset
441 "ft1000_hw:ft1000_reset_card:Put DSP in reset and take ASIC out of reset\n");
442 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
444 // Setting MAGNEMITE ASIC to big endian mode
445 ft1000_write_reg(dev, FT1000_REG_SUP_CTRL, HOST_INTF_BE);
446 // Download bootloader
449 // Take DSP out of reset
450 ft1000_write_reg(dev, FT1000_REG_RESET, 0);
451 // FLARION_DSP_ACTIVE;
453 DEBUG(0, "ft1000_hw:ft1000_reset_card:Take DSP out of reset\n");
455 // Wait for 0xfefe indicating dsp ready before starting download
456 for (i = 0; i < 50; i++) {
458 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DPRAM_FEFE,
459 FT1000_MAG_DPRAM_FEFE_INDX);
460 if (tempword == 0xfefe) {
468 "ft1000_hw:ft1000_reset_card:No FEFE detected from DSP\n");
473 // Take DSP out of reset
474 ft1000_write_reg(dev, FT1000_REG_RESET, ~DSP_RESET_BIT);
478 if (card_download(dev, fw_entry->data, fw_entry->size)) {
479 DEBUG(1, "card download unsuccessful\n");
482 DEBUG(1, "card download successful\n");
487 if (info->AsicID == ELECTRABUZZ_ID) {
488 // Need to initialize the FIFO length counter to zero in order to sync up
491 ft1000_write_dpram(dev, FT1000_FIFO_LEN, info->fifo_cnt);
492 // Initialize DSP heartbeat area to ho
493 ft1000_write_dpram(dev, FT1000_HI_HO, ho);
494 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
495 DEBUG(1, "ft1000_hw:ft1000_reset_asic:hi_ho value = 0x%x\n",
498 // Initialize DSP heartbeat area to ho
499 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, ho_mag,
500 FT1000_MAG_HI_HO_INDX);
502 ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO,
503 FT1000_MAG_HI_HO_INDX);
504 DEBUG(1, "ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n",
509 ft1000_enable_interrupts(dev);
511 /* Schedule heartbeat process to run every 2 seconds */
512 // poll_timer.expires = jiffies + (2*HZ);
513 // poll_timer.data = (u_long)dev;
514 // add_timer(&poll_timer);
520 //---------------------------------------------------------------------------
522 // Function: ft1000_chkcard
523 // Description: This function will check if the device is presently available on
526 // dev - device structure
528 // status - false (device is not present)
529 // true (device is present)
531 //---------------------------------------------------------------------------
532 static int ft1000_chkcard(struct net_device *dev)
536 // Mask register is used to check for device presence since it is never
538 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);
541 "ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");
544 // The system will return the value of 0xffff for the version register
545 // if the device is not present.
546 tempword = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
547 if (tempword == 0xffff) {
549 "ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n");
556 //---------------------------------------------------------------------------
558 // Function: ft1000_hbchk
559 // Description: This function will perform the heart beat check of the DSP as
562 // dev - device structure
566 //---------------------------------------------------------------------------
567 static void ft1000_hbchk(u_long data)
569 struct net_device *dev = (struct net_device *)data;
571 struct ft1000_info *info;
574 info = netdev_priv(dev);
576 if (info->CardReady == 1) {
577 // Perform dsp heartbeat check
578 if (info->AsicID == ELECTRABUZZ_ID) {
579 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
582 ntohs(ft1000_read_dpram_mag_16
583 (dev, FT1000_MAG_HI_HO,
584 FT1000_MAG_HI_HO_INDX));
586 DEBUG(1, "ft1000_hw:ft1000_hbchk:hi_ho value = 0x%x\n",
588 // Let's perform another check if ho is not detected
589 if (tempword != ho) {
590 if (info->AsicID == ELECTRABUZZ_ID) {
591 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
594 tempword = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX));
597 if (tempword != ho) {
599 "ft1000: heartbeat failed - no ho detected\n");
600 if (info->AsicID == ELECTRABUZZ_ID) {
602 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
604 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
606 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
608 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
611 ft1000_read_dpram_mag_16(dev,
612 FT1000_MAG_DSP_TIMER0,
613 FT1000_MAG_DSP_TIMER0_INDX);
615 ft1000_read_dpram_mag_16(dev,
616 FT1000_MAG_DSP_TIMER1,
617 FT1000_MAG_DSP_TIMER1_INDX);
619 ft1000_read_dpram_mag_16(dev,
620 FT1000_MAG_DSP_TIMER2,
621 FT1000_MAG_DSP_TIMER2_INDX);
623 ft1000_read_dpram_mag_16(dev,
624 FT1000_MAG_DSP_TIMER3,
625 FT1000_MAG_DSP_TIMER3_INDX);
627 info->DrvErrNum = DSP_HB_INFO;
628 if (ft1000_reset_card(dev) == 0) {
630 "ft1000: Hardware Failure Detected - PC Card disabled\n");
631 info->ProgConStat = 0xff;
634 /* Schedule this module to run every 2 seconds */
635 poll_timer.expires = jiffies + (2*HZ);
636 poll_timer.data = (u_long)dev;
637 add_timer(&poll_timer);
641 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
642 // Let's check doorbell again if fail
643 if (tempword & FT1000_DB_HB) {
644 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
646 if (tempword & FT1000_DB_HB) {
648 "ft1000: heartbeat doorbell not clear by firmware\n");
649 if (info->AsicID == ELECTRABUZZ_ID) {
651 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
653 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
655 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
657 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
660 ft1000_read_dpram_mag_16(dev,
661 FT1000_MAG_DSP_TIMER0,
662 FT1000_MAG_DSP_TIMER0_INDX);
664 ft1000_read_dpram_mag_16(dev,
665 FT1000_MAG_DSP_TIMER1,
666 FT1000_MAG_DSP_TIMER1_INDX);
668 ft1000_read_dpram_mag_16(dev,
669 FT1000_MAG_DSP_TIMER2,
670 FT1000_MAG_DSP_TIMER2_INDX);
672 ft1000_read_dpram_mag_16(dev,
673 FT1000_MAG_DSP_TIMER3,
674 FT1000_MAG_DSP_TIMER3_INDX);
676 info->DrvErrNum = DSP_HB_INFO;
677 if (ft1000_reset_card(dev) == 0) {
679 "ft1000: Hardware Failure Detected - PC Card disabled\n");
680 info->ProgConStat = 0xff;
683 /* Schedule this module to run every 2 seconds */
684 poll_timer.expires = jiffies + (2*HZ);
685 poll_timer.data = (u_long)dev;
686 add_timer(&poll_timer);
689 // Set dedicated area to hi and ring appropriate doorbell according
690 // to hi/ho heartbeat protocol
691 if (info->AsicID == ELECTRABUZZ_ID) {
692 ft1000_write_dpram(dev, FT1000_HI_HO, hi);
694 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, hi_mag,
695 FT1000_MAG_HI_HO_INDX);
698 if (info->AsicID == ELECTRABUZZ_ID) {
699 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
702 ntohs(ft1000_read_dpram_mag_16
703 (dev, FT1000_MAG_HI_HO,
704 FT1000_MAG_HI_HO_INDX));
706 // Let's write hi again if fail
707 if (tempword != hi) {
708 if (info->AsicID == ELECTRABUZZ_ID) {
709 ft1000_write_dpram(dev, FT1000_HI_HO, hi);
712 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, hi_mag, FT1000_MAG_HI_HO_INDX);
715 if (info->AsicID == ELECTRABUZZ_ID) {
716 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
719 tempword = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX));
724 if (tempword != hi) {
726 "ft1000: heartbeat failed - cannot write hi into DPRAM\n");
727 if (info->AsicID == ELECTRABUZZ_ID) {
729 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
731 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
733 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
735 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
738 ft1000_read_dpram_mag_16(dev,
739 FT1000_MAG_DSP_TIMER0,
740 FT1000_MAG_DSP_TIMER0_INDX);
742 ft1000_read_dpram_mag_16(dev,
743 FT1000_MAG_DSP_TIMER1,
744 FT1000_MAG_DSP_TIMER1_INDX);
746 ft1000_read_dpram_mag_16(dev,
747 FT1000_MAG_DSP_TIMER2,
748 FT1000_MAG_DSP_TIMER2_INDX);
750 ft1000_read_dpram_mag_16(dev,
751 FT1000_MAG_DSP_TIMER3,
752 FT1000_MAG_DSP_TIMER3_INDX);
754 info->DrvErrNum = DSP_HB_INFO;
755 if (ft1000_reset_card(dev) == 0) {
757 "ft1000: Hardware Failure Detected - PC Card disabled\n");
758 info->ProgConStat = 0xff;
761 /* Schedule this module to run every 2 seconds */
762 poll_timer.expires = jiffies + (2*HZ);
763 poll_timer.data = (u_long)dev;
764 add_timer(&poll_timer);
767 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_HB);
771 /* Schedule this module to run every 2 seconds */
772 poll_timer.expires = jiffies + (2 * HZ);
773 poll_timer.data = (u_long) dev;
774 add_timer(&poll_timer);
777 //---------------------------------------------------------------------------
779 // Function: ft1000_send_cmd
784 //---------------------------------------------------------------------------
785 static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype)
787 struct ft1000_info *info = netdev_priv(dev);
792 size += sizeof(struct pseudo_hdr);
793 // check for odd byte and increment to 16-bit word align value
794 if ((size & 0x0001)) {
797 DEBUG(1, "FT1000:ft1000_send_cmd:total length = %d\n", size);
798 DEBUG(1, "FT1000:ft1000_send_cmd:length = %d\n", ntohs(*ptempbuffer));
799 // put message into slow queue area
800 // All messages are in the form total_len + pseudo header + message body
801 spin_lock_irqsave(&info->dpram_lock, flags);
803 // Make sure SLOWQ doorbell is clear
804 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
806 while (tempword & FT1000_DB_DPRAM_TX) {
810 spin_unlock_irqrestore(&info->dpram_lock, flags);
813 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
816 if (info->AsicID == ELECTRABUZZ_ID) {
817 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
818 FT1000_DPRAM_TX_BASE);
819 // Write total length to dpram
820 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, size);
821 // Write pseudo header and messgae body
822 for (i = 0; i < (size >> 1); i++) {
823 DEBUG(1, "FT1000:ft1000_send_cmd:data %d = 0x%x\n", i,
825 tempword = htons(*ptempbuffer++);
826 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, tempword);
829 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
830 FT1000_DPRAM_MAG_TX_BASE);
831 // Write total length to dpram
832 ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAH, htons(size));
833 // Write pseudo header and messgae body
834 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
835 FT1000_DPRAM_MAG_TX_BASE + 1);
836 for (i = 0; i < (size >> 2); i++) {
837 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n",
840 dev->base_addr + FT1000_REG_MAG_DPDATAL);
841 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n",
844 dev->base_addr + FT1000_REG_MAG_DPDATAH);
846 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer);
847 outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAL);
848 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer);
849 outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAH);
851 spin_unlock_irqrestore(&info->dpram_lock, flags);
853 // ring doorbell to notify DSP that we have a message ready
854 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_DPRAM_TX);
857 //---------------------------------------------------------------------------
859 // Function: ft1000_receive_cmd
860 // Description: This function will read a message from the dpram area.
862 // dev - network device structure
863 // pbuffer - caller supply address to buffer
864 // pnxtph - pointer to next pseudo header
866 // Status = 0 (unsuccessful)
869 //---------------------------------------------------------------------------
870 static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,
871 int maxsz, u16 *pnxtph)
873 struct ft1000_info *info = netdev_priv(dev);
880 if (info->AsicID == ELECTRABUZZ_ID) {
881 size = ( ft1000_read_dpram(dev, *pnxtph) ) + sizeof(struct pseudo_hdr);
884 ntohs(ft1000_read_dpram_mag_16
885 (dev, FT1000_MAG_PH_LEN,
886 FT1000_MAG_PH_LEN_INDX)) + sizeof(struct pseudo_hdr);
890 "FT1000:ft1000_receive_cmd:Invalid command length = %d\n",
894 ppseudohdr = (u16 *) pbuffer;
895 spin_lock_irqsave(&info->dpram_lock, flags);
896 if (info->AsicID == ELECTRABUZZ_ID) {
897 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
898 FT1000_DPRAM_RX_BASE + 2);
899 for (i = 0; i <= (size >> 1); i++) {
901 ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
902 *pbuffer++ = ntohs(tempword);
905 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
906 FT1000_DPRAM_MAG_RX_BASE);
907 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
908 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
910 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
911 FT1000_DPRAM_MAG_RX_BASE + 1);
912 for (i = 0; i <= (size >> 2); i++) {
915 FT1000_REG_MAG_DPDATAL);
919 FT1000_REG_MAG_DPDATAH);
922 //copy odd aligned word
923 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAL);
924 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
926 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
927 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
931 //copy odd byte from fifo
932 tempword = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
933 *pbuffer = ntohs(tempword);
935 spin_unlock_irqrestore(&info->dpram_lock, flags);
937 // Check if pseudo header checksum is good
938 // Calculate pseudo header checksum
939 tempword = *ppseudohdr++;
940 for (i = 1; i < 7; i++) {
941 tempword ^= *ppseudohdr++;
943 if ((tempword != *ppseudohdr)) {
945 "FT1000:ft1000_receive_cmd:Pseudo header checksum mismatch\n");
953 //---------------------------------------------------------------------------
955 // Function: ft1000_proc_drvmsg
956 // Description: This function will process the various driver messages.
958 // dev - device structure
959 // pnxtph - pointer to next pseudo header
963 //---------------------------------------------------------------------------
964 static void ft1000_proc_drvmsg(struct net_device *dev)
966 struct ft1000_info *info = netdev_priv(dev);
969 struct media_msg *pmediamsg;
970 struct dsp_init_msg *pdspinitmsg;
971 struct drv_msg *pdrvmsg;
974 struct prov_record *ptr;
975 struct pseudo_hdr *ppseudo_hdr;
983 if (info->AsicID == ELECTRABUZZ_ID) {
984 tempword = FT1000_DPRAM_RX_BASE+2;
987 tempword = FT1000_DPRAM_MAG_RX_BASE;
989 if ( ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword) ) {
991 // Get the message type which is total_len + PSEUDO header + msgtype + message body
992 pdrvmsg = (struct drv_msg *) & cmdbuffer[0];
993 msgtype = ntohs(pdrvmsg->type);
994 DEBUG(1, "Command message type = 0x%x\n", msgtype);
998 "Got a provisioning request message from DSP\n");
1000 while (list_empty(&info->prov_list) == 0) {
1001 DEBUG(0, "Sending a provisioning message\n");
1002 // Make sure SLOWQ doorbell is clear
1004 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1006 while (tempword & FT1000_DB_DPRAM_TX) {
1014 list_entry(info->prov_list.next,
1015 struct prov_record, list);
1016 len = *(u16 *) ptr->pprov_data;
1019 pmsg = (u16 *) ptr->pprov_data;
1020 ppseudo_hdr = (struct pseudo_hdr *) pmsg;
1021 // Insert slow queue sequence number
1022 ppseudo_hdr->seq_num = info->squeseqnum++;
1023 ppseudo_hdr->portsrc = 0;
1024 // Calculate new checksum
1025 ppseudo_hdr->checksum = *pmsg++;
1026 DEBUG(1, "checksum = 0x%x\n",
1027 ppseudo_hdr->checksum);
1028 for (i = 1; i < 7; i++) {
1029 ppseudo_hdr->checksum ^= *pmsg++;
1030 DEBUG(1, "checksum = 0x%x\n",
1031 ppseudo_hdr->checksum);
1034 ft1000_send_cmd (dev, (u16 *)ptr->pprov_data, len, SLOWQ_TYPE);
1035 list_del(&ptr->list);
1036 kfree(ptr->pprov_data);
1039 // Indicate adapter is ready to take application messages after all
1040 // provisioning messages are sent
1041 info->CardReady = 1;
1044 pmediamsg = (struct media_msg *) & cmdbuffer[0];
1045 if (info->ProgConStat != 0xFF) {
1046 if (pmediamsg->state) {
1047 DEBUG(1, "Media is up\n");
1048 if (info->mediastate == 0) {
1049 netif_carrier_on(dev);
1050 netif_wake_queue(dev);
1051 info->mediastate = 1;
1052 do_gettimeofday(&tv);
1053 info->ConTm = tv.tv_sec;
1056 DEBUG(1, "Media is down\n");
1057 if (info->mediastate == 1) {
1058 info->mediastate = 0;
1059 netif_carrier_off(dev);
1060 netif_stop_queue(dev);
1066 DEBUG(1,"Media is down\n");
1067 if (info->mediastate == 1) {
1068 info->mediastate = 0;
1069 netif_carrier_off(dev);
1070 netif_stop_queue(dev);
1076 pdspinitmsg = (struct dsp_init_msg *) & cmdbuffer[0];
1077 memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ);
1078 DEBUG(1, "DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n",
1079 info->DspVer[0], info->DspVer[1], info->DspVer[2],
1081 memcpy(info->HwSerNum, pdspinitmsg->HwSerNum,
1083 memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ);
1084 memcpy(info->eui64, pdspinitmsg->eui64, EUISZ);
1085 dev->dev_addr[0] = info->eui64[0];
1086 dev->dev_addr[1] = info->eui64[1];
1087 dev->dev_addr[2] = info->eui64[2];
1088 dev->dev_addr[3] = info->eui64[5];
1089 dev->dev_addr[4] = info->eui64[6];
1090 dev->dev_addr[5] = info->eui64[7];
1092 if (ntohs(pdspinitmsg->length) ==
1093 (sizeof(struct dsp_init_msg) - 20)) {
1094 memcpy(info->ProductMode,
1095 pdspinitmsg->ProductMode, MODESZ);
1096 memcpy(info->RfCalVer, pdspinitmsg->RfCalVer,
1098 memcpy(info->RfCalDate, pdspinitmsg->RfCalDate,
1100 DEBUG(1, "RFCalVer = 0x%2x 0x%2x\n",
1101 info->RfCalVer[0], info->RfCalVer[1]);
1105 case DSP_STORE_INFO:
1106 DEBUG(1, "FT1000:drivermsg:Got DSP_STORE_INFO\n");
1107 tempword = ntohs(pdrvmsg->length);
1108 info->DSPInfoBlklen = tempword;
1109 if (tempword < (MAX_DSP_SESS_REC - 4)) {
1110 pmsg = (u16 *) & pdrvmsg->data[0];
1111 for (i = 0; i < ((tempword + 1) / 2); i++) {
1113 "FT1000:drivermsg:dsp info data = 0x%x\n",
1115 info->DSPInfoBlk[i + 10] = *pmsg++;
1120 DEBUG(1, "FT1000:drivermsg:Got DSP_GET_INFO\n");
1121 // copy dsp info block to dsp
1122 // allow any outstanding ioctl to finish
1124 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1125 if (tempword & FT1000_DB_DPRAM_TX) {
1128 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1129 if (tempword & FT1000_DB_DPRAM_TX) {
1134 if ((tempword & FT1000_DB_DPRAM_TX) == 0) {
1135 // Put message into Slow Queue
1136 // Form Pseudo header
1137 pmsg = (u16 *) info->DSPInfoBlk;
1138 ppseudo_hdr = (struct pseudo_hdr *) pmsg;
1139 ppseudo_hdr->length =
1140 htons(info->DSPInfoBlklen + 4);
1141 ppseudo_hdr->source = 0x10;
1142 ppseudo_hdr->destination = 0x20;
1143 ppseudo_hdr->portdest = 0;
1144 ppseudo_hdr->portsrc = 0;
1145 ppseudo_hdr->sh_str_id = 0;
1146 ppseudo_hdr->control = 0;
1147 ppseudo_hdr->rsvd1 = 0;
1148 ppseudo_hdr->rsvd2 = 0;
1149 ppseudo_hdr->qos_class = 0;
1150 // Insert slow queue sequence number
1151 ppseudo_hdr->seq_num = info->squeseqnum++;
1152 // Insert application id
1153 ppseudo_hdr->portsrc = 0;
1154 // Calculate new checksum
1155 ppseudo_hdr->checksum = *pmsg++;
1156 for (i = 1; i < 7; i++) {
1157 ppseudo_hdr->checksum ^= *pmsg++;
1159 info->DSPInfoBlk[8] = 0x7200;
1160 info->DSPInfoBlk[9] =
1161 htons(info->DSPInfoBlklen);
1162 ft1000_send_cmd (dev, (u16 *)info->DSPInfoBlk, (u16)(info->DSPInfoBlklen+4), 0);
1166 case GET_DRV_ERR_RPT_MSG:
1167 DEBUG(1, "FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n");
1168 // copy driver error message to dsp
1169 // allow any outstanding ioctl to finish
1171 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1172 if (tempword & FT1000_DB_DPRAM_TX) {
1175 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1176 if (tempword & FT1000_DB_DPRAM_TX) {
1181 if ((tempword & FT1000_DB_DPRAM_TX) == 0) {
1182 // Put message into Slow Queue
1183 // Form Pseudo header
1184 pmsg = (u16 *) & tempbuffer[0];
1185 ppseudo_hdr = (struct pseudo_hdr *) pmsg;
1186 ppseudo_hdr->length = htons(0x0012);
1187 ppseudo_hdr->source = 0x10;
1188 ppseudo_hdr->destination = 0x20;
1189 ppseudo_hdr->portdest = 0;
1190 ppseudo_hdr->portsrc = 0;
1191 ppseudo_hdr->sh_str_id = 0;
1192 ppseudo_hdr->control = 0;
1193 ppseudo_hdr->rsvd1 = 0;
1194 ppseudo_hdr->rsvd2 = 0;
1195 ppseudo_hdr->qos_class = 0;
1196 // Insert slow queue sequence number
1197 ppseudo_hdr->seq_num = info->squeseqnum++;
1198 // Insert application id
1199 ppseudo_hdr->portsrc = 0;
1200 // Calculate new checksum
1201 ppseudo_hdr->checksum = *pmsg++;
1202 for (i=1; i<7; i++) {
1203 ppseudo_hdr->checksum ^= *pmsg++;
1205 pmsg = (u16 *) & tempbuffer[16];
1206 *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG);
1207 *pmsg++ = htons(0x000e);
1208 *pmsg++ = htons(info->DSP_TIME[0]);
1209 *pmsg++ = htons(info->DSP_TIME[1]);
1210 *pmsg++ = htons(info->DSP_TIME[2]);
1211 *pmsg++ = htons(info->DSP_TIME[3]);
1212 convert.byte[0] = info->DspVer[0];
1213 convert.byte[1] = info->DspVer[1];
1214 *pmsg++ = convert.wrd;
1215 convert.byte[0] = info->DspVer[2];
1216 convert.byte[1] = info->DspVer[3];
1217 *pmsg++ = convert.wrd;
1218 *pmsg++ = htons(info->DrvErrNum);
1220 ft1000_send_cmd (dev, (u16 *)&tempbuffer[0], (u16)(0x0012), 0);
1221 info->DrvErrNum = 0;
1231 //---------------------------------------------------------------------------
1233 // Function: ft1000_parse_dpram_msg
1234 // Description: This function will parse the message received from the DSP
1235 // via the DPRAM interface.
1237 // dev - device structure
1242 //---------------------------------------------------------------------------
1243 static int ft1000_parse_dpram_msg(struct net_device *dev)
1245 struct ft1000_info *info = netdev_priv(dev);
1252 unsigned long flags;
1254 doorbell = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1255 DEBUG(1, "Doorbell = 0x%x\n", doorbell);
1257 if (doorbell & FT1000_ASIC_RESET_REQ) {
1258 // Copy DSP session record from info block
1259 spin_lock_irqsave(&info->dpram_lock, flags);
1260 if (info->AsicID == ELECTRABUZZ_ID) {
1261 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
1262 FT1000_DPRAM_RX_BASE);
1263 for (i = 0; i < MAX_DSP_SESS_REC; i++) {
1264 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA,
1265 info->DSPSess.Rec[i]);
1268 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
1269 FT1000_DPRAM_MAG_RX_BASE);
1270 for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) {
1271 outl(info->DSPSess.MagRec[i],
1272 dev->base_addr + FT1000_REG_MAG_DPDATA);
1275 spin_unlock_irqrestore(&info->dpram_lock, flags);
1277 // clear ASIC RESET request
1278 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1279 FT1000_ASIC_RESET_REQ);
1280 DEBUG(1, "Got an ASIC RESET Request\n");
1281 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1282 FT1000_ASIC_RESET_DSP);
1284 if (info->AsicID == MAGNEMITE_ID) {
1285 // Setting MAGNEMITE ASIC to big endian mode
1286 ft1000_write_reg(dev, FT1000_REG_SUP_CTRL,
1291 if (doorbell & FT1000_DSP_ASIC_RESET) {
1293 "FT1000:ft1000_parse_dpram_msg: Got a dsp ASIC reset message\n");
1294 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1295 FT1000_DSP_ASIC_RESET);
1300 if (doorbell & FT1000_DB_DPRAM_RX) {
1302 "FT1000:ft1000_parse_dpram_msg: Got a slow queue message\n");
1303 nxtph = FT1000_DPRAM_RX_BASE + 2;
1304 if (info->AsicID == ELECTRABUZZ_ID) {
1306 ft1000_read_dpram(dev, FT1000_DPRAM_RX_BASE);
1309 ntohs(ft1000_read_dpram_mag_16
1310 (dev, FT1000_MAG_TOTAL_LEN,
1311 FT1000_MAG_TOTAL_LEN_INDX));
1313 DEBUG(1, "FT1000:ft1000_parse_dpram_msg:total length = %d\n",
1315 if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) {
1318 // ft1000_read_reg will return a value that needs to be byteswap
1319 // in order to get DSP_QID_OFFSET.
1320 if (info->AsicID == ELECTRABUZZ_ID) {
1324 DSP_QID_OFFSET + FT1000_DPRAM_RX_BASE +
1328 (ft1000_read_dpram_mag_16
1329 (dev, FT1000_MAG_PORT_ID,
1330 FT1000_MAG_PORT_ID_INDX) & 0xff);
1332 DEBUG(1, "DSP_QID = 0x%x\n", portid);
1334 if (portid == DRIVERID) {
1335 // We are assumming one driver message from the DSP at a time.
1336 ft1000_proc_drvmsg(dev);
1339 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_DPRAM_RX);
1342 if (doorbell & FT1000_DB_COND_RESET) {
1343 // Reset ASIC and DSP
1344 if (info->AsicID == ELECTRABUZZ_ID) {
1346 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
1348 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
1350 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
1352 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
1355 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER0,
1356 FT1000_MAG_DSP_TIMER0_INDX);
1358 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER1,
1359 FT1000_MAG_DSP_TIMER1_INDX);
1361 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER2,
1362 FT1000_MAG_DSP_TIMER2_INDX);
1364 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER3,
1365 FT1000_MAG_DSP_TIMER3_INDX);
1367 info->DrvErrNum = DSP_CONDRESET_INFO;
1368 DEBUG(1, "ft1000_hw:DSP conditional reset requested\n");
1369 ft1000_reset_card(dev);
1370 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1371 FT1000_DB_COND_RESET);
1373 // let's clear any unexpected doorbells from DSP
1375 doorbell & ~(FT1000_DB_DPRAM_RX | FT1000_ASIC_RESET_REQ |
1376 FT1000_DB_COND_RESET | 0xff00);
1378 DEBUG(1, "Clearing unexpected doorbell = 0x%x\n", doorbell);
1379 ft1000_write_reg(dev, FT1000_REG_DOORBELL, doorbell);
1386 //---------------------------------------------------------------------------
1388 // Function: ft1000_flush_fifo
1389 // Description: This function will flush one packet from the downlink
1392 // dev - device structure
1393 // drv_err - driver error causing the flush fifo
1397 //---------------------------------------------------------------------------
1398 static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
1400 struct ft1000_info *info = netdev_priv(dev);
1401 struct ft1000_pcmcia *pcmcia = info->priv;
1406 DEBUG(1, "ft1000:ft1000_hw:ft1000_flush_fifo called\n");
1407 if (pcmcia->PktIntfErr > MAX_PH_ERR) {
1408 if (info->AsicID == ELECTRABUZZ_ID) {
1410 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
1412 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
1414 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
1416 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
1419 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER0,
1420 FT1000_MAG_DSP_TIMER0_INDX);
1422 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER1,
1423 FT1000_MAG_DSP_TIMER1_INDX);
1425 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER2,
1426 FT1000_MAG_DSP_TIMER2_INDX);
1428 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER3,
1429 FT1000_MAG_DSP_TIMER3_INDX);
1431 info->DrvErrNum = DrvErrNum;
1432 ft1000_reset_card(dev);
1435 // Flush corrupted pkt from FIFO
1438 if (info->AsicID == ELECTRABUZZ_ID) {
1440 ft1000_read_reg(dev, FT1000_REG_DFIFO);
1442 ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT);
1445 inl(dev->base_addr + FT1000_REG_MAG_DFR);
1447 inw(dev->base_addr + FT1000_REG_MAG_DFSR);
1450 // This should never happen unless the ASIC is broken.
1451 // We must reset to recover.
1452 if ((i > 2048) || (tempword == 0)) {
1453 if (info->AsicID == ELECTRABUZZ_ID) {
1455 ft1000_read_dpram(dev,
1458 ft1000_read_dpram(dev,
1461 ft1000_read_dpram(dev,
1464 ft1000_read_dpram(dev,
1468 ft1000_read_dpram_mag_16(dev,
1469 FT1000_MAG_DSP_TIMER0,
1470 FT1000_MAG_DSP_TIMER0_INDX);
1472 ft1000_read_dpram_mag_16(dev,
1473 FT1000_MAG_DSP_TIMER1,
1474 FT1000_MAG_DSP_TIMER1_INDX);
1476 ft1000_read_dpram_mag_16(dev,
1477 FT1000_MAG_DSP_TIMER2,
1478 FT1000_MAG_DSP_TIMER2_INDX);
1480 ft1000_read_dpram_mag_16(dev,
1481 FT1000_MAG_DSP_TIMER3,
1482 FT1000_MAG_DSP_TIMER3_INDX);
1484 if (tempword == 0) {
1485 // Let's check if ASIC reads are still ok by reading the Mask register
1486 // which is never zero at this point of the code.
1488 inw(dev->base_addr +
1489 FT1000_REG_SUP_IMASK);
1490 if (tempword == 0) {
1491 // This indicates that we can not communicate with the ASIC
1495 // Let's assume that we really flush the FIFO
1496 pcmcia->PktIntfErr++;
1500 info->DrvErrNum = FIFO_FLUSH_MAXLIMIT;
1504 tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
1505 } while ((tempword & 0x03) != 0x03);
1506 if (info->AsicID == ELECTRABUZZ_ID) {
1508 DEBUG(0, "Flushing FIFO complete = %x\n", tempword);
1509 // Flush last word in FIFO.
1510 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1511 // Update FIFO counter for DSP
1513 DEBUG(0, "Flush Data byte count to dsp = %d\n", i);
1514 info->fifo_cnt += i;
1515 ft1000_write_dpram(dev, FT1000_FIFO_LEN,
1518 DEBUG(0, "Flushing FIFO complete = %x\n", tempword);
1519 // Flush last word in FIFO
1520 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1521 tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
1522 DEBUG(0, "FT1000_REG_SUP_STAT = 0x%x\n", tempword);
1523 tempword = inw(dev->base_addr + FT1000_REG_MAG_DFSR);
1524 DEBUG(0, "FT1000_REG_MAG_DFSR = 0x%x\n", tempword);
1527 pcmcia->PktIntfErr++;
1532 //---------------------------------------------------------------------------
1534 // Function: ft1000_copy_up_pkt
1535 // Description: This function will pull Flarion packets out of the Downlink
1536 // FIFO and convert it to an ethernet packet. The ethernet packet will
1537 // then be deliver to the TCP/IP stack.
1539 // dev - device structure
1544 //---------------------------------------------------------------------------
1545 static int ft1000_copy_up_pkt(struct net_device *dev)
1548 struct ft1000_info *info = netdev_priv(dev);
1550 struct sk_buff *skb;
1558 DEBUG(1, "ft1000_copy_up_pkt\n");
1560 if (info->AsicID == ELECTRABUZZ_ID) {
1561 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1564 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1565 len = ntohs(tempword);
1568 DEBUG(1, "Number of Bytes in FIFO = %d\n", len);
1570 if (len > ENET_MAX_SIZE) {
1571 DEBUG(0, "size of ethernet packet invalid\n");
1572 if (info->AsicID == MAGNEMITE_ID) {
1573 // Read High word to complete 32 bit access
1574 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1576 ft1000_flush_fifo(dev, DSP_PKTLEN_INFO);
1577 info->stats.rx_errors++;
1581 skb = dev_alloc_skb(len + 12 + 2);
1584 DEBUG(0, "No Network buffers available\n");
1585 // Read High word to complete 32 bit access
1586 if (info->AsicID == MAGNEMITE_ID) {
1587 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1589 ft1000_flush_fifo(dev, 0);
1590 info->stats.rx_errors++;
1593 pbuffer = (u8 *) skb_put(skb, len + 12);
1596 if (info->AsicID == ELECTRABUZZ_ID) {
1597 for (i = 1; i < 7; i++) {
1598 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1601 // read checksum value
1602 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1604 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1605 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1608 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1609 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1612 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1613 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1616 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1617 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1620 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1621 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1624 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1625 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1628 // read checksum value
1629 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1630 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1633 if (chksum != tempword) {
1634 DEBUG(0, "Packet checksum mismatch 0x%x 0x%x\n", chksum,
1636 ft1000_flush_fifo(dev, DSP_PKTPHCKSUM_INFO);
1637 info->stats.rx_errors++;
1641 //subtract the number of bytes read already
1645 *pbuffer++ = dev->dev_addr[0];
1646 *pbuffer++ = dev->dev_addr[1];
1647 *pbuffer++ = dev->dev_addr[2];
1648 *pbuffer++ = dev->dev_addr[3];
1649 *pbuffer++ = dev->dev_addr[4];
1650 *pbuffer++ = dev->dev_addr[5];
1658 if (info->AsicID == ELECTRABUZZ_ID) {
1659 for (i = 0; i < len / 2; i++) {
1660 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1661 *pbuffer++ = (u8) (tempword >> 8);
1662 *pbuffer++ = (u8) tempword;
1663 if (ft1000_chkcard(dev) == false) {
1669 // Need to read one more word if odd byte
1671 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1672 *pbuffer++ = (u8) (tempword >> 8);
1675 ptemplong = (u32 *) pbuffer;
1676 for (i = 0; i < len / 4; i++) {
1677 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1678 DEBUG(1, "Data = 0x%8x\n", templong);
1679 *ptemplong++ = templong;
1682 // Need to read one more word if odd align.
1684 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1685 DEBUG(1, "Data = 0x%8x\n", templong);
1686 *ptemplong++ = templong;
1691 DEBUG(1, "Data passed to Protocol layer:\n");
1692 for (i = 0; i < len + 12; i++) {
1693 DEBUG(1, "Protocol Data: 0x%x\n ", *ptemp++);
1697 skb->protocol = eth_type_trans(skb, dev);
1698 skb->ip_summed = CHECKSUM_UNNECESSARY;
1701 info->stats.rx_packets++;
1702 // Add on 12 bytes for MAC address which was removed
1703 info->stats.rx_bytes += (len + 12);
1705 if (info->AsicID == ELECTRABUZZ_ID) {
1706 // track how many bytes have been read from FIFO - round up to 16 bit word
1707 tempword = len + 16;
1708 if (tempword & 0x01)
1710 info->fifo_cnt += tempword;
1711 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, FT1000_FIFO_LEN);
1712 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, info->fifo_cnt);
1718 //---------------------------------------------------------------------------
1720 // Function: ft1000_copy_down_pkt
1721 // Description: This function will take an ethernet packet and convert it to
1722 // a Flarion packet prior to sending it to the ASIC Downlink
1725 // dev - device structure
1726 // packet - address of ethernet packet
1727 // len - length of IP packet
1732 //---------------------------------------------------------------------------
1733 static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)
1735 struct ft1000_info *info = netdev_priv(dev);
1736 struct ft1000_pcmcia *pcmcia = info->priv;
1738 struct pseudo_hdr blk;
1739 u16 buff[sizeof(struct pseudo_hdr) >> 1];
1740 u8 buffc[sizeof(struct pseudo_hdr)];
1745 DEBUG(1, "ft1000_hw: copy_down_pkt()\n");
1747 // Check if there is room on the FIFO
1748 if (len > ft1000_read_fifo_len(dev)) {
1750 if (len > ft1000_read_fifo_len(dev)) {
1753 if (len > ft1000_read_fifo_len(dev)) {
1756 if (len > ft1000_read_fifo_len(dev)) {
1759 if (len > ft1000_read_fifo_len(dev)) {
1762 if (len > ft1000_read_fifo_len(dev)) {
1765 if (len > ft1000_read_fifo_len(dev)) {
1767 "ft1000_hw:ft1000_copy_down_pkt:Transmit FIFO is fulli - pkt drop\n");
1768 info->stats.tx_errors++;
1772 // Create pseudo header and send pseudo/ip to hardware
1773 if (info->AsicID == ELECTRABUZZ_ID) {
1774 pseudo.blk.length = len;
1776 pseudo.blk.length = ntohs(len);
1778 pseudo.blk.source = DSPID; // Need to swap to get in correct order
1779 pseudo.blk.destination = HOSTID;
1780 pseudo.blk.portdest = NETWORKID; // Need to swap to get in correct order
1781 pseudo.blk.portsrc = DSPAIRID;
1782 pseudo.blk.sh_str_id = 0;
1783 pseudo.blk.control = 0;
1784 pseudo.blk.rsvd1 = 0;
1785 pseudo.blk.seq_num = 0;
1786 pseudo.blk.rsvd2 = pcmcia->packetseqnum++;
1787 pseudo.blk.qos_class = 0;
1788 /* Calculate pseudo header checksum */
1789 pseudo.blk.checksum = pseudo.buff[0];
1790 for (i = 1; i < 7; i++) {
1791 pseudo.blk.checksum ^= pseudo.buff[i];
1795 if (info->AsicID == ELECTRABUZZ_ID) {
1796 // copy first word to UFIFO_BEG reg
1797 ft1000_write_reg(dev, FT1000_REG_UFIFO_BEG, pseudo.buff[0]);
1798 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 0 BEG = 0x%04x\n",
1801 // copy subsequent words to UFIFO_MID reg
1802 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[1]);
1803 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 1 MID = 0x%04x\n",
1805 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[2]);
1806 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 2 MID = 0x%04x\n",
1808 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[3]);
1809 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 3 MID = 0x%04x\n",
1811 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[4]);
1812 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 4 MID = 0x%04x\n",
1814 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[5]);
1815 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 5 MID = 0x%04x\n",
1817 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[6]);
1818 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 6 MID = 0x%04x\n",
1820 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[7]);
1821 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 7 MID = 0x%04x\n",
1824 // Write PPP type + IP Packet into Downlink FIFO
1825 for (i = 0; i < (len >> 1) - 1; i++) {
1826 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,
1829 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1830 i + 8, htons(*packet));
1834 // Check for odd byte
1836 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,
1839 "ft1000_hw:ft1000_copy_down_pkt:data MID = 0x%04x\n",
1842 ft1000_write_reg(dev, FT1000_REG_UFIFO_END,
1845 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1846 i + 8, htons(*packet));
1848 ft1000_write_reg(dev, FT1000_REG_UFIFO_END,
1851 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1852 i + 8, htons(*packet));
1855 outl(*(u32 *) & pseudo.buff[0],
1856 dev->base_addr + FT1000_REG_MAG_UFDR);
1857 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1858 *(u32 *) & pseudo.buff[0]);
1859 outl(*(u32 *) & pseudo.buff[2],
1860 dev->base_addr + FT1000_REG_MAG_UFDR);
1861 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1862 *(u32 *) & pseudo.buff[2]);
1863 outl(*(u32 *) & pseudo.buff[4],
1864 dev->base_addr + FT1000_REG_MAG_UFDR);
1865 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1866 *(u32 *) & pseudo.buff[4]);
1867 outl(*(u32 *) & pseudo.buff[6],
1868 dev->base_addr + FT1000_REG_MAG_UFDR);
1869 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1870 *(u32 *) & pseudo.buff[6]);
1872 plong = (u32 *) packet;
1873 // Write PPP type + IP Packet into Downlink FIFO
1874 for (i = 0; i < (len >> 2); i++) {
1875 outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR);
1878 // Check for odd alignment
1881 "ft1000_hw:ft1000_copy_down_pkt:data = 0x%8x\n",
1883 outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR);
1885 outl(1, dev->base_addr + FT1000_REG_MAG_UFER);
1888 info->stats.tx_packets++;
1889 // Add 14 bytes for MAC address plus ethernet type
1890 info->stats.tx_bytes += (len + 14);
1894 static struct net_device_stats *ft1000_stats(struct net_device *dev)
1896 struct ft1000_info *info = netdev_priv(dev);
1897 return (&info->stats);
1900 static int ft1000_open(struct net_device *dev)
1903 DEBUG(0, "ft1000_hw: ft1000_open is called\n");
1905 ft1000_reset_card(dev);
1906 DEBUG(0, "ft1000_hw: ft1000_open is ended\n");
1908 /* schedule ft1000_hbchk to perform periodic heartbeat checks on DSP and ASIC */
1909 init_timer(&poll_timer);
1910 poll_timer.expires = jiffies + (2 * HZ);
1911 poll_timer.data = (u_long) dev;
1912 add_timer(&poll_timer);
1914 DEBUG(0, "ft1000_hw: ft1000_open is ended2\n");
1918 static int ft1000_close(struct net_device *dev)
1920 struct ft1000_info *info = netdev_priv(dev);
1922 DEBUG(0, "ft1000_hw: ft1000_close()\n");
1924 info->CardReady = 0;
1925 del_timer(&poll_timer);
1927 if (ft1000_card_present == 1) {
1928 DEBUG(0, "Media is down\n");
1929 netif_stop_queue(dev);
1931 ft1000_disable_interrupts(dev);
1932 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
1935 ft1000_reset_asic(dev);
1940 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
1942 struct ft1000_info *info = netdev_priv(dev);
1945 DEBUG(1, "ft1000_hw: ft1000_start_xmit()\n");
1947 DEBUG(1, "ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n");
1951 DEBUG(1, "ft1000_hw: ft1000_start_xmit:length of packet = %d\n",
1954 pdata = (u8 *) skb->data;
1956 if (info->mediastate == 0) {
1957 /* Drop packet is mediastate is down */
1958 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:mediastate is down\n");
1962 if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) {
1963 /* Drop packet which has invalid size */
1965 "ft1000_hw:ft1000_copy_down_pkt:invalid ethernet length\n");
1968 ft1000_copy_down_pkt(dev, (u16 *) (pdata + ENET_HEADER_SIZE - 2),
1969 skb->len - ENET_HEADER_SIZE + 2);
1976 static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
1978 struct net_device *dev = (struct net_device *)dev_id;
1979 struct ft1000_info *info = netdev_priv(dev);
1984 DEBUG(1, "ft1000_hw: ft1000_interrupt()\n");
1986 if (info->CardReady == 0) {
1987 ft1000_disable_interrupts(dev);
1991 if (ft1000_chkcard(dev) == false) {
1992 ft1000_disable_interrupts(dev);
1996 ft1000_disable_interrupts(dev);
1998 // Read interrupt type
1999 inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
2001 // Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type
2003 if (inttype & ISR_DOORBELL_PEND)
2004 ft1000_parse_dpram_msg(dev);
2006 if (inttype & ISR_RCV) {
2007 DEBUG(1, "Data in FIFO\n");
2011 // Check if we have packets in the Downlink FIFO
2012 if (info->AsicID == ELECTRABUZZ_ID) {
2014 ft1000_read_reg(dev,
2015 FT1000_REG_DFIFO_STAT);
2018 ft1000_read_reg(dev,
2019 FT1000_REG_MAG_DFSR);
2021 if (tempword & 0x1f) {
2022 ft1000_copy_up_pkt(dev);
2027 } while (cnt < MAX_RCV_LOOP);
2031 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
2032 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
2033 ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
2035 // Read interrupt type
2036 inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR);
2037 DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype);
2039 ft1000_enable_interrupts(dev);
2043 void stop_ft1000_card(struct net_device *dev)
2045 struct ft1000_info *info = netdev_priv(dev);
2046 struct prov_record *ptr;
2049 DEBUG(0, "ft1000_hw: stop_ft1000_card()\n");
2051 info->CardReady = 0;
2052 ft1000_card_present = 0;
2053 netif_stop_queue(dev);
2054 ft1000_disable_interrupts(dev);
2056 // Make sure we free any memory reserve for provisioning
2057 while (list_empty(&info->prov_list) == 0) {
2058 ptr = list_entry(info->prov_list.next, struct prov_record, list);
2059 list_del(&ptr->list);
2060 kfree(ptr->pprov_data);
2066 if (info->registered) {
2067 unregister_netdev(dev);
2068 info->registered = 0;
2071 free_irq(dev->irq, dev);
2072 release_region(dev->base_addr,256);
2073 release_firmware(fw_entry);
2074 flarion_ft1000_cnt--;
2075 ft1000CleanupProc(dev);
2079 static void ft1000_get_drvinfo(struct net_device *dev,
2080 struct ethtool_drvinfo *info)
2082 struct ft1000_info *ft_info;
2083 ft_info = netdev_priv(dev);
2085 strlcpy(info->driver, "ft1000", sizeof(info->driver));
2086 snprintf(info->bus_info, sizeof(info->bus_info), "PCMCIA 0x%lx",
2088 snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d.%d.%d",
2089 ft_info->DspVer[0], ft_info->DspVer[1], ft_info->DspVer[2],
2090 ft_info->DspVer[3]);
2093 static u32 ft1000_get_link(struct net_device *dev)
2095 struct ft1000_info *info;
2096 info = netdev_priv(dev);
2097 return info->mediastate;
2100 static const struct ethtool_ops ops = {
2101 .get_drvinfo = ft1000_get_drvinfo,
2102 .get_link = ft1000_get_link
2105 struct net_device *init_ft1000_card(struct pcmcia_device *link,
2108 struct ft1000_info *info;
2109 struct ft1000_pcmcia *pcmcia;
2110 struct net_device *dev;
2112 static const struct net_device_ops ft1000ops = // Slavius 21.10.2009 due to kernel changes
2114 .ndo_open = &ft1000_open,
2115 .ndo_stop = &ft1000_close,
2116 .ndo_start_xmit = &ft1000_start_xmit,
2117 .ndo_get_stats = &ft1000_stats,
2120 DEBUG(1, "ft1000_hw: init_ft1000_card()\n");
2121 DEBUG(1, "ft1000_hw: irq = %d\n", link->irq);
2122 DEBUG(1, "ft1000_hw: port = 0x%04x\n", link->resource[0]->start);
2124 flarion_ft1000_cnt++;
2126 if (flarion_ft1000_cnt > 1) {
2127 flarion_ft1000_cnt--;
2130 "ft1000: This driver can not support more than one instance\n");
2134 dev = alloc_etherdev(sizeof(struct ft1000_info));
2136 printk(KERN_ERR "ft1000: failed to allocate etherdev\n");
2140 SET_NETDEV_DEV(dev, &link->dev);
2141 info = netdev_priv(dev);
2143 memset(info, 0, sizeof(struct ft1000_info));
2145 DEBUG(1, "address of dev = 0x%8x\n", (u32) dev);
2146 DEBUG(1, "address of dev info = 0x%8x\n", (u32) info);
2147 DEBUG(0, "device name = %s\n", dev->name);
2149 memset(&info->stats, 0, sizeof(struct net_device_stats));
2151 info->priv = kzalloc(sizeof(struct ft1000_pcmcia), GFP_KERNEL);
2152 pcmcia = info->priv;
2153 pcmcia->link = link;
2155 spin_lock_init(&info->dpram_lock);
2156 info->DrvErrNum = 0;
2157 info->registered = 1;
2158 info->ft1000_reset = ft1000_reset;
2159 info->mediastate = 0;
2161 info->CardReady = 0;
2162 info->DSP_TIME[0] = 0;
2163 info->DSP_TIME[1] = 0;
2164 info->DSP_TIME[2] = 0;
2165 info->DSP_TIME[3] = 0;
2166 flarion_ft1000_cnt = 0;
2168 INIT_LIST_HEAD(&info->prov_list);
2170 info->squeseqnum = 0;
2172 // dev->hard_start_xmit = &ft1000_start_xmit;
2173 // dev->get_stats = &ft1000_stats;
2174 // dev->open = &ft1000_open;
2175 // dev->stop = &ft1000_close;
2177 dev->netdev_ops = &ft1000ops; // Slavius 21.10.2009 due to kernel changes
2179 DEBUG(0, "device name = %s\n", dev->name);
2181 dev->irq = link->irq;
2182 dev->base_addr = link->resource[0]->start;
2183 if (pcmcia_get_mac_from_cis(link, dev)) {
2184 printk(KERN_ERR "ft1000: Could not read mac address\n");
2188 if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
2189 printk(KERN_ERR "ft1000: Could not request_irq\n");
2193 if (request_region(dev->base_addr, 256, dev->name) == NULL) {
2194 printk(KERN_ERR "ft1000: Could not request_region\n");
2198 if (register_netdev(dev) != 0) {
2199 DEBUG(0, "ft1000: Could not register netdev");
2203 info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
2204 if (info->AsicID == ELECTRABUZZ_ID) {
2205 DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n");
2206 if (request_firmware(&fw_entry, "ft1000.img", &link->dev) != 0) {
2207 printk(KERN_INFO "ft1000: Could not open ft1000.img\n");
2211 DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n");
2212 if (request_firmware(&fw_entry, "ft2000.img", &link->dev) != 0) {
2213 printk(KERN_INFO "ft1000: Could not open ft2000.img\n");
2218 ft1000_enable_interrupts(dev);
2220 ft1000InitProc(dev);
2221 ft1000_card_present = 1;
2222 SET_ETHTOOL_OPS(dev, &ops);
2223 printk(KERN_INFO "ft1000: %s: addr 0x%04lx irq %d, MAC addr %pM\n",
2224 dev->name, dev->base_addr, dev->irq, dev->dev_addr);
2228 unregister_netdev(dev);
2230 release_region(dev->base_addr, 256);
2232 free_irq(dev->irq, dev);