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
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);
339 * Let's use the register provided by the Magnemite ASIC to reset the
342 if (info->AsicID == MAGNEMITE_ID) {
343 ft1000_write_reg(dev, FT1000_REG_RESET,
344 (DSP_RESET_BIT | ASIC_RESET_BIT));
347 if (info->AsicID == ELECTRABUZZ_ID) {
348 /* set watermark to -1 in order to not generate an interrupt */
349 ft1000_write_reg(dev, FT1000_REG_WATERMARK, 0xffff);
351 /* set watermark to -1 in order to not generate an interrupt */
352 ft1000_write_reg(dev, FT1000_REG_MAG_WATERMARK, 0xffff);
354 /* clear interrupts */
355 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
356 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
357 ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
358 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
359 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
363 /*---------------------------------------------------------------------------
365 Function: ft1000_reset_card
366 Description: This function will reset the card
368 dev - device structure
370 status - false (card reset fail)
371 true (card reset successful)
373 -------------------------------------------------------------------------*/
374 static int ft1000_reset_card(struct net_device *dev)
376 struct ft1000_info *info = netdev_priv(dev);
380 struct prov_record *ptr;
382 DEBUG(1, "ft1000_hw:ft1000_reset_card called.....\n");
385 info->ProgConStat = 0;
386 info->squeseqnum = 0;
387 ft1000_disable_interrupts(dev);
389 /* del_timer(&poll_timer); */
391 /* Make sure we free any memory reserve for provisioning */
392 while (list_empty(&info->prov_list) == 0) {
394 "ft1000_hw:ft1000_reset_card:deleting provisioning record\n");
395 ptr = list_entry(info->prov_list.next, struct prov_record, list);
396 list_del(&ptr->list);
397 kfree(ptr->pprov_data);
401 if (info->AsicID == ELECTRABUZZ_ID) {
402 DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting DSP\n");
403 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
406 "ft1000_hw:ft1000_reset_card:resetting ASIC and DSP\n");
407 ft1000_write_reg(dev, FT1000_REG_RESET,
408 (DSP_RESET_BIT | ASIC_RESET_BIT));
411 /* Copy DSP session record into info block if this is not a coldstart */
412 if (ft1000_card_present == 1) {
413 spin_lock_irqsave(&info->dpram_lock, flags);
414 if (info->AsicID == ELECTRABUZZ_ID) {
415 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
416 FT1000_DPRAM_RX_BASE);
417 for (i = 0; i < MAX_DSP_SESS_REC; i++) {
418 info->DSPSess.Rec[i] =
420 FT1000_REG_DPRAM_DATA);
423 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
424 FT1000_DPRAM_MAG_RX_BASE);
425 for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) {
426 info->DSPSess.MagRec[i] =
427 inl(dev->base_addr + FT1000_REG_MAG_DPDATA);
430 spin_unlock_irqrestore(&info->dpram_lock, flags);
433 DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting ASIC\n");
436 ft1000_reset_asic(dev);
438 DEBUG(1, "ft1000_hw:ft1000_reset_card:downloading dsp image\n");
440 if (info->AsicID == MAGNEMITE_ID) {
441 /* Put dsp in reset and take ASIC out of reset */
443 "ft1000_hw:ft1000_reset_card:Put DSP in reset and take ASIC out of reset\n");
444 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
446 /* Setting MAGNEMITE ASIC to big endian mode */
447 ft1000_write_reg(dev, FT1000_REG_SUP_CTRL, HOST_INTF_BE);
448 /* Download bootloader */
451 /* Take DSP out of reset */
452 ft1000_write_reg(dev, FT1000_REG_RESET, 0);
453 /* FLARION_DSP_ACTIVE; */
455 DEBUG(0, "ft1000_hw:ft1000_reset_card:Take DSP out of reset\n");
457 /* Wait for 0xfefe indicating dsp ready before starting download */
458 for (i = 0; i < 50; i++) {
460 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DPRAM_FEFE,
461 FT1000_MAG_DPRAM_FEFE_INDX);
462 if (tempword == 0xfefe) {
470 "ft1000_hw:ft1000_reset_card:No FEFE detected from DSP\n");
475 /* Take DSP out of reset */
476 ft1000_write_reg(dev, FT1000_REG_RESET, ~DSP_RESET_BIT);
480 if (card_download(dev, fw_entry->data, fw_entry->size)) {
481 DEBUG(1, "card download unsuccessful\n");
484 DEBUG(1, "card download successful\n");
489 if (info->AsicID == ELECTRABUZZ_ID) {
491 * Need to initialize the FIFO length counter to zero in order to sync up
495 ft1000_write_dpram(dev, FT1000_FIFO_LEN, info->fifo_cnt);
496 /* Initialize DSP heartbeat area to ho */
497 ft1000_write_dpram(dev, FT1000_HI_HO, ho);
498 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
499 DEBUG(1, "ft1000_hw:ft1000_reset_asic:hi_ho value = 0x%x\n",
502 /* Initialize DSP heartbeat area to ho */
503 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, ho_mag,
504 FT1000_MAG_HI_HO_INDX);
506 ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO,
507 FT1000_MAG_HI_HO_INDX);
508 DEBUG(1, "ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n",
513 ft1000_enable_interrupts(dev);
515 /* Schedule heartbeat process to run every 2 seconds */
516 /* poll_timer.expires = jiffies + (2*HZ); */
517 /* poll_timer.data = (u_long)dev; */
518 /* add_timer(&poll_timer); */
524 /*---------------------------------------------------------------------------
526 Function: ft1000_chkcard
527 Description: This function will check if the device is presently available on
530 dev - device structure
532 status - false (device is not present)
533 true (device is present)
535 -------------------------------------------------------------------------*/
536 static int ft1000_chkcard(struct net_device *dev)
541 * Mask register is used to check for device presence since it is never
544 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);
547 "ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");
551 * The system will return the value of 0xffff for the version register
552 * if the device is not present.
554 tempword = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
555 if (tempword == 0xffff) {
557 "ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n");
564 /*---------------------------------------------------------------------------
566 Function: ft1000_hbchk
567 Description: This function will perform the heart beat check of the DSP as
570 dev - device structure
574 -------------------------------------------------------------------------*/
575 static void ft1000_hbchk(u_long data)
577 struct net_device *dev = (struct net_device *)data;
579 struct ft1000_info *info;
582 info = netdev_priv(dev);
584 if (info->CardReady == 1) {
585 /* Perform dsp heartbeat check */
586 if (info->AsicID == ELECTRABUZZ_ID) {
587 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
590 ntohs(ft1000_read_dpram_mag_16
591 (dev, FT1000_MAG_HI_HO,
592 FT1000_MAG_HI_HO_INDX));
594 DEBUG(1, "ft1000_hw:ft1000_hbchk:hi_ho value = 0x%x\n",
596 /* Let's perform another check if ho is not detected */
597 if (tempword != ho) {
598 if (info->AsicID == ELECTRABUZZ_ID) {
599 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
602 tempword = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX));
605 if (tempword != ho) {
607 "ft1000: heartbeat failed - no ho detected\n");
608 if (info->AsicID == ELECTRABUZZ_ID) {
610 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
612 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
614 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
616 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
619 ft1000_read_dpram_mag_16(dev,
620 FT1000_MAG_DSP_TIMER0,
621 FT1000_MAG_DSP_TIMER0_INDX);
623 ft1000_read_dpram_mag_16(dev,
624 FT1000_MAG_DSP_TIMER1,
625 FT1000_MAG_DSP_TIMER1_INDX);
627 ft1000_read_dpram_mag_16(dev,
628 FT1000_MAG_DSP_TIMER2,
629 FT1000_MAG_DSP_TIMER2_INDX);
631 ft1000_read_dpram_mag_16(dev,
632 FT1000_MAG_DSP_TIMER3,
633 FT1000_MAG_DSP_TIMER3_INDX);
635 info->DrvErrNum = DSP_HB_INFO;
636 if (ft1000_reset_card(dev) == 0) {
638 "ft1000: Hardware Failure Detected - PC Card disabled\n");
639 info->ProgConStat = 0xff;
642 /* Schedule this module to run every 2 seconds */
643 poll_timer.expires = jiffies + (2*HZ);
644 poll_timer.data = (u_long)dev;
645 add_timer(&poll_timer);
649 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
650 /* Let's check doorbell again if fail */
651 if (tempword & FT1000_DB_HB) {
652 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
654 if (tempword & FT1000_DB_HB) {
656 "ft1000: heartbeat doorbell not clear by firmware\n");
657 if (info->AsicID == ELECTRABUZZ_ID) {
659 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
661 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
663 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
665 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
668 ft1000_read_dpram_mag_16(dev,
669 FT1000_MAG_DSP_TIMER0,
670 FT1000_MAG_DSP_TIMER0_INDX);
672 ft1000_read_dpram_mag_16(dev,
673 FT1000_MAG_DSP_TIMER1,
674 FT1000_MAG_DSP_TIMER1_INDX);
676 ft1000_read_dpram_mag_16(dev,
677 FT1000_MAG_DSP_TIMER2,
678 FT1000_MAG_DSP_TIMER2_INDX);
680 ft1000_read_dpram_mag_16(dev,
681 FT1000_MAG_DSP_TIMER3,
682 FT1000_MAG_DSP_TIMER3_INDX);
684 info->DrvErrNum = DSP_HB_INFO;
685 if (ft1000_reset_card(dev) == 0) {
687 "ft1000: Hardware Failure Detected - PC Card disabled\n");
688 info->ProgConStat = 0xff;
691 /* Schedule this module to run every 2 seconds */
692 poll_timer.expires = jiffies + (2*HZ);
693 poll_timer.data = (u_long)dev;
694 add_timer(&poll_timer);
698 * Set dedicated area to hi and ring appropriate doorbell according
699 * to hi/ho heartbeat protocol
701 if (info->AsicID == ELECTRABUZZ_ID) {
702 ft1000_write_dpram(dev, FT1000_HI_HO, hi);
704 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, hi_mag,
705 FT1000_MAG_HI_HO_INDX);
708 if (info->AsicID == ELECTRABUZZ_ID) {
709 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
712 ntohs(ft1000_read_dpram_mag_16
713 (dev, FT1000_MAG_HI_HO,
714 FT1000_MAG_HI_HO_INDX));
716 /* Let's write hi again if fail */
717 if (tempword != hi) {
718 if (info->AsicID == ELECTRABUZZ_ID) {
719 ft1000_write_dpram(dev, FT1000_HI_HO, hi);
722 ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, hi_mag, FT1000_MAG_HI_HO_INDX);
725 if (info->AsicID == ELECTRABUZZ_ID) {
726 tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
729 tempword = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX));
734 if (tempword != hi) {
736 "ft1000: heartbeat failed - cannot write hi into DPRAM\n");
737 if (info->AsicID == ELECTRABUZZ_ID) {
739 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
741 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
743 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
745 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
748 ft1000_read_dpram_mag_16(dev,
749 FT1000_MAG_DSP_TIMER0,
750 FT1000_MAG_DSP_TIMER0_INDX);
752 ft1000_read_dpram_mag_16(dev,
753 FT1000_MAG_DSP_TIMER1,
754 FT1000_MAG_DSP_TIMER1_INDX);
756 ft1000_read_dpram_mag_16(dev,
757 FT1000_MAG_DSP_TIMER2,
758 FT1000_MAG_DSP_TIMER2_INDX);
760 ft1000_read_dpram_mag_16(dev,
761 FT1000_MAG_DSP_TIMER3,
762 FT1000_MAG_DSP_TIMER3_INDX);
764 info->DrvErrNum = DSP_HB_INFO;
765 if (ft1000_reset_card(dev) == 0) {
767 "ft1000: Hardware Failure Detected - PC Card disabled\n");
768 info->ProgConStat = 0xff;
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 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_HB);
781 /* Schedule this module to run every 2 seconds */
782 poll_timer.expires = jiffies + (2 * HZ);
783 poll_timer.data = (u_long) dev;
784 add_timer(&poll_timer);
787 /*---------------------------------------------------------------------------
789 Function: ft1000_send_cmd
794 -------------------------------------------------------------------------*/
795 static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype)
797 struct ft1000_info *info = netdev_priv(dev);
802 size += sizeof(struct pseudo_hdr);
803 /* check for odd byte and increment to 16-bit word align value */
804 if ((size & 0x0001)) {
807 DEBUG(1, "FT1000:ft1000_send_cmd:total length = %d\n", size);
808 DEBUG(1, "FT1000:ft1000_send_cmd:length = %d\n", ntohs(*ptempbuffer));
810 * put message into slow queue area
811 * All messages are in the form total_len + pseudo header + message body
813 spin_lock_irqsave(&info->dpram_lock, flags);
815 /* Make sure SLOWQ doorbell is clear */
816 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
818 while (tempword & FT1000_DB_DPRAM_TX) {
822 spin_unlock_irqrestore(&info->dpram_lock, flags);
825 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
828 if (info->AsicID == ELECTRABUZZ_ID) {
829 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
830 FT1000_DPRAM_TX_BASE);
831 /* Write total length to dpram */
832 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, size);
833 /* Write pseudo header and messgae body */
834 for (i = 0; i < (size >> 1); i++) {
835 DEBUG(1, "FT1000:ft1000_send_cmd:data %d = 0x%x\n", i,
837 tempword = htons(*ptempbuffer++);
838 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, tempword);
841 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
842 FT1000_DPRAM_MAG_TX_BASE);
843 /* Write total length to dpram */
844 ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAH, htons(size));
845 /* Write pseudo header and messgae body */
846 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
847 FT1000_DPRAM_MAG_TX_BASE + 1);
848 for (i = 0; i < (size >> 2); i++) {
849 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n",
852 dev->base_addr + FT1000_REG_MAG_DPDATAL);
853 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n",
856 dev->base_addr + FT1000_REG_MAG_DPDATAH);
858 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer);
859 outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAL);
860 DEBUG(1, "FT1000:ft1000_send_cmd:data = 0x%x\n", *ptempbuffer);
861 outw(*ptempbuffer++, dev->base_addr + FT1000_REG_MAG_DPDATAH);
863 spin_unlock_irqrestore(&info->dpram_lock, flags);
865 /* ring doorbell to notify DSP that we have a message ready */
866 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_DPRAM_TX);
869 /*---------------------------------------------------------------------------
871 Function: ft1000_receive_cmd
872 Description: This function will read a message from the dpram area.
874 dev - network device structure
875 pbuffer - caller supply address to buffer
876 pnxtph - pointer to next pseudo header
878 Status = 0 (unsuccessful)
881 -------------------------------------------------------------------------*/
882 static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,
883 int maxsz, u16 *pnxtph)
885 struct ft1000_info *info = netdev_priv(dev);
892 if (info->AsicID == ELECTRABUZZ_ID) {
893 size = ( ft1000_read_dpram(dev, *pnxtph) ) + sizeof(struct pseudo_hdr);
896 ntohs(ft1000_read_dpram_mag_16
897 (dev, FT1000_MAG_PH_LEN,
898 FT1000_MAG_PH_LEN_INDX)) + sizeof(struct pseudo_hdr);
902 "FT1000:ft1000_receive_cmd:Invalid command length = %d\n",
906 ppseudohdr = (u16 *) pbuffer;
907 spin_lock_irqsave(&info->dpram_lock, flags);
908 if (info->AsicID == ELECTRABUZZ_ID) {
909 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
910 FT1000_DPRAM_RX_BASE + 2);
911 for (i = 0; i <= (size >> 1); i++) {
913 ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
914 *pbuffer++ = ntohs(tempword);
917 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
918 FT1000_DPRAM_MAG_RX_BASE);
919 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
920 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
922 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
923 FT1000_DPRAM_MAG_RX_BASE + 1);
924 for (i = 0; i <= (size >> 2); i++) {
927 FT1000_REG_MAG_DPDATAL);
931 FT1000_REG_MAG_DPDATAH);
934 /* copy odd aligned word */
935 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAL);
936 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
938 *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
939 DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);
943 /* copy odd byte from fifo */
944 tempword = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
945 *pbuffer = ntohs(tempword);
947 spin_unlock_irqrestore(&info->dpram_lock, flags);
950 * Check if pseudo header checksum is good
951 * Calculate pseudo header checksum
953 tempword = *ppseudohdr++;
954 for (i = 1; i < 7; i++) {
955 tempword ^= *ppseudohdr++;
957 if ((tempword != *ppseudohdr)) {
959 "FT1000:ft1000_receive_cmd:Pseudo header checksum mismatch\n");
960 /* Drop this message */
967 /*---------------------------------------------------------------------------
969 Function: ft1000_proc_drvmsg
970 Description: This function will process the various driver messages.
972 dev - device structure
973 pnxtph - pointer to next pseudo header
977 -------------------------------------------------------------------------*/
978 static void ft1000_proc_drvmsg(struct net_device *dev)
980 struct ft1000_info *info = netdev_priv(dev);
983 struct media_msg *pmediamsg;
984 struct dsp_init_msg *pdspinitmsg;
985 struct drv_msg *pdrvmsg;
988 struct prov_record *ptr;
989 struct pseudo_hdr *ppseudo_hdr;
997 if (info->AsicID == ELECTRABUZZ_ID) {
998 tempword = FT1000_DPRAM_RX_BASE+2;
1001 tempword = FT1000_DPRAM_MAG_RX_BASE;
1003 if ( ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword) ) {
1005 /* Get the message type which is total_len + PSEUDO header + msgtype + message body */
1006 pdrvmsg = (struct drv_msg *) & cmdbuffer[0];
1007 msgtype = ntohs(pdrvmsg->type);
1008 DEBUG(1, "Command message type = 0x%x\n", msgtype);
1012 "Got a provisioning request message from DSP\n");
1014 while (list_empty(&info->prov_list) == 0) {
1015 DEBUG(0, "Sending a provisioning message\n");
1016 /* Make sure SLOWQ doorbell is clear */
1018 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1020 while (tempword & FT1000_DB_DPRAM_TX) {
1028 list_entry(info->prov_list.next,
1029 struct prov_record, list);
1030 len = *(u16 *) ptr->pprov_data;
1033 pmsg = (u16 *) ptr->pprov_data;
1034 ppseudo_hdr = (struct pseudo_hdr *) pmsg;
1035 /* Insert slow queue sequence number */
1036 ppseudo_hdr->seq_num = info->squeseqnum++;
1037 ppseudo_hdr->portsrc = 0;
1038 /* Calculate new checksum */
1039 ppseudo_hdr->checksum = *pmsg++;
1040 DEBUG(1, "checksum = 0x%x\n",
1041 ppseudo_hdr->checksum);
1042 for (i = 1; i < 7; i++) {
1043 ppseudo_hdr->checksum ^= *pmsg++;
1044 DEBUG(1, "checksum = 0x%x\n",
1045 ppseudo_hdr->checksum);
1048 ft1000_send_cmd (dev, (u16 *)ptr->pprov_data, len, SLOWQ_TYPE);
1049 list_del(&ptr->list);
1050 kfree(ptr->pprov_data);
1054 * Indicate adapter is ready to take application messages after all
1055 * provisioning messages are sent
1057 info->CardReady = 1;
1060 pmediamsg = (struct media_msg *) & cmdbuffer[0];
1061 if (info->ProgConStat != 0xFF) {
1062 if (pmediamsg->state) {
1063 DEBUG(1, "Media is up\n");
1064 if (info->mediastate == 0) {
1065 netif_carrier_on(dev);
1066 netif_wake_queue(dev);
1067 info->mediastate = 1;
1068 do_gettimeofday(&tv);
1069 info->ConTm = tv.tv_sec;
1072 DEBUG(1, "Media is down\n");
1073 if (info->mediastate == 1) {
1074 info->mediastate = 0;
1075 netif_carrier_off(dev);
1076 netif_stop_queue(dev);
1082 DEBUG(1,"Media is down\n");
1083 if (info->mediastate == 1) {
1084 info->mediastate = 0;
1085 netif_carrier_off(dev);
1086 netif_stop_queue(dev);
1092 pdspinitmsg = (struct dsp_init_msg *) & cmdbuffer[0];
1093 memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ);
1094 DEBUG(1, "DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n",
1095 info->DspVer[0], info->DspVer[1], info->DspVer[2],
1097 memcpy(info->HwSerNum, pdspinitmsg->HwSerNum,
1099 memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ);
1100 memcpy(info->eui64, pdspinitmsg->eui64, EUISZ);
1101 dev->dev_addr[0] = info->eui64[0];
1102 dev->dev_addr[1] = info->eui64[1];
1103 dev->dev_addr[2] = info->eui64[2];
1104 dev->dev_addr[3] = info->eui64[5];
1105 dev->dev_addr[4] = info->eui64[6];
1106 dev->dev_addr[5] = info->eui64[7];
1108 if (ntohs(pdspinitmsg->length) ==
1109 (sizeof(struct dsp_init_msg) - 20)) {
1110 memcpy(info->ProductMode,
1111 pdspinitmsg->ProductMode, MODESZ);
1112 memcpy(info->RfCalVer, pdspinitmsg->RfCalVer,
1114 memcpy(info->RfCalDate, pdspinitmsg->RfCalDate,
1116 DEBUG(1, "RFCalVer = 0x%2x 0x%2x\n",
1117 info->RfCalVer[0], info->RfCalVer[1]);
1121 case DSP_STORE_INFO:
1122 DEBUG(1, "FT1000:drivermsg:Got DSP_STORE_INFO\n");
1123 tempword = ntohs(pdrvmsg->length);
1124 info->DSPInfoBlklen = tempword;
1125 if (tempword < (MAX_DSP_SESS_REC - 4)) {
1126 pmsg = (u16 *) & pdrvmsg->data[0];
1127 for (i = 0; i < ((tempword + 1) / 2); i++) {
1129 "FT1000:drivermsg:dsp info data = 0x%x\n",
1131 info->DSPInfoBlk[i + 10] = *pmsg++;
1136 DEBUG(1, "FT1000:drivermsg:Got DSP_GET_INFO\n");
1138 * copy dsp info block to dsp
1139 * allow any outstanding ioctl to finish
1142 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1143 if (tempword & FT1000_DB_DPRAM_TX) {
1146 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1147 if (tempword & FT1000_DB_DPRAM_TX) {
1152 if ((tempword & FT1000_DB_DPRAM_TX) == 0) {
1154 * Put message into Slow Queue
1155 * Form Pseudo header
1157 pmsg = (u16 *) info->DSPInfoBlk;
1158 ppseudo_hdr = (struct pseudo_hdr *) pmsg;
1159 ppseudo_hdr->length =
1160 htons(info->DSPInfoBlklen + 4);
1161 ppseudo_hdr->source = 0x10;
1162 ppseudo_hdr->destination = 0x20;
1163 ppseudo_hdr->portdest = 0;
1164 ppseudo_hdr->portsrc = 0;
1165 ppseudo_hdr->sh_str_id = 0;
1166 ppseudo_hdr->control = 0;
1167 ppseudo_hdr->rsvd1 = 0;
1168 ppseudo_hdr->rsvd2 = 0;
1169 ppseudo_hdr->qos_class = 0;
1170 /* Insert slow queue sequence number */
1171 ppseudo_hdr->seq_num = info->squeseqnum++;
1172 /* Insert application id */
1173 ppseudo_hdr->portsrc = 0;
1174 /* Calculate new checksum */
1175 ppseudo_hdr->checksum = *pmsg++;
1176 for (i = 1; i < 7; i++) {
1177 ppseudo_hdr->checksum ^= *pmsg++;
1179 info->DSPInfoBlk[8] = 0x7200;
1180 info->DSPInfoBlk[9] =
1181 htons(info->DSPInfoBlklen);
1182 ft1000_send_cmd (dev, (u16 *)info->DSPInfoBlk, (u16)(info->DSPInfoBlklen+4), 0);
1186 case GET_DRV_ERR_RPT_MSG:
1187 DEBUG(1, "FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n");
1189 * copy driver error message to dsp
1190 * allow any outstanding ioctl to finish
1193 tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1194 if (tempword & FT1000_DB_DPRAM_TX) {
1197 ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1198 if (tempword & FT1000_DB_DPRAM_TX) {
1203 if ((tempword & FT1000_DB_DPRAM_TX) == 0) {
1205 * Put message into Slow Queue
1206 * Form Pseudo header
1208 pmsg = (u16 *) & tempbuffer[0];
1209 ppseudo_hdr = (struct pseudo_hdr *) pmsg;
1210 ppseudo_hdr->length = htons(0x0012);
1211 ppseudo_hdr->source = 0x10;
1212 ppseudo_hdr->destination = 0x20;
1213 ppseudo_hdr->portdest = 0;
1214 ppseudo_hdr->portsrc = 0;
1215 ppseudo_hdr->sh_str_id = 0;
1216 ppseudo_hdr->control = 0;
1217 ppseudo_hdr->rsvd1 = 0;
1218 ppseudo_hdr->rsvd2 = 0;
1219 ppseudo_hdr->qos_class = 0;
1220 /* Insert slow queue sequence number */
1221 ppseudo_hdr->seq_num = info->squeseqnum++;
1222 /* Insert application id */
1223 ppseudo_hdr->portsrc = 0;
1224 /* Calculate new checksum */
1225 ppseudo_hdr->checksum = *pmsg++;
1226 for (i=1; i<7; i++) {
1227 ppseudo_hdr->checksum ^= *pmsg++;
1229 pmsg = (u16 *) & tempbuffer[16];
1230 *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG);
1231 *pmsg++ = htons(0x000e);
1232 *pmsg++ = htons(info->DSP_TIME[0]);
1233 *pmsg++ = htons(info->DSP_TIME[1]);
1234 *pmsg++ = htons(info->DSP_TIME[2]);
1235 *pmsg++ = htons(info->DSP_TIME[3]);
1236 convert.byte[0] = info->DspVer[0];
1237 convert.byte[1] = info->DspVer[1];
1238 *pmsg++ = convert.wrd;
1239 convert.byte[0] = info->DspVer[2];
1240 convert.byte[1] = info->DspVer[3];
1241 *pmsg++ = convert.wrd;
1242 *pmsg++ = htons(info->DrvErrNum);
1244 ft1000_send_cmd (dev, (u16 *)&tempbuffer[0], (u16)(0x0012), 0);
1245 info->DrvErrNum = 0;
1255 /*---------------------------------------------------------------------------
1257 Function: ft1000_parse_dpram_msg
1258 Description: This function will parse the message received from the DSP
1259 via the DPRAM interface.
1261 dev - device structure
1266 -------------------------------------------------------------------------*/
1267 static int ft1000_parse_dpram_msg(struct net_device *dev)
1269 struct ft1000_info *info = netdev_priv(dev);
1276 unsigned long flags;
1278 doorbell = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
1279 DEBUG(1, "Doorbell = 0x%x\n", doorbell);
1281 if (doorbell & FT1000_ASIC_RESET_REQ) {
1282 /* Copy DSP session record from info block */
1283 spin_lock_irqsave(&info->dpram_lock, flags);
1284 if (info->AsicID == ELECTRABUZZ_ID) {
1285 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
1286 FT1000_DPRAM_RX_BASE);
1287 for (i = 0; i < MAX_DSP_SESS_REC; i++) {
1288 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA,
1289 info->DSPSess.Rec[i]);
1292 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
1293 FT1000_DPRAM_MAG_RX_BASE);
1294 for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) {
1295 outl(info->DSPSess.MagRec[i],
1296 dev->base_addr + FT1000_REG_MAG_DPDATA);
1299 spin_unlock_irqrestore(&info->dpram_lock, flags);
1301 /* clear ASIC RESET request */
1302 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1303 FT1000_ASIC_RESET_REQ);
1304 DEBUG(1, "Got an ASIC RESET Request\n");
1305 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1306 FT1000_ASIC_RESET_DSP);
1308 if (info->AsicID == MAGNEMITE_ID) {
1309 /* Setting MAGNEMITE ASIC to big endian mode */
1310 ft1000_write_reg(dev, FT1000_REG_SUP_CTRL,
1315 if (doorbell & FT1000_DSP_ASIC_RESET) {
1317 "FT1000:ft1000_parse_dpram_msg: Got a dsp ASIC reset message\n");
1318 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1319 FT1000_DSP_ASIC_RESET);
1324 if (doorbell & FT1000_DB_DPRAM_RX) {
1326 "FT1000:ft1000_parse_dpram_msg: Got a slow queue message\n");
1327 nxtph = FT1000_DPRAM_RX_BASE + 2;
1328 if (info->AsicID == ELECTRABUZZ_ID) {
1330 ft1000_read_dpram(dev, FT1000_DPRAM_RX_BASE);
1333 ntohs(ft1000_read_dpram_mag_16
1334 (dev, FT1000_MAG_TOTAL_LEN,
1335 FT1000_MAG_TOTAL_LEN_INDX));
1337 DEBUG(1, "FT1000:ft1000_parse_dpram_msg:total length = %d\n",
1339 if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) {
1343 * ft1000_read_reg will return a value that needs to be byteswap
1344 * in order to get DSP_QID_OFFSET.
1346 if (info->AsicID == ELECTRABUZZ_ID) {
1350 DSP_QID_OFFSET + FT1000_DPRAM_RX_BASE +
1354 (ft1000_read_dpram_mag_16
1355 (dev, FT1000_MAG_PORT_ID,
1356 FT1000_MAG_PORT_ID_INDX) & 0xff);
1358 DEBUG(1, "DSP_QID = 0x%x\n", portid);
1360 if (portid == DRIVERID) {
1361 /* We are assumming one driver message from the DSP at a time. */
1362 ft1000_proc_drvmsg(dev);
1365 ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_DPRAM_RX);
1368 if (doorbell & FT1000_DB_COND_RESET) {
1369 /* Reset ASIC and DSP */
1370 if (info->AsicID == ELECTRABUZZ_ID) {
1372 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
1374 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
1376 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
1378 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
1381 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER0,
1382 FT1000_MAG_DSP_TIMER0_INDX);
1384 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER1,
1385 FT1000_MAG_DSP_TIMER1_INDX);
1387 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER2,
1388 FT1000_MAG_DSP_TIMER2_INDX);
1390 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER3,
1391 FT1000_MAG_DSP_TIMER3_INDX);
1393 info->DrvErrNum = DSP_CONDRESET_INFO;
1394 DEBUG(1, "ft1000_hw:DSP conditional reset requested\n");
1395 ft1000_reset_card(dev);
1396 ft1000_write_reg(dev, FT1000_REG_DOORBELL,
1397 FT1000_DB_COND_RESET);
1399 /* let's clear any unexpected doorbells from DSP */
1401 doorbell & ~(FT1000_DB_DPRAM_RX | FT1000_ASIC_RESET_REQ |
1402 FT1000_DB_COND_RESET | 0xff00);
1404 DEBUG(1, "Clearing unexpected doorbell = 0x%x\n", doorbell);
1405 ft1000_write_reg(dev, FT1000_REG_DOORBELL, doorbell);
1412 /*---------------------------------------------------------------------------
1414 Function: ft1000_flush_fifo
1415 Description: This function will flush one packet from the downlink
1418 dev - device structure
1419 drv_err - driver error causing the flush fifo
1423 -------------------------------------------------------------------------*/
1424 static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
1426 struct ft1000_info *info = netdev_priv(dev);
1427 struct ft1000_pcmcia *pcmcia = info->priv;
1432 DEBUG(1, "ft1000:ft1000_hw:ft1000_flush_fifo called\n");
1433 if (pcmcia->PktIntfErr > MAX_PH_ERR) {
1434 if (info->AsicID == ELECTRABUZZ_ID) {
1436 ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
1438 ft1000_read_dpram(dev, FT1000_DSP_TIMER1);
1440 ft1000_read_dpram(dev, FT1000_DSP_TIMER2);
1442 ft1000_read_dpram(dev, FT1000_DSP_TIMER3);
1445 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER0,
1446 FT1000_MAG_DSP_TIMER0_INDX);
1448 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER1,
1449 FT1000_MAG_DSP_TIMER1_INDX);
1451 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER2,
1452 FT1000_MAG_DSP_TIMER2_INDX);
1454 ft1000_read_dpram_mag_16(dev, FT1000_MAG_DSP_TIMER3,
1455 FT1000_MAG_DSP_TIMER3_INDX);
1457 info->DrvErrNum = DrvErrNum;
1458 ft1000_reset_card(dev);
1461 /* Flush corrupted pkt from FIFO */
1464 if (info->AsicID == ELECTRABUZZ_ID) {
1466 ft1000_read_reg(dev, FT1000_REG_DFIFO);
1468 ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT);
1471 inl(dev->base_addr + FT1000_REG_MAG_DFR);
1473 inw(dev->base_addr + FT1000_REG_MAG_DFSR);
1477 * This should never happen unless the ASIC is broken.
1478 * We must reset to recover.
1480 if ((i > 2048) || (tempword == 0)) {
1481 if (info->AsicID == ELECTRABUZZ_ID) {
1483 ft1000_read_dpram(dev,
1486 ft1000_read_dpram(dev,
1489 ft1000_read_dpram(dev,
1492 ft1000_read_dpram(dev,
1496 ft1000_read_dpram_mag_16(dev,
1497 FT1000_MAG_DSP_TIMER0,
1498 FT1000_MAG_DSP_TIMER0_INDX);
1500 ft1000_read_dpram_mag_16(dev,
1501 FT1000_MAG_DSP_TIMER1,
1502 FT1000_MAG_DSP_TIMER1_INDX);
1504 ft1000_read_dpram_mag_16(dev,
1505 FT1000_MAG_DSP_TIMER2,
1506 FT1000_MAG_DSP_TIMER2_INDX);
1508 ft1000_read_dpram_mag_16(dev,
1509 FT1000_MAG_DSP_TIMER3,
1510 FT1000_MAG_DSP_TIMER3_INDX);
1512 if (tempword == 0) {
1514 * Let's check if ASIC reads are still ok by reading the Mask register
1515 * which is never zero at this point of the code.
1518 inw(dev->base_addr +
1519 FT1000_REG_SUP_IMASK);
1520 if (tempword == 0) {
1521 /* This indicates that we can not communicate with the ASIC */
1525 /* Let's assume that we really flush the FIFO */
1526 pcmcia->PktIntfErr++;
1530 info->DrvErrNum = FIFO_FLUSH_MAXLIMIT;
1534 tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
1535 } while ((tempword & 0x03) != 0x03);
1536 if (info->AsicID == ELECTRABUZZ_ID) {
1538 DEBUG(0, "Flushing FIFO complete = %x\n", tempword);
1539 /* Flush last word in FIFO. */
1540 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1541 /* Update FIFO counter for DSP */
1543 DEBUG(0, "Flush Data byte count to dsp = %d\n", i);
1544 info->fifo_cnt += i;
1545 ft1000_write_dpram(dev, FT1000_FIFO_LEN,
1548 DEBUG(0, "Flushing FIFO complete = %x\n", tempword);
1549 /* Flush last word in FIFO */
1550 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1551 tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
1552 DEBUG(0, "FT1000_REG_SUP_STAT = 0x%x\n", tempword);
1553 tempword = inw(dev->base_addr + FT1000_REG_MAG_DFSR);
1554 DEBUG(0, "FT1000_REG_MAG_DFSR = 0x%x\n", tempword);
1557 pcmcia->PktIntfErr++;
1562 /*---------------------------------------------------------------------------
1564 Function: ft1000_copy_up_pkt
1565 Description: This function will pull Flarion packets out of the Downlink
1566 FIFO and convert it to an ethernet packet. The ethernet packet will
1567 then be deliver to the TCP/IP stack.
1569 dev - device structure
1574 -------------------------------------------------------------------------*/
1575 static int ft1000_copy_up_pkt(struct net_device *dev)
1578 struct ft1000_info *info = netdev_priv(dev);
1580 struct sk_buff *skb;
1588 DEBUG(1, "ft1000_copy_up_pkt\n");
1590 if (info->AsicID == ELECTRABUZZ_ID) {
1591 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1594 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1595 len = ntohs(tempword);
1598 DEBUG(1, "Number of Bytes in FIFO = %d\n", len);
1600 if (len > ENET_MAX_SIZE) {
1601 DEBUG(0, "size of ethernet packet invalid\n");
1602 if (info->AsicID == MAGNEMITE_ID) {
1603 /* Read High word to complete 32 bit access */
1604 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1606 ft1000_flush_fifo(dev, DSP_PKTLEN_INFO);
1607 info->stats.rx_errors++;
1611 skb = dev_alloc_skb(len + 12 + 2);
1614 DEBUG(0, "No Network buffers available\n");
1615 /* Read High word to complete 32 bit access */
1616 if (info->AsicID == MAGNEMITE_ID) {
1617 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1619 ft1000_flush_fifo(dev, 0);
1620 info->stats.rx_errors++;
1623 pbuffer = (u8 *) skb_put(skb, len + 12);
1626 if (info->AsicID == ELECTRABUZZ_ID) {
1627 for (i = 1; i < 7; i++) {
1628 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1631 /* read checksum value */
1632 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1634 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1635 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1638 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1639 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1642 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1643 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1646 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1647 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1650 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1651 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1654 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRL);
1655 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1658 /* read checksum value */
1659 tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
1660 DEBUG(1, "Pseudo = 0x%x\n", tempword);
1663 if (chksum != tempword) {
1664 DEBUG(0, "Packet checksum mismatch 0x%x 0x%x\n", chksum,
1666 ft1000_flush_fifo(dev, DSP_PKTPHCKSUM_INFO);
1667 info->stats.rx_errors++;
1671 /* subtract the number of bytes read already */
1674 /* fake MAC address */
1675 *pbuffer++ = dev->dev_addr[0];
1676 *pbuffer++ = dev->dev_addr[1];
1677 *pbuffer++ = dev->dev_addr[2];
1678 *pbuffer++ = dev->dev_addr[3];
1679 *pbuffer++ = dev->dev_addr[4];
1680 *pbuffer++ = dev->dev_addr[5];
1688 if (info->AsicID == ELECTRABUZZ_ID) {
1689 for (i = 0; i < len / 2; i++) {
1690 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1691 *pbuffer++ = (u8) (tempword >> 8);
1692 *pbuffer++ = (u8) tempword;
1693 if (ft1000_chkcard(dev) == false) {
1699 /* Need to read one more word if odd byte */
1701 tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
1702 *pbuffer++ = (u8) (tempword >> 8);
1705 ptemplong = (u32 *) pbuffer;
1706 for (i = 0; i < len / 4; i++) {
1707 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1708 DEBUG(1, "Data = 0x%8x\n", templong);
1709 *ptemplong++ = templong;
1712 /* Need to read one more word if odd align. */
1714 templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
1715 DEBUG(1, "Data = 0x%8x\n", templong);
1716 *ptemplong++ = templong;
1721 DEBUG(1, "Data passed to Protocol layer:\n");
1722 for (i = 0; i < len + 12; i++) {
1723 DEBUG(1, "Protocol Data: 0x%x\n ", *ptemp++);
1727 skb->protocol = eth_type_trans(skb, dev);
1728 skb->ip_summed = CHECKSUM_UNNECESSARY;
1731 info->stats.rx_packets++;
1732 /* Add on 12 bytes for MAC address which was removed */
1733 info->stats.rx_bytes += (len + 12);
1735 if (info->AsicID == ELECTRABUZZ_ID) {
1736 /* track how many bytes have been read from FIFO - round up to 16 bit word */
1737 tempword = len + 16;
1738 if (tempword & 0x01)
1740 info->fifo_cnt += tempword;
1741 ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, FT1000_FIFO_LEN);
1742 ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, info->fifo_cnt);
1748 /*---------------------------------------------------------------------------
1750 Function: ft1000_copy_down_pkt
1751 Description: This function will take an ethernet packet and convert it to
1752 a Flarion packet prior to sending it to the ASIC Downlink
1755 dev - device structure
1756 packet - address of ethernet packet
1757 len - length of IP packet
1762 -------------------------------------------------------------------------*/
1763 static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)
1765 struct ft1000_info *info = netdev_priv(dev);
1766 struct ft1000_pcmcia *pcmcia = info->priv;
1768 struct pseudo_hdr blk;
1769 u16 buff[sizeof(struct pseudo_hdr) >> 1];
1770 u8 buffc[sizeof(struct pseudo_hdr)];
1775 DEBUG(1, "ft1000_hw: copy_down_pkt()\n");
1777 /* Check if there is room on the FIFO */
1778 if (len > ft1000_read_fifo_len(dev)) {
1780 if (len > ft1000_read_fifo_len(dev)) {
1783 if (len > ft1000_read_fifo_len(dev)) {
1786 if (len > ft1000_read_fifo_len(dev)) {
1789 if (len > ft1000_read_fifo_len(dev)) {
1792 if (len > ft1000_read_fifo_len(dev)) {
1795 if (len > ft1000_read_fifo_len(dev)) {
1797 "ft1000_hw:ft1000_copy_down_pkt:Transmit FIFO is fulli - pkt drop\n");
1798 info->stats.tx_errors++;
1802 /* Create pseudo header and send pseudo/ip to hardware */
1803 if (info->AsicID == ELECTRABUZZ_ID) {
1804 pseudo.blk.length = len;
1806 pseudo.blk.length = ntohs(len);
1808 pseudo.blk.source = DSPID; /* Need to swap to get in correct order */
1809 pseudo.blk.destination = HOSTID;
1810 pseudo.blk.portdest = NETWORKID; /* Need to swap to get in correct order */
1811 pseudo.blk.portsrc = DSPAIRID;
1812 pseudo.blk.sh_str_id = 0;
1813 pseudo.blk.control = 0;
1814 pseudo.blk.rsvd1 = 0;
1815 pseudo.blk.seq_num = 0;
1816 pseudo.blk.rsvd2 = pcmcia->packetseqnum++;
1817 pseudo.blk.qos_class = 0;
1818 /* Calculate pseudo header checksum */
1819 pseudo.blk.checksum = pseudo.buff[0];
1820 for (i = 1; i < 7; i++) {
1821 pseudo.blk.checksum ^= pseudo.buff[i];
1824 /* Production Mode */
1825 if (info->AsicID == ELECTRABUZZ_ID) {
1826 /* copy first word to UFIFO_BEG reg */
1827 ft1000_write_reg(dev, FT1000_REG_UFIFO_BEG, pseudo.buff[0]);
1828 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 0 BEG = 0x%04x\n",
1831 /* copy subsequent words to UFIFO_MID reg */
1832 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[1]);
1833 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 1 MID = 0x%04x\n",
1835 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[2]);
1836 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 2 MID = 0x%04x\n",
1838 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[3]);
1839 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 3 MID = 0x%04x\n",
1841 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[4]);
1842 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 4 MID = 0x%04x\n",
1844 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[5]);
1845 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 5 MID = 0x%04x\n",
1847 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[6]);
1848 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 6 MID = 0x%04x\n",
1850 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[7]);
1851 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 7 MID = 0x%04x\n",
1854 /* Write PPP type + IP Packet into Downlink FIFO */
1855 for (i = 0; i < (len >> 1) - 1; i++) {
1856 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,
1859 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1860 i + 8, htons(*packet));
1864 /* Check for odd byte */
1866 ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,
1869 "ft1000_hw:ft1000_copy_down_pkt:data MID = 0x%04x\n",
1872 ft1000_write_reg(dev, FT1000_REG_UFIFO_END,
1875 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1876 i + 8, htons(*packet));
1878 ft1000_write_reg(dev, FT1000_REG_UFIFO_END,
1881 "ft1000_hw:ft1000_copy_down_pkt:data %d MID = 0x%04x\n",
1882 i + 8, htons(*packet));
1885 outl(*(u32 *) & pseudo.buff[0],
1886 dev->base_addr + FT1000_REG_MAG_UFDR);
1887 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1888 *(u32 *) & pseudo.buff[0]);
1889 outl(*(u32 *) & pseudo.buff[2],
1890 dev->base_addr + FT1000_REG_MAG_UFDR);
1891 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1892 *(u32 *) & pseudo.buff[2]);
1893 outl(*(u32 *) & pseudo.buff[4],
1894 dev->base_addr + FT1000_REG_MAG_UFDR);
1895 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1896 *(u32 *) & pseudo.buff[4]);
1897 outl(*(u32 *) & pseudo.buff[6],
1898 dev->base_addr + FT1000_REG_MAG_UFDR);
1899 DEBUG(1, "ft1000_copy_down_pkt: Pseudo = 0x%8x\n",
1900 *(u32 *) & pseudo.buff[6]);
1902 plong = (u32 *) packet;
1903 /* Write PPP type + IP Packet into Downlink FIFO */
1904 for (i = 0; i < (len >> 2); i++) {
1905 outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR);
1908 /* Check for odd alignment */
1911 "ft1000_hw:ft1000_copy_down_pkt:data = 0x%8x\n",
1913 outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR);
1915 outl(1, dev->base_addr + FT1000_REG_MAG_UFER);
1918 info->stats.tx_packets++;
1919 /* Add 14 bytes for MAC address plus ethernet type */
1920 info->stats.tx_bytes += (len + 14);
1924 static struct net_device_stats *ft1000_stats(struct net_device *dev)
1926 struct ft1000_info *info = netdev_priv(dev);
1927 return (&info->stats);
1930 static int ft1000_open(struct net_device *dev)
1933 DEBUG(0, "ft1000_hw: ft1000_open is called\n");
1935 ft1000_reset_card(dev);
1936 DEBUG(0, "ft1000_hw: ft1000_open is ended\n");
1938 /* schedule ft1000_hbchk to perform periodic heartbeat checks on DSP and ASIC */
1939 init_timer(&poll_timer);
1940 poll_timer.expires = jiffies + (2 * HZ);
1941 poll_timer.data = (u_long) dev;
1942 add_timer(&poll_timer);
1944 DEBUG(0, "ft1000_hw: ft1000_open is ended2\n");
1948 static int ft1000_close(struct net_device *dev)
1950 struct ft1000_info *info = netdev_priv(dev);
1952 DEBUG(0, "ft1000_hw: ft1000_close()\n");
1954 info->CardReady = 0;
1955 del_timer(&poll_timer);
1957 if (ft1000_card_present == 1) {
1958 DEBUG(0, "Media is down\n");
1959 netif_stop_queue(dev);
1961 ft1000_disable_interrupts(dev);
1962 ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT);
1965 ft1000_reset_asic(dev);
1970 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
1972 struct ft1000_info *info = netdev_priv(dev);
1975 DEBUG(1, "ft1000_hw: ft1000_start_xmit()\n");
1977 DEBUG(1, "ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n");
1981 DEBUG(1, "ft1000_hw: ft1000_start_xmit:length of packet = %d\n",
1984 pdata = (u8 *) skb->data;
1986 if (info->mediastate == 0) {
1987 /* Drop packet is mediastate is down */
1988 DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:mediastate is down\n");
1992 if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) {
1993 /* Drop packet which has invalid size */
1995 "ft1000_hw:ft1000_copy_down_pkt:invalid ethernet length\n");
1998 ft1000_copy_down_pkt(dev, (u16 *) (pdata + ENET_HEADER_SIZE - 2),
1999 skb->len - ENET_HEADER_SIZE + 2);
2006 static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
2008 struct net_device *dev = (struct net_device *)dev_id;
2009 struct ft1000_info *info = netdev_priv(dev);
2014 DEBUG(1, "ft1000_hw: ft1000_interrupt()\n");
2016 if (info->CardReady == 0) {
2017 ft1000_disable_interrupts(dev);
2021 if (ft1000_chkcard(dev) == false) {
2022 ft1000_disable_interrupts(dev);
2026 ft1000_disable_interrupts(dev);
2028 /* Read interrupt type */
2029 inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
2031 /* Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type */
2033 if (inttype & ISR_DOORBELL_PEND)
2034 ft1000_parse_dpram_msg(dev);
2036 if (inttype & ISR_RCV) {
2037 DEBUG(1, "Data in FIFO\n");
2041 /* Check if we have packets in the Downlink FIFO */
2042 if (info->AsicID == ELECTRABUZZ_ID) {
2044 ft1000_read_reg(dev,
2045 FT1000_REG_DFIFO_STAT);
2048 ft1000_read_reg(dev,
2049 FT1000_REG_MAG_DFSR);
2051 if (tempword & 0x1f) {
2052 ft1000_copy_up_pkt(dev);
2057 } while (cnt < MAX_RCV_LOOP);
2060 /* clear interrupts */
2061 tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
2062 DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
2063 ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
2065 /* Read interrupt type */
2066 inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR);
2067 DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype);
2069 ft1000_enable_interrupts(dev);
2073 void stop_ft1000_card(struct net_device *dev)
2075 struct ft1000_info *info = netdev_priv(dev);
2076 struct prov_record *ptr;
2079 DEBUG(0, "ft1000_hw: stop_ft1000_card()\n");
2081 info->CardReady = 0;
2082 ft1000_card_present = 0;
2083 netif_stop_queue(dev);
2084 ft1000_disable_interrupts(dev);
2086 /* Make sure we free any memory reserve for provisioning */
2087 while (list_empty(&info->prov_list) == 0) {
2088 ptr = list_entry(info->prov_list.next, struct prov_record, list);
2089 list_del(&ptr->list);
2090 kfree(ptr->pprov_data);
2096 if (info->registered) {
2097 unregister_netdev(dev);
2098 info->registered = 0;
2101 free_irq(dev->irq, dev);
2102 release_region(dev->base_addr,256);
2103 release_firmware(fw_entry);
2104 flarion_ft1000_cnt--;
2105 ft1000CleanupProc(dev);
2109 static void ft1000_get_drvinfo(struct net_device *dev,
2110 struct ethtool_drvinfo *info)
2112 struct ft1000_info *ft_info;
2113 ft_info = netdev_priv(dev);
2115 strlcpy(info->driver, "ft1000", sizeof(info->driver));
2116 snprintf(info->bus_info, sizeof(info->bus_info), "PCMCIA 0x%lx",
2118 snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d.%d.%d",
2119 ft_info->DspVer[0], ft_info->DspVer[1], ft_info->DspVer[2],
2120 ft_info->DspVer[3]);
2123 static u32 ft1000_get_link(struct net_device *dev)
2125 struct ft1000_info *info;
2126 info = netdev_priv(dev);
2127 return info->mediastate;
2130 static const struct ethtool_ops ops = {
2131 .get_drvinfo = ft1000_get_drvinfo,
2132 .get_link = ft1000_get_link
2135 struct net_device *init_ft1000_card(struct pcmcia_device *link,
2138 struct ft1000_info *info;
2139 struct ft1000_pcmcia *pcmcia;
2140 struct net_device *dev;
2142 static const struct net_device_ops ft1000ops = /* Slavius 21.10.2009 due to kernel changes */
2144 .ndo_open = &ft1000_open,
2145 .ndo_stop = &ft1000_close,
2146 .ndo_start_xmit = &ft1000_start_xmit,
2147 .ndo_get_stats = &ft1000_stats,
2150 DEBUG(1, "ft1000_hw: init_ft1000_card()\n");
2151 DEBUG(1, "ft1000_hw: irq = %d\n", link->irq);
2152 DEBUG(1, "ft1000_hw: port = 0x%04x\n", link->resource[0]->start);
2154 flarion_ft1000_cnt++;
2156 if (flarion_ft1000_cnt > 1) {
2157 flarion_ft1000_cnt--;
2160 "ft1000: This driver can not support more than one instance\n");
2164 dev = alloc_etherdev(sizeof(struct ft1000_info));
2166 printk(KERN_ERR "ft1000: failed to allocate etherdev\n");
2170 SET_NETDEV_DEV(dev, &link->dev);
2171 info = netdev_priv(dev);
2173 memset(info, 0, sizeof(struct ft1000_info));
2175 DEBUG(1, "address of dev = 0x%8x\n", (u32) dev);
2176 DEBUG(1, "address of dev info = 0x%8x\n", (u32) info);
2177 DEBUG(0, "device name = %s\n", dev->name);
2179 memset(&info->stats, 0, sizeof(struct net_device_stats));
2181 info->priv = kzalloc(sizeof(struct ft1000_pcmcia), GFP_KERNEL);
2182 pcmcia = info->priv;
2183 pcmcia->link = link;
2185 spin_lock_init(&info->dpram_lock);
2186 info->DrvErrNum = 0;
2187 info->registered = 1;
2188 info->ft1000_reset = ft1000_reset;
2189 info->mediastate = 0;
2191 info->CardReady = 0;
2192 info->DSP_TIME[0] = 0;
2193 info->DSP_TIME[1] = 0;
2194 info->DSP_TIME[2] = 0;
2195 info->DSP_TIME[3] = 0;
2196 flarion_ft1000_cnt = 0;
2198 INIT_LIST_HEAD(&info->prov_list);
2200 info->squeseqnum = 0;
2202 /* dev->hard_start_xmit = &ft1000_start_xmit; */
2203 /* dev->get_stats = &ft1000_stats; */
2204 /* dev->open = &ft1000_open; */
2205 /* dev->stop = &ft1000_close; */
2207 dev->netdev_ops = &ft1000ops; /* Slavius 21.10.2009 due to kernel changes */
2209 DEBUG(0, "device name = %s\n", dev->name);
2211 dev->irq = link->irq;
2212 dev->base_addr = link->resource[0]->start;
2213 if (pcmcia_get_mac_from_cis(link, dev)) {
2214 printk(KERN_ERR "ft1000: Could not read mac address\n");
2218 if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
2219 printk(KERN_ERR "ft1000: Could not request_irq\n");
2223 if (request_region(dev->base_addr, 256, dev->name) == NULL) {
2224 printk(KERN_ERR "ft1000: Could not request_region\n");
2228 if (register_netdev(dev) != 0) {
2229 DEBUG(0, "ft1000: Could not register netdev");
2233 info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
2234 if (info->AsicID == ELECTRABUZZ_ID) {
2235 DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n");
2236 if (request_firmware(&fw_entry, "ft1000.img", &link->dev) != 0) {
2237 printk(KERN_INFO "ft1000: Could not open ft1000.img\n");
2241 DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n");
2242 if (request_firmware(&fw_entry, "ft2000.img", &link->dev) != 0) {
2243 printk(KERN_INFO "ft1000: Could not open ft2000.img\n");
2248 ft1000_enable_interrupts(dev);
2250 ft1000InitProc(dev);
2251 ft1000_card_present = 1;
2252 SET_ETHTOOL_OPS(dev, &ops);
2253 printk(KERN_INFO "ft1000: %s: addr 0x%04lx irq %d, MAC addr %pM\n",
2254 dev->name, dev->base_addr, dev->irq, dev->dev_addr);
2258 unregister_netdev(dev);
2260 release_region(dev->base_addr, 256);
2262 free_irq(dev->irq, dev);