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/system.h>
33 #include <asm/bitops.h>
35 #include <linux/netdevice.h>
36 #include <linux/etherdevice.h>
37 #include <linux/skbuff.h>
38 #include <linux/if_arp.h>
39 #include <linux/ioport.h>
40 #include <linux/wait.h>
41 #include <linux/vmalloc.h>
43 #include <linux/firmware.h>
44 #include <linux/ethtool.h>
47 #define DEBUG(n, args...) printk(KERN_DEBUG args);
49 #define DEBUG(n, args...)
52 #include <linux/delay.h>
53 #include "ft1000_dev.h"
56 int card_download(struct net_device *dev, void *pFileStart, UINT FileLength);
58 void ft1000InitProc(struct net_device *dev);
59 void ft1000CleanupProc(struct net_device *dev);
61 const struct firmware *fw_entry;
63 static void ft1000_hbchk(u_long data);
64 static struct timer_list poll_timer = {
68 static u16 cmdbuffer[1024];
69 static u8 tempbuffer[1600];
70 static u8 ft1000_card_present = 0;
71 static u8 flarion_ft1000_cnt = 0;
73 static irqreturn_t ft1000_interrupt(int irq, void *dev_id);
74 static void ft1000_enable_interrupts(struct net_device *dev);
75 static void ft1000_disable_interrupts(struct net_device *dev);
80 ("Support for Flarion Flash OFDM NIC Device. Support for PCMCIA when used with ft1000_cs.");
81 MODULE_LICENSE("GPL");
82 MODULE_SUPPORTED_DEVICE("FT1000");
84 #define MAX_RCV_LOOP 100
86 //---------------------------------------------------------------------------
88 // Function: ft1000_asic_read
89 // Descripton: This function will retrieve the value of a specific ASIC
92 // dev - network device structure
93 // offset - ASIC register to read
95 // value - value of ASIC register
97 //---------------------------------------------------------------------------
98 inline u16 ft1000_asic_read(struct net_device *dev, u16 offset)
100 return (ft1000_read_reg(dev, offset));
103 //---------------------------------------------------------------------------
105 // Function: ft1000_asic_write
106 // Descripton: This function will set the value of a specific ASIC
109 // dev - network device structure
110 // value - value to set ASIC register
114 //---------------------------------------------------------------------------
115 inline void ft1000_asic_write(struct net_device *dev, u16 offset, u16 value)
117 ft1000_write_reg(dev, offset, value);
120 //---------------------------------------------------------------------------
122 // Function: ft1000_read_fifo_len
123 // Descripton: This function will read the ASIC Uplink FIFO status register
124 // which will return the number of bytes remaining in the Uplink FIFO.
125 // Sixteen bytes are subtracted to make sure that the ASIC does not
126 // reach its threshold.
128 // dev - network device structure
130 // value - number of bytes available in the ASIC Uplink FIFO.
132 //---------------------------------------------------------------------------
133 static inline u16 ft1000_read_fifo_len(struct net_device *dev)
135 FT1000_INFO *info = netdev_priv(dev);
137 if (info->AsicID == ELECTRABUZZ_ID) {
138 return (ft1000_read_reg(dev, FT1000_REG_UFIFO_STAT) - 16);
140 return (ft1000_read_reg(dev, FT1000_REG_MAG_UFSR) - 16);
144 //---------------------------------------------------------------------------
146 // Function: ft1000_read_dpram
147 // Descripton: This function will read the specific area of dpram
148 // (Electrabuzz ASIC only)
150 // dev - device structure
151 // offset - index of dpram
153 // value - value of dpram
155 //---------------------------------------------------------------------------
156 u16 ft1000_read_dpram(struct net_device * dev, int offset)
158 FT1000_INFO *info = netdev_priv(dev);
162 // Provide mutual exclusive access while reading ASIC registers.
163 spin_lock_irqsave(&info->dpram_lock, flags);
164 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
165 data = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
166 spin_unlock_irqrestore(&info->dpram_lock, flags);
171 //---------------------------------------------------------------------------
173 // Function: ft1000_write_dpram
174 // Descripton: This function will write to a specific area of dpram
175 // (Electrabuzz ASIC only)
177 // dev - device structure
178 // offset - index of dpram
179 // value - value to write
183 //---------------------------------------------------------------------------
184 static inline void ft1000_write_dpram(struct net_device *dev,
185 int offset, u16 value)
187 FT1000_INFO *info = netdev_priv(dev);
190 // Provide mutual exclusive access while reading ASIC registers.
191 spin_lock_irqsave(&info->dpram_lock, flags);
192 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
193 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, value);
194 spin_unlock_irqrestore(&info->dpram_lock, flags);
197 //---------------------------------------------------------------------------
199 // Function: ft1000_read_dpram_mag_16
200 // Descripton: This function will read the specific area of dpram
201 // (Magnemite ASIC only)
203 // dev - device structure
204 // offset - index of dpram
206 // value - value of dpram
208 //---------------------------------------------------------------------------
209 u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index)
211 FT1000_INFO *info = netdev_priv(dev);
215 // Provide mutual exclusive access while reading ASIC registers.
216 spin_lock_irqsave(&info->dpram_lock, flags);
217 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
218 // check if we want to read upper or lower 32-bit word
220 data = ft1000_read_reg(dev, FT1000_REG_MAG_DPDATAL);
222 data = ft1000_read_reg(dev, FT1000_REG_MAG_DPDATAH);
224 spin_unlock_irqrestore(&info->dpram_lock, flags);
229 //---------------------------------------------------------------------------
231 // Function: ft1000_write_dpram_mag_16
232 // Descripton: This function will write to a specific area of dpram
233 // (Magnemite ASIC only)
235 // dev - device structure
236 // offset - index of dpram
237 // value - value to write
241 //---------------------------------------------------------------------------
242 static inline void ft1000_write_dpram_mag_16(struct net_device *dev,
243 int offset, u16 value, int Index)
245 FT1000_INFO *info = netdev_priv(dev);
248 // Provide mutual exclusive access while reading ASIC registers.
249 spin_lock_irqsave(&info->dpram_lock, flags);
250 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
252 ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAL, value);
254 ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAH, value);
256 spin_unlock_irqrestore(&info->dpram_lock, flags);
259 //---------------------------------------------------------------------------
261 // Function: ft1000_read_dpram_mag_32
262 // Descripton: This function will read the specific area of dpram
263 // (Magnemite ASIC only)
265 // dev - device structure
266 // offset - index of dpram
268 // value - value of dpram
270 //---------------------------------------------------------------------------
271 u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset)
273 FT1000_INFO *info = netdev_priv(dev);
277 // Provide mutual exclusive access while reading ASIC registers.
278 spin_lock_irqsave(&info->dpram_lock, flags);
279 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
280 data = inl(dev->base_addr + FT1000_REG_MAG_DPDATAL);
281 spin_unlock_irqrestore(&info->dpram_lock, flags);
286 //---------------------------------------------------------------------------
288 // Function: ft1000_write_dpram_mag_32
289 // Descripton: This function will write to a specific area of dpram
290 // (Magnemite ASIC only)
292 // dev - device structure
293 // offset - index of dpram
294 // value - value to write
298 //---------------------------------------------------------------------------
299 void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value)
301 FT1000_INFO *info = netdev_priv(dev);
304 // Provide mutual exclusive access while reading ASIC registers.
305 spin_lock_irqsave(&info->dpram_lock, flags);
306 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);
307 outl(value, dev->base_addr + FT1000_REG_MAG_DPDATAL);
308 spin_unlock_irqrestore(&info->dpram_lock, flags);
311 //---------------------------------------------------------------------------
313 // Function: ft1000_enable_interrupts
314 // Descripton: This function will enable interrupts base on the current interrupt mask.
316 // dev - device structure
320 //---------------------------------------------------------------------------
321 static void ft1000_enable_interrupts(struct net_device *dev)
323 FT1000_INFO *info = netdev_priv(dev);
326 DEBUG(1, "ft1000_hw:ft1000_enable_interrupts()\n");
327 ft1000_write_reg(dev, FT1000_REG_SUP_IMASK,
328 info->CurrentInterruptEnableMask);
329 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);
331 "ft1000_hw:ft1000_enable_interrupts:current interrupt enable mask = 0x%x\n",
333 info->InterruptsEnabled = TRUE;
336 //---------------------------------------------------------------------------
338 // Function: ft1000_disable_interrupts
339 // Descripton: This function will disable all interrupts.
341 // dev - device structure
345 //---------------------------------------------------------------------------
346 static void ft1000_disable_interrupts(struct net_device *dev)
348 FT1000_INFO *info = netdev_priv(dev);
351 DEBUG(1, "ft1000_hw: ft1000_disable_interrupts()\n");
352 ft1000_write_reg(dev, FT1000_REG_SUP_IMASK, ISR_MASK_ALL);
353 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);
355 "ft1000_hw:ft1000_disable_interrupts:current interrupt enable mask = 0x%x\n",
357 info->InterruptsEnabled = FALSE;
360 //---------------------------------------------------------------------------
362 // Function: ft1000_reset_asic
363 // Descripton: This function will call the Card Service function to reset the
366 // dev - device structure
370 //---------------------------------------------------------------------------
371 static void ft1000_reset_asic(struct net_device *dev)
373 FT1000_INFO *info = netdev_priv(dev);
376 DEBUG(1, "ft1000_hw:ft1000_reset_asic called\n");
378 (*info->ft1000_reset) (info->link);
379 info->ASICResetNum++;
381 // Let's use the register provided by the Magnemite ASIC to reset the
383 if (info->AsicID == MAGNEMITE_ID) {
384 ft1000_write_reg(dev, FT1000_REG_RESET,
385 (DSP_RESET_BIT | ASIC_RESET_BIT));
388 if (info->AsicID == ELECTRABUZZ_ID) {
389 // set watermark to -1 in order to not generate an interrrupt
390 ft1000_write_reg(dev, FT1000_REG_WATERMARK, 0xffff);
392 // set watermark to -1 in order to not generate an interrrupt
393 ft1000_write_reg(dev, FT1000_REG_MAG_WATERMARK, 0xffff);
396 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
397 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
398 ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
399 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
400 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
404 //---------------------------------------------------------------------------
406 // Function: ft1000_reset_card
407 // Descripton: This function will reset the card
409 // dev - device structure
411 // status - FALSE (card reset fail)
412 // TRUE (card reset successful)
414 //---------------------------------------------------------------------------
415 static int ft1000_reset_card(struct net_device *dev)
417 FT1000_INFO *info = netdev_priv(dev);
423 DEBUG(1, "ft1000_hw:ft1000_reset_card called.....\n");
426 info->ProgConStat = 0;
427 info->squeseqnum = 0;
428 ft1000_disable_interrupts(dev);
430 // del_timer(&poll_timer);
432 // Make sure we free any memory reserve for provisioning
433 while (list_empty(&info->prov_list) == 0) {
435 "ft1000_hw:ft1000_reset_card:deleting provisioning record\n");
436 ptr = list_entry(info->prov_list.next, PROV_RECORD, list);
437 list_del(&ptr->list);
438 kfree(ptr->pprov_data);
442 if (info->AsicID == ELECTRABUZZ_ID) {
443 DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting DSP\n");
444 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
447 "ft1000_hw:ft1000_reset_card:resetting ASIC and DSP\n");
448 ft1000_write_reg(dev, FT1000_REG_RESET,
449 (DSP_RESET_BIT | ASIC_RESET_BIT));
452 // Copy DSP session record into info block if this is not a coldstart
453 if (ft1000_card_present == 1) {
454 spin_lock_irqsave(&info->dpram_lock, flags);
455 if (info->AsicID == ELECTRABUZZ_ID) {
456 if (info->DspHibernateFlag == 0) {
457 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
458 FT1000_DPRAM_RX_BASE);
459 for (i = 0; i < MAX_DSP_SESS_REC; i++) {
460 info->DSPSess.Rec[i] =
462 FT1000_REG_DPRAM_DATA);
466 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
467 FT1000_DPRAM_MAG_RX_BASE);
468 for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) {
469 info->DSPSess.MagRec[i] =
470 inl(dev->base_addr + FT1000_REG_MAG_DPDATA);
473 spin_unlock_irqrestore(&info->dpram_lock, flags);
476 DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting ASIC\n");
479 ft1000_reset_asic(dev);
483 DEBUG(1, "ft1000_hw:ft1000_reset_card:downloading dsp image\n");
485 if (info->AsicID == MAGNEMITE_ID) {
486 // Put dsp in reset and take ASIC out of reset
488 "ft1000_hw:ft1000_reset_card:Put DSP in reset and take ASIC out of reset\n");
489 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
491 // Setting MAGNEMITE ASIC to big endian mode
492 ft1000_write_reg(dev, FT1000_REG_SUP_CTRL, HOST_INTF_BE);
493 // Download bootloader
496 // Take DSP out of reset
497 ft1000_write_reg(dev, FT1000_REG_RESET, 0);
498 // FLARION_DSP_ACTIVE;
500 DEBUG(0, "ft1000_hw:ft1000_reset_card:Take DSP out of reset\n");
502 // Wait for 0xfefe indicating dsp ready before starting download
503 for (i = 0; i < 50; i++) {
505 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DPRAM_FEFE,
506 FT1000_MAG_DPRAM_FEFE_INDX);
507 if (tempword == 0xfefe) {
515 "ft1000_hw:ft1000_reset_card:No FEFE detected from DSP\n");
520 // Take DSP out of reset
521 ft1000_write_reg(dev, FT1000_REG_RESET, ~DSP_RESET_BIT);
525 if (card_download(dev, fw_entry->data, fw_entry->size)) {
526 DEBUG(1, "card download unsuccessful\n");
529 DEBUG(1, "card download successful\n");
534 if (info->AsicID == ELECTRABUZZ_ID) {
535 // Need to initialize the FIFO length counter to zero in order to sync up
538 ft1000_write_dpram(dev, FT1000_FIFO_LEN, info->fifo_cnt);
539 // Initialize DSP heartbeat area to ho
540 ft1000_write_dpram(dev, FT1000_HI_HO, ho);
541 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
542 DEBUG(1, "ft1000_hw:ft1000_reset_asic:hi_ho value = 0x%x\n",
545 // Initialize DSP heartbeat area to ho
546 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, ho_mag,
547 FT1000_MAG_HI_HO_INDX);
549 ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO,
550 FT1000_MAG_HI_HO_INDX);
551 DEBUG(1, "ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n",
556 ft1000_enable_interrupts(dev);
558 /* Schedule heartbeat process to run every 2 seconds */
559 // poll_timer.expires = jiffies + (2*HZ);
560 // poll_timer.data = (u_long)dev;
561 // add_timer(&poll_timer);
567 //---------------------------------------------------------------------------
569 // Function: ft1000_chkcard
570 // Descripton: This function will check if the device is presently available on
573 // dev - device structure
575 // status - FALSE (device is not present)
576 // TRUE (device is present)
578 //---------------------------------------------------------------------------
579 static int ft1000_chkcard(struct net_device *dev)
583 // Mask register is used to check for device presence since it is never
585 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);
588 "ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");
591 // The system will return the value of 0xffff for the version register
592 // if the device is not present.
593 tempword = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
594 if (tempword == 0xffff) {
596 "ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n");
603 //---------------------------------------------------------------------------
605 // Function: ft1000_hbchk
606 // Descripton: This function will perform the heart beat check of the DSP as
609 // dev - device structure
613 //---------------------------------------------------------------------------
614 static void ft1000_hbchk(u_long data)
616 struct net_device *dev = (struct net_device *)data;
621 info = netdev_priv(dev);
623 if (info->CardReady == 1) {
624 // Perform dsp heartbeat check
625 if (info->AsicID == ELECTRABUZZ_ID) {
626 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
629 ntohs(ft1000_read_dpram_mag_16
630 (dev, FT1000_MAG_HI_HO,
631 FT1000_MAG_HI_HO_INDX));
633 DEBUG(1, "ft1000_hw:ft1000_hbchk:hi_ho value = 0x%x\n",
635 // Let's perform another check if ho is not detected
636 if (tempword != ho) {
637 if (info->AsicID == ELECTRABUZZ_ID) {
638 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
641 tempword = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX));
644 if (tempword != ho) {
646 "ft1000: heartbeat failed - no ho detected\n");
647 if (info->AsicID == ELECTRABUZZ_ID) {
649 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
651 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
653 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
655 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
658 ft1000_read_dpram_mag_16(dev,
659 FT1000_MAG_DSP_TIMER0,
660 FT1000_MAG_DSP_TIMER0_INDX);
662 ft1000_read_dpram_mag_16(dev,
663 FT1000_MAG_DSP_TIMER1,
664 FT1000_MAG_DSP_TIMER1_INDX);
666 ft1000_read_dpram_mag_16(dev,
667 FT1000_MAG_DSP_TIMER2,
668 FT1000_MAG_DSP_TIMER2_INDX);
670 ft1000_read_dpram_mag_16(dev,
671 FT1000_MAG_DSP_TIMER3,
672 FT1000_MAG_DSP_TIMER3_INDX);
674 info->DrvErrNum = DSP_HB_INFO;
675 if (ft1000_reset_card(dev) == 0) {
677 "ft1000: Hardware Failure Detected - PC Card disabled\n");
678 info->ProgConStat = 0xff;
681 /* Schedule this module to run every 2 seconds */
682 poll_timer.expires = jiffies + (2*HZ);
683 poll_timer.data = (u_long)dev;
684 add_timer(&poll_timer);
688 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
689 // Let's check doorbell again if fail
690 if (tempword & FT1000_DB_HB) {
691 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
693 if (tempword & FT1000_DB_HB) {
695 "ft1000: heartbeat doorbell not clear by firmware\n");
696 if (info->AsicID == ELECTRABUZZ_ID) {
698 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
700 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
702 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
704 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
707 ft1000_read_dpram_mag_16(dev,
708 FT1000_MAG_DSP_TIMER0,
709 FT1000_MAG_DSP_TIMER0_INDX);
711 ft1000_read_dpram_mag_16(dev,
712 FT1000_MAG_DSP_TIMER1,
713 FT1000_MAG_DSP_TIMER1_INDX);
715 ft1000_read_dpram_mag_16(dev,
716 FT1000_MAG_DSP_TIMER2,
717 FT1000_MAG_DSP_TIMER2_INDX);
719 ft1000_read_dpram_mag_16(dev,
720 FT1000_MAG_DSP_TIMER3,
721 FT1000_MAG_DSP_TIMER3_INDX);
723 info->DrvErrNum = DSP_HB_INFO;
724 if (ft1000_reset_card(dev) == 0) {
726 "ft1000: Hardware Failure Detected - PC Card disabled\n");
727 info->ProgConStat = 0xff;
730 /* Schedule this module to run every 2 seconds */
731 poll_timer.expires = jiffies + (2*HZ);
732 poll_timer.data = (u_long)dev;
733 add_timer(&poll_timer);
736 // Set dedicated area to hi and ring appropriate doorbell according
737 // to hi/ho heartbeat protocol
738 if (info->AsicID == ELECTRABUZZ_ID) {
739 ft1000_write_dpram(dev, FT1000_HI_HO, hi);
741 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, hi_mag,
742 FT1000_MAG_HI_HO_INDX);
745 if (info->AsicID == ELECTRABUZZ_ID) {
746 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
749 ntohs(ft1000_read_dpram_mag_16
750 (dev, FT1000_MAG_HI_HO,
751 FT1000_MAG_HI_HO_INDX));
753 // Let's write hi again if fail
754 if (tempword != hi) {
755 if (info->AsicID == ELECTRABUZZ_ID) {
756 ft1000_write_dpram(dev, FT1000_HI_HO, hi);
759 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, hi_mag, FT1000_MAG_HI_HO_INDX);
762 if (info->AsicID == ELECTRABUZZ_ID) {
763 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
766 tempword = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX));
771 if (tempword != hi) {
773 "ft1000: heartbeat failed - cannot write hi into DPRAM\n");
774 if (info->AsicID == ELECTRABUZZ_ID) {
776 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
778 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
780 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
782 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
785 ft1000_read_dpram_mag_16(dev,
786 FT1000_MAG_DSP_TIMER0,
787 FT1000_MAG_DSP_TIMER0_INDX);
789 ft1000_read_dpram_mag_16(dev,
790 FT1000_MAG_DSP_TIMER1,
791 FT1000_MAG_DSP_TIMER1_INDX);
793 ft1000_read_dpram_mag_16(dev,
794 FT1000_MAG_DSP_TIMER2,
795 FT1000_MAG_DSP_TIMER2_INDX);
797 ft1000_read_dpram_mag_16(dev,
798 FT1000_MAG_DSP_TIMER3,
799 FT1000_MAG_DSP_TIMER3_INDX);
801 info->DrvErrNum = DSP_HB_INFO;
802 if (ft1000_reset_card(dev) == 0) {
804 "ft1000: Hardware Failure Detected - PC Card disabled\n");
805 info->ProgConStat = 0xff;
808 /* Schedule this module to run every 2 seconds */
809 poll_timer.expires = jiffies + (2*HZ);
810 poll_timer.data = (u_long)dev;
811 add_timer(&poll_timer);
814 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_HB);
818 /* Schedule this module to run every 2 seconds */
819 poll_timer.expires = jiffies + (2 * HZ);
820 poll_timer.data = (u_long) dev;
821 add_timer(&poll_timer);
824 //---------------------------------------------------------------------------
826 // Function: ft1000_send_cmd
831 //---------------------------------------------------------------------------
832 void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype)
834 FT1000_INFO *info = netdev_priv(dev);
840 // check for odd byte and increment to 16-bit word align value
841 if ((size & 0x0001)) {
844 DEBUG(1, "FT1000:ft1000_send_cmd:total length = %d\n", size);
845 DEBUG(1, "FT1000:ft1000_send_cmd:length = %d\n", ntohs(*ptempbuffer));
846 // put message into slow queue area
847 // All messages are in the form total_len + pseudo header + message body
848 spin_lock_irqsave(&info->dpram_lock, flags);
850 // Make sure SLOWQ doorbell is clear
851 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
853 while (tempword & FT1000_DB_DPRAM_TX) {
857 spin_unlock_irqrestore(&info->dpram_lock, flags);
860 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
863 if (info->AsicID == ELECTRABUZZ_ID) {
864 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
865 FT1000_DPRAM_TX_BASE);
866 // Write total length to dpram
867 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, size);
868 // Write pseudo header and messgae body
869 for (i = 0; i < (size >> 1); i++) {
870 DEBUG(1, "FT1000:ft1000_send_cmd:data %d = 0x%x\n", i,
872 tempword = htons(*ptempbuffer++);
873 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, tempword);
876 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
877 FT1000_DPRAM_MAG_TX_BASE);
878 // Write total length to dpram
879 ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAH, htons(size));
880 // Write pseudo header and messgae body
881 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
882 FT1000_DPRAM_MAG_TX_BASE + 1);
883 for (i = 0; i < (size >> 2); i++) {
884 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n",
887 dev->base_addr + FT1000_REG_MAG_DPDATAL);
888 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n",
891 dev->base_addr + FT1000_REG_MAG_DPDATAH);
893 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer);
894 outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAL);
895 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer);
896 outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAH);
898 spin_unlock_irqrestore(&info->dpram_lock, flags);
900 // ring doorbell to notify DSP that we have a message ready
901 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_DPRAM_TX);
904 //---------------------------------------------------------------------------
906 // Function: ft1000_receive_cmd
907 // Descripton: This function will read a message from the dpram area.
909 // dev - network device structure
910 // pbuffer - caller supply address to buffer
911 // pnxtph - pointer to next pseudo header
913 // Status = 0 (unsuccessful)
916 //---------------------------------------------------------------------------
917 BOOLEAN ft1000_receive_cmd(struct net_device *dev, u16 * pbuffer, int maxsz, u16 *pnxtph)
919 FT1000_INFO *info = netdev_priv(dev);
926 if (info->AsicID == ELECTRABUZZ_ID) {
927 size = ( ft1000_read_dpram(dev, *pnxtph) ) + PSEUDOSZ;
930 ntohs(ft1000_read_dpram_mag_16
931 (dev, FT1000_MAG_PH_LEN,
932 FT1000_MAG_PH_LEN_INDX)) + PSEUDOSZ;
936 "FT1000:ft1000_receive_cmd:Invalid command length = %d\n",
940 ppseudohdr = (u16 *) pbuffer;
941 spin_lock_irqsave(&info->dpram_lock, flags);
942 if (info->AsicID == ELECTRABUZZ_ID) {
943 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
944 FT1000_DPRAM_RX_BASE + 2);
945 for (i = 0; i <= (size >> 1); i++) {
947 ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
948 *pbuffer++ = ntohs(tempword);
951 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
952 FT1000_DPRAM_MAG_RX_BASE);
953 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
954 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
956 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
957 FT1000_DPRAM_MAG_RX_BASE + 1);
958 for (i = 0; i <= (size >> 2); i++) {
961 FT1000_REG_MAG_DPDATAL);
965 FT1000_REG_MAG_DPDATAH);
968 //copy odd aligned word
969 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAL);
970 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
972 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
973 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
977 //copy odd byte from fifo
978 tempword = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
979 *pbuffer = ntohs(tempword);
981 spin_unlock_irqrestore(&info->dpram_lock, flags);
983 // Check if pseudo header checksum is good
984 // Calculate pseudo header checksum
985 tempword = *ppseudohdr++;
986 for (i = 1; i < 7; i++) {
987 tempword ^= *ppseudohdr++;
989 if ((tempword != *ppseudohdr)) {
991 "FT1000:ft1000_receive_cmd:Pseudo header checksum mismatch\n");
999 //---------------------------------------------------------------------------
1001 // Function: ft1000_proc_drvmsg
1002 // Descripton: This function will process the various driver messages.
1004 // dev - device structure
1005 // pnxtph - pointer to next pseudo header
1009 //---------------------------------------------------------------------------
1010 void ft1000_proc_drvmsg(struct net_device *dev)
1012 FT1000_INFO *info = netdev_priv(dev);
1015 PMEDIAMSG pmediamsg;
1016 PDSPINITMSG pdspinitmsg;
1021 PPSEUDO_HDR ppseudo_hdr;
1029 if (info->AsicID == ELECTRABUZZ_ID) {
1030 tempword = FT1000_DPRAM_RX_BASE+2;
1033 tempword = FT1000_DPRAM_MAG_RX_BASE;
1035 if ( ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword) ) {
1037 // Get the message type which is total_len + PSEUDO header + msgtype + message body
1038 pdrvmsg = (PDRVMSG) & cmdbuffer[0];
1039 msgtype = ntohs(pdrvmsg->type);
1040 DEBUG(1, "Command message type = 0x%x\n", msgtype);
1044 "Got a provisioning request message from DSP\n");
1046 while (list_empty(&info->prov_list) == 0) {
1047 DEBUG(0, "Sending a provisioning message\n");
1048 // Make sure SLOWQ doorbell is clear
1050 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1052 while (tempword & FT1000_DB_DPRAM_TX) {
1060 list_entry(info->prov_list.next,
1062 len = *(u16 *) ptr->pprov_data;
1065 pmsg = (PUSHORT) ptr->pprov_data;
1066 ppseudo_hdr = (PPSEUDO_HDR) pmsg;
1067 // Insert slow queue sequence number
1068 ppseudo_hdr->seq_num = info->squeseqnum++;
1069 ppseudo_hdr->portsrc = 0;
1070 // Calculate new checksum
1071 ppseudo_hdr->checksum = *pmsg++;
1072 DEBUG(1, "checksum = 0x%x\n",
1073 ppseudo_hdr->checksum);
1074 for (i = 1; i < 7; i++) {
1075 ppseudo_hdr->checksum ^= *pmsg++;
1076 DEBUG(1, "checksum = 0x%x\n",
1077 ppseudo_hdr->checksum);
1080 ft1000_send_cmd (dev, (u16 *)ptr->pprov_data, len, SLOWQ_TYPE);
1081 list_del(&ptr->list);
1082 kfree(ptr->pprov_data);
1085 // Indicate adapter is ready to take application messages after all
1086 // provisioning messages are sent
1087 info->CardReady = 1;
1090 pmediamsg = (PMEDIAMSG) & cmdbuffer[0];
1091 if (info->ProgConStat != 0xFF) {
1092 if (pmediamsg->state) {
1093 DEBUG(1, "Media is up\n");
1094 if (info->mediastate == 0) {
1095 netif_carrier_on(dev);
1096 netif_wake_queue(dev);
1097 info->mediastate = 1;
1098 do_gettimeofday(&tv);
1099 info->ConTm = tv.tv_sec;
1102 DEBUG(1, "Media is down\n");
1103 if (info->mediastate == 1) {
1104 info->mediastate = 0;
1105 netif_carrier_off(dev);
1106 netif_stop_queue(dev);
1112 DEBUG(1,"Media is down\n");
1113 if (info->mediastate == 1) {
1114 info->mediastate = 0;
1115 netif_carrier_off(dev);
1116 netif_stop_queue(dev);
1122 pdspinitmsg = (PDSPINITMSG) & cmdbuffer[0];
1123 memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ);
1124 DEBUG(1, "DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n",
1125 info->DspVer[0], info->DspVer[1], info->DspVer[2],
1127 memcpy(info->HwSerNum, pdspinitmsg->HwSerNum,
1129 memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ);
1130 memcpy(info->eui64, pdspinitmsg->eui64, EUISZ);
1131 dev->dev_addr[0] = info->eui64[0];
1132 dev->dev_addr[1] = info->eui64[1];
1133 dev->dev_addr[2] = info->eui64[2];
1134 dev->dev_addr[3] = info->eui64[5];
1135 dev->dev_addr[4] = info->eui64[6];
1136 dev->dev_addr[5] = info->eui64[7];
1138 if (ntohs(pdspinitmsg->length) ==
1139 (sizeof(DSPINITMSG) - 20)) {
1140 memcpy(info->ProductMode,
1141 pdspinitmsg->ProductMode, MODESZ);
1142 memcpy(info->RfCalVer, pdspinitmsg->RfCalVer,
1144 memcpy(info->RfCalDate, pdspinitmsg->RfCalDate,
1146 DEBUG(1, "RFCalVer = 0x%2x 0x%2x\n",
1147 info->RfCalVer[0], info->RfCalVer[1]);
1151 case DSP_STORE_INFO:
1152 DEBUG(1, "FT1000:drivermsg:Got DSP_STORE_INFO\n");
1153 tempword = ntohs(pdrvmsg->length);
1154 info->DSPInfoBlklen = tempword;
1155 if (tempword < (MAX_DSP_SESS_REC - 4)) {
1156 pmsg = (PUSHORT) & pdrvmsg->data[0];
1157 for (i = 0; i < ((tempword + 1) / 2); i++) {
1159 "FT1000:drivermsg:dsp info data = 0x%x\n",
1161 info->DSPInfoBlk[i + 10] = *pmsg++;
1166 DEBUG(1, "FT1000:drivermsg:Got DSP_GET_INFO\n");
1167 // copy dsp info block to dsp
1168 info->DrvMsgPend = 1;
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 = (PUSHORT) info->DSPInfoBlk;
1185 ppseudo_hdr = (PPSEUDO_HDR) pmsg;
1186 ppseudo_hdr->length =
1187 htons(info->DSPInfoBlklen + 4);
1188 ppseudo_hdr->source = 0x10;
1189 ppseudo_hdr->destination = 0x20;
1190 ppseudo_hdr->portdest = 0;
1191 ppseudo_hdr->portsrc = 0;
1192 ppseudo_hdr->sh_str_id = 0;
1193 ppseudo_hdr->control = 0;
1194 ppseudo_hdr->rsvd1 = 0;
1195 ppseudo_hdr->rsvd2 = 0;
1196 ppseudo_hdr->qos_class = 0;
1197 // Insert slow queue sequence number
1198 ppseudo_hdr->seq_num = info->squeseqnum++;
1199 // Insert application id
1200 ppseudo_hdr->portsrc = 0;
1201 // Calculate new checksum
1202 ppseudo_hdr->checksum = *pmsg++;
1203 for (i = 1; i < 7; i++) {
1204 ppseudo_hdr->checksum ^= *pmsg++;
1206 info->DSPInfoBlk[8] = 0x7200;
1207 info->DSPInfoBlk[9] =
1208 htons(info->DSPInfoBlklen);
1209 ft1000_send_cmd (dev, (PUSHORT)info->DSPInfoBlk, (USHORT)(info->DSPInfoBlklen+4), 0);
1211 info->DrvMsgPend = 0;
1214 case GET_DRV_ERR_RPT_MSG:
1215 DEBUG(1, "FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n");
1216 // copy driver error message to dsp
1217 info->DrvMsgPend = 1;
1218 // allow any outstanding ioctl to finish
1220 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1221 if (tempword & FT1000_DB_DPRAM_TX) {
1224 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1225 if (tempword & FT1000_DB_DPRAM_TX) {
1230 if ((tempword & FT1000_DB_DPRAM_TX) == 0) {
1231 // Put message into Slow Queue
1232 // Form Pseudo header
1233 pmsg = (PUSHORT) & tempbuffer[0];
1234 ppseudo_hdr = (PPSEUDO_HDR) pmsg;
1235 ppseudo_hdr->length = htons(0x0012);
1236 ppseudo_hdr->source = 0x10;
1237 ppseudo_hdr->destination = 0x20;
1238 ppseudo_hdr->portdest = 0;
1239 ppseudo_hdr->portsrc = 0;
1240 ppseudo_hdr->sh_str_id = 0;
1241 ppseudo_hdr->control = 0;
1242 ppseudo_hdr->rsvd1 = 0;
1243 ppseudo_hdr->rsvd2 = 0;
1244 ppseudo_hdr->qos_class = 0;
1245 // Insert slow queue sequence number
1246 ppseudo_hdr->seq_num = info->squeseqnum++;
1247 // Insert application id
1248 ppseudo_hdr->portsrc = 0;
1249 // Calculate new checksum
1250 ppseudo_hdr->checksum = *pmsg++;
1251 for (i=1; i<7; i++) {
1252 ppseudo_hdr->checksum ^= *pmsg++;
1254 pmsg = (PUSHORT) & tempbuffer[16];
1255 *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG);
1256 *pmsg++ = htons(0x000e);
1257 *pmsg++ = htons(info->DSP_TIME[0]);
1258 *pmsg++ = htons(info->DSP_TIME[1]);
1259 *pmsg++ = htons(info->DSP_TIME[2]);
1260 *pmsg++ = htons(info->DSP_TIME[3]);
1261 convert.byte[0] = info->DspVer[0];
1262 convert.byte[1] = info->DspVer[1];
1263 *pmsg++ = convert.wrd;
1264 convert.byte[0] = info->DspVer[2];
1265 convert.byte[1] = info->DspVer[3];
1266 *pmsg++ = convert.wrd;
1267 *pmsg++ = htons(info->DrvErrNum);
1269 ft1000_send_cmd (dev, (PUSHORT)&tempbuffer[0], (USHORT)(0x0012), 0);
1270 info->DrvErrNum = 0;
1272 info->DrvMsgPend = 0;
1281 //---------------------------------------------------------------------------
1283 // Function: ft1000_parse_dpram_msg
1284 // Descripton: This function will parse the message received from the DSP
1285 // via the DPRAM interface.
1287 // dev - device structure
1292 //---------------------------------------------------------------------------
1293 int ft1000_parse_dpram_msg(struct net_device *dev)
1295 FT1000_INFO *info = netdev_priv(dev);
1302 unsigned long flags;
1304 doorbell = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1305 DEBUG(1, "Doorbell = 0x%x\n", doorbell);
1307 if (doorbell & FT1000_ASIC_RESET_REQ) {
1308 // Copy DSP session record from info block
1309 spin_lock_irqsave(&info->dpram_lock, flags);
1310 if (info->AsicID == ELECTRABUZZ_ID) {
1311 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
1312 FT1000_DPRAM_RX_BASE);
1313 for (i = 0; i < MAX_DSP_SESS_REC; i++) {
1314 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA,
1315 info->DSPSess.Rec[i]);
1318 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
1319 FT1000_DPRAM_MAG_RX_BASE);
1320 for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) {
1321 outl(info->DSPSess.MagRec[i],
1322 dev->base_addr + FT1000_REG_MAG_DPDATA);
1325 spin_unlock_irqrestore(&info->dpram_lock, flags);
1327 // clear ASIC RESET request
1328 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1329 FT1000_ASIC_RESET_REQ);
1330 DEBUG(1, "Got an ASIC RESET Request\n");
1331 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1332 FT1000_ASIC_RESET_DSP);
1334 if (info->AsicID == MAGNEMITE_ID) {
1335 // Setting MAGNEMITE ASIC to big endian mode
1336 ft1000_write_reg(dev, FT1000_REG_SUP_CTRL,
1339 info->DspAsicReset = 0;
1342 if (doorbell & FT1000_DSP_ASIC_RESET) {
1344 "FT1000:ft1000_parse_dpram_msg: Got a dsp ASIC reset message\n");
1345 info->DspAsicReset = 1;
1346 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1347 FT1000_DSP_ASIC_RESET);
1352 if (doorbell & FT1000_DB_DPRAM_RX) {
1354 "FT1000:ft1000_parse_dpram_msg: Got a slow queue message\n");
1355 nxtph = FT1000_DPRAM_RX_BASE + 2;
1356 if (info->AsicID == ELECTRABUZZ_ID) {
1358 ft1000_read_dpram(dev, FT1000_DPRAM_RX_BASE);
1361 ntohs(ft1000_read_dpram_mag_16
1362 (dev, FT1000_MAG_TOTAL_LEN,
1363 FT1000_MAG_TOTAL_LEN_INDX));
1365 DEBUG(1, "FT1000:ft1000_parse_dpram_msg:total length = %d\n",
1367 if ((total_len < MAX_CMD_SQSIZE) && (total_len > PSEUDOSZ)) {
1370 // ft1000_read_reg will return a value that needs to be byteswap
1371 // in order to get DSP_QID_OFFSET.
1372 if (info->AsicID == ELECTRABUZZ_ID) {
1376 DSP_QID_OFFSET + FT1000_DPRAM_RX_BASE +
1380 (ft1000_read_dpram_mag_16
1381 (dev, FT1000_MAG_PORT_ID,
1382 FT1000_MAG_PORT_ID_INDX) & 0xff);
1384 DEBUG(1, "DSP_QID = 0x%x\n", portid);
1386 if (portid == DRIVERID) {
1387 // We are assumming one driver message from the DSP at a time.
1388 ft1000_proc_drvmsg(dev);
1391 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_DPRAM_RX);
1394 if (doorbell & FT1000_DB_COND_RESET) {
1395 // Reset ASIC and DSP
1396 if (info->AsicID == ELECTRABUZZ_ID) {
1398 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
1400 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
1402 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
1404 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
1407 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER0,
1408 FT1000_MAG_DSP_TIMER0_INDX);
1410 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER1,
1411 FT1000_MAG_DSP_TIMER1_INDX);
1413 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER2,
1414 FT1000_MAG_DSP_TIMER2_INDX);
1416 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER3,
1417 FT1000_MAG_DSP_TIMER3_INDX);
1419 info->DrvErrNum = DSP_CONDRESET_INFO;
1420 DEBUG(1, "ft1000_hw:DSP conditional reset requested\n");
1421 ft1000_reset_card(dev);
1422 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1423 FT1000_DB_COND_RESET);
1425 // let's clear any unexpected doorbells from DSP
1427 doorbell & ~(FT1000_DB_DPRAM_RX | FT1000_ASIC_RESET_REQ |
1428 FT1000_DB_COND_RESET | 0xff00);
1430 DEBUG(1, "Clearing unexpected doorbell = 0x%x\n", doorbell);
1431 ft1000_write_reg(dev, FT1000_REG_DOORBELL, doorbell);
1438 //---------------------------------------------------------------------------
1440 // Function: ft1000_flush_fifo
1441 // Descripton: This function will flush one packet from the downlink
1444 // dev - device structure
1445 // drv_err - driver error causing the flush fifo
1449 //---------------------------------------------------------------------------
1450 static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
1452 FT1000_INFO *info = netdev_priv(dev);
1457 DEBUG(1, "ft1000:ft1000_hw:ft1000_flush_fifo called\n");
1458 if (info->PktIntfErr > MAX_PH_ERR) {
1459 if (info->AsicID == ELECTRABUZZ_ID) {
1461 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
1463 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
1465 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
1467 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
1470 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER0,
1471 FT1000_MAG_DSP_TIMER0_INDX);
1473 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER1,
1474 FT1000_MAG_DSP_TIMER1_INDX);
1476 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER2,
1477 FT1000_MAG_DSP_TIMER2_INDX);
1479 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER3,
1480 FT1000_MAG_DSP_TIMER3_INDX);
1482 info->DrvErrNum = DrvErrNum;
1483 ft1000_reset_card(dev);
1486 // Flush corrupted pkt from FIFO
1489 if (info->AsicID == ELECTRABUZZ_ID) {
1491 ft1000_read_reg(dev, FT1000_REG_DFIFO);
1493 ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT);
1496 inl(dev->base_addr + FT1000_REG_MAG_DFR);
1498 inw(dev->base_addr + FT1000_REG_MAG_DFSR);
1501 // This should never happen unless the ASIC is broken.
1502 // We must reset to recover.
1503 if ((i > 2048) || (tempword == 0)) {
1504 if (info->AsicID == ELECTRABUZZ_ID) {
1506 ft1000_read_dpram(dev,
1509 ft1000_read_dpram(dev,
1512 ft1000_read_dpram(dev,
1515 ft1000_read_dpram(dev,
1519 ft1000_read_dpram_mag_16(dev,
1520 FT1000_MAG_DSP_TIMER0,
1521 FT1000_MAG_DSP_TIMER0_INDX);
1523 ft1000_read_dpram_mag_16(dev,
1524 FT1000_MAG_DSP_TIMER1,
1525 FT1000_MAG_DSP_TIMER1_INDX);
1527 ft1000_read_dpram_mag_16(dev,
1528 FT1000_MAG_DSP_TIMER2,
1529 FT1000_MAG_DSP_TIMER2_INDX);
1531 ft1000_read_dpram_mag_16(dev,
1532 FT1000_MAG_DSP_TIMER3,
1533 FT1000_MAG_DSP_TIMER3_INDX);
1535 if (tempword == 0) {
1536 // Let's check if ASIC reads are still ok by reading the Mask register
1537 // which is never zero at this point of the code.
1539 inw(dev->base_addr +
1540 FT1000_REG_SUP_IMASK);
1541 if (tempword == 0) {
1542 // This indicates that we can not communicate with the ASIC
1546 // Let's assume that we really flush the FIFO
1551 info->DrvErrNum = FIFO_FLUSH_MAXLIMIT;
1555 tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
1556 } while ((tempword & 0x03) != 0x03);
1557 if (info->AsicID == ELECTRABUZZ_ID) {
1559 DEBUG(0, "Flushing FIFO complete = %x\n", tempword);
1560 // Flush last word in FIFO.
1561 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1562 // Update FIFO counter for DSP
1564 DEBUG(0, "Flush Data byte count to dsp = %d\n", i);
1565 info->fifo_cnt += i;
1566 ft1000_write_dpram(dev, FT1000_FIFO_LEN,
1569 DEBUG(0, "Flushing FIFO complete = %x\n", tempword);
1570 // Flush last word in FIFO
1571 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1572 tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
1573 DEBUG(0, "FT1000_REG_SUP_STAT = 0x%x\n", tempword);
1574 tempword = inw(dev->base_addr + FT1000_REG_MAG_DFSR);
1575 DEBUG(0, "FT1000_REG_MAG_DFSR = 0x%x\n", tempword);
1583 //---------------------------------------------------------------------------
1585 // Function: ft1000_copy_up_pkt
1586 // Descripton: This function will pull Flarion packets out of the Downlink
1587 // FIFO and convert it to an ethernet packet. The ethernet packet will
1588 // then be deliver to the TCP/IP stack.
1590 // dev - device structure
1595 //---------------------------------------------------------------------------
1596 int ft1000_copy_up_pkt(struct net_device *dev)
1599 FT1000_INFO *info = netdev_priv(dev);
1601 struct sk_buff *skb;
1609 DEBUG(1, "ft1000_copy_up_pkt\n");
1611 if (info->AsicID == ELECTRABUZZ_ID) {
1612 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1615 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1616 len = ntohs(tempword);
1619 DEBUG(1, "Number of Bytes in FIFO = %d\n", len);
1621 if (len > ENET_MAX_SIZE) {
1622 DEBUG(0, "size of ethernet packet invalid\n");
1623 if (info->AsicID == MAGNEMITE_ID) {
1624 // Read High word to complete 32 bit access
1625 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1627 ft1000_flush_fifo(dev, DSP_PKTLEN_INFO);
1628 info->stats.rx_errors++;
1632 skb = dev_alloc_skb(len + 12 + 2);
1635 DEBUG(0, "No Network buffers available\n");
1636 // Read High word to complete 32 bit access
1637 if (info->AsicID == MAGNEMITE_ID) {
1638 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1640 ft1000_flush_fifo(dev, 0);
1641 info->stats.rx_errors++;
1644 pbuffer = (u8 *) skb_put(skb, len + 12);
1647 if (info->AsicID == ELECTRABUZZ_ID) {
1648 for (i = 1; i < 7; i++) {
1649 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1652 // read checksum value
1653 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1655 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1656 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1659 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1660 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1663 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1664 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1667 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1668 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1671 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1672 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1675 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1676 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1679 // read checksum value
1680 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1681 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1684 if (chksum != tempword) {
1685 DEBUG(0, "Packet checksum mismatch 0x%x 0x%x\n", chksum,
1687 ft1000_flush_fifo(dev, DSP_PKTPHCKSUM_INFO);
1688 info->stats.rx_errors++;
1692 //subtract the number of bytes read already
1696 *pbuffer++ = dev->dev_addr[0];
1697 *pbuffer++ = dev->dev_addr[1];
1698 *pbuffer++ = dev->dev_addr[2];
1699 *pbuffer++ = dev->dev_addr[3];
1700 *pbuffer++ = dev->dev_addr[4];
1701 *pbuffer++ = dev->dev_addr[5];
1709 if (info->AsicID == ELECTRABUZZ_ID) {
1710 for (i = 0; i < len / 2; i++) {
1711 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1712 *pbuffer++ = (u8) (tempword >> 8);
1713 *pbuffer++ = (u8) tempword;
1714 if (ft1000_chkcard(dev) == FALSE) {
1720 // Need to read one more word if odd byte
1722 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1723 *pbuffer++ = (u8) (tempword >> 8);
1726 ptemplong = (u32 *) pbuffer;
1727 for (i = 0; i < len / 4; i++) {
1728 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1729 DEBUG(1, "Data = 0x%8x\n", templong);
1730 *ptemplong++ = templong;
1733 // Need to read one more word if odd align.
1735 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1736 DEBUG(1, "Data = 0x%8x\n", templong);
1737 *ptemplong++ = templong;
1742 DEBUG(1, "Data passed to Protocol layer:\n");
1743 for (i = 0; i < len + 12; i++) {
1744 DEBUG(1, "Protocol Data: 0x%x\n ", *ptemp++);
1748 skb->protocol = eth_type_trans(skb, dev);
1749 skb->ip_summed = CHECKSUM_UNNECESSARY;
1752 info->stats.rx_packets++;
1753 // Add on 12 bytes for MAC address which was removed
1754 info->stats.rx_bytes += (len + 12);
1756 if (info->AsicID == ELECTRABUZZ_ID) {
1757 // track how many bytes have been read from FIFO - round up to 16 bit word
1758 tempword = len + 16;
1759 if (tempword & 0x01)
1761 info->fifo_cnt += tempword;
1762 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, FT1000_FIFO_LEN);
1763 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, info->fifo_cnt);
1769 //---------------------------------------------------------------------------
1771 // Function: ft1000_copy_down_pkt
1772 // Descripton: This function will take an ethernet packet and convert it to
1773 // a Flarion packet prior to sending it to the ASIC Downlink
1776 // dev - device structure
1777 // packet - address of ethernet packet
1778 // len - length of IP packet
1783 //---------------------------------------------------------------------------
1784 int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)
1786 FT1000_INFO *info = netdev_priv(dev);
1789 u16 buff[sizeof(PSEUDO_HDR) >> 1];
1790 u8 buffc[sizeof(PSEUDO_HDR)];
1795 DEBUG(1, "ft1000_hw: copy_down_pkt()\n");
1797 // Check if there is room on the FIFO
1798 if (len > ft1000_read_fifo_len(dev)) {
1800 if (len > ft1000_read_fifo_len(dev)) {
1803 if (len > ft1000_read_fifo_len(dev)) {
1806 if (len > ft1000_read_fifo_len(dev)) {
1809 if (len > ft1000_read_fifo_len(dev)) {
1812 if (len > ft1000_read_fifo_len(dev)) {
1815 if (len > ft1000_read_fifo_len(dev)) {
1817 "ft1000_hw:ft1000_copy_down_pkt:Transmit FIFO is fulli - pkt drop\n");
1818 info->stats.tx_errors++;
1822 // Create pseudo header and send pseudo/ip to hardware
1823 if (info->AsicID == ELECTRABUZZ_ID) {
1824 pseudo.blk.length = len;
1826 pseudo.blk.length = ntohs(len);
1828 pseudo.blk.source = DSPID; // Need to swap to get in correct order
1829 pseudo.blk.destination = HOSTID;
1830 pseudo.blk.portdest = NETWORKID; // Need to swap to get in correct order
1831 pseudo.blk.portsrc = DSPAIRID;
1832 pseudo.blk.sh_str_id = 0;
1833 pseudo.blk.control = 0;
1834 pseudo.blk.rsvd1 = 0;
1835 pseudo.blk.seq_num = 0;
1836 pseudo.blk.rsvd2 = info->packetseqnum++;
1837 pseudo.blk.qos_class = 0;
1838 /* Calculate pseudo header checksum */
1839 pseudo.blk.checksum = pseudo.buff[0];
1840 for (i = 1; i < 7; i++) {
1841 pseudo.blk.checksum ^= pseudo.buff[i];
1845 if (info->AsicID == ELECTRABUZZ_ID) {
1846 // copy first word to UFIFO_BEG reg
1847 ft1000_write_reg(dev, FT1000_REG_UFIFO_BEG, pseudo.buff[0]);
1848 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 0 BEG = 0x%04x\n",
1851 // copy subsequent words to UFIFO_MID reg
1852 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[1]);
1853 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 1 MID = 0x%04x\n",
1855 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[2]);
1856 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 2 MID = 0x%04x\n",
1858 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[3]);
1859 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 3 MID = 0x%04x\n",
1861 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[4]);
1862 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 4 MID = 0x%04x\n",
1864 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[5]);
1865 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 5 MID = 0x%04x\n",
1867 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[6]);
1868 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 6 MID = 0x%04x\n",
1870 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[7]);
1871 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 7 MID = 0x%04x\n",
1874 // Write PPP type + IP Packet into Downlink FIFO
1875 for (i = 0; i < (len >> 1) - 1; i++) {
1876 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,
1879 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1880 i + 8, htons(*packet));
1884 // Check for odd byte
1886 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,
1889 "ft1000_hw:ft1000_copy_down_pkt:data MID = 0x%04x\n",
1892 ft1000_write_reg(dev, FT1000_REG_UFIFO_END,
1895 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1896 i + 8, htons(*packet));
1898 ft1000_write_reg(dev, FT1000_REG_UFIFO_END,
1901 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1902 i + 8, htons(*packet));
1905 outl(*(u32 *) & pseudo.buff[0],
1906 dev->base_addr + FT1000_REG_MAG_UFDR);
1907 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1908 *(u32 *) & pseudo.buff[0]);
1909 outl(*(u32 *) & pseudo.buff[2],
1910 dev->base_addr + FT1000_REG_MAG_UFDR);
1911 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1912 *(u32 *) & pseudo.buff[2]);
1913 outl(*(u32 *) & pseudo.buff[4],
1914 dev->base_addr + FT1000_REG_MAG_UFDR);
1915 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1916 *(u32 *) & pseudo.buff[4]);
1917 outl(*(u32 *) & pseudo.buff[6],
1918 dev->base_addr + FT1000_REG_MAG_UFDR);
1919 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1920 *(u32 *) & pseudo.buff[6]);
1922 plong = (u32 *) packet;
1923 // Write PPP type + IP Packet into Downlink FIFO
1924 for (i = 0; i < (len >> 2); i++) {
1925 outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR);
1928 // Check for odd alignment
1931 "ft1000_hw:ft1000_copy_down_pkt:data = 0x%8x\n",
1933 outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR);
1935 outl(1, dev->base_addr + FT1000_REG_MAG_UFER);
1938 info->stats.tx_packets++;
1939 // Add 14 bytes for MAC adddress plus ethernet type
1940 info->stats.tx_bytes += (len + 14);
1944 static struct net_device_stats *ft1000_stats(struct net_device *dev)
1946 FT1000_INFO *info = netdev_priv(dev);
1947 return (&info->stats);
1950 static int ft1000_open(struct net_device *dev)
1953 DEBUG(0, "ft1000_hw: ft1000_open is called\n");
1955 ft1000_reset_card(dev);
1956 DEBUG(0, "ft1000_hw: ft1000_open is ended\n");
1958 /* schedule ft1000_hbchk to perform periodic heartbeat checks on DSP and ASIC */
1959 init_timer(&poll_timer);
1960 poll_timer.expires = jiffies + (2 * HZ);
1961 poll_timer.data = (u_long) dev;
1962 add_timer(&poll_timer);
1964 DEBUG(0, "ft1000_hw: ft1000_open is ended2\n");
1968 static int ft1000_close(struct net_device *dev)
1970 FT1000_INFO *info = netdev_priv(dev);
1972 DEBUG(0, "ft1000_hw: ft1000_close()\n");
1974 info->CardReady = 0;
1975 del_timer(&poll_timer);
1977 if (ft1000_card_present == 1) {
1978 DEBUG(0, "Media is down\n");
1979 netif_stop_queue(dev);
1981 ft1000_disable_interrupts(dev);
1982 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
1985 ft1000_reset_asic(dev);
1990 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
1992 FT1000_INFO *info = netdev_priv(dev);
1995 DEBUG(1, "ft1000_hw: ft1000_start_xmit()\n");
1997 DEBUG(1, "ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n");
2001 DEBUG(1, "ft1000_hw: ft1000_start_xmit:length of packet = %d\n",
2004 pdata = (u8 *) skb->data;
2006 if (info->mediastate == 0) {
2007 /* Drop packet is mediastate is down */
2008 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:mediastate is down\n");
2012 if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) {
2013 /* Drop packet which has invalid size */
2015 "ft1000_hw:ft1000_copy_down_pkt:invalid ethernet length\n");
2018 ft1000_copy_down_pkt(dev, (u16 *) (pdata + ENET_HEADER_SIZE - 2),
2019 skb->len - ENET_HEADER_SIZE + 2);
2026 static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
2028 struct net_device *dev = (struct net_device *)dev_id;
2029 FT1000_INFO *info = netdev_priv(dev);
2034 DEBUG(1, "ft1000_hw: ft1000_interrupt()\n");
2036 if (info->CardReady == 0) {
2037 ft1000_disable_interrupts(dev);
2041 if (ft1000_chkcard(dev) == FALSE) {
2042 ft1000_disable_interrupts(dev);
2046 ft1000_disable_interrupts(dev);
2048 // Read interrupt type
2049 inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
2051 // Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type
2053 if (inttype & ISR_DOORBELL_PEND) {
2054 ft1000_parse_dpram_msg(dev);
2057 if (inttype & ISR_RCV) {
2058 DEBUG(1, "Data in FIFO\n");
2062 // Check if we have packets in the Downlink FIFO
2063 if (info->AsicID == ELECTRABUZZ_ID) {
2065 ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT);
2068 ft1000_read_reg(dev, FT1000_REG_MAG_DFSR);
2070 if (tempword & 0x1f) {
2071 ft1000_copy_up_pkt(dev);
2076 } while (cnt < MAX_RCV_LOOP);
2080 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
2081 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
2082 ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
2084 // Read interrupt type
2085 inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR);
2086 DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype);
2088 ft1000_enable_interrupts(dev);
2092 void stop_ft1000_card(struct net_device *dev)
2094 FT1000_INFO *info = netdev_priv(dev);
2098 DEBUG(0, "ft1000_hw: stop_ft1000_card()\n");
2100 info->CardReady = 0;
2101 ft1000_card_present = 0;
2102 netif_stop_queue(dev);
2103 ft1000_disable_interrupts(dev);
2105 // Make sure we free any memory reserve for provisioning
2106 while (list_empty(&info->prov_list) == 0) {
2107 ptr = list_entry(info->prov_list.next, PROV_RECORD, list);
2108 list_del(&ptr->list);
2109 kfree(ptr->pprov_data);
2113 if (info->registered) {
2114 unregister_netdev(dev);
2115 info->registered = 0;
2118 free_irq(dev->irq, dev);
2119 release_region(dev->base_addr,256);
2120 release_firmware(fw_entry);
2121 flarion_ft1000_cnt--;
2122 ft1000CleanupProc(dev);
2126 static void ft1000_get_drvinfo(struct net_device *dev,
2127 struct ethtool_drvinfo *info)
2129 FT1000_INFO *ft_info;
2130 ft_info = netdev_priv(dev);
2132 snprintf(info->driver, 32, "ft1000");
2133 snprintf(info->bus_info, ETHTOOL_BUSINFO_LEN, "PCMCIA 0x%lx",
2135 snprintf(info->fw_version, 32, "%d.%d.%d.%d", ft_info->DspVer[0],
2136 ft_info->DspVer[1], ft_info->DspVer[2], ft_info->DspVer[3]);
2139 static u32 ft1000_get_link(struct net_device *dev)
2142 info = netdev_priv(dev);
2143 return info->mediastate;
2146 static const struct ethtool_ops ops = {
2147 .get_drvinfo = ft1000_get_drvinfo,
2148 .get_link = ft1000_get_link
2151 struct net_device *init_ft1000_card(unsigned short irq, int port,
2152 unsigned char *mac_addr, void *ft1000_reset,
2153 void *link, struct device *fdev)
2156 struct net_device *dev;
2159 static const struct net_device_ops ft1000ops = // Slavius 21.10.2009 due to kernel changes
2161 .ndo_open = &ft1000_open,
2162 .ndo_stop = &ft1000_close,
2163 .ndo_start_xmit = &ft1000_start_xmit,
2164 .ndo_get_stats = &ft1000_stats,
2167 DEBUG(1, "ft1000_hw: init_ft1000_card()\n");
2168 DEBUG(1, "ft1000_hw: irq = %d\n", irq);
2169 DEBUG(1, "ft1000_hw: port = 0x%04x\n", port);
2171 flarion_ft1000_cnt++;
2173 if (flarion_ft1000_cnt > 1) {
2174 flarion_ft1000_cnt--;
2177 "ft1000: This driver can not support more than one instance\n");
2181 dev = alloc_etherdev(sizeof(FT1000_INFO));
2183 printk(KERN_ERR "ft1000: failed to allocate etherdev\n");
2187 SET_NETDEV_DEV(dev, fdev);
2188 info = netdev_priv(dev);
2190 memset(info, 0, sizeof(FT1000_INFO));
2192 DEBUG(1, "address of dev = 0x%8x\n", (u32) dev);
2193 DEBUG(1, "address of dev info = 0x%8x\n", (u32) info);
2194 DEBUG(0, "device name = %s\n", dev->name);
2196 memset(&info->stats, 0, sizeof(struct net_device_stats));
2198 spin_lock_init(&info->dpram_lock);
2199 info->DrvErrNum = 0;
2200 info->ASICResetNum = 0;
2201 info->registered = 1;
2203 info->ft1000_reset = ft1000_reset;
2204 info->mediastate = 0;
2206 info->DeviceCreated = FALSE;
2207 info->DeviceMajor = 0;
2208 info->CurrentInterruptEnableMask = ISR_DEFAULT_MASK;
2209 info->InterruptsEnabled = FALSE;
2210 info->CardReady = 0;
2211 info->DSP_TIME[0] = 0;
2212 info->DSP_TIME[1] = 0;
2213 info->DSP_TIME[2] = 0;
2214 info->DSP_TIME[3] = 0;
2215 flarion_ft1000_cnt = 0;
2217 INIT_LIST_HEAD(&info->prov_list);
2219 info->squeseqnum = 0;
2221 // dev->hard_start_xmit = &ft1000_start_xmit;
2222 // dev->get_stats = &ft1000_stats;
2223 // dev->open = &ft1000_open;
2224 // dev->stop = &ft1000_close;
2226 dev->netdev_ops = &ft1000ops; // Slavius 21.10.2009 due to kernel changes
2228 DEBUG(0, "device name = %s\n", dev->name);
2230 for (i = 0; i < 6; i++) {
2231 dev->dev_addr[i] = mac_addr[i];
2232 DEBUG(1, "ft1000_hw: mac_addr %d = 0x%02x\n", i, mac_addr[i]);
2235 netif_stop_queue(dev);
2237 dev->base_addr = port;
2239 if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
2240 printk(KERN_ERR "ft1000: Could not request_irq\n");
2244 if (request_region(dev->base_addr, 256, dev->name) == NULL) {
2245 printk(KERN_ERR "ft1000: Could not request_region\n");
2249 if (register_netdev(dev) != 0) {
2250 DEBUG(0, "ft1000: Could not register netdev");
2254 info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
2255 if (info->AsicID == ELECTRABUZZ_ID) {
2256 DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n");
2257 if (request_firmware(&fw_entry, "ft1000.img", fdev) != 0) {
2258 printk(KERN_INFO "ft1000: Could not open ft1000.img\n");
2262 DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n");
2263 if (request_firmware(&fw_entry, "ft2000.img", fdev) != 0) {
2264 printk(KERN_INFO "ft1000: Could not open ft2000.img\n");
2269 ft1000_enable_interrupts(dev);
2271 ft1000InitProc(dev);
2272 ft1000_card_present = 1;
2273 SET_ETHTOOL_OPS(dev, &ops);
2275 "ft1000: %s: addr 0x%04lx irq %d, MAC addr %02x:%02x:%02x:%02x:%02x:%02x\n",
2276 dev->name, dev->base_addr, dev->irq, dev->dev_addr[0],
2277 dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3],
2278 dev->dev_addr[4], dev->dev_addr[5]);
2282 unregister_netdev(dev);
2284 release_region(dev->base_addr, 256);
2286 free_irq(dev->irq, dev);
2292 EXPORT_SYMBOL(init_ft1000_card);
2293 EXPORT_SYMBOL(stop_ft1000_card);
2294 EXPORT_SYMBOL(flarion_ft1000_cnt);