diff options
Diffstat (limited to 'drivers/staging/ft1000')
| -rw-r--r-- | drivers/staging/ft1000/ft1000-pcmcia/boot.h | 304 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-pcmcia/ft1000.h | 15 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c | 6 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c | 2 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 768 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c | 4 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 14 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 693 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 1638 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h | 142 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_proc.c | 35 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 11 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 44 | ||||
| -rw-r--r-- | drivers/staging/ft1000/ft1000.h | 163 | 
14 files changed, 1739 insertions, 2100 deletions
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/boot.h b/drivers/staging/ft1000/ft1000-pcmcia/boot.h index 1fc4ac12e24..60c015c1c28 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/boot.h +++ b/drivers/staging/ft1000/ft1000-pcmcia/boot.h @@ -1,158 +1,158 @@ -//--------------------------------------------------------------------------- -// FT1000 driver for Flarion Flash OFDM NIC Device -// -// Copyright (C) 2002 Flarion Technologies, All rights reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) any -// later version. This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for -// more details. You should have received a copy of the GNU General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., 59 Temple Place - -// Suite 330, Boston, MA 02111-1307, USA. -//--------------------------------------------------------------------------- -// -// File:         boot.h -// -// Description:    boatloader -// -// History: -// 1/11/05    Whc                Ported to Linux. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- +   FT1000 driver for Flarion Flash OFDM NIC Device + +   Copyright (C) 2002 Flarion Technologies, All rights reserved. + +   This program is free software; you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation; either version 2 of the License, or (at your option) any +   later version. This program is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. You should have received a copy of the GNU General Public +   License along with this program; if not, write to the +   Free Software Foundation, Inc., 59 Temple Place - +   Suite 330, Boston, MA 02111-1307, USA. +  --------------------------------------------------------------------------- + +   File:         boot.h + +   Description:    boatloader + +   History: +   1/11/05    Whc                Ported to Linux. + +---------------------------------------------------------------------------*/  #ifndef _BOOTH_  #define _BOOTH_ -// Official bootloader -unsigned char bootimage [] = { -0x00,0x00,0x01,0x5E,0x00,0x00 -,0x00,0x00,0x00,0x00,0x02,0xD7 -,0x00,0x00,0x01,0x5E,0x46,0xB3 -,0xE6,0x02,0x00,0x98,0xE6,0x8C -,0x00,0x98,0xFB,0x92,0xFF,0xFF -,0x98,0xFB,0x94,0xFF,0xFF,0x98 -,0xFB,0x06,0x08,0x00,0x98,0xFB -,0x96,0x84,0x00,0x98,0xFB,0x08 -,0x1C,0x00,0x98,0xFB,0x51,0x25 -,0x10,0x1C,0x00,0xE6,0x51,0x01 -,0x07,0xFD,0x4C,0xFF,0x20,0xF5 -,0x51,0x02,0x20,0x08,0x00,0x4C -,0xFF,0x20,0x3C,0x00,0xC0,0x64 -,0x98,0xC0,0x66,0x98,0xC0,0x68 -,0x98,0xC0,0x6A,0x98,0xC0,0x6C -,0x98,0x90,0x08,0x90,0x09,0x90 -,0x0A,0x90,0x0B,0x90,0x0C,0x90 -,0x0D,0x90,0x0E,0x90,0x0F,0x90 -,0x04,0x90,0x06,0xFB,0x51,0x22 -,0x16,0x08,0x03,0xFB,0x51,0x52 -,0x16,0x08,0x04,0xFB,0x51,0x24 -,0x2B,0x08,0x06,0xFB,0x51,0x54 -,0x2B,0x08,0x07,0xFB,0x51,0x24 -,0x2B,0x08,0x09,0xFB,0x51,0x54 -,0x2B,0x08,0x0A,0xFB,0x51,0x12 -,0x16,0x08,0x0C,0xFB,0x51,0x52 -,0x16,0x08,0x0D,0x78,0x00,0x00 -,0x00,0x16,0x00,0x00,0xEC,0x31 -,0xAE,0x00,0x00,0x81,0x4C,0x0F -,0xE6,0x43,0xFF,0xEC,0x31,0x4E -,0x00,0x00,0x91,0xEC,0x31,0xAE -,0x00,0x00,0x91,0x4C,0x0F,0xE6 -,0x43,0xFF,0xEC,0x31,0x5E,0x00 -,0x00,0xA1,0xEB,0x31,0x08,0x00 -,0x00,0xA6,0xEB,0x31,0x08,0x00 -,0x00,0xAC,0x3C,0x00,0xEB,0x31 -,0x08,0x00,0x00,0xA8,0x76,0xFE -,0xFE,0x08,0xEB,0x31,0x08,0x20 -,0x00,0x00,0x76,0xFF,0xFF,0x18 -,0xED,0x31,0x08,0x20,0x00,0x00 -,0x26,0x10,0x04,0x10,0xF5,0x3C -,0x01,0x3C,0x00,0x08,0x01,0x12 -,0x3C,0x11,0x3C,0x00,0x08,0x01 -,0x0B,0x08,0x00,0x6D,0xEC,0x31 -,0xAE,0x20,0x00,0x06,0xED,0x4D -,0x08,0x00,0x00,0x67,0x80,0x6F -,0x00,0x01,0x0B,0x6F,0x00,0x02 -,0x2E,0x76,0xEE,0x01,0x48,0x06 -,0x01,0x39,0xED,0x4D,0x18,0x00 -,0x02,0xED,0x4D,0x08,0x00,0x04 -,0x14,0x06,0xA4,0xED,0x31,0x22 -,0x00,0x00,0xAC,0x76,0xEE,0x07 -,0x48,0x6D,0x22,0x01,0x1E,0x08 -,0x01,0x58,0xEB,0x31,0x08,0x00 -,0x00,0xAC,0x06,0xFF,0xBA,0x3C -,0x00,0xEB,0x31,0x08,0x20,0x00 -,0x04,0x3C,0x30,0xEB,0x31,0x08 -,0x20,0x00,0x02,0x3C,0x10,0xEB -,0x31,0x08,0x20,0x00,0x00,0xED -,0x31,0x08,0x20,0x00,0x00,0x04 -,0x10,0xF7,0xED,0x31,0x08,0x00 -,0x00,0xA2,0x91,0x00,0x9C,0x3C -,0x80,0xEB,0x31,0x08,0x20,0x00 -,0x04,0x3C,0x20,0xEB,0x31,0x08 -,0x20,0x00,0x02,0x3C,0x10,0xEB -,0x31,0x08,0x20,0x00,0x00,0xED -,0x31,0x08,0x20,0x00,0x00,0x04 -,0x10,0xF7,0xED,0x31,0x08,0x20 -,0x00,0x04,0x42,0x10,0x90,0x08 -,0xEC,0x31,0xAE,0x20,0x00,0x06 -,0xA4,0x41,0x08,0x00,0xB6,0xED -,0x41,0x28,0x7D,0xFF,0xFF,0x22 -,0xB3,0x40,0x98,0x2A,0x32,0xEB -,0x41,0x28,0xB4,0x43,0xFC,0x05 -,0xFF,0xE6,0xA0,0x31,0x20,0x00 -,0x06,0xEB,0x31,0x08,0x20,0x00 -,0x04,0x3C,0x20,0xEB,0x31,0x08 -,0x20,0x00,0x02,0x3C,0x10,0xEB -,0x31,0x08,0x20,0x00,0x00,0xED -,0x31,0x08,0x20,0x00,0x00,0x04 -,0x10,0xF7,0xED,0x31,0x08,0x20 -,0x00,0x04,0x42,0x10,0x90,0x08 -,0xEC,0x31,0xAE,0x20,0x00,0x06 -,0xA4,0x41,0x08,0x00,0x68,0xED -,0x41,0x28,0x7D,0xFF,0xFF,0x22 -,0xB3,0x40,0x98,0x2A,0x32,0xEB -,0x41,0x28,0xB4,0x43,0xFC,0x05 -,0xFF,0xE6,0x48,0x04,0xEB,0x31 -,0x08,0x20,0x00,0x04,0xEB,0x31 -,0x18,0x20,0x00,0x02,0x3C,0x11 -,0xEB,0x31,0x18,0x20,0x00,0x00 -,0xED,0x31,0x08,0x20,0x00,0x00 -,0x04,0x10,0xF7,0xED,0x31,0x08 -,0x20,0x00,0x02,0x66,0x00,0x6F -,0x00,0x01,0x16,0x76,0xEE,0x06 -,0x48,0x4A,0x1E,0x48,0x04,0xED -,0x31,0x08,0x20,0x00,0x04,0xEB -,0x31,0x08,0x00,0x00,0xA4,0x48 -,0x04,0xED,0x31,0x08,0x20,0x00 -,0x04,0xEB,0x31,0x08,0x00,0x00 -,0xA2,0x48,0x04,0x20,0x20,0x4A -,0x7C,0x46,0x82,0x50,0x05,0x50 -,0x15,0xB5,0x1E,0x98,0xED,0x31 -,0x08,0x00,0x00,0xA8,0x10,0x47 -,0x3B,0x2C,0x01,0xDB,0x40,0x11 -,0x98,0xC1,0x1E,0x98,0x10,0x07 -,0x30,0xF9,0x40,0x07,0x18,0x98 -,0x2A,0x10,0xEB,0x31,0x08,0x00 -,0x00,0xA8,0xA4,0x1E,0x98,0xBB -,0x1E,0x98,0x50,0x14,0x50,0x04 -,0x46,0x83,0x48,0x04,0x02,0x01 -,0x00,0x50,0x05,0x50,0x15,0x10 -,0x87,0x3F,0x90,0x2B,0x18,0x01 -,0x00,0xC0,0x31,0x00,0x00,0xAE -,0xDF,0x41,0x00,0x08,0x00,0x1A -,0x42,0x11,0x67,0x01,0xDF,0x41 -,0x02,0x08,0x00,0x10,0x42,0x11 -,0x62,0x01,0xB4,0x43,0x4A,0x68 -,0x50,0x14,0x50,0x04,0x24,0x10 -,0x48,0x04,0xF2,0x31,0x00,0x01 -,0x00,0x00,0xAE,0xF6,0x31,0x00 -,0x01,0x00,0x00,0xAE,0x62,0xE4 -,0xE5,0x61,0x04,0x48,0x04,0xE5 -,0x63,0x05,0x48,0x04,0x20,0x20 -,0x00,0x00,0x00,0x00 +/* Official bootloader */ +static unsigned char bootimage[] = { +	0x00, 0x00, 0x01, 0x5E, 0x00, 0x00, +	0x00, 0x00, 0x00, 0x00, 0x02, 0xD7, +	0x00, 0x00, 0x01, 0x5E, 0x46, 0xB3, +	0xE6, 0x02, 0x00, 0x98, 0xE6, 0x8C, +	0x00, 0x98, 0xFB, 0x92, 0xFF, 0xFF, +	0x98, 0xFB, 0x94, 0xFF, 0xFF, 0x98, +	0xFB, 0x06, 0x08, 0x00, 0x98, 0xFB, +	0x96, 0x84, 0x00, 0x98, 0xFB, 0x08, +	0x1C, 0x00, 0x98, 0xFB, 0x51, 0x25, +	0x10, 0x1C, 0x00, 0xE6, 0x51, 0x01, +	0x07, 0xFD, 0x4C, 0xFF, 0x20, 0xF5, +	0x51, 0x02, 0x20, 0x08, 0x00, 0x4C, +	0xFF, 0x20, 0x3C, 0x00, 0xC0, 0x64, +	0x98, 0xC0, 0x66, 0x98, 0xC0, 0x68, +	0x98, 0xC0, 0x6A, 0x98, 0xC0, 0x6C, +	0x98, 0x90, 0x08, 0x90, 0x09, 0x90, +	0x0A, 0x90, 0x0B, 0x90, 0x0C, 0x90, +	0x0D, 0x90, 0x0E, 0x90, 0x0F, 0x90, +	0x04, 0x90, 0x06, 0xFB, 0x51, 0x22, +	0x16, 0x08, 0x03, 0xFB, 0x51, 0x52, +	0x16, 0x08, 0x04, 0xFB, 0x51, 0x24, +	0x2B, 0x08, 0x06, 0xFB, 0x51, 0x54, +	0x2B, 0x08, 0x07, 0xFB, 0x51, 0x24, +	0x2B, 0x08, 0x09, 0xFB, 0x51, 0x54, +	0x2B, 0x08, 0x0A, 0xFB, 0x51, 0x12, +	0x16, 0x08, 0x0C, 0xFB, 0x51, 0x52, +	0x16, 0x08, 0x0D, 0x78, 0x00, 0x00, +	0x00, 0x16, 0x00, 0x00, 0xEC, 0x31, +	0xAE, 0x00, 0x00, 0x81, 0x4C, 0x0F, +	0xE6, 0x43, 0xFF, 0xEC, 0x31, 0x4E, +	0x00, 0x00, 0x91, 0xEC, 0x31, 0xAE, +	0x00, 0x00, 0x91, 0x4C, 0x0F, 0xE6, +	0x43, 0xFF, 0xEC, 0x31, 0x5E, 0x00, +	0x00, 0xA1, 0xEB, 0x31, 0x08, 0x00, +	0x00, 0xA6, 0xEB, 0x31, 0x08, 0x00, +	0x00, 0xAC, 0x3C, 0x00, 0xEB, 0x31, +	0x08, 0x00, 0x00, 0xA8, 0x76, 0xFE, +	0xFE, 0x08, 0xEB, 0x31, 0x08, 0x20, +	0x00, 0x00, 0x76, 0xFF, 0xFF, 0x18, +	0xED, 0x31, 0x08, 0x20, 0x00, 0x00, +	0x26, 0x10, 0x04, 0x10, 0xF5, 0x3C, +	0x01, 0x3C, 0x00, 0x08, 0x01, 0x12, +	0x3C, 0x11, 0x3C, 0x00, 0x08, 0x01, +	0x0B, 0x08, 0x00, 0x6D, 0xEC, 0x31, +	0xAE, 0x20, 0x00, 0x06, 0xED, 0x4D, +	0x08, 0x00, 0x00, 0x67, 0x80, 0x6F, +	0x00, 0x01, 0x0B, 0x6F, 0x00, 0x02, +	0x2E, 0x76, 0xEE, 0x01, 0x48, 0x06, +	0x01, 0x39, 0xED, 0x4D, 0x18, 0x00, +	0x02, 0xED, 0x4D, 0x08, 0x00, 0x04, +	0x14, 0x06, 0xA4, 0xED, 0x31, 0x22, +	0x00, 0x00, 0xAC, 0x76, 0xEE, 0x07, +	0x48, 0x6D, 0x22, 0x01, 0x1E, 0x08, +	0x01, 0x58, 0xEB, 0x31, 0x08, 0x00, +	0x00, 0xAC, 0x06, 0xFF, 0xBA, 0x3C, +	0x00, 0xEB, 0x31, 0x08, 0x20, 0x00, +	0x04, 0x3C, 0x30, 0xEB, 0x31, 0x08, +	0x20, 0x00, 0x02, 0x3C, 0x10, 0xEB, +	0x31, 0x08, 0x20, 0x00, 0x00, 0xED, +	0x31, 0x08, 0x20, 0x00, 0x00, 0x04, +	0x10, 0xF7, 0xED, 0x31, 0x08, 0x00, +	0x00, 0xA2, 0x91, 0x00, 0x9C, 0x3C, +	0x80, 0xEB, 0x31, 0x08, 0x20, 0x00, +	0x04, 0x3C, 0x20, 0xEB, 0x31, 0x08, +	0x20, 0x00, 0x02, 0x3C, 0x10, 0xEB, +	0x31, 0x08, 0x20, 0x00, 0x00, 0xED, +	0x31, 0x08, 0x20, 0x00, 0x00, 0x04, +	0x10, 0xF7, 0xED, 0x31, 0x08, 0x20, +	0x00, 0x04, 0x42, 0x10, 0x90, 0x08, +	0xEC, 0x31, 0xAE, 0x20, 0x00, 0x06, +	0xA4, 0x41, 0x08, 0x00, 0xB6, 0xED, +	0x41, 0x28, 0x7D, 0xFF, 0xFF, 0x22, +	0xB3, 0x40, 0x98, 0x2A, 0x32, 0xEB, +	0x41, 0x28, 0xB4, 0x43, 0xFC, 0x05, +	0xFF, 0xE6, 0xA0, 0x31, 0x20, 0x00, +	0x06, 0xEB, 0x31, 0x08, 0x20, 0x00, +	0x04, 0x3C, 0x20, 0xEB, 0x31, 0x08, +	0x20, 0x00, 0x02, 0x3C, 0x10, 0xEB, +	0x31, 0x08, 0x20, 0x00, 0x00, 0xED, +	0x31, 0x08, 0x20, 0x00, 0x00, 0x04, +	0x10, 0xF7, 0xED, 0x31, 0x08, 0x20, +	0x00, 0x04, 0x42, 0x10, 0x90, 0x08, +	0xEC, 0x31, 0xAE, 0x20, 0x00, 0x06, +	0xA4, 0x41, 0x08, 0x00, 0x68, 0xED, +	0x41, 0x28, 0x7D, 0xFF, 0xFF, 0x22, +	0xB3, 0x40, 0x98, 0x2A, 0x32, 0xEB, +	0x41, 0x28, 0xB4, 0x43, 0xFC, 0x05, +	0xFF, 0xE6, 0x48, 0x04, 0xEB, 0x31, +	0x08, 0x20, 0x00, 0x04, 0xEB, 0x31, +	0x18, 0x20, 0x00, 0x02, 0x3C, 0x11, +	0xEB, 0x31, 0x18, 0x20, 0x00, 0x00, +	0xED, 0x31, 0x08, 0x20, 0x00, 0x00, +	0x04, 0x10, 0xF7, 0xED, 0x31, 0x08, +	0x20, 0x00, 0x02, 0x66, 0x00, 0x6F, +	0x00, 0x01, 0x16, 0x76, 0xEE, 0x06, +	0x48, 0x4A, 0x1E, 0x48, 0x04, 0xED, +	0x31, 0x08, 0x20, 0x00, 0x04, 0xEB, +	0x31, 0x08, 0x00, 0x00, 0xA4, 0x48, +	0x04, 0xED, 0x31, 0x08, 0x20, 0x00, +	0x04, 0xEB, 0x31, 0x08, 0x00, 0x00, +	0xA2, 0x48, 0x04, 0x20, 0x20, 0x4A, +	0x7C, 0x46, 0x82, 0x50, 0x05, 0x50, +	0x15, 0xB5, 0x1E, 0x98, 0xED, 0x31, +	0x08, 0x00, 0x00, 0xA8, 0x10, 0x47, +	0x3B, 0x2C, 0x01, 0xDB, 0x40, 0x11, +	0x98, 0xC1, 0x1E, 0x98, 0x10, 0x07, +	0x30, 0xF9, 0x40, 0x07, 0x18, 0x98, +	0x2A, 0x10, 0xEB, 0x31, 0x08, 0x00, +	0x00, 0xA8, 0xA4, 0x1E, 0x98, 0xBB, +	0x1E, 0x98, 0x50, 0x14, 0x50, 0x04, +	0x46, 0x83, 0x48, 0x04, 0x02, 0x01, +	0x00, 0x50, 0x05, 0x50, 0x15, 0x10, +	0x87, 0x3F, 0x90, 0x2B, 0x18, 0x01, +	0x00, 0xC0, 0x31, 0x00, 0x00, 0xAE, +	0xDF, 0x41, 0x00, 0x08, 0x00, 0x1A, +	0x42, 0x11, 0x67, 0x01, 0xDF, 0x41, +	0x02, 0x08, 0x00, 0x10, 0x42, 0x11, +	0x62, 0x01, 0xB4, 0x43, 0x4A, 0x68, +	0x50, 0x14, 0x50, 0x04, 0x24, 0x10, +	0x48, 0x04, 0xF2, 0x31, 0x00, 0x01, +	0x00, 0x00, 0xAE, 0xF6, 0x31, 0x00, +	0x01, 0x00, 0x00, 0xAE, 0x62, 0xE4, +	0xE5, 0x61, 0x04, 0x48, 0x04, 0xE5, +	0x63, 0x05, 0x48, 0x04, 0x20, 0x20, +	0x00, 0x00, 0x00, 0x00  };  #endif diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h index 65f7ab6cb46..0c21ac68003 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h @@ -25,7 +25,10 @@  #define FT1000_DPRAM_BASE	0x0000	/* Dual Port RAM starting offset */ -/* Maximum number of occurrence of pseudo header errors before resetting PC Card. */ +/* + * Maximum number of occurrence of pseudo header errors before resetting PC + * Card. + */  #define MAX_PH_ERR	300  #define SUCCESS	0x00 @@ -40,16 +43,17 @@ struct ft1000_pcmcia {  struct pcmcia_device;  struct net_device;  extern struct net_device *init_ft1000_card(struct pcmcia_device *link, -						void *ft1000_reset); +					   void *ft1000_reset);  extern void stop_ft1000_card(struct net_device *dev);  extern int card_download(struct net_device *dev, const u8 *pFileStart, -			size_t FileLength); +			 size_t FileLength);  extern void ft1000InitProc(struct net_device *dev);  extern void ft1000CleanupProc(struct net_device *dev);  extern u16 ft1000_read_dpram(struct net_device *dev, int offset);  extern void card_bootload(struct net_device *dev); -extern u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index); +extern u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, +				    int Index);  extern u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset);  void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value); @@ -60,7 +64,8 @@ static inline u16 ft1000_read_reg(struct net_device *dev, u16 offset)  }  /* Set the value of a given ASIC register. */ -static inline void ft1000_write_reg(struct net_device *dev, u16 offset, u16 value) +static inline void ft1000_write_reg(struct net_device *dev, u16 offset, +				    u16 value)  {  	outw(value, dev->base_addr + offset);  } diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c index f376ca43720..1f8b3ca35c6 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c @@ -95,20 +95,20 @@ static int ft1000_config(struct pcmcia_device *link)  	/* setup IO window */  	ret = pcmcia_loop_config(link, ft1000_confcheck, NULL);  	if (ret) { -		printk(KERN_INFO "ft1000: Could not configure pcmcia\n"); +		dev_err(&link->dev, "Could not configure pcmcia\n");  		return -ENODEV;  	}  	/* configure device */  	ret = pcmcia_enable_device(link);  	if (ret) { -		printk(KERN_INFO "ft1000: could not enable pcmcia\n"); +		dev_err(&link->dev, "Could not enable pcmcia\n");  		goto failed;  	}  	link->priv = init_ft1000_card(link, &ft1000_reset);  	if (!link->priv) { -		printk(KERN_INFO "ft1000: Could not register as network device\n"); +		dev_err(&link->dev, "Could not register as network device\n");  		goto failed;  	} diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c index 6311b2ff581..d44e8583ad1 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c @@ -304,7 +304,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart,  	struct dsp_file_hdr *pFileHdr5;  	struct dsp_image_info *pDspImageInfoV6 = NULL;  	long requested_version; -	bool bGoodVersion = 0; +	bool bGoodVersion = false;  	struct drv_msg *pMailBoxData;  	u16 *pUsData = NULL;  	u16 *pUsFile = NULL; diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 29d0a72f0d6..a6158bef58e 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -15,7 +15,7 @@     License along with this program; if not, write to the     Free Software Foundation, Inc., 59 Temple Place -     Suite 330, Boston, MA 02111-1307, USA. ------------------------------------------------------------------------------*/ +  -------------------------------------------------------------------------*/  #include <linux/kernel.h>  #include <linux/module.h> @@ -80,19 +80,19 @@ MODULE_SUPPORTED_DEVICE("FT1000");  #define MAX_RCV_LOOP   100 -//--------------------------------------------------------------------------- -// -// Function:   ft1000_read_fifo_len -// Description: This function will read the ASIC Uplink FIFO status register -//             which will return the number of bytes remaining in the Uplink FIFO. -//             Sixteen bytes are subtracted to make sure that the ASIC does not -//             reach its threshold. -// Input: -//     dev    - network device structure -// Output: -//     value  - number of bytes available in the ASIC Uplink FIFO. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_read_fifo_len +   Description: This function will read the ASIC Uplink FIFO status register +               which will return the number of bytes remaining in the Uplink FIFO. +               Sixteen bytes are subtracted to make sure that the ASIC does not +               reach its threshold. +   Input: +       dev    - network device structure +   Output: +       value  - number of bytes available in the ASIC Uplink FIFO. + +  -------------------------------------------------------------------------*/  static inline u16 ft1000_read_fifo_len(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -103,25 +103,25 @@ static inline u16 ft1000_read_fifo_len(struct net_device *dev)  		return (ft1000_read_reg(dev, FT1000_REG_MAG_UFSR) - 16);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_read_dpram -// Description: This function will read the specific area of dpram -//             (Electrabuzz ASIC only) -// Input: -//     dev    - device structure -//     offset - index of dpram -// Output: -//     value  - value of dpram -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_read_dpram +   Description: This function will read the specific area of dpram +               (Electrabuzz ASIC only) +   Input: +       dev    - device structure +       offset - index of dpram +   Output: +       value  - value of dpram + +  -------------------------------------------------------------------------*/  u16 ft1000_read_dpram(struct net_device *dev, int offset)  {  	struct ft1000_info *info = netdev_priv(dev);  	unsigned long flags;  	u16 data; -	// Provide mutual exclusive access while reading ASIC registers. +	/* Provide mutual exclusive access while reading ASIC registers. */  	spin_lock_irqsave(&info->dpram_lock, flags);  	ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);  	data = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA); @@ -130,54 +130,54 @@ u16 ft1000_read_dpram(struct net_device *dev, int offset)  	return (data);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_write_dpram -// Description: This function will write to a specific area of dpram -//             (Electrabuzz ASIC only) -// Input: -//     dev    - device structure -//     offset - index of dpram -//     value  - value to write -// Output: -//     none. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_write_dpram +   Description: This function will write to a specific area of dpram +               (Electrabuzz ASIC only) +   Input: +       dev    - device structure +       offset - index of dpram +       value  - value to write +   Output: +       none. + +  -------------------------------------------------------------------------*/  static inline void ft1000_write_dpram(struct net_device *dev,  					  int offset, u16 value)  {  	struct ft1000_info *info = netdev_priv(dev);  	unsigned long flags; -	// Provide mutual exclusive access while reading ASIC registers. +	/* Provide mutual exclusive access while reading ASIC registers. */  	spin_lock_irqsave(&info->dpram_lock, flags);  	ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);  	ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, value);  	spin_unlock_irqrestore(&info->dpram_lock, flags);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_read_dpram_mag_16 -// Description: This function will read the specific area of dpram -//             (Magnemite ASIC only) -// Input: -//     dev    - device structure -//     offset - index of dpram -// Output: -//     value  - value of dpram -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_read_dpram_mag_16 +   Description: This function will read the specific area of dpram +               (Magnemite ASIC only) +   Input: +       dev    - device structure +       offset - index of dpram +   Output: +       value  - value of dpram + +  -------------------------------------------------------------------------*/  u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index)  {  	struct ft1000_info *info = netdev_priv(dev);  	unsigned long flags;  	u16 data; -	// Provide mutual exclusive access while reading ASIC registers. +	/* Provide mutual exclusive access while reading ASIC registers. */  	spin_lock_irqsave(&info->dpram_lock, flags);  	ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset); -	// check if we want to read upper or lower 32-bit word +	/* check if we want to read upper or lower 32-bit word */  	if (Index) {  		data = ft1000_read_reg(dev, FT1000_REG_MAG_DPDATAL);  	} else { @@ -188,26 +188,26 @@ u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index)  	return (data);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_write_dpram_mag_16 -// Description: This function will write to a specific area of dpram -//             (Magnemite ASIC only) -// Input: -//     dev    - device structure -//     offset - index of dpram -//     value  - value to write -// Output: -//     none. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_write_dpram_mag_16 +   Description: This function will write to a specific area of dpram +               (Magnemite ASIC only) +   Input: +       dev    - device structure +       offset - index of dpram +       value  - value to write +   Output: +       none. + +  -------------------------------------------------------------------------*/  static inline void ft1000_write_dpram_mag_16(struct net_device *dev,  						 int offset, u16 value, int Index)  {  	struct ft1000_info *info = netdev_priv(dev);  	unsigned long flags; -	// Provide mutual exclusive access while reading ASIC registers. +	/* Provide mutual exclusive access while reading ASIC registers. */  	spin_lock_irqsave(&info->dpram_lock, flags);  	ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);  	if (Index) { @@ -218,25 +218,25 @@ static inline void ft1000_write_dpram_mag_16(struct net_device *dev,  	spin_unlock_irqrestore(&info->dpram_lock, flags);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_read_dpram_mag_32 -// Description: This function will read the specific area of dpram -//             (Magnemite ASIC only) -// Input: -//     dev    - device structure -//     offset - index of dpram -// Output: -//     value  - value of dpram -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_read_dpram_mag_32 +   Description: This function will read the specific area of dpram +               (Magnemite ASIC only) +   Input: +       dev    - device structure +       offset - index of dpram +   Output: +       value  - value of dpram + +  -------------------------------------------------------------------------*/  u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset)  {  	struct ft1000_info *info = netdev_priv(dev);  	unsigned long flags;  	u32 data; -	// Provide mutual exclusive access while reading ASIC registers. +	/* Provide mutual exclusive access while reading ASIC registers. */  	spin_lock_irqsave(&info->dpram_lock, flags);  	ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);  	data = inl(dev->base_addr + FT1000_REG_MAG_DPDATAL); @@ -245,41 +245,41 @@ u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset)  	return (data);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_write_dpram_mag_32 -// Description: This function will write to a specific area of dpram -//             (Magnemite ASIC only) -// Input: -//     dev    - device structure -//     offset - index of dpram -//     value  - value to write -// Output: -//     none. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_write_dpram_mag_32 +   Description: This function will write to a specific area of dpram +               (Magnemite ASIC only) +   Input: +       dev    - device structure +       offset - index of dpram +       value  - value to write +   Output: +       none. + +  -------------------------------------------------------------------------*/  void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value)  {  	struct ft1000_info *info = netdev_priv(dev);  	unsigned long flags; -	// Provide mutual exclusive access while reading ASIC registers. +	/* Provide mutual exclusive access while reading ASIC registers. */  	spin_lock_irqsave(&info->dpram_lock, flags);  	ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, offset);  	outl(value, dev->base_addr + FT1000_REG_MAG_DPDATAL);  	spin_unlock_irqrestore(&info->dpram_lock, flags);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_enable_interrupts -// Description: This function will enable interrupts base on the current interrupt mask. -// Input: -//     dev    - device structure -// Output: -//     None. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_enable_interrupts +   Description: This function will enable interrupts base on the current interrupt mask. +   Input: +       dev    - device structure +   Output: +       None. + +  -------------------------------------------------------------------------*/  static void ft1000_enable_interrupts(struct net_device *dev)  {  	u16 tempword; @@ -292,16 +292,16 @@ static void ft1000_enable_interrupts(struct net_device *dev)  		  tempword);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_disable_interrupts -// Description: This function will disable all interrupts. -// Input: -//     dev    - device structure -// Output: -//     None. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_disable_interrupts +   Description: This function will disable all interrupts. +   Input: +       dev    - device structure +   Output: +       None. + +  -------------------------------------------------------------------------*/  static void ft1000_disable_interrupts(struct net_device *dev)  {  	u16 tempword; @@ -314,17 +314,17 @@ static void ft1000_disable_interrupts(struct net_device *dev)  		  tempword);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_reset_asic -// Description: This function will call the Card Service function to reset the -//             ASIC. -// Input: -//     dev    - device structure -// Output: -//     none -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_reset_asic +   Description: This function will call the Card Service function to reset the +               ASIC. +   Input: +       dev    - device structure +   Output: +       none + +  -------------------------------------------------------------------------*/  static void ft1000_reset_asic(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -335,21 +335,23 @@ static void ft1000_reset_asic(struct net_device *dev)  	(*info->ft1000_reset) (pcmcia->link); -	// Let's use the register provided by the Magnemite ASIC to reset the -	// ASIC and DSP. +	/* +	 * Let's use the register provided by the Magnemite ASIC to reset the +	 * ASIC and DSP. +	 */  	if (info->AsicID == MAGNEMITE_ID) {  		ft1000_write_reg(dev, FT1000_REG_RESET,  				 (DSP_RESET_BIT | ASIC_RESET_BIT));  	}  	mdelay(1);  	if (info->AsicID == ELECTRABUZZ_ID) { -		// set watermark to -1 in order to not generate an interrupt +		/* set watermark to -1 in order to not generate an interrupt */  		ft1000_write_reg(dev, FT1000_REG_WATERMARK, 0xffff);  	} else { -		// set watermark to -1 in order to not generate an interrupt +		/* set watermark to -1 in order to not generate an interrupt */  		ft1000_write_reg(dev, FT1000_REG_MAG_WATERMARK, 0xffff);  	} -	// clear interrupts +	/* clear interrupts */  	tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);  	DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);  	ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword); @@ -358,17 +360,17 @@ static void ft1000_reset_asic(struct net_device *dev)  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_reset_card -// Description: This function will reset the card -// Input: -//     dev    - device structure -// Output: -//     status - false (card reset fail) -//              true  (card reset successful) -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_reset_card +   Description: This function will reset the card +   Input: +       dev    - device structure +   Output: +       status - false (card reset fail) +                true  (card reset successful) + +  -------------------------------------------------------------------------*/  static int ft1000_reset_card(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -384,9 +386,9 @@ static int ft1000_reset_card(struct net_device *dev)  	info->squeseqnum = 0;  	ft1000_disable_interrupts(dev); -//	del_timer(&poll_timer); +	/* del_timer(&poll_timer); */ -	// Make sure we free any memory reserve for provisioning +	/* Make sure we free any memory reserve for provisioning */  	while (list_empty(&info->prov_list) == 0) {  		DEBUG(0,  			  "ft1000_hw:ft1000_reset_card:deleting provisioning record\n"); @@ -406,7 +408,7 @@ static int ft1000_reset_card(struct net_device *dev)  				 (DSP_RESET_BIT | ASIC_RESET_BIT));  	} -	// Copy DSP session record into info block if this is not a coldstart +	/* Copy DSP session record into info block if this is not a coldstart */  	if (ft1000_card_present == 1) {  		spin_lock_irqsave(&info->dpram_lock, flags);  		if (info->AsicID == ELECTRABUZZ_ID) { @@ -430,29 +432,29 @@ static int ft1000_reset_card(struct net_device *dev)  	DEBUG(1, "ft1000_hw:ft1000_reset_card:resetting ASIC\n");  	mdelay(10); -	//reset ASIC +	/* reset ASIC */  	ft1000_reset_asic(dev);  	DEBUG(1, "ft1000_hw:ft1000_reset_card:downloading dsp image\n");  	if (info->AsicID == MAGNEMITE_ID) { -		// Put dsp in reset and take ASIC out of reset +		/* Put dsp in reset and take ASIC out of reset */  		DEBUG(0,  			  "ft1000_hw:ft1000_reset_card:Put DSP in reset and take ASIC out of reset\n");  		ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT); -		// Setting MAGNEMITE ASIC to big endian mode +		/* Setting MAGNEMITE ASIC to big endian mode */  		ft1000_write_reg(dev, FT1000_REG_SUP_CTRL, HOST_INTF_BE); -		// Download bootloader +		/* Download bootloader */  		card_bootload(dev); -		// Take DSP out of reset +		/* Take DSP out of reset */  		ft1000_write_reg(dev, FT1000_REG_RESET, 0); -		// FLARION_DSP_ACTIVE; +		/* FLARION_DSP_ACTIVE; */  		mdelay(10);  		DEBUG(0, "ft1000_hw:ft1000_reset_card:Take DSP out of reset\n"); -		// Wait for 0xfefe indicating dsp ready before starting download +		/* Wait for 0xfefe indicating dsp ready before starting download */  		for (i = 0; i < 50; i++) {  			tempword =  				ft1000_read_dpram_mag_16(dev, FT1000_MAG_DPRAM_FEFE, @@ -470,7 +472,7 @@ static int ft1000_reset_card(struct net_device *dev)  		}  	} else { -		// Take DSP out of reset +		/* Take DSP out of reset */  		ft1000_write_reg(dev, FT1000_REG_RESET, ~DSP_RESET_BIT);  		mdelay(10);  	} @@ -485,17 +487,19 @@ static int ft1000_reset_card(struct net_device *dev)  	mdelay(10);  	if (info->AsicID == ELECTRABUZZ_ID) { -		// Need to initialize the FIFO length counter to zero in order to sync up -		// with the DSP +		/* +		 * Need to initialize the FIFO length counter to zero in order to sync up +		 * with the DSP +		 */  		info->fifo_cnt = 0;  		ft1000_write_dpram(dev, FT1000_FIFO_LEN, info->fifo_cnt); -		// Initialize DSP heartbeat area to ho +		/* Initialize DSP heartbeat area to ho */  		ft1000_write_dpram(dev, FT1000_HI_HO, ho);  		tempword = ft1000_read_dpram(dev, FT1000_HI_HO);  		DEBUG(1, "ft1000_hw:ft1000_reset_asic:hi_ho value = 0x%x\n",  			  tempword);  	} else { -		// Initialize DSP heartbeat area to ho +		/* Initialize DSP heartbeat area to ho */  		ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, ho_mag,  					  FT1000_MAG_HI_HO_INDX);  		tempword = @@ -509,40 +513,44 @@ static int ft1000_reset_card(struct net_device *dev)  	ft1000_enable_interrupts(dev);  	/* Schedule heartbeat process to run every 2 seconds */ -//	poll_timer.expires = jiffies + (2*HZ); -//	poll_timer.data = (u_long)dev; -//	add_timer(&poll_timer); +	/* poll_timer.expires = jiffies + (2*HZ); */ +	/* poll_timer.data = (u_long)dev; */ +	/* add_timer(&poll_timer); */  	return true;  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_chkcard -// Description: This function will check if the device is presently available on -//             the system. -// Input: -//     dev    - device structure -// Output: -//     status - false (device is not present) -//              true  (device is present) -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_chkcard +   Description: This function will check if the device is presently available on +               the system. +   Input: +       dev    - device structure +   Output: +       status - false (device is not present) +                true  (device is present) + +  -------------------------------------------------------------------------*/  static int ft1000_chkcard(struct net_device *dev)  {  	u16 tempword; -	// Mask register is used to check for device presence since it is never -	// set to zero. +	/* +	 * Mask register is used to check for device presence since it is never +	 * set to zero. +	 */  	tempword = ft1000_read_reg(dev, FT1000_REG_SUP_IMASK);  	if (tempword == 0) {  		DEBUG(1,  			  "ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");  		return false;  	} -	// The system will return the value of 0xffff for the version register -	// if the device is not present. +	/* +	 * The system will return the value of 0xffff for the version register +	 * if the device is not present. +	 */  	tempword = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);  	if (tempword == 0xffff) {  		DEBUG(1, @@ -553,17 +561,17 @@ static int ft1000_chkcard(struct net_device *dev)  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_hbchk -// Description: This function will perform the heart beat check of the DSP as -//             well as the ASIC. -// Input: -//     dev    - device structure -// Output: -//     none -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_hbchk +   Description: This function will perform the heart beat check of the DSP as +               well as the ASIC. +   Input: +       dev    - device structure +   Output: +       none + +  -------------------------------------------------------------------------*/  static void ft1000_hbchk(u_long data)  {  	struct net_device *dev = (struct net_device *)data; @@ -574,7 +582,7 @@ static void ft1000_hbchk(u_long data)  	info = netdev_priv(dev);  	if (info->CardReady == 1) { -		// Perform dsp heartbeat check +		/* Perform dsp heartbeat check */  		if (info->AsicID == ELECTRABUZZ_ID) {  			tempword = ft1000_read_dpram(dev, FT1000_HI_HO);  		} else { @@ -585,7 +593,7 @@ static void ft1000_hbchk(u_long data)  		}  		DEBUG(1, "ft1000_hw:ft1000_hbchk:hi_ho value = 0x%x\n",  			  tempword); -		// Let's perform another check if ho is not detected +		/* Let's perform another check if ho is not detected */  		if (tempword != ho) {  			if (info->AsicID == ELECTRABUZZ_ID) {  				tempword = ft1000_read_dpram(dev, FT1000_HI_HO); @@ -639,7 +647,7 @@ static void ft1000_hbchk(u_long data)  		}  		tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL); -		// Let's check doorbell again if fail +		/* Let's check doorbell again if fail */  		if (tempword & FT1000_DB_HB) {  			tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);  		} @@ -686,8 +694,10 @@ static void ft1000_hbchk(u_long data)  			add_timer(&poll_timer);  			return;  		} -		// Set dedicated area to hi and ring appropriate doorbell according -		// to hi/ho heartbeat protocol +		/* +		 * Set dedicated area to hi and ring appropriate doorbell according +		 * to hi/ho heartbeat protocol +		 */  		if (info->AsicID == ELECTRABUZZ_ID) {  			ft1000_write_dpram(dev, FT1000_HI_HO, hi);  		} else { @@ -703,7 +713,7 @@ static void ft1000_hbchk(u_long data)  				  (dev, FT1000_MAG_HI_HO,  				   FT1000_MAG_HI_HO_INDX));  		} -        // Let's write hi again if fail +		/* Let's write hi again if fail */  		if (tempword != hi) {  			if (info->AsicID == ELECTRABUZZ_ID) {  				ft1000_write_dpram(dev, FT1000_HI_HO, hi); @@ -774,14 +784,14 @@ static void ft1000_hbchk(u_long data)  	add_timer(&poll_timer);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_send_cmd -// Description: -// Input: -// Output: -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_send_cmd +   Description: +   Input: +   Output: + +  -------------------------------------------------------------------------*/  static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -790,17 +800,19 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size,  	unsigned long flags;  	size += sizeof(struct pseudo_hdr); -	// check for odd byte and increment to 16-bit word align value +	/* check for odd byte and increment to 16-bit word align value */  	if ((size & 0x0001)) {  		size++;  	}  	DEBUG(1, "FT1000:ft1000_send_cmd:total length = %d\n", size);  	DEBUG(1, "FT1000:ft1000_send_cmd:length = %d\n", ntohs(*ptempbuffer)); -	// put message into slow queue area -	// All messages are in the form total_len + pseudo header + message body +	/* +	 * put message into slow queue area +	 * All messages are in the form total_len + pseudo header + message body +	 */  	spin_lock_irqsave(&info->dpram_lock, flags); -    // Make sure SLOWQ doorbell is clear +    /* Make sure SLOWQ doorbell is clear */      tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);      i=0;      while (tempword & FT1000_DB_DPRAM_TX) { @@ -816,9 +828,9 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size,  	if (info->AsicID == ELECTRABUZZ_ID) {  		ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,  				 FT1000_DPRAM_TX_BASE); -		// Write total length to dpram +		/* Write total length to dpram */  		ft1000_write_reg(dev, FT1000_REG_DPRAM_DATA, size); -		// Write pseudo header and messgae body +		/* Write pseudo header and messgae body */  		for (i = 0; i < (size >> 1); i++) {  			DEBUG(1, "FT1000:ft1000_send_cmd:data %d = 0x%x\n", i,  				  *ptempbuffer); @@ -828,9 +840,9 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size,  	} else {  		ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,  				 FT1000_DPRAM_MAG_TX_BASE); -		// Write total length to dpram +		/* Write total length to dpram */  		ft1000_write_reg(dev, FT1000_REG_MAG_DPDATAH, htons(size)); -		// Write pseudo header and messgae body +		/* Write pseudo header and messgae body */  		ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,  				 FT1000_DPRAM_MAG_TX_BASE + 1);  		for (i = 0; i < (size >> 2); i++) { @@ -850,23 +862,23 @@ static void ft1000_send_cmd (struct net_device *dev, u16 *ptempbuffer, int size,  	}  	spin_unlock_irqrestore(&info->dpram_lock, flags); -	// ring doorbell to notify DSP that we have a message ready +	/* ring doorbell to notify DSP that we have a message ready */  	ft1000_write_reg(dev, FT1000_REG_DOORBELL, FT1000_DB_DPRAM_TX);  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_receive_cmd -// Description: This function will read a message from the dpram area. -// Input: -//    dev - network device structure -//    pbuffer - caller supply address to buffer -//    pnxtph - pointer to next pseudo header -// Output: -//   Status = 0 (unsuccessful) -//          = 1 (successful) -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_receive_cmd +   Description: This function will read a message from the dpram area. +   Input: +      dev - network device structure +      pbuffer - caller supply address to buffer +      pnxtph - pointer to next pseudo header +   Output: +     Status = 0 (unsuccessful) +            = 1 (successful) + +  -------------------------------------------------------------------------*/  static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,  				int maxsz, u16 *pnxtph)  { @@ -919,7 +931,7 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,  					FT1000_REG_MAG_DPDATAH);  				pbuffer++;  			} -			//copy odd aligned word +			/* copy odd aligned word */  			*pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAL);  			DEBUG(1, "ft1000_hw:received data = 0x%x\n", *pbuffer);  			pbuffer++; @@ -928,14 +940,16 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,  			pbuffer++;  		}  		if (size & 0x0001) { -			//copy odd byte from fifo +			/* copy odd byte from fifo */  			tempword = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);  			*pbuffer = ntohs(tempword);  		}  		spin_unlock_irqrestore(&info->dpram_lock, flags); -		// Check if pseudo header checksum is good -		// Calculate pseudo header checksum +		/* +		 * Check if pseudo header checksum is good +		 * Calculate pseudo header checksum +		 */  		tempword = *ppseudohdr++;  		for (i = 1; i < 7; i++) {  			tempword ^= *ppseudohdr++; @@ -943,24 +957,24 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,  		if ((tempword != *ppseudohdr)) {  			DEBUG(1,  				  "FT1000:ft1000_receive_cmd:Pseudo header checksum mismatch\n"); -			// Drop this message +			/* Drop this message */  			return false;  		}  		return true;  	}  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_proc_drvmsg -// Description: This function will process the various driver messages. -// Input: -//     dev    - device structure -//     pnxtph - pointer to next pseudo header -// Output: -//     none -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_proc_drvmsg +   Description: This function will process the various driver messages. +   Input: +       dev    - device structure +       pnxtph - pointer to next pseudo header +   Output: +       none + +  -------------------------------------------------------------------------*/  static void ft1000_proc_drvmsg(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -988,7 +1002,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev)      }      if ( ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword) ) { -		// Get the message type which is total_len + PSEUDO header + msgtype + message body +		/* Get the message type which is total_len + PSEUDO header + msgtype + message body */  		pdrvmsg = (struct drv_msg *) & cmdbuffer[0];  		msgtype = ntohs(pdrvmsg->type);  		DEBUG(1, "Command message type = 0x%x\n", msgtype); @@ -999,7 +1013,7 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  			mdelay(25);  			while (list_empty(&info->prov_list) == 0) {  				DEBUG(0, "Sending a provisioning message\n"); -				// Make sure SLOWQ doorbell is clear +				/* Make sure SLOWQ doorbell is clear */  				tempword =  					ft1000_read_reg(dev, FT1000_REG_DOORBELL);  				i = 0; @@ -1018,10 +1032,10 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  				pmsg = (u16 *) ptr->pprov_data;  				ppseudo_hdr = (struct pseudo_hdr *) pmsg; -				// Insert slow queue sequence number +				/* Insert slow queue sequence number */  				ppseudo_hdr->seq_num = info->squeseqnum++;  				ppseudo_hdr->portsrc = 0; -				// Calculate new checksum +				/* Calculate new checksum */  				ppseudo_hdr->checksum = *pmsg++;  				DEBUG(1, "checksum = 0x%x\n",  					  ppseudo_hdr->checksum); @@ -1036,8 +1050,10 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  				kfree(ptr->pprov_data);  				kfree(ptr);  			} -			// Indicate adapter is ready to take application messages after all -			// provisioning messages are sent +			/* +			 * Indicate adapter is ready to take application messages after all +			 * provisioning messages are sent +			 */  			info->CardReady = 1;  			break;  		case MEDIA_STATE: @@ -1118,8 +1134,10 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  			break;  		case DSP_GET_INFO:  			DEBUG(1, "FT1000:drivermsg:Got DSP_GET_INFO\n"); -			// copy dsp info block to dsp -			// allow any outstanding ioctl to finish +			/* +			 * copy dsp info block to dsp +			 * allow any outstanding ioctl to finish +			 */  			mdelay(10);  			tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);  			if (tempword & FT1000_DB_DPRAM_TX) { @@ -1132,8 +1150,10 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  			}  			if ((tempword & FT1000_DB_DPRAM_TX) == 0) { -				// Put message into Slow Queue -				// Form Pseudo header +				/* +				 * Put message into Slow Queue +				 * Form Pseudo header +				 */  				pmsg = (u16 *) info->DSPInfoBlk;  				ppseudo_hdr = (struct pseudo_hdr *) pmsg;  				ppseudo_hdr->length = @@ -1147,11 +1167,11 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  				ppseudo_hdr->rsvd1 = 0;  				ppseudo_hdr->rsvd2 = 0;  				ppseudo_hdr->qos_class = 0; -				// Insert slow queue sequence number +				/* Insert slow queue sequence number */  				ppseudo_hdr->seq_num = info->squeseqnum++; -				// Insert application id +				/* Insert application id */  				ppseudo_hdr->portsrc = 0; -				// Calculate new checksum +				/* Calculate new checksum */  				ppseudo_hdr->checksum = *pmsg++;  				for (i = 1; i < 7; i++) {  					ppseudo_hdr->checksum ^= *pmsg++; @@ -1165,8 +1185,10 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  			break;  		case GET_DRV_ERR_RPT_MSG:  			DEBUG(1, "FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n"); -			// copy driver error message to dsp -			// allow any outstanding ioctl to finish +			/* +			 * copy driver error message to dsp +			 * allow any outstanding ioctl to finish +			 */  			mdelay(10);  			tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);  			if (tempword & FT1000_DB_DPRAM_TX) { @@ -1179,8 +1201,10 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  			}  			if ((tempword & FT1000_DB_DPRAM_TX) == 0) { -				// Put message into Slow Queue -				// Form Pseudo header +				/* +				 * Put message into Slow Queue +				 * Form Pseudo header +				 */  				pmsg = (u16 *) & tempbuffer[0];  				ppseudo_hdr = (struct pseudo_hdr *) pmsg;  				ppseudo_hdr->length = htons(0x0012); @@ -1193,11 +1217,11 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  				ppseudo_hdr->rsvd1 = 0;  				ppseudo_hdr->rsvd2 = 0;  				ppseudo_hdr->qos_class = 0; -				// Insert slow queue sequence number +				/* Insert slow queue sequence number */  				ppseudo_hdr->seq_num = info->squeseqnum++; -				// Insert application id +				/* Insert application id */  				ppseudo_hdr->portsrc = 0; -				// Calculate new checksum +				/* Calculate new checksum */                  ppseudo_hdr->checksum = *pmsg++;                  for (i=1; i<7; i++) {                      ppseudo_hdr->checksum ^= *pmsg++; @@ -1228,18 +1252,18 @@ static void ft1000_proc_drvmsg(struct net_device *dev)  	}  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_parse_dpram_msg -// Description: This function will parse the message received from the DSP -//             via the DPRAM interface. -// Input: -//     dev    - device structure -// Output: -//     status - FAILURE -//              SUCCESS -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_parse_dpram_msg +   Description: This function will parse the message received from the DSP +               via the DPRAM interface. +   Input: +       dev    - device structure +   Output: +       status - FAILURE +                SUCCESS + +  -------------------------------------------------------------------------*/  static int ft1000_parse_dpram_msg(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -1255,7 +1279,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  	DEBUG(1, "Doorbell = 0x%x\n", doorbell);  	if (doorbell & FT1000_ASIC_RESET_REQ) { -		// Copy DSP session record from info block +		/* Copy DSP session record from info block */  		spin_lock_irqsave(&info->dpram_lock, flags);  		if (info->AsicID == ELECTRABUZZ_ID) {  			ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR, @@ -1274,7 +1298,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  		}  		spin_unlock_irqrestore(&info->dpram_lock, flags); -		// clear ASIC RESET request +		/* clear ASIC RESET request */  		ft1000_write_reg(dev, FT1000_REG_DOORBELL,  				 FT1000_ASIC_RESET_REQ);  		DEBUG(1, "Got an ASIC RESET Request\n"); @@ -1282,7 +1306,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  				 FT1000_ASIC_RESET_DSP);  		if (info->AsicID == MAGNEMITE_ID) { -			// Setting MAGNEMITE ASIC to big endian mode +			/* Setting MAGNEMITE ASIC to big endian mode */  			ft1000_write_reg(dev, FT1000_REG_SUP_CTRL,  					 HOST_INTF_BE);  		} @@ -1315,8 +1339,10 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  		if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) {              total_len += nxtph;              cnt = 0; -            // ft1000_read_reg will return a value that needs to be byteswap -            // in order to get DSP_QID_OFFSET. +			/* +			 * ft1000_read_reg will return a value that needs to be byteswap +			 * in order to get DSP_QID_OFFSET. +			 */  			if (info->AsicID == ELECTRABUZZ_ID) {  				portid =  					(ft1000_read_dpram @@ -1332,7 +1358,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  			DEBUG(1, "DSP_QID = 0x%x\n", portid);  			if (portid == DRIVERID) { -				// We are assumming one driver message from the DSP at a time. +				/* We are assumming one driver message from the DSP at a time. */  				ft1000_proc_drvmsg(dev);  			}  		} @@ -1340,7 +1366,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  	}  	if (doorbell & FT1000_DB_COND_RESET) { -		// Reset ASIC and DSP +		/* Reset ASIC and DSP */  		if (info->AsicID == ELECTRABUZZ_ID) {  			info->DSP_TIME[0] =  				ft1000_read_dpram(dev, FT1000_DSP_TIMER0); @@ -1370,7 +1396,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  		ft1000_write_reg(dev, FT1000_REG_DOORBELL,  				 FT1000_DB_COND_RESET);  	} -	// let's clear any unexpected doorbells from DSP +	/* let's clear any unexpected doorbells from DSP */  	doorbell =  		doorbell & ~(FT1000_DB_DPRAM_RX | FT1000_ASIC_RESET_REQ |  			 FT1000_DB_COND_RESET | 0xff00); @@ -1383,18 +1409,18 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_flush_fifo -// Description: This function will flush one packet from the downlink -//             FIFO. -// Input: -//     dev      - device structure -//     drv_err  - driver error causing the flush fifo -// Output: -//     None. -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_flush_fifo +   Description: This function will flush one packet from the downlink +               FIFO. +   Input: +       dev      - device structure +       drv_err  - driver error causing the flush fifo +   Output: +       None. + +  -------------------------------------------------------------------------*/  static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -1432,7 +1458,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)  		ft1000_reset_card(dev);  		return;  	} else { -		// Flush corrupted pkt from FIFO +		/* Flush corrupted pkt from FIFO */  		i = 0;  		do {  			if (info->AsicID == ELECTRABUZZ_ID) { @@ -1447,8 +1473,10 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)  					inw(dev->base_addr + FT1000_REG_MAG_DFSR);  			}  			i++; -			// This should never happen unless the ASIC is broken. -			// We must reset to recover. +			/* +			 * This should never happen unless the ASIC is broken. +			 * We must reset to recover. +			 */  			if ((i > 2048) || (tempword == 0)) {  				if (info->AsicID == ELECTRABUZZ_ID) {  					info->DSP_TIME[0] = @@ -1482,17 +1510,19 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)  									 FT1000_MAG_DSP_TIMER3_INDX);  				}  				if (tempword == 0) { -					// Let's check if ASIC reads are still ok by reading the Mask register -					// which is never zero at this point of the code. +					/* +					 * Let's check if ASIC reads are still ok by reading the Mask register +					 * which is never zero at this point of the code. +					 */  					tempword =  						inw(dev->base_addr +  						FT1000_REG_SUP_IMASK);  					if (tempword == 0) { -						// This indicates that we can not communicate with the ASIC +						/* This indicates that we can not communicate with the ASIC */  						info->DrvErrNum =  							FIFO_FLUSH_BADCNT;  					} else { -						// Let's assume that we really flush the FIFO +						/* Let's assume that we really flush the FIFO */  						pcmcia->PktIntfErr++;  						return;  					} @@ -1506,9 +1536,9 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)  		if (info->AsicID == ELECTRABUZZ_ID) {  			i++;  			DEBUG(0, "Flushing FIFO complete = %x\n", tempword); -			// Flush last word in FIFO. +			/* Flush last word in FIFO. */  			tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO); -			// Update FIFO counter for DSP +			/* Update FIFO counter for DSP */  			i = i * 2;  			DEBUG(0, "Flush Data byte count to dsp = %d\n", i);  			info->fifo_cnt += i; @@ -1516,7 +1546,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)  					   info->fifo_cnt);  		} else {  			DEBUG(0, "Flushing FIFO complete = %x\n", tempword); -			// Flush last word in FIFO +			/* Flush last word in FIFO */  			templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);  			tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);  			DEBUG(0, "FT1000_REG_SUP_STAT = 0x%x\n", tempword); @@ -1529,19 +1559,19 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)  	}  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_copy_up_pkt -// Description: This function will pull Flarion packets out of the Downlink -//             FIFO and convert it to an ethernet packet.  The ethernet packet will -//             then be deliver to the TCP/IP stack. -// Input: -//     dev    - device structure -// Output: -//     status - FAILURE -//              SUCCESS -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_copy_up_pkt +   Description: This function will pull Flarion packets out of the Downlink +               FIFO and convert it to an ethernet packet.  The ethernet packet will +               then be deliver to the TCP/IP stack. +   Input: +       dev    - device structure +   Output: +       status - FAILURE +                SUCCESS + +  -------------------------------------------------------------------------*/  static int ft1000_copy_up_pkt(struct net_device *dev)  {  	u16 tempword; @@ -1556,7 +1586,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  	u32 templong;  	DEBUG(1, "ft1000_copy_up_pkt\n"); -	// Read length +	/* Read length */  	if (info->AsicID == ELECTRABUZZ_ID) {  		tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);  		len = tempword; @@ -1570,7 +1600,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  	if (len > ENET_MAX_SIZE) {  		DEBUG(0, "size of ethernet packet invalid\n");  		if (info->AsicID == MAGNEMITE_ID) { -			// Read High word to complete 32 bit access +			/* Read High word to complete 32 bit access */  			tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);  		}  		ft1000_flush_fifo(dev, DSP_PKTLEN_INFO); @@ -1582,7 +1612,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  	if (skb == NULL) {  		DEBUG(0, "No Network buffers available\n"); -		// Read High word to complete 32 bit access +		/* Read High word to complete 32 bit access */  		if (info->AsicID == MAGNEMITE_ID) {  			tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);  		} @@ -1592,13 +1622,13 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  	}  	pbuffer = (u8 *) skb_put(skb, len + 12); -	// Pseudo header +	/* Pseudo header */  	if (info->AsicID == ELECTRABUZZ_ID) {  		for (i = 1; i < 7; i++) {  			tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);  			chksum ^= tempword;  		} -		// read checksum value +		/* read checksum value */  		tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);  	} else {  		tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH); @@ -1625,7 +1655,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  		DEBUG(1, "Pseudo = 0x%x\n", tempword);  		chksum ^= tempword; -		// read checksum value +		/* read checksum value */  		tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);  		DEBUG(1, "Pseudo = 0x%x\n", tempword);  	} @@ -1638,10 +1668,10 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  		kfree_skb(skb);  		return FAILURE;  	} -	//subtract the number of bytes read already +	/* subtract the number of bytes read already */  	ptemp = pbuffer; -	// fake MAC address +	/* fake MAC address */  	*pbuffer++ = dev->dev_addr[0];  	*pbuffer++ = dev->dev_addr[1];  	*pbuffer++ = dev->dev_addr[2]; @@ -1666,7 +1696,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  			}  		} -		// Need to read one more word if odd byte +		/* Need to read one more word if odd byte */  		if (len & 0x0001) {  			tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);  			*pbuffer++ = (u8) (tempword >> 8); @@ -1679,7 +1709,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  			*ptemplong++ = templong;  		} -		// Need to read one more word if odd align. +		/* Need to read one more word if odd align. */  		if (len & 0x0003) {  			templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);  			DEBUG(1, "Data = 0x%8x\n", templong); @@ -1699,11 +1729,11 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  	netif_rx(skb);  	info->stats.rx_packets++; -	// Add on 12 bytes for MAC address which was removed +	/* Add on 12 bytes for MAC address which was removed */  	info->stats.rx_bytes += (len + 12);  	if (info->AsicID == ELECTRABUZZ_ID) { -		// track how many bytes have been read from FIFO - round up to 16 bit word +		/* track how many bytes have been read from FIFO - round up to 16 bit word */  		tempword = len + 16;  		if (tempword & 0x01)  			tempword++; @@ -1715,21 +1745,21 @@ static int ft1000_copy_up_pkt(struct net_device *dev)  	return SUCCESS;  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_copy_down_pkt -// Description: This function will take an ethernet packet and convert it to -//             a Flarion packet prior to sending it to the ASIC Downlink -//             FIFO. -// Input: -//     dev    - device structure -//     packet - address of ethernet packet -//     len    - length of IP packet -// Output: -//     status - FAILURE -//              SUCCESS -// -//--------------------------------------------------------------------------- +/*--------------------------------------------------------------------------- + +   Function:   ft1000_copy_down_pkt +   Description: This function will take an ethernet packet and convert it to +               a Flarion packet prior to sending it to the ASIC Downlink +               FIFO. +   Input: +       dev    - device structure +       packet - address of ethernet packet +       len    - length of IP packet +   Output: +       status - FAILURE +                SUCCESS + +  -------------------------------------------------------------------------*/  static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -1744,7 +1774,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  	DEBUG(1, "ft1000_hw: copy_down_pkt()\n"); -	// Check if there is room on the FIFO +	/* Check if there is room on the FIFO */  	if (len > ft1000_read_fifo_len(dev)) {  		udelay(10);  		if (len > ft1000_read_fifo_len(dev)) { @@ -1769,15 +1799,15 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  			return SUCCESS;  		}  	} -	// Create pseudo header and send pseudo/ip to hardware +	/* Create pseudo header and send pseudo/ip to hardware */  	if (info->AsicID == ELECTRABUZZ_ID) {  		pseudo.blk.length = len;  	} else {  		pseudo.blk.length = ntohs(len);  	} -	pseudo.blk.source = DSPID;	// Need to swap to get in correct order +	pseudo.blk.source = DSPID;	/* Need to swap to get in correct order */  	pseudo.blk.destination = HOSTID; -	pseudo.blk.portdest = NETWORKID;	// Need to swap to get in correct order +	pseudo.blk.portdest = NETWORKID;	/* Need to swap to get in correct order */  	pseudo.blk.portsrc = DSPAIRID;  	pseudo.blk.sh_str_id = 0;  	pseudo.blk.control = 0; @@ -1791,14 +1821,14 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  		pseudo.blk.checksum ^= pseudo.buff[i];  	} -	// Production Mode +	/* Production Mode */  	if (info->AsicID == ELECTRABUZZ_ID) { -		// copy first word to UFIFO_BEG reg +		/* copy first word to UFIFO_BEG reg */  		ft1000_write_reg(dev, FT1000_REG_UFIFO_BEG, pseudo.buff[0]);  		DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 0 BEG = 0x%04x\n",  			  pseudo.buff[0]); -		// copy subsequent words to UFIFO_MID reg +		/* copy subsequent words to UFIFO_MID reg */  		ft1000_write_reg(dev, FT1000_REG_UFIFO_MID, pseudo.buff[1]);  		DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 1 MID = 0x%04x\n",  			  pseudo.buff[1]); @@ -1821,7 +1851,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  		DEBUG(1, "ft1000_hw:ft1000_copy_down_pkt:data 7 MID = 0x%04x\n",  			  pseudo.buff[7]); -		// Write PPP type + IP Packet into Downlink FIFO +		/* Write PPP type + IP Packet into Downlink FIFO */  		for (i = 0; i < (len >> 1) - 1; i++) {  			ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,  					 htons(*packet)); @@ -1831,7 +1861,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  			packet++;  		} -		// Check for odd byte +		/* Check for odd byte */  		if (len & 0x0001) {  			ft1000_write_reg(dev, FT1000_REG_UFIFO_MID,  					 htons(*packet)); @@ -1870,12 +1900,12 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  			  *(u32 *) & pseudo.buff[6]);  		plong = (u32 *) packet; -		// Write PPP type + IP Packet into Downlink FIFO +		/* Write PPP type + IP Packet into Downlink FIFO */  		for (i = 0; i < (len >> 2); i++) {  			outl(*plong++, dev->base_addr + FT1000_REG_MAG_UFDR);  		} -		// Check for odd alignment +		/* Check for odd alignment */  		if (len & 0x0003) {  			DEBUG(1,  				  "ft1000_hw:ft1000_copy_down_pkt:data = 0x%8x\n", @@ -1886,7 +1916,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)  	}  	info->stats.tx_packets++; -	// Add 14 bytes for MAC address plus ethernet type +	/* Add 14 bytes for MAC address plus ethernet type */  	info->stats.tx_bytes += (len + 14);  	return SUCCESS;  } @@ -1931,7 +1961,7 @@ static int ft1000_close(struct net_device *dev)  		ft1000_disable_interrupts(dev);  		ft1000_write_reg(dev, FT1000_REG_RESET, DSP_RESET_BIT); -		//reset ASIC +		/* reset ASIC */  		ft1000_reset_asic(dev);  	}  	return 0; @@ -1995,10 +2025,10 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)  	ft1000_disable_interrupts(dev); -	// Read interrupt type +	/* Read interrupt type */  	inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR); -    // Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type +	/* Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type */  	while (inttype) {  		if (inttype & ISR_DOORBELL_PEND)  			ft1000_parse_dpram_msg(dev); @@ -2008,7 +2038,7 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)  			cnt = 0;  			do { -				// Check if we have packets in the Downlink FIFO +				/* Check if we have packets in the Downlink FIFO */  				if (info->AsicID == ELECTRABUZZ_ID) {  					tempword =  					ft1000_read_reg(dev, @@ -2027,12 +2057,12 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)  			} while (cnt < MAX_RCV_LOOP);  		} -		// clear interrupts +		/* clear interrupts */  		tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);  		DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);  		ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword); -		// Read interrupt type +		/* Read interrupt type */  		inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR);  		DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype);  	} @@ -2044,7 +2074,7 @@ void stop_ft1000_card(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev);  	struct prov_record *ptr; -//	int cnt; +	/* int cnt; */  	DEBUG(0, "ft1000_hw: stop_ft1000_card()\n"); @@ -2053,7 +2083,7 @@ void stop_ft1000_card(struct net_device *dev)  	netif_stop_queue(dev);  	ft1000_disable_interrupts(dev); -	// Make sure we free any memory reserve for provisioning +	/* Make sure we free any memory reserve for provisioning */  	while (list_empty(&info->prov_list) == 0) {  		ptr = list_entry(info->prov_list.next, struct prov_record, list);  		list_del(&ptr->list); @@ -2109,7 +2139,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,  	struct ft1000_pcmcia *pcmcia;  	struct net_device *dev; -	static const struct net_device_ops ft1000ops =		// Slavius 21.10.2009 due to kernel changes +	static const struct net_device_ops ft1000ops =		/* Slavius 21.10.2009 due to kernel changes */  	{  		.ndo_open = &ft1000_open,  		.ndo_stop = &ft1000_close, @@ -2169,12 +2199,12 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,  	info->squeseqnum = 0; -//	dev->hard_start_xmit = &ft1000_start_xmit; -//	dev->get_stats = &ft1000_stats; -//	dev->open = &ft1000_open; -//	dev->stop = &ft1000_close; +	/* dev->hard_start_xmit = &ft1000_start_xmit; */ +	/* dev->get_stats = &ft1000_stats; */ +	/* dev->open = &ft1000_open; */ +	/* dev->stop = &ft1000_close; */ -	dev->netdev_ops = &ft1000ops;		// Slavius 21.10.2009 due to kernel changes +	dev->netdev_ops = &ft1000ops;		/* Slavius 21.10.2009 due to kernel changes */  	DEBUG(0, "device name = %s\n", dev->name); @@ -2219,7 +2249,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,  	ft1000InitProc(dev);  	ft1000_card_present = 1; -	SET_ETHTOOL_OPS(dev, &ops); +	dev->ethtool_ops = &ops;  	printk(KERN_INFO "ft1000: %s: addr 0x%04lx irq %d, MAC addr %pM\n",  			dev->name, dev->base_addr, dev->irq, dev->dev_addr);  	return dev; diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c index b2330f1df7e..88f6f9ce304 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c @@ -32,14 +32,14 @@  #define seq_putx(m, message, size, var) \  	seq_printf(m, message);	\ -	for(i = 0; i < (size - 1); i++) { \ +	for (i = 0; i < (size - 1); i++) { \  		seq_printf(m, "%02x:", var[i]); \  	} \  	seq_printf(m, "%02x\n", var[i])  #define seq_putd(m, message, size, var) \  	seq_printf(m, message); \ -	for(i = 0; i < (size - 1); i++) { \ +	for (i = 0; i < (size - 1); i++) { \  		seq_printf(m, "%d.", var[i]); \  	} \  	seq_printf(m, "%d\n", var[i]) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 68a55ce6920..a8945b78596 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -417,8 +417,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command,      u16 tempword;      unsigned long flags;      struct timeval tv; -    IOCTL_GET_VER get_ver_data; -    IOCTL_GET_DSP_STAT get_stat_data; +	struct IOCTL_GET_VER get_ver_data; +	struct IOCTL_GET_DSP_STAT get_stat_data;      u8 ConnectionMsg[] = {0x00,0x44,0x10,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x93,0x64,                            0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a,                            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -527,8 +527,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command,          break;      case IOCTL_SET_DPRAM_CMD:          { -            IOCTL_DPRAM_BLK *dpram_data = NULL; -            /* IOCTL_DPRAM_COMMAND dpram_command; */ +		struct IOCTL_DPRAM_BLK *dpram_data = NULL; +		/* struct IOCTL_DPRAM_COMMAND dpram_command; */              u16 qtype;              u16 msgsz;  		struct pseudo_hdr *ppseudo_hdr; @@ -560,6 +560,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command,                  /* Get the length field to see how many bytes to copy */                  result = get_user(msgsz, (__u16 __user *)argp); +		if (result) +			break;                  msgsz = ntohs(msgsz);                  /* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */ @@ -670,7 +672,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,      case IOCTL_GET_DPRAM_CMD:          {  		struct dpram_blk *pdpram_blk; -            IOCTL_DPRAM_BLK __user *pioctl_dpram; +		struct IOCTL_DPRAM_BLK __user *pioctl_dpram;              int msglen;              /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ @@ -783,7 +785,7 @@ static int ft1000_release(struct inode *inode, struct file *file)      /* initialize application information */      ft1000dev->appcnt--; -    DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, ft1000dev->appcnt); +    DEBUG("ft1000_chdev:%s:appcnt = %d\n", __func__, ft1000dev->appcnt);      ft1000dev->app_info[i].fileobject = NULL;      return 0; diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 5190c8ac4e0..65f98016713 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1,14 +1,9 @@ -//===================================================== -// CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. -// -// -// This file is part of Express Card USB Driver -// -// $Id: -//==================================================== -// 20090926; aelias; removed compiler warnings; ubuntu 9.04; 2.6.28-15-generic - -#include <linux/init.h> +/* +* CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. +* +* This file is part of Express Card USB Driver +*/ +  #include <linux/kernel.h>  #include <linux/module.h>  #include <linux/netdevice.h> @@ -59,7 +54,7 @@  #define  MAX_LENGTH              0x7f0 -// Temporary download mechanism for Magnemite +/* Temporary download mechanism for Magnemite */  #define  DWNLD_MAG_TYPE_LOC          0x00  #define  DWNLD_MAG_LEN_LOC           0x01  #define  DWNLD_MAG_ADDR_LOC          0x02 @@ -78,56 +73,45 @@  #define  HANDSHAKE_MAG_TIMEOUT_VALUE 0xF1F1 -// New Magnemite downloader +/* New Magnemite downloader */  #define  DWNLD_MAG1_HANDSHAKE_LOC     0x00  #define  DWNLD_MAG1_TYPE_LOC          0x01  #define  DWNLD_MAG1_SIZE_LOC          0x02  #define  DWNLD_MAG1_PS_HDR_LOC        0x03  struct dsp_file_hdr { -   long              version_id;          // Version ID of this image format. -   long              package_id;          // Package ID of code release. -   long              build_date;          // Date/time stamp when file was built. -   long              commands_offset;     // Offset to attached commands in Pseudo Hdr format. -   long              loader_offset;       // Offset to bootloader code. -   long              loader_code_address; // Start address of bootloader. -   long              loader_code_end;     // Where bootloader code ends. -   long              loader_code_size; -   long              version_data_offset; // Offset were scrambled version data begins. -   long              version_data_size;   // Size, in words, of scrambled version data. -   long              nDspImages;          // Number of DSP images in file. +	long              version_id;          /* Version ID of this image format. */ +	long              package_id;          /* Package ID of code release. */ +	long              build_date;          /* Date/time stamp when file was built. */ +	long              commands_offset;     /* Offset to attached commands in Pseudo Hdr format. */ +	long              loader_offset;       /* Offset to bootloader code. */ +	long              loader_code_address; /* Start address of bootloader. */ +	long              loader_code_end;     /* Where bootloader code ends. */ +	long              loader_code_size; +	long              version_data_offset; /* Offset were scrambled version data begins. */ +	long              version_data_size;   /* Size, in words, of scrambled version data. */ +	long              nDspImages;          /* Number of DSP images in file. */  };  #pragma pack(1)  struct dsp_image_info { -   long              coff_date;           // Date/time when DSP Coff image was built. -   long              begin_offset;        // Offset in file where image begins. -   long              end_offset;          // Offset in file where image begins. -   long              run_address;         // On chip Start address of DSP code. -   long              image_size;          // Size of image. -   long              version;             // Embedded version # of DSP code. -   unsigned short    checksum;            // DSP File checksum -   unsigned short    pad1; +	long              coff_date;           /* Date/time when DSP Coff image was built. */ +	long              begin_offset;        /* Offset in file where image begins. */ +	long              end_offset;          /* Offset in file where image begins. */ +	long              run_address;         /* On chip Start address of DSP code. */ +	long              image_size;          /* Size of image. */ +	long              version;             /* Embedded version # of DSP code. */ +	unsigned short    checksum;            /* DSP File checksum */ +	unsigned short    pad1;  }; -//--------------------------------------------------------------------------- -// Function:    check_usb_db -// -// Parameters:  struct ft1000_usb  - device structure -// -// Returns:     0 - success -// -// Description: This function checks if the doorbell register is cleared -// -// Notes: -// -//--------------------------------------------------------------------------- -static u32 check_usb_db (struct ft1000_usb *ft1000dev) +/* checks if the doorbell register is cleared */ +static int check_usb_db(struct ft1000_usb *ft1000dev)  {  	int loopcnt;  	u16 temp; -	u32 status; +	int status;  	loopcnt = 0; @@ -166,28 +150,15 @@ static u32 check_usb_db (struct ft1000_usb *ft1000dev)  		}  	} -	return HANDSHAKE_MAG_TIMEOUT_VALUE; +	return -1;  } -//--------------------------------------------------------------------------- -// Function:    get_handshake -// -// Parameters:  struct ft1000_usb  - device structure -//              u16 expected_value - the handshake value expected -// -// Returns:     handshakevalue - success -//              HANDSHAKE_TIMEOUT_VALUE - failure -// -// Description: This function gets the handshake and compare with the expected value -// -// Notes: -// -//--------------------------------------------------------------------------- +/* gets the handshake and compares it with the expected value */  static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)  {  	u16 handshake;  	int loopcnt; -	u32 status = 0; +	int status = 0;  	loopcnt = 0; @@ -200,9 +171,8 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)  				ft1000dev->fcodeldr);  			ft1000dev->fcodeldr = 0;  			status = check_usb_db(ft1000dev); -			if (status != STATUS_SUCCESS) { +			if (status != 0) {  				DEBUG("get_handshake: check_usb_db failed\n"); -				status = STATUS_FAILURE;  				break;  			}  			status = ft1000_write_register(ft1000dev, @@ -229,25 +199,12 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)  	return HANDSHAKE_TIMEOUT_VALUE;  } -//--------------------------------------------------------------------------- -// Function:    put_handshake -// -// Parameters:  struct ft1000_usb  - device structure -//              u16 handshake_value - handshake to be written -// -// Returns:     none -// -// Description: This function write the handshake value to the handshake location -//              in DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- -static void put_handshake(struct ft1000_usb *ft1000dev,u16 handshake_value) +/* write the handshake value to the handshake location */ +static void put_handshake(struct ft1000_usb *ft1000dev, u16 handshake_value)  {  	u32 tempx;  	u16 tempword; -	u32 status; +	int status;  	tempx = (u32)handshake_value;  	tempx = ntohl(tempx); @@ -267,7 +224,7 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value)  	u16 handshake;  	int loopcnt;  	u16 temp; -	u32 status = 0; +	int status = 0;  	loopcnt = 0;  	handshake = 0; @@ -309,29 +266,18 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value)  	return HANDSHAKE_TIMEOUT_VALUE;  } -static void put_handshake_usb(struct ft1000_usb *ft1000dev,u16 handshake_value) +static void put_handshake_usb(struct ft1000_usb *ft1000dev, u16 handshake_value)  {  	int i; -        for (i=0; i<1000; i++); +	for (i = 0; i < 1000; i++) +		;  } -//--------------------------------------------------------------------------- -// Function:    get_request_type -// -// Parameters:  struct ft1000_usb  - device structure -// -// Returns:     request type - success -// -// Description: This function returns the request type -// -// Notes: -// -//---------------------------------------------------------------------------  static u16 get_request_type(struct ft1000_usb *ft1000dev)  {  	u16 request_type; -	u32 status; +	int status;  	u16 tempword;  	u32 tempx; @@ -354,7 +300,7 @@ static u16 get_request_type(struct ft1000_usb *ft1000dev)  static u16 get_request_type_usb(struct ft1000_usb *ft1000dev)  {  	u16 request_type; -	u32 status; +	int status;  	u16 tempword;  	u32 tempx; @@ -380,23 +326,11 @@ static u16 get_request_type_usb(struct ft1000_usb *ft1000dev)  	return request_type;  } -//--------------------------------------------------------------------------- -// Function:    get_request_value -// -// Parameters:  struct ft1000_usb  - device structure -// -// Returns:     request value - success -// -// Description: This function returns the request value -// -// Notes: -// -//---------------------------------------------------------------------------  static long get_request_value(struct ft1000_usb *ft1000dev)  {  	u32 value;  	u16 tempword; -	u32 status; +	int status;  	if (ft1000dev->bootmode == 1) {  		status = fix_ft1000_read_dpram32(ft1000dev, @@ -416,23 +350,11 @@ static long get_request_value(struct ft1000_usb *ft1000dev)  } -//--------------------------------------------------------------------------- -// Function:    put_request_value -// -// Parameters:  struct ft1000_usb  - device structure -//              long lvalue - value to be put into DPRAM location DWNLD_MAG1_SIZE_LOC -// -// Returns:     none -// -// Description: This function writes a value to DWNLD_MAG1_SIZE_LOC -// -// Notes: -// -//--------------------------------------------------------------------------- +/* writes a value to DWNLD_MAG1_SIZE_LOC */  static void put_request_value(struct ft1000_usb *ft1000dev, long lvalue)  {  	u32    tempx; -	u32    status; +	int    status;  	tempx = ntohl(lvalue);  	status = fix_ft1000_write_dpram32(ft1000dev, DWNLD_MAG1_SIZE_LOC, @@ -441,18 +363,7 @@ static void put_request_value(struct ft1000_usb *ft1000dev, long lvalue) -//--------------------------------------------------------------------------- -// Function:    hdr_checksum -// -// Parameters:  struct pseudo_hdr *pHdr - Pseudo header pointer -// -// Returns:     checksum - success -// -// Description: This function returns the checksum of the pseudo header -// -// Notes: -// -//--------------------------------------------------------------------------- +/* returns the checksum of the pseudo header */  static u16 hdr_checksum(struct pseudo_hdr *pHdr)  {  	u16   *usPtr = (u16 *)pHdr; @@ -471,172 +382,146 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset)  	for (i = 0; i < len; i++) {  		if (buff_w[i] != buff_r[i + offset]) -			return -1; +			return -EREMOTEIO;  	}  	return 0;  } -//--------------------------------------------------------------------------- -// Function:    write_blk -// -// Parameters:  struct ft1000_usb  - device structure -//              u16 **pUsFile - DSP image file pointer in u16 -//              u8  **pUcFile - DSP image file pointer in u8 -//              long   word_length - length of the buffer to be written -//                                   to DPRAM -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function writes a block of DSP image to DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- -static u32 write_blk (struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) +static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, +		u16 tempbuffer[], u16 dpram)  { -   u32 Status = STATUS_SUCCESS; -   u16 dpram; -   int loopcnt, i, j; -   u16 tempword; -   u16 tempbuffer[64]; -   u16 resultbuffer[64]; - -   //DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); -   dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; -   tempword = *(*pUsFile); -   (*pUsFile)++; -   Status = ft1000_write_dpram16(ft1000dev, dpram, tempword, 0); -   tempword = *(*pUsFile); -   (*pUsFile)++; -   Status = ft1000_write_dpram16(ft1000dev, dpram++, tempword, 1); - -   *pUcFile = *pUcFile + 4; -   word_length--; -   tempword = (u16)word_length; -   word_length = (word_length / 16) + 1; -   for (; word_length > 0; word_length--) /* In words */ -   { -	   loopcnt = 0; - -	      for (i=0; i<32; i++) -	      { -		       if (tempword != 0) -		       { -    		           tempbuffer[i++] = *(*pUsFile); -			   (*pUsFile)++; -   	    	           tempbuffer[i] = *(*pUsFile); -			   (*pUsFile)++; -			   *pUcFile = *pUcFile + 4; -			   loopcnt++; -			   tempword--; -		       } -		       else -		       { -			   tempbuffer[i++] = 0; -			   tempbuffer[i] = 0; -                       } -	      } - -              //DEBUG("write_blk: loopcnt is %d\n", loopcnt); -              //DEBUG("write_blk: bootmode = %d\n", bootmode); -              //DEBUG("write_blk: dpram = %x\n", dpram); -	      if (ft1000dev->bootmode == 0) -	      { -		 if (dpram >= 0x3F4) -                     Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 8); -	         else -                    Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 64); -	      } -	      else -	      { -                 for (j=0; j<10; j++) -                 { -                   Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 64); -		   if (Status == STATUS_SUCCESS) -		   { -		       // Work around for ASIC bit stuffing problem. -		       if ( (tempbuffer[31] & 0xfe00) == 0xfe00) -		       { -      		           Status = ft1000_write_dpram32(ft1000dev, dpram+12, (u8 *)&tempbuffer[24], 64); -		       } -    		       // Let's check the data written -	    	       Status = ft1000_read_dpram32 (ft1000dev, dpram, (u8 *)&resultbuffer[0], 64); -		       if ( (tempbuffer[31] & 0xfe00) == 0xfe00) -		       { -				if (check_buffers(tempbuffer, resultbuffer, 28, 0)) { +	int status; +	u16 resultbuffer[64]; +	int i; + +	for (i = 0; i < 10; i++) { +		status = ft1000_write_dpram32(ft1000dev, dpram, +				(u8 *)&tempbuffer[0], 64); +		if (status == 0) { +			/* Work around for ASIC bit stuffing problem. */ +			if ((tempbuffer[31] & 0xfe00) == 0xfe00) { +				status = ft1000_write_dpram32(ft1000dev, +						dpram+12, (u8 *)&tempbuffer[24], +						64); +			} +			/* Let's check the data written */ +			status = ft1000_read_dpram32(ft1000dev, dpram, +					(u8 *)&resultbuffer[0], 64); +			if ((tempbuffer[31] & 0xfe00) == 0xfe00) { +				if (check_buffers(tempbuffer, resultbuffer, 28, +							0)) {  					DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n"); -					msleep(10); -					Status = STATUS_FAILURE; +					usleep_range(9000, 11000);  					break;  				} -   			   Status = ft1000_read_dpram32 (ft1000dev, dpram+12, (u8 *)&resultbuffer[0], 64); +				status = ft1000_read_dpram32(ft1000dev, +						dpram+12, +						(u8 *)&resultbuffer[0], 64); -				if (check_buffers(tempbuffer, resultbuffer, 16, 24)) { +				if (check_buffers(tempbuffer, resultbuffer, 16, +							24)) {  					DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n"); -					msleep(10); -					Status = STATUS_FAILURE; +					usleep_range(9000, 11000);  					break;  				} -			    -			} -			else -			{ -				if (check_buffers(tempbuffer, resultbuffer, 32, 0)) { +			} else { +				if (check_buffers(tempbuffer, resultbuffer, 32, +							0)) {  					DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n"); -					msleep(10); -					Status = STATUS_FAILURE; +					usleep_range(9000, 11000);  					break;  				} -			      			} - -			if (Status == STATUS_SUCCESS) -			    break; - -		    } +			if (status == 0) +				break;  		} +	} +	return status; +} -		if (Status != STATUS_SUCCESS) -		{ -                    DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); -		    break; +/* writes a block of DSP image to DPRAM + * Parameters:  struct ft1000_usb  - device structure + *              u16 **pUsFile - DSP image file pointer in u16 + *              u8  **pUcFile - DSP image file pointer in u8 + *              long word_length - length of the buffer to be written to DPRAM + */ +static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, +		long word_length) +{ +	int status = 0; +	u16 dpram; +	int loopcnt, i; +	u16 tempword; +	u16 tempbuffer[64]; + +	/*DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); */ +	dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; +	tempword = *(*pUsFile); +	(*pUsFile)++; +	status = ft1000_write_dpram16(ft1000dev, dpram, tempword, 0); +	tempword = *(*pUsFile); +	(*pUsFile)++; +	status = ft1000_write_dpram16(ft1000dev, dpram++, tempword, 1); + +	*pUcFile = *pUcFile + 4; +	word_length--; +	tempword = (u16)word_length; +	word_length = (word_length / 16) + 1; +	for (; word_length > 0; word_length--) { /* In words */ +		loopcnt = 0; +		for (i = 0; i < 32; i++) { +			if (tempword != 0) { +				tempbuffer[i++] = *(*pUsFile); +				(*pUsFile)++; +				tempbuffer[i] = *(*pUsFile); +				(*pUsFile)++; +				*pUcFile = *pUcFile + 4; +				loopcnt++; +				tempword--; +			} else { +				tempbuffer[i++] = 0; +				tempbuffer[i] = 0; +			}  		} -	     } -   	     dpram = dpram + loopcnt; -   } - -   return Status; +		/*DEBUG("write_blk: loopcnt is %d\n", loopcnt); */ +		/*DEBUG("write_blk: bootmode = %d\n", bootmode); */ +		/*DEBUG("write_blk: dpram = %x\n", dpram); */ +		if (ft1000dev->bootmode == 0) { +			if (dpram >= 0x3F4) +				status = ft1000_write_dpram32(ft1000dev, dpram, +						(u8 *)&tempbuffer[0], 8); +			else +				status = ft1000_write_dpram32(ft1000dev, dpram, +						(u8 *)&tempbuffer[0], 64); +		} else { +			status = write_dpram32_and_check(ft1000dev, tempbuffer, +					dpram); +			if (status != 0) { +				DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); +				break; +			} +		} +		dpram = dpram + loopcnt; +	} +	return status;  } -static void usb_dnld_complete (struct urb *urb) +static void usb_dnld_complete(struct urb *urb)  { -    //DEBUG("****** usb_dnld_complete\n"); +	/* DEBUG("****** usb_dnld_complete\n"); */  } -//--------------------------------------------------------------------------- -// Function:    write_blk_fifo -// -// Parameters:  struct ft1000_usb  - device structure -//              u16 **pUsFile - DSP image file pointer in u16 -//              u8  **pUcFile - DSP image file pointer in u8 -//              long   word_length - length of the buffer to be written -//                                   to DPRAM -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function writes a block of DSP image to DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- -static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, +/* writes a block of DSP image to DPRAM + * Parameters:  struct ft1000_usb  - device structure + *              u16 **pUsFile - DSP image file pointer in u16 + *              u8  **pUcFile - DSP image file pointer in u8 + *              long word_length - length of the buffer to be written to DPRAM + */ +static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile,  			  u8 **pUcFile, long word_length)  { -	u32 Status = STATUS_SUCCESS;  	int byte_length;  	byte_length = word_length * 4; @@ -661,25 +546,74 @@ static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile,  	*pUsFile = *pUsFile + (word_length << 1);  	*pUcFile = *pUcFile + (word_length << 2); -	return Status; +	return 0; +} + +static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, +		u32 *state) +{ +	int status = 0; + +	DEBUG("FT1000:STATE_START_DWNLD\n"); +	if (ft1000dev->usbboot) +		*hshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY); +	else +		*hshake = get_handshake(ft1000dev, HANDSHAKE_DSP_BL_READY); +	if (*hshake == HANDSHAKE_DSP_BL_READY) { +		DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); +		put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY); +	} else if (*hshake == HANDSHAKE_TIMEOUT_VALUE) { +		status = -ETIMEDOUT; +	} else { +		DEBUG("FT1000:download:Download error: Handshake failed\n"); +		status = -ENETRESET; +	} +	*state = STATE_BOOT_DWNLD; +	return status; +} + +static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, +		 u8 **c_file, const u8 *endpoint, bool boot_case) +{ +	long word_length; +	int status = 0; + +	/*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/ +	word_length = get_request_value(ft1000dev); +	/*DEBUG("FT1000:word_length = 0x%x\n", (int)word_length); */ +	/*NdisMSleep (100); */ +	if (word_length > MAX_LENGTH) { +		DEBUG("FT1000:download:Download error: Max length exceeded\n"); +		return -1; +	} +	if ((word_length * 2 + (long)c_file) > (long)endpoint) { +		/* Error, beyond boot code range.*/ +		DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", (int)word_length); +		return -1; +	} +	if (word_length & 0x1) +		word_length++; +	word_length = word_length / 2; + +	if (boot_case) { +		status = write_blk(ft1000dev, s_file, c_file, word_length); +		/*DEBUG("write_blk returned %d\n", status); */ +	} else { +		status = write_blk_fifo(ft1000dev, s_file, c_file, word_length); +		if (ft1000dev->usbboot == 0) +			ft1000dev->usbboot++; +		if (ft1000dev->usbboot == 1) +			status |= ft1000_write_dpram16(ft1000dev, +					DWNLD_MAG1_PS_HDR_LOC, 0, 0); +	} +	return status;  } -//--------------------------------------------------------------------------- -// -//  Function:   scram_dnldr -// -//  Synopsis:   Scramble downloader for Harley based ASIC via USB interface -// -//  Arguments:  pFileStart              - pointer to start of file -//              FileLength              - file length -// -//  Returns:    status                  - return code -//--------------------------------------------------------------------------- - -u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, +/* Scramble downloader for Harley based ASIC via USB interface */ +int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  		u32 FileLength)  { -	u16 status = STATUS_SUCCESS; +	int status = 0;  	u32 state;  	u16 handshake;  	struct pseudo_hdr *pseudo_header; @@ -687,7 +621,6 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  	long word_length;  	u16 request;  	u16 temp; -	u16 tempword;  	struct dsp_file_hdr *file_hdr;  	struct dsp_image_info *dsp_img_info = NULL; @@ -716,9 +649,9 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  	ft1000dev->usbboot = 0;  	ft1000dev->dspalive = 0xffff; -	// -	// Get version id of file, at first 4 bytes of file, for newer files. -	// +	/* +	 * Get version id of file, at first 4 bytes of file, for newer files. +	 */  	state = STATE_START_DWNLD; @@ -733,34 +666,13 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  	loader_code_address = file_hdr->loader_code_address;  	loader_code_size = file_hdr->loader_code_size; -	correct_version = FALSE; +	correct_version = false; -	while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE)) { +	while ((status == 0) && (state != STATE_DONE_FILE)) {  		switch (state) {  		case STATE_START_DWNLD: -			DEBUG("FT1000:STATE_START_DWNLD\n"); -			if (ft1000dev->usbboot) -				handshake = -				    get_handshake_usb(ft1000dev, -						      HANDSHAKE_DSP_BL_READY); -			else -				handshake = -				    get_handshake(ft1000dev, -						  HANDSHAKE_DSP_BL_READY); - -			if (handshake == HANDSHAKE_DSP_BL_READY) { -				DEBUG -				    ("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); -				put_handshake(ft1000dev, -					      HANDSHAKE_DRIVER_READY); -			} else { -				DEBUG -				    ("FT1000:download:Download error: Handshake failed\n"); -				status = STATUS_FAILURE; -			} - -			state = STATE_BOOT_DWNLD; - +			status = scram_start_dwnld(ft1000dev, &handshake, +						   &state);  			break;  		case STATE_BOOT_DWNLD: @@ -788,52 +700,22 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  					/* Reposition ptrs to beginning of code section */  					s_file = (u16 *) (boot_end);  					c_file = (u8 *) (boot_end); -					//DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file); -					//DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file); +					/* DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file); */ +					/* DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file); */  					state = STATE_CODE_DWNLD;  					ft1000dev->fcodeldr = 1;  					break;  				case REQUEST_CODE_SEGMENT: -					//DEBUG("FT1000:REQUEST_CODE_SEGMENT\n"); -					word_length = -					    get_request_value(ft1000dev); -					//DEBUG("FT1000:word_length = 0x%x\n", (int)word_length); -					//NdisMSleep (100); -					if (word_length > MAX_LENGTH) { -						DEBUG -						    ("FT1000:download:Download error: Max length exceeded\n"); -						status = STATUS_FAILURE; -						break; -					} -					if ((word_length * 2 + c_file) > -					    boot_end) { -						/* -						 * Error, beyond boot code range. -						 */ -						DEBUG -						    ("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", -						     (int)word_length); -						status = STATUS_FAILURE; -						break; -					} -					/* -					 * Position ASIC DPRAM auto-increment pointer. -					 */ -					dpram = (u16) DWNLD_MAG1_PS_HDR_LOC; -					if (word_length & 0x1) -						word_length++; -					word_length = word_length / 2; - -					status = -					    write_blk(ft1000dev, &s_file, -						      &c_file, word_length); -					//DEBUG("write_blk returned %d\n", status); -					break; +					status = request_code_segment(ft1000dev, +							&s_file, &c_file, +							(const u8 *)boot_end, +							true); +				break;  				default:  					DEBUG  					    ("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n",  					     request); -					status = STATUS_FAILURE; +					status = -1;  					break;  				}  				if (ft1000dev->usbboot) @@ -845,13 +727,13 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  			} else {  				DEBUG  				    ("FT1000:download:Download error: Handshake failed\n"); -				status = STATUS_FAILURE; +				status = -1;  			}  			break;  		case STATE_CODE_DWNLD: -			//DEBUG("FT1000:STATE_CODE_DWNLD\n"); +			/* DEBUG("FT1000:STATE_CODE_DWNLD\n"); */  			ft1000dev->bootmode = 0;  			if (ft1000dev->usbboot)  				handshake = @@ -889,7 +771,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  					} else {  						DEBUG  						    ("FT1000:download:Download error: Got Run address request before image offset request.\n"); -						status = STATUS_FAILURE; +						status = -1;  						break;  					}  					break; @@ -905,7 +787,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  					} else {  						DEBUG  						    ("FT1000:download:Download error: Got Size request before image offset request.\n"); -						status = STATUS_FAILURE; +						status = -1;  						break;  					}  					break; @@ -921,60 +803,25 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  					state = STATE_DONE_DWNLD;  					break;  				case REQUEST_CODE_SEGMENT: -					//DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n"); +					/* DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n"); */  					if (!correct_version) {  						DEBUG  						    ("FT1000:download:Download error: Got Code Segment request before image offset request.\n"); -						status = STATUS_FAILURE; +						status = -1;  						break;  					} -					word_length = -					    get_request_value(ft1000dev); -					//DEBUG("FT1000:download:word_length = %d\n", (int)word_length); -					if (word_length > MAX_LENGTH) { -						DEBUG -						    ("FT1000:download:Download error: Max length exceeded\n"); -						status = STATUS_FAILURE; -						break; -					} -					if ((word_length * 2 + c_file) > -					    code_end) { -						/* -						 * Error, beyond boot code range. -						 */ -						DEBUG -						    ("FT1000:download:Download error: Requested len=%d exceeds DSP code boundary.\n", -						     (int)word_length); -						status = STATUS_FAILURE; -						break; -					} -					/* -					 * Position ASIC DPRAM auto-increment pointer. -					 */ -					dpram = (u16) DWNLD_MAG1_PS_HDR_LOC; -					if (word_length & 0x1) -						word_length++; -					word_length = word_length / 2; - -					write_blk_fifo(ft1000dev, &s_file, -						       &c_file, word_length); -					if (ft1000dev->usbboot == 0) -						ft1000dev->usbboot++; -					if (ft1000dev->usbboot == 1) { -						tempword = 0; -						ft1000_write_dpram16(ft1000dev, -								     DWNLD_MAG1_PS_HDR_LOC, -								     tempword, -								     0); -					} +					status = request_code_segment(ft1000dev, +							&s_file, &c_file, +							(const u8 *)code_end, +							false);  					break;  				case REQUEST_MAILBOX_DATA:  					DEBUG  					    ("FT1000:download: REQUEST_MAILBOX_DATA\n"); -					// Convert length from byte count to word count. Make sure we round up. +					/* Convert length from byte count to word count. Make sure we round up. */  					word_length =  					    (long)(pft1000info->DSPInfoBlklen +  						   1) / 2; @@ -987,7 +834,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  					 * Position ASIC DPRAM auto-increment pointer.  					 */ -					data = (u16 *) & mailbox_data->data[0]; +					data = (u16 *) &mailbox_data->data[0];  					dpram = (u16) DWNLD_MAG1_PS_HDR_LOC;  					if (word_length & 0x1)  						word_length++; @@ -1001,7 +848,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  						status =  						    fix_ft1000_write_dpram32  						    (ft1000dev, dpram++, -						     (u8 *) & templong); +						     (u8 *) &templong);  					}  					break; @@ -1036,7 +883,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  						status =  						    fix_ft1000_write_dpram32  						    (ft1000dev, dpram++, -						     (u8 *) & templong); +						     (u8 *) &templong);  					}  					break; @@ -1044,7 +891,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  				case REQUEST_CODE_BY_VERSION:  					DEBUG  					    ("FT1000:download:REQUEST_CODE_BY_VERSION\n"); -					correct_version = FALSE; +					correct_version = false;  					requested_version =  					    get_request_value(ft1000dev); @@ -1061,7 +908,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  						if (dsp_img_info->version ==  						    requested_version) { -							correct_version = TRUE; +							correct_version = true;  							DEBUG  							    ("FT1000:download: correct_version is TRUE\n");  							s_file = @@ -1090,7 +937,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  						}  						dsp_img_info++; -					}	//end of for +					}	/* end of for */  					if (!correct_version) {  						/* @@ -1099,7 +946,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  						DEBUG  						    ("FT1000:download:Download error: Bad Version Request = 0x%x.\n",  						     (int)requested_version); -						status = STATUS_FAILURE; +						status = -1;  						break;  					}  					break; @@ -1108,7 +955,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  					DEBUG  					    ("FT1000:download:Download error: Bad request type=%d in CODE download state.\n",  					     request); -					status = STATUS_FAILURE; +					status = -1;  					break;  				}  				if (ft1000dev->usbboot) @@ -1120,7 +967,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  			} else {  				DEBUG  				    ("FT1000:download:Download error: Handshake failed\n"); -				status = STATUS_FAILURE; +				status = -1;  			}  			break; @@ -1137,13 +984,13 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  			if (pseudo_header->checksum ==  			    hdr_checksum(pseudo_header)) {  				if (pseudo_header->portdest != -				    0x80 /* Dsp OAM */ ) { +				    0x80 /* Dsp OAM */) {  					state = STATE_DONE_PROV;  					break;  				}  				pseudo_header_len = ntohs(pseudo_header->length);	/* Byte length for PROV records */ -				// Get buffer for provisioning data +				/* Get buffer for provisioning data */  				pbuffer =  				    kmalloc((pseudo_header_len +  					     sizeof(struct pseudo_hdr)), @@ -1153,7 +1000,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  					       (u32) (pseudo_header_len +  						      sizeof(struct  							     pseudo_hdr))); -					// link provisioning data +					/* link provisioning data */  					pprov_record =  					    kmalloc(sizeof(struct prov_record),  						    GFP_ATOMIC); @@ -1164,7 +1011,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  							      list,  							      &pft1000info->  							      prov_list); -						// Move to next entry if available +						/* Move to next entry if available */  						c_file =  						    (u8 *) ((unsigned long)  							    c_file + @@ -1177,14 +1024,14 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  						}  					} else {  						kfree(pbuffer); -						status = STATUS_FAILURE; +						status = -1;  					}  				} else { -					status = STATUS_FAILURE; +					status = -1;  				}  			} else {  				/* Checksum did not compute */ -				status = STATUS_FAILURE; +				status = -1;  			}  			DEBUG  			    ("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n", @@ -1197,24 +1044,23 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  			break;  		default: -			status = STATUS_FAILURE; +			status = -1;  			break;  		}		/* End Switch */ -		if (status != STATUS_SUCCESS) { +		if (status != 0)  			break; -		}  /****        // Check if Card is present        status = Harley_Read_Register(&temp, FT1000_REG_SUP_IMASK);        if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0x0000) ) { -          break; +	break;        }        status = Harley_Read_Register(&temp, FT1000_REG_ASIC_ID);        if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0xffff) ) { -          break; +	break;        }  ****/ @@ -1226,4 +1072,3 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  	return status;  } - diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index 9b8fed7b405..b6a77088cfe 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -1,12 +1,9 @@ -//===================================================== -// CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. -// -// -// This file is part of Express Card USB Driver -// -// $Id: -//==================================================== -#include <linux/init.h> +/* CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. +* +* +* This file is part of Express Card USB Driver +*/ +  #include <linux/kernel.h>  #include <linux/module.h>  #include <linux/netdevice.h> @@ -27,45 +24,32 @@  #define HARLEY_READ_OPERATION    0xc1  #define HARLEY_WRITE_OPERATION   0x41 -//#define JDEBUG +#if 0 +#define JDEBUG +#endif -static int ft1000_reset(void *ft1000dev);  static int ft1000_submit_rx_urb(struct ft1000_info *info); -static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev); -static int ft1000_open (struct net_device *dev); -static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev); -static int ft1000_chkcard (struct ft1000_usb *dev);  static u8 tempbuffer[1600];  #define MAX_RCV_LOOP   100 -//--------------------------------------------------------------------------- -// Function:    ft1000_control -// -// Parameters:  ft1000_usb  - device structure -//              pipe - usb control message pipe -//              request - control request -//              requesttype - control message request type -//              value - value to be written or 0 -//              index - register index -//              data - data buffer to hold the read/write values -//              size - data size -//              timeout - control message time out value -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function sends a control message via USB interface synchronously -// -// Notes: -// -//--------------------------------------------------------------------------- +/* send a control message via USB interface synchronously +*  Parameters:  ft1000_usb  - device structure +*               pipe - usb control message pipe +*               request - control request +*               requesttype - control message request type +*               value - value to be written or 0 +*               index - register index +*               data - data buffer to hold the read/write values +*               size - data size +*               timeout - control message time out value +*/  static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe,  			  u8 request, u8 requesttype, u16 value, u16 index,  			  void *data, u16 size, int timeout)  { -	u16 ret; +	int ret;  	if ((ft1000dev == NULL) || (ft1000dev->dev == NULL)) {  		DEBUG("ft1000dev or ft1000dev->dev == NULL, failure\n"); @@ -81,26 +65,11 @@ static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe,  	return ret;  } -//--------------------------------------------------------------------------- -// Function:    ft1000_read_register -// -// Parameters:  ft1000_usb  - device structure -//              Data - data buffer to hold the value read -//              nRegIndex - register index -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function returns the value in a register -// -// Notes: -// -//--------------------------------------------------------------------------- - -int ft1000_read_register(struct ft1000_usb *ft1000dev, u16* Data, +/* returns the value in a register */ +int ft1000_read_register(struct ft1000_usb *ft1000dev, u16 *Data,  			 u16 nRegIndx)  { -	int ret = STATUS_SUCCESS; +	int ret = 0;  	ret = ft1000_control(ft1000dev,  			     usb_rcvctrlpipe(ft1000dev->dev, 0), @@ -115,25 +84,11 @@ int ft1000_read_register(struct ft1000_usb *ft1000dev, u16* Data,  	return ret;  } -//--------------------------------------------------------------------------- -// Function:    ft1000_write_register -// -// Parameters:  ft1000_usb  - device structure -//              value - value to write into a register -//              nRegIndex - register index -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function writes the value in a register -// -// Notes: -// -//--------------------------------------------------------------------------- +/* writes the value in a register */  int ft1000_write_register(struct ft1000_usb *ft1000dev, u16 value,  			  u16 nRegIndx)  { -	int ret = STATUS_SUCCESS; +	int ret = 0;  	ret = ft1000_control(ft1000dev,  			     usb_sndctrlpipe(ft1000dev->dev, 0), @@ -148,27 +103,11 @@ int ft1000_write_register(struct ft1000_usb *ft1000dev, u16 value,  	return ret;  } -//--------------------------------------------------------------------------- -// Function:    ft1000_read_dpram32 -// -// Parameters:  ft1000_usb  - device structure -//              indx - starting address to read -//              buffer - data buffer to hold the data read -//              cnt - number of byte read from DPRAM -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function read a number of bytes from DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- - +/* read a number of bytes from DPRAM */  int ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,  			u16 cnt)  { -	int ret = STATUS_SUCCESS; +	int ret = 0;  	ret = ft1000_control(ft1000dev,  			     usb_rcvctrlpipe(ft1000dev->dev, 0), @@ -183,26 +122,11 @@ int ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,  	return ret;  } -//--------------------------------------------------------------------------- -// Function:    ft1000_write_dpram32 -// -// Parameters:  ft1000_usb  - device structure -//              indx - starting address to write the data -//              buffer - data buffer to write into DPRAM -//              cnt - number of bytes to write -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function writes into DPRAM a number of bytes -// -// Notes: -// -//--------------------------------------------------------------------------- +/* writes into DPRAM a number of bytes */  int ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,  			 u16 cnt)  { -	int ret = STATUS_SUCCESS; +	int ret = 0;  	if (cnt % 4)  		cnt += cnt - (cnt % 4); @@ -220,26 +144,11 @@ int ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,  	return ret;  } -//--------------------------------------------------------------------------- -// Function:    ft1000_read_dpram16 -// -// Parameters:  ft1000_usb  - device structure -//              indx - starting address to read -//              buffer - data buffer to hold the data read -//              hightlow - high or low 16 bit word -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function read 16 bits from DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- +/* read 16 bits from DPRAM */  int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,  			u8 highlow)  { -	int ret = STATUS_SUCCESS; +	int ret = 0;  	u8 request;  	if (highlow == 0) @@ -260,25 +169,11 @@ int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,  	return ret;  } -//--------------------------------------------------------------------------- -// Function:    ft1000_write_dpram16 -// -// Parameters:  ft1000_usb  - device structure -//              indx - starting address to write the data -//              value - 16bits value to write -//              hightlow - high or low 16 bit word -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function writes into DPRAM a number of bytes -// -// Notes: -// -//--------------------------------------------------------------------------- -int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, u8 highlow) +/* write into DPRAM a number of bytes */ +int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, +		u8 highlow)  { -	int ret = STATUS_SUCCESS; +	int ret = 0;  	u8 request;  	if (highlow == 0) @@ -299,33 +194,18 @@ int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, u8 h  	return ret;  } -//--------------------------------------------------------------------------- -// Function:    fix_ft1000_read_dpram32 -// -// Parameters:  ft1000_usb  - device structure -//              indx - starting address to read -//              buffer - data buffer to hold the data read -// -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function read DPRAM 4 words at a time -// -// Notes: -// -//--------------------------------------------------------------------------- +/* read DPRAM 4 words at a time */  int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx,  			    u8 *buffer)  {  	u8 buf[16];  	u16 pos; -	int ret = STATUS_SUCCESS; +	int ret = 0;  	pos = (indx / 4) * 4;  	ret = ft1000_read_dpram32(ft1000dev, pos, buf, 16); -	if (ret == STATUS_SUCCESS) { +	if (ret == 0) {  		pos = (indx % 4) * 4;  		*buffer++ = buf[pos++];  		*buffer++ = buf[pos++]; @@ -343,22 +223,7 @@ int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx,  } -//--------------------------------------------------------------------------- -// Function:    fix_ft1000_write_dpram32 -// -// Parameters:  ft1000_usb  - device structure -//              indx - starting address to write -//              buffer - data buffer to write -// -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function write to DPRAM 4 words at a time -// -// Notes: -// -//--------------------------------------------------------------------------- +/* Description: This function write to DPRAM 4 words at a time */  int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer)  {  	u16 pos1; @@ -367,13 +232,13 @@ int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer)  	u8 buf[32];  	u8 resultbuffer[32];  	u8 *pdata; -	int ret  = STATUS_SUCCESS; +	int ret  = 0;  	pos1 = (indx / 4) * 4;  	pdata = buffer;  	ret = ft1000_read_dpram32(ft1000dev, pos1, buf, 16); -	if (ret == STATUS_SUCCESS) { +	if (ret == 0) {  		pos2 = (indx % 4)*4;  		buf[pos2++] = *buffer++;  		buf[pos2++] = *buffer++; @@ -387,24 +252,24 @@ int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer)  	ret = ft1000_read_dpram32(ft1000dev, pos1, (u8 *)&resultbuffer[0], 16); -	if (ret == STATUS_SUCCESS) { +	if (ret == 0) {  		buffer = pdata;  		for (i = 0; i < 16; i++) {  			if (buf[i] != resultbuffer[i]) -				ret = STATUS_FAILURE; +				ret = -1;  		}  	} -	if (ret == STATUS_FAILURE) { +	if (ret == -1) {  		ret = ft1000_write_dpram32(ft1000dev, pos1,  					   (u8 *)&tempbuffer[0], 16);  		ret = ft1000_read_dpram32(ft1000dev, pos1,  					  (u8 *)&resultbuffer[0], 16); -		if (ret == STATUS_SUCCESS) { +		if (ret == 0) {  			buffer = pdata;  			for (i = 0; i < 16; i++) {  				if (tempbuffer[i] != resultbuffer[i]) { -					ret = STATUS_FAILURE; +					ret = -1;  					DEBUG("%s Failed to write\n",  					      __func__);  				} @@ -415,20 +280,10 @@ int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer)  	return ret;  } - -//------------------------------------------------------------------------ -// -//  Function:   card_reset_dsp -// -//  Synopsis:   This function is called to reset or activate the DSP -// -//  Arguments:  value                  - reset or activate -// -//  Returns:    None -//----------------------------------------------------------------------- +/* reset or activate the DSP */  static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value)  { -	u16 status = STATUS_SUCCESS; +	int status = 0;  	u16 tempword;  	status = ft1000_write_register(ft1000dev, HOST_INTF_BE, @@ -462,21 +317,11 @@ static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value)  	}  } -//--------------------------------------------------------------------------- -// Function:    card_send_command -// -// Parameters:  ft1000_usb  - device structure -//              ptempbuffer - command buffer -//              size - command buffer size -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function sends a command to ASIC -// -// Notes: -// -//--------------------------------------------------------------------------- +/* send a command to ASIC +*  Parameters:  ft1000_usb  - device structure +*               ptempbuffer - command buffer +*               size - command buffer size +*/  void card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,  		       int size)  { @@ -491,7 +336,7 @@ void card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,  	ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);  	if (temp & 0x0100) -		msleep(10); +		usleep_range(900, 1100);  	/* check for odd word */  	size = size + 2; @@ -501,32 +346,24 @@ void card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,  		size += 4 - (size % 4);  	ft1000_write_dpram32(ft1000dev, 0, commandbuf, size); -	msleep(1); +	usleep_range(900, 1100);  	ft1000_write_register(ft1000dev, FT1000_DB_DPRAM_TX,  			      FT1000_REG_DOORBELL); -	msleep(1); +	usleep_range(900, 1100);  	ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL); -	if ((temp & 0x0100) == 0) { -		//DEBUG("card_send_command: Message sent\n"); -	} +#if 0 +	if ((temp & 0x0100) == 0) +		DEBUG("card_send_command: Message sent\n"); +#endif  } -//-------------------------------------------------------------------------- -// -//  Function:   dsp_reload -// -//  Synopsis:   This function is called to load or reload the DSP -// -//  Arguments:  ft1000dev - device structure -// -//  Returns:    None -//----------------------------------------------------------------------- +/* load or reload the DSP */  int dsp_reload(struct ft1000_usb *ft1000dev)  { -	u16 status; +	int status;  	u16 tempword;  	u32 templong; @@ -564,7 +401,7 @@ int dsp_reload(struct ft1000_usb *ft1000dev)  	/* call codeloader */  	status = scram_dnldr(ft1000dev, pFileStart, FileLength); -	if (status != STATUS_SUCCESS) +	if (status != 0)  		return -EIO;  	msleep(1000); @@ -574,17 +411,7 @@ int dsp_reload(struct ft1000_usb *ft1000dev)  	return 0;  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_reset_asic -// Description: This function will call the Card Service function to reset the -//             ASIC. -// Input: -//     dev    - device structure -// Output: -//     none -// -//--------------------------------------------------------------------------- +/* call the Card Service function to reset the ASIC. */  static void ft1000_reset_asic(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -612,18 +439,6 @@ static void ft1000_reset_asic(struct net_device *dev)  	DEBUG("ft1000_hw: interrupt status register = 0x%x\n", tempword);  } - -//--------------------------------------------------------------------------- -// -// Function:   ft1000_reset_card -// Description: This function will reset the card -// Input: -//     dev    - device structure -// Output: -//     status - FALSE (card reset fail) -//              TRUE  (card reset successful) -// -//---------------------------------------------------------------------------  static int ft1000_reset_card(struct net_device *dev)  {  	struct ft1000_info *info = netdev_priv(dev); @@ -633,9 +448,9 @@ static int ft1000_reset_card(struct net_device *dev)  	DEBUG("ft1000_hw:ft1000_reset_card called.....\n"); -	ft1000dev->fCondResetPend = 1; +	ft1000dev->fCondResetPend = true;  	info->CardReady = 0; -	ft1000dev->fProvComplete = 0; +	ft1000dev->fProvComplete = false;  	/* Make sure we free any memory reserve for provisioning */  	while (list_empty(&info->prov_list) == 0) { @@ -666,34 +481,183 @@ static int ft1000_reset_card(struct net_device *dev)  	info->CardReady = 1; -	ft1000dev->fCondResetPend = 0; +	ft1000dev->fCondResetPend = false;  	return TRUE;  } -static const struct net_device_ops ftnet_ops = +/* callback function when a urb is transmitted */ +static void ft1000_usb_transmit_complete(struct urb *urb) +{ + +	struct ft1000_usb *ft1000dev = urb->context; + +	if (urb->status) +		pr_err("%s: TX status %d\n", ft1000dev->net->name, urb->status); + +	netif_wake_queue(ft1000dev->net); +} + +/* take an ethernet packet and convert it to a Flarion +*  packet prior to sending it to the ASIC Downlink FIFO. +*/ +static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) +{ +	struct ft1000_info *pInfo = netdev_priv(netdev); +	struct ft1000_usb *pFt1000Dev = pInfo->priv; + +	int count, ret; +	u8 *t; +	struct pseudo_hdr hdr; + +	if (!pInfo->CardReady) { +		DEBUG("ft1000_copy_down_pkt::Card Not Ready\n"); +		return -ENODEV; +	} + +	count = sizeof(struct pseudo_hdr) + len; +	if (count > MAX_BUF_SIZE) { +		DEBUG("Error:ft1000_copy_down_pkt:Message Size Overflow!\n"); +		DEBUG("size = %d\n", count); +		return -EINVAL; +	} + +	if (count % 4) +		count = count + (4 - (count % 4)); + +	memset(&hdr, 0, sizeof(struct pseudo_hdr)); + +	hdr.length = ntohs(count); +	hdr.source = 0x10; +	hdr.destination = 0x20; +	hdr.portdest = 0x20; +	hdr.portsrc = 0x10; +	hdr.sh_str_id = 0x91; +	hdr.control = 0x00; + +	hdr.checksum = hdr.length ^ hdr.source ^ hdr.destination ^ +	    hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control; + +	memcpy(&pFt1000Dev->tx_buf[0], &hdr, sizeof(hdr)); +	memcpy(&(pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)]), packet, len); + +	netif_stop_queue(netdev); + +	usb_fill_bulk_urb(pFt1000Dev->tx_urb, +			  pFt1000Dev->dev, +			  usb_sndbulkpipe(pFt1000Dev->dev, +					  pFt1000Dev->bulk_out_endpointAddr), +			  pFt1000Dev->tx_buf, count, +			  ft1000_usb_transmit_complete, (void *)pFt1000Dev); + +	t = (u8 *) pFt1000Dev->tx_urb->transfer_buffer; + +	ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC); + +	if (ret) { +		DEBUG("ft1000 failed tx_urb %d\n", ret); +		return ret; +	} else { +		pInfo->stats.tx_packets++; +		pInfo->stats.tx_bytes += (len + 14); +	} + +	return 0; +} + +/* transmit an ethernet packet +*  Parameters:  skb - socket buffer to be sent +*               dev - network device +*/ +static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)  { +	struct ft1000_info *pInfo = netdev_priv(dev); +	struct ft1000_usb *pFt1000Dev = pInfo->priv; +	u8 *pdata; +	int maxlen, pipe; + +	if (skb == NULL) { +		DEBUG("ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n"); +		return NETDEV_TX_OK; +	} + +	if (pFt1000Dev->status & FT1000_STATUS_CLOSING) { +		DEBUG("network driver is closed, return\n"); +		goto err; +	} + +	pipe = +	    usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr); +	maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe)); + +	pdata = (u8 *) skb->data; + +	if (pInfo->mediastate == 0) { +		/* Drop packet is mediastate is down */ +		DEBUG("ft1000_hw:ft1000_start_xmit:mediastate is down\n"); +		goto err; +	} + +	if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) { +		/* Drop packet which has invalid size */ +		DEBUG("ft1000_hw:ft1000_start_xmit:invalid ethernet length\n"); +		goto err; +	} + +	ft1000_copy_down_pkt(dev, (pdata + ENET_HEADER_SIZE - 2), +			     skb->len - ENET_HEADER_SIZE + 2); + +err: +	dev_kfree_skb(skb); + +	return NETDEV_TX_OK; +} + +/* open the network driver */ +static int ft1000_open(struct net_device *dev) +{ +	struct ft1000_info *pInfo = netdev_priv(dev); +	struct ft1000_usb *pFt1000Dev = pInfo->priv; +	struct timeval tv; + +	DEBUG("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber); + +	pInfo->stats.rx_bytes = 0; +	pInfo->stats.tx_bytes = 0; +	pInfo->stats.rx_packets = 0; +	pInfo->stats.tx_packets = 0; +	do_gettimeofday(&tv); +	pInfo->ConTm = tv.tv_sec; +	pInfo->ProgConStat = 0; + +	netif_start_queue(dev); + +	netif_carrier_on(dev); + +	return ft1000_submit_rx_urb(pInfo); +} + +static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev) +{ +	struct ft1000_info *info = netdev_priv(dev); + +	return &(info->stats); +} + +static const struct net_device_ops ftnet_ops = {  	.ndo_open = &ft1000_open,  	.ndo_stop = &ft1000_close,  	.ndo_start_xmit = &ft1000_start_xmit,  	.ndo_get_stats = &ft1000_netdev_stats,  }; +/* initialize the network device */ +static int ft1000_reset(void *dev) +{ +	ft1000_reset_card(dev); +	return 0; +} -//--------------------------------------------------------------------------- -// Function:    init_ft1000_netdev -// -// Parameters:  ft1000dev  - device structure -// -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function initialize the network device -// -// Notes: -// -//---------------------------------------------------------------------------  int init_ft1000_netdev(struct ft1000_usb *ft1000dev)  {  	struct net_device *netdev; @@ -725,14 +689,14 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev)  		card_nr[1] = '\0';  		ret_val = kstrtou8(card_nr, 10, &gCardIndex);  		if (ret_val) { -			printk(KERN_ERR "Can't parse netdev\n"); +			netdev_err(ft1000dev->net, "Can't parse netdev\n");  			goto err_net;  		}  		ft1000dev->CardNumber = gCardIndex;  		DEBUG("card number = %d\n", ft1000dev->CardNumber);  	} else { -		printk(KERN_ERR "ft1000: Invalid device name\n"); +		netdev_err(ft1000dev->net, "ft1000: Invalid device name\n");  		ret_val = -ENXIO;  		goto err_net;  	} @@ -752,8 +716,8 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev)  	pInfo->DSP_TIME[1] = 0;  	pInfo->DSP_TIME[2] = 0;  	pInfo->DSP_TIME[3] = 0; -	ft1000dev->fAppMsgPend = 0; -	ft1000dev->fCondResetPend = 0; +	ft1000dev->fAppMsgPend = false; +	ft1000dev->fCondResetPend = false;  	ft1000dev->usbboot = 0;  	ft1000dev->dspalive = 0;  	memset(&ft1000dev->tempbuf[0], 0, sizeof(ft1000dev->tempbuf)); @@ -808,20 +772,7 @@ err_net:  	return ret_val;  } -//--------------------------------------------------------------------------- -// Function:    reg_ft1000_netdev -// -// Parameters:  ft1000dev  - device structure -// -// -// Returns:     STATUS_SUCCESS - success -//              STATUS_FAILURE - failure -// -// Description: This function register the network driver -// -// Notes: -// -//--------------------------------------------------------------------------- +/* register the network driver */  int reg_ft1000_netdev(struct ft1000_usb *ft1000dev,  		      struct usb_interface *intf)  { @@ -854,188 +805,9 @@ int reg_ft1000_netdev(struct ft1000_usb *ft1000dev,  	return 0;  } -int ft1000_reset(void *dev) -{ -	ft1000_reset_card(dev); -	return 0; -} - -//--------------------------------------------------------------------------- -// Function:    ft1000_usb_transmit_complete -// -// Parameters:  urb  - transmitted usb urb -// -// -// Returns:     none -// -// Description: This is the callback function when a urb is transmitted -// -// Notes: -// -//--------------------------------------------------------------------------- -static void ft1000_usb_transmit_complete(struct urb *urb) -{ - -	struct ft1000_usb *ft1000dev = urb->context; - -	if (urb->status) -		pr_err("%s: TX status %d\n", ft1000dev->net->name, urb->status); - -	netif_wake_queue(ft1000dev->net); -} - -//--------------------------------------------------------------------------- -// -// Function:   ft1000_copy_down_pkt -// Description: This function will take an ethernet packet and convert it to -//             a Flarion packet prior to sending it to the ASIC Downlink -//             FIFO. -// Input: -//     dev    - device structure -//     packet - address of ethernet packet -//     len    - length of IP packet -// Output: -//     status - FAILURE -//              SUCCESS -// -//--------------------------------------------------------------------------- -static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len) -{ -	struct ft1000_info *pInfo = netdev_priv(netdev); -	struct ft1000_usb *pFt1000Dev = pInfo->priv; - -	int count, ret; -	u8 *t; -	struct pseudo_hdr hdr; - -	if (!pInfo->CardReady) { -		DEBUG("ft1000_copy_down_pkt::Card Not Ready\n"); -		return -ENODEV; -	} - -	count = sizeof(struct pseudo_hdr) + len; -	if (count > MAX_BUF_SIZE) { -		DEBUG("Error:ft1000_copy_down_pkt:Message Size Overflow!\n"); -		DEBUG("size = %d\n", count); -		return -EINVAL; -	} - -	if (count % 4) -		count = count + (4 - (count % 4)); - -	memset(&hdr, 0, sizeof(struct pseudo_hdr)); - -	hdr.length = ntohs(count); -	hdr.source = 0x10; -	hdr.destination = 0x20; -	hdr.portdest = 0x20; -	hdr.portsrc = 0x10; -	hdr.sh_str_id = 0x91; -	hdr.control = 0x00; - -	hdr.checksum = hdr.length ^ hdr.source ^ hdr.destination ^ -	    hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control; - -	memcpy(&pFt1000Dev->tx_buf[0], &hdr, sizeof(hdr)); -	memcpy(&(pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)]), packet, len); - -	netif_stop_queue(netdev); - -	usb_fill_bulk_urb(pFt1000Dev->tx_urb, -			  pFt1000Dev->dev, -			  usb_sndbulkpipe(pFt1000Dev->dev, -					  pFt1000Dev->bulk_out_endpointAddr), -			  pFt1000Dev->tx_buf, count, -			  ft1000_usb_transmit_complete, (void *)pFt1000Dev); - -	t = (u8 *) pFt1000Dev->tx_urb->transfer_buffer; - -	ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC); - -	if (ret) { -		DEBUG("ft1000 failed tx_urb %d\n", ret); -		return ret; -	} else { -		pInfo->stats.tx_packets++; -		pInfo->stats.tx_bytes += (len + 14); -	} - -	return 0; -} - - -//--------------------------------------------------------------------------- -// Function:    ft1000_start_xmit -// -// Parameters:  skb - socket buffer to be sent -//              dev - network device -// -// -// Returns:     none -// -// Description: transmit a ethernet packet -// -// Notes: -// -//--------------------------------------------------------------------------- -static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ -	struct ft1000_info *pInfo = netdev_priv(dev); -	struct ft1000_usb *pFt1000Dev = pInfo->priv; -	u8 *pdata; -	int maxlen, pipe; - -	if (skb == NULL) { -		DEBUG("ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n"); -		return NETDEV_TX_OK; -	} - -	if (pFt1000Dev->status & FT1000_STATUS_CLOSING) { -		DEBUG("network driver is closed, return\n"); -		goto err; -	} - -	pipe = -	    usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr); -	maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe)); - -	pdata = (u8 *) skb->data; - -	if (pInfo->mediastate == 0) { -		/* Drop packet is mediastate is down */ -		DEBUG("ft1000_hw:ft1000_start_xmit:mediastate is down\n"); -		goto err; -	} - -	if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) { -		/* Drop packet which has invalid size */ -		DEBUG("ft1000_hw:ft1000_start_xmit:invalid ethernet length\n"); -		goto err; -	} - -	ft1000_copy_down_pkt(dev, (pdata + ENET_HEADER_SIZE - 2), -			     skb->len - ENET_HEADER_SIZE + 2); - -err: -	dev_kfree_skb(skb); - -	return NETDEV_TX_OK; -} - - -//--------------------------------------------------------------------------- -// -// Function:   ft1000_copy_up_pkt -// Description: This function will take a packet from the FIFO up link and -//             convert it into an ethernet packet and deliver it to the IP stack -// Input: -//     urb - the receiving usb urb -// -// Output: -//     status - FAILURE -//              SUCCESS -// -//--------------------------------------------------------------------------- +/* take a packet from the FIFO up link and +*  convert it into an ethernet packet and deliver it to the IP stack +*/  static int ft1000_copy_up_pkt(struct urb *urb)  {  	struct ft1000_info *info = urb->context; @@ -1053,9 +825,9 @@ static int ft1000_copy_up_pkt(struct urb *urb)  	if (ft1000dev->status & FT1000_STATUS_CLOSING) {  		DEBUG("network driver is closed, return\n"); -		return STATUS_SUCCESS; +		return 0;  	} -	// Read length +	/* Read length */  	len = urb->transfer_buffer_length;  	lena = urb->actual_length; @@ -1068,7 +840,7 @@ static int ft1000_copy_up_pkt(struct urb *urb)  	if (tempword != *chksum) {  		info->stats.rx_errors++;  		ft1000_submit_rx_urb(info); -		return STATUS_FAILURE; +		return -1;  	}  	skb = dev_alloc_skb(len + 12 + 2); @@ -1077,7 +849,7 @@ static int ft1000_copy_up_pkt(struct urb *urb)  		DEBUG("ft1000_copy_up_pkt: No Network buffers available\n");  		info->stats.rx_errors++;  		ft1000_submit_rx_urb(info); -		return STATUS_FAILURE; +		return -1;  	}  	pbuffer = (u8 *) skb_put(skb, len + 12); @@ -1114,23 +886,11 @@ static int ft1000_copy_up_pkt(struct urb *urb)  	ft1000_submit_rx_urb(info); -	return SUCCESS; +	return 0;  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_submit_rx_urb -// Description: the receiving function of the network driver -// -// Input: -//     info - a private structure contains the device information -// -// Output: -//     status - FAILURE -//              SUCCESS -// -//--------------------------------------------------------------------------- +/* the receiving function of the network driver */  static int ft1000_submit_rx_urb(struct ft1000_info *info)  {  	int result; @@ -1159,58 +919,7 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info)  	return 0;  } - -//--------------------------------------------------------------------------- -// Function:    ft1000_open -// -// Parameters: -//              dev - network device -// -// -// Returns:     none -// -// Description: open the network driver -// -// Notes: -// -//--------------------------------------------------------------------------- -static int ft1000_open(struct net_device *dev) -{ -	struct ft1000_info *pInfo = netdev_priv(dev); -	struct ft1000_usb *pFt1000Dev = pInfo->priv; -	struct timeval tv; - -	DEBUG("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber); - -	pInfo->stats.rx_bytes = 0; -	pInfo->stats.tx_bytes = 0; -	pInfo->stats.rx_packets = 0; -	pInfo->stats.tx_packets = 0; -	do_gettimeofday(&tv); -	pInfo->ConTm = tv.tv_sec; -	pInfo->ProgConStat = 0; - -	netif_start_queue(dev); - -	netif_carrier_on(dev); - -	return ft1000_submit_rx_urb(pInfo); -} - -//--------------------------------------------------------------------------- -// Function:    ft1000_close -// -// Parameters: -//              net - network device -// -// -// Returns:     none -// -// Description: close the network driver -// -// Notes: -// -//--------------------------------------------------------------------------- +/* close the network driver */  int ft1000_close(struct net_device *net)  {  	struct ft1000_info *pInfo = netdev_priv(net); @@ -1228,34 +937,14 @@ int ft1000_close(struct net_device *net)  	return 0;  } -static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev) -{ -	struct ft1000_info *info = netdev_priv(dev); - -	return &(info->stats); -} - - -//--------------------------------------------------------------------------- -// -// Function:   ft1000_chkcard -// Description: This function will check if the device is presently available on -//             the system. -// Input: -//     dev    - device structure -// Output: -//     status - FALSE (device is not present) -//              TRUE  (device is present) -// -//--------------------------------------------------------------------------- +/* check if the device is presently available on the system. */  static int ft1000_chkcard(struct ft1000_usb *dev)  {  	u16 tempword; -	u16 status; +	int status;  	if (dev->fCondResetPend) { -		DEBUG -		    ("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n"); +		DEBUG("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n");  		return TRUE;  	}  	/* Mask register is used to check for device presence since it is never @@ -1263,8 +952,7 @@ static int ft1000_chkcard(struct ft1000_usb *dev)  	 */  	status = ft1000_read_register(dev, &tempword, FT1000_REG_SUP_IMASK);  	if (tempword == 0) { -		DEBUG -		    ("ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n"); +		DEBUG("ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");  		return FALSE;  	}  	/* The system will return the value of 0xffff for the version register @@ -1273,30 +961,22 @@ static int ft1000_chkcard(struct ft1000_usb *dev)  	status = ft1000_read_register(dev, &tempword, FT1000_REG_ASIC_ID);  	if (tempword != 0x1b01) {  		dev->status |= FT1000_STATUS_CLOSING; -		DEBUG -		    ("ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n"); +		DEBUG("ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n");  		return FALSE;  	}  	return TRUE;  } -//--------------------------------------------------------------------------- -// -// Function:   ft1000_receive_cmd -// Description: This function will read a message from the dpram area. -// Input: -//    dev - network device structure -//    pbuffer - caller supply address to buffer -//    pnxtph - pointer to next pseudo header -// Output: -//   Status = 0 (unsuccessful) -//          = 1 (successful) -// -//--------------------------------------------------------------------------- +/* read a message from the dpram area. +*  Input: +*    dev - network device structure +*    pbuffer - caller supply address to buffer +*/  static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer, -			       int maxsz, u16 *pnxtph) +			       int maxsz)  { -	u16 size, ret; +	u16 size; +	int ret;  	u16 *ppseudohdr;  	int i;  	u16 tempword; @@ -1368,7 +1048,7 @@ static int ft1000_dsp_prov(void *arg)  	struct prov_record *ptr;  	struct pseudo_hdr *ppseudo_hdr;  	u16 *pmsg; -	u16 status; +	int status;  	u16 TempShortBuf[256];  	DEBUG("*** DspProv Entered\n"); @@ -1390,7 +1070,7 @@ static int ft1000_dsp_prov(void *arg)  			i++;  			if (i == 10) {  				DEBUG("FT1000:ft1000_dsp_prov:message drop\n"); -				return STATUS_FAILURE; +				return -1;  			}  			ft1000_read_register(dev, &tempword,  					     FT1000_REG_DOORBELL); @@ -1414,9 +1094,8 @@ static int ft1000_dsp_prov(void *arg)  			ppseudo_hdr->portsrc = 0;  			/* Calculate new checksum */  			ppseudo_hdr->checksum = *pmsg++; -			for (i = 1; i < 7; i++) { +			for (i = 1; i < 7; i++)  				ppseudo_hdr->checksum ^= *pmsg++; -			}  			TempShortBuf[0] = 0;  			TempShortBuf[1] = htons(len); @@ -1434,17 +1113,17 @@ static int ft1000_dsp_prov(void *arg)  			kfree(ptr->pprov_data);  			kfree(ptr);  		} -		msleep(10); +		usleep_range(9000, 11000);  	}  	DEBUG("DSP Provisioning List Entry finished\n");  	msleep(100); -	dev->fProvComplete = 1; +	dev->fProvComplete = true;  	info->CardReady = 1; -	return STATUS_SUCCESS; +	return 0;  }  static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) @@ -1458,7 +1137,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size)  	u16 i;  	struct pseudo_hdr *ppseudo_hdr;  	u16 *pmsg; -	u16 status; +	int status;  	union {  		u8 byte[2];  		u16 wrd; @@ -1466,7 +1145,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size)  	char *cmdbuffer = kmalloc(1600, GFP_KERNEL);  	if (!cmdbuffer) -		return STATUS_FAILURE; +		return -ENOMEM;  	status = ft1000_read_dpram32(dev, 0x200, cmdbuffer, size); @@ -1490,154 +1169,179 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size)  	DEBUG("ft1000_proc_drvmsg:Command message type = 0x%x\n", msgtype);  	switch (msgtype) {  	case MEDIA_STATE:{ -			DEBUG -			    ("ft1000_proc_drvmsg:Command message type = MEDIA_STATE"); - -			pmediamsg = (struct media_msg *)&cmdbuffer[0]; -			if (info->ProgConStat != 0xFF) { -				if (pmediamsg->state) { -					DEBUG("Media is up\n"); -					if (info->mediastate == 0) { -						if (dev->NetDevRegDone) { -							netif_wake_queue(dev-> -									 net); -						} -						info->mediastate = 1; -					} -				} else { -					DEBUG("Media is down\n"); -					if (info->mediastate == 1) { -						info->mediastate = 0; -						if (dev->NetDevRegDone) { -						} -						info->ConTm = 0; -					} +		DEBUG("ft1000_proc_drvmsg:Command message type = MEDIA_STATE"); +		pmediamsg = (struct media_msg *)&cmdbuffer[0]; +		if (info->ProgConStat != 0xFF) { +			if (pmediamsg->state) { +				DEBUG("Media is up\n"); +				if (info->mediastate == 0) { +					if (dev->NetDevRegDone) +						netif_wake_queue(dev->net); +					info->mediastate = 1;  				}  			} else {  				DEBUG("Media is down\n");  				if (info->mediastate == 1) {  					info->mediastate = 0; -					info->ConTm = 0; +					if (dev->NetDevRegDone) +						info->ConTm = 0;  				}  			} -			break; +		} else { +			DEBUG("Media is down\n"); +			if (info->mediastate == 1) { +				info->mediastate = 0; +				info->ConTm = 0; +			}  		} +		break; +	}  	case DSP_INIT_MSG:{ -			DEBUG -			    ("ft1000_proc_drvmsg:Command message type = DSP_INIT_MSG"); - -			pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[2]; -			memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ); -			DEBUG("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", -			      info->DspVer[0], info->DspVer[1], info->DspVer[2], -			      info->DspVer[3]); -			memcpy(info->HwSerNum, pdspinitmsg->HwSerNum, -			       HWSERNUMSZ); -			memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ); -			memcpy(info->eui64, pdspinitmsg->eui64, EUISZ); -			DEBUG("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n", -			      info->eui64[0], info->eui64[1], info->eui64[2], -			      info->eui64[3], info->eui64[4], info->eui64[5], -			      info->eui64[6], info->eui64[7]); -			dev->net->dev_addr[0] = info->eui64[0]; -			dev->net->dev_addr[1] = info->eui64[1]; -			dev->net->dev_addr[2] = info->eui64[2]; -			dev->net->dev_addr[3] = info->eui64[5]; -			dev->net->dev_addr[4] = info->eui64[6]; -			dev->net->dev_addr[5] = info->eui64[7]; - -			if (ntohs(pdspinitmsg->length) == -			    (sizeof(struct dsp_init_msg) - 20)) { -				memcpy(info->ProductMode, -				       pdspinitmsg->ProductMode, MODESZ); -				memcpy(info->RfCalVer, pdspinitmsg->RfCalVer, -				       CALVERSZ); -				memcpy(info->RfCalDate, pdspinitmsg->RfCalDate, -				       CALDATESZ); -				DEBUG("RFCalVer = 0x%2x 0x%2x\n", -				      info->RfCalVer[0], info->RfCalVer[1]); -			} -			break; +		DEBUG("ft1000_proc_drvmsg:Command message type = DSP_INIT_MSG"); +		pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[2]; +		memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ); +		DEBUG("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", +		      info->DspVer[0], info->DspVer[1], info->DspVer[2], +		      info->DspVer[3]); +		memcpy(info->HwSerNum, pdspinitmsg->HwSerNum, +		       HWSERNUMSZ); +		memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ); +		memcpy(info->eui64, pdspinitmsg->eui64, EUISZ); +		DEBUG("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n", +		      info->eui64[0], info->eui64[1], info->eui64[2], +		      info->eui64[3], info->eui64[4], info->eui64[5], +		      info->eui64[6], info->eui64[7]); +		dev->net->dev_addr[0] = info->eui64[0]; +		dev->net->dev_addr[1] = info->eui64[1]; +		dev->net->dev_addr[2] = info->eui64[2]; +		dev->net->dev_addr[3] = info->eui64[5]; +		dev->net->dev_addr[4] = info->eui64[6]; +		dev->net->dev_addr[5] = info->eui64[7]; + +		if (ntohs(pdspinitmsg->length) == +		    (sizeof(struct dsp_init_msg) - 20)) { +			memcpy(info->ProductMode, pdspinitmsg->ProductMode, +					MODESZ); +			memcpy(info->RfCalVer, pdspinitmsg->RfCalVer, CALVERSZ); +			memcpy(info->RfCalDate, pdspinitmsg->RfCalDate, +			       CALDATESZ); +			DEBUG("RFCalVer = 0x%2x 0x%2x\n", info->RfCalVer[0], +					info->RfCalVer[1]);  		} +		break; +	}  	case DSP_PROVISION:{ -			DEBUG -			    ("ft1000_proc_drvmsg:Command message type = DSP_PROVISION\n"); - -			/* kick off dspprov routine to start provisioning -			 * Send provisioning data to DSP -			 */ -			if (list_empty(&info->prov_list) == 0) { -				dev->fProvComplete = 0; -				status = ft1000_dsp_prov(dev); -				if (status != STATUS_SUCCESS) -					goto out; -			} else { -				dev->fProvComplete = 1; -				status = -				    ft1000_write_register(dev, FT1000_DB_HB, -							  FT1000_REG_DOORBELL); -				DEBUG -				    ("FT1000:drivermsg:No more DSP provisioning data in dsp image\n"); -			} -			DEBUG("ft1000_proc_drvmsg:DSP PROVISION is done\n"); -			break; +		DEBUG("ft1000_proc_drvmsg:Command message type = DSP_PROVISION\n"); + +		/* kick off dspprov routine to start provisioning +		 * Send provisioning data to DSP +		 */ +		if (list_empty(&info->prov_list) == 0) { +			dev->fProvComplete = false; +			status = ft1000_dsp_prov(dev); +			if (status != 0) +				goto out; +		} else { +			dev->fProvComplete = true; +			status = ft1000_write_register(dev, FT1000_DB_HB, +					FT1000_REG_DOORBELL); +			DEBUG("FT1000:drivermsg:No more DSP provisioning data in dsp image\n");  		} +		DEBUG("ft1000_proc_drvmsg:DSP PROVISION is done\n"); +		break; +	}  	case DSP_STORE_INFO:{ -			DEBUG -			    ("ft1000_proc_drvmsg:Command message type = DSP_STORE_INFO"); - -			DEBUG("FT1000:drivermsg:Got DSP_STORE_INFO\n"); -			tempword = ntohs(pdrvmsg->length); -			info->DSPInfoBlklen = tempword; -			if (tempword < (MAX_DSP_SESS_REC - 4)) { -				pmsg = (u16 *) &pdrvmsg->data[0]; -				for (i = 0; i < ((tempword + 1) / 2); i++) { -					DEBUG -					    ("FT1000:drivermsg:dsp info data = 0x%x\n", -					     *pmsg); -					info->DSPInfoBlk[i + 10] = *pmsg++; -				} -			} else { -				info->DSPInfoBlklen = 0; +		DEBUG("ft1000_proc_drvmsg:Command message type = DSP_STORE_INFO"); +		DEBUG("FT1000:drivermsg:Got DSP_STORE_INFO\n"); +		tempword = ntohs(pdrvmsg->length); +		info->DSPInfoBlklen = tempword; +		if (tempword < (MAX_DSP_SESS_REC - 4)) { +			pmsg = (u16 *) &pdrvmsg->data[0]; +			for (i = 0; i < ((tempword + 1) / 2); i++) { +				DEBUG("FT1000:drivermsg:dsp info data = 0x%x\n", *pmsg); +				info->DSPInfoBlk[i + 10] = *pmsg++;  			} -			break; +		} else { +			info->DSPInfoBlklen = 0;  		} +		break; +	}  	case DSP_GET_INFO:{ -			DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n"); -			/* copy dsp info block to dsp */ -			dev->DrvMsgPend = 1; -			/* allow any outstanding ioctl to finish */ +		DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n"); +		/* copy dsp info block to dsp */ +		dev->DrvMsgPend = 1; +		/* allow any outstanding ioctl to finish */ +		mdelay(10); +		status = ft1000_read_register(dev, &tempword, +				FT1000_REG_DOORBELL); +		if (tempword & FT1000_DB_DPRAM_TX) {  			mdelay(10); -			status = -			    ft1000_read_register(dev, &tempword, -						 FT1000_REG_DOORBELL); +			status = ft1000_read_register(dev, &tempword, +					FT1000_REG_DOORBELL);  			if (tempword & FT1000_DB_DPRAM_TX) {  				mdelay(10); -				status = -				    ft1000_read_register(dev, &tempword, -							 FT1000_REG_DOORBELL); -				if (tempword & FT1000_DB_DPRAM_TX) { -					mdelay(10); -					status = -					    ft1000_read_register(dev, &tempword, -								 FT1000_REG_DOORBELL); -					if (tempword & FT1000_DB_DPRAM_TX) -						break; -				} +				status = ft1000_read_register(dev, &tempword, +						FT1000_REG_DOORBELL); +				if (tempword & FT1000_DB_DPRAM_TX) +					break;  			} -			/* Put message into Slow Queue -			 * Form Pseudo header -			 */ -			pmsg = (u16 *) info->DSPInfoBlk; -			*pmsg++ = 0; -			*pmsg++ = -			    htons(info->DSPInfoBlklen + 20 + -				  info->DSPInfoBlklen); -			ppseudo_hdr = -			    (struct pseudo_hdr *)(u16 *) &info->DSPInfoBlk[2]; -			ppseudo_hdr->length = -			    htons(info->DSPInfoBlklen + 4 + -				  info->DSPInfoBlklen); +		} +		/* Put message into Slow Queue Form Pseudo header */ +		pmsg = (u16 *) info->DSPInfoBlk; +		*pmsg++ = 0; +		*pmsg++ = htons(info->DSPInfoBlklen + 20 + info->DSPInfoBlklen); +		ppseudo_hdr = +		    (struct pseudo_hdr *)(u16 *) &info->DSPInfoBlk[2]; +		ppseudo_hdr->length = htons(info->DSPInfoBlklen + 4 +				+ info->DSPInfoBlklen); +		ppseudo_hdr->source = 0x10; +		ppseudo_hdr->destination = 0x20; +		ppseudo_hdr->portdest = 0; +		ppseudo_hdr->portsrc = 0; +		ppseudo_hdr->sh_str_id = 0; +		ppseudo_hdr->control = 0; +		ppseudo_hdr->rsvd1 = 0; +		ppseudo_hdr->rsvd2 = 0; +		ppseudo_hdr->qos_class = 0; +		/* Insert slow queue sequence number */ +		ppseudo_hdr->seq_num = info->squeseqnum++; +		/* Insert application id */ +		ppseudo_hdr->portsrc = 0; +		/* Calculate new checksum */ +		ppseudo_hdr->checksum = *pmsg++; +		for (i = 1; i < 7; i++) +			ppseudo_hdr->checksum ^= *pmsg++; + +		info->DSPInfoBlk[10] = 0x7200; +		info->DSPInfoBlk[11] = htons(info->DSPInfoBlklen); +		status = ft1000_write_dpram32(dev, 0, +				(u8 *)&info->DSPInfoBlk[0], +				(unsigned short)(info->DSPInfoBlklen + 22)); +		status = ft1000_write_register(dev, FT1000_DB_DPRAM_TX, +				FT1000_REG_DOORBELL); +		dev->DrvMsgPend = 0; +		break; +	} +	case GET_DRV_ERR_RPT_MSG:{ +		DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n"); +		/* copy driver error message to dsp */ +		dev->DrvMsgPend = 1; +		/* allow any outstanding ioctl to finish */ +		mdelay(10); +		status = ft1000_read_register(dev, &tempword, +				FT1000_REG_DOORBELL); +		if (tempword & FT1000_DB_DPRAM_TX) { +			mdelay(10); +			status = ft1000_read_register(dev, &tempword, +					FT1000_REG_DOORBELL); +			if (tempword & FT1000_DB_DPRAM_TX) +				mdelay(10); +		} +		if ((tempword & FT1000_DB_DPRAM_TX) == 0) { +			/* Put message into Slow Queue Form Pseudo header */ +			pmsg = (u16 *) &tempbuffer[0]; +			ppseudo_hdr = (struct pseudo_hdr *)pmsg; +			ppseudo_hdr->length = htons(0x0012);  			ppseudo_hdr->source = 0x10;  			ppseudo_hdr->destination = 0x20;  			ppseudo_hdr->portdest = 0; @@ -1656,293 +1360,245 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size)  			for (i = 1; i < 7; i++)  				ppseudo_hdr->checksum ^= *pmsg++; -			info->DSPInfoBlk[10] = 0x7200; -			info->DSPInfoBlk[11] = htons(info->DSPInfoBlklen); -			status = -			    ft1000_write_dpram32(dev, 0, -						 (u8 *) &info->DSPInfoBlk[0], -						 (unsigned short)(info-> -								  DSPInfoBlklen -								  + 22)); -			status = -			    ft1000_write_register(dev, FT1000_DB_DPRAM_TX, -						  FT1000_REG_DOORBELL); -			dev->DrvMsgPend = 0; - -			break; +			pmsg = (u16 *) &tempbuffer[16]; +			*pmsg++ = htons(RSP_DRV_ERR_RPT_MSG); +			*pmsg++ = htons(0x000e); +			*pmsg++ = htons(info->DSP_TIME[0]); +			*pmsg++ = htons(info->DSP_TIME[1]); +			*pmsg++ = htons(info->DSP_TIME[2]); +			*pmsg++ = htons(info->DSP_TIME[3]); +			convert.byte[0] = info->DspVer[0]; +			convert.byte[1] = info->DspVer[1]; +			*pmsg++ = convert.wrd; +			convert.byte[0] = info->DspVer[2]; +			convert.byte[1] = info->DspVer[3]; +			*pmsg++ = convert.wrd; +			*pmsg++ = htons(info->DrvErrNum); + +			card_send_command(dev, (unsigned char *)&tempbuffer[0], +					(u16)(0x0012 + PSEUDOSZ)); +			info->DrvErrNum = 0;  		} - -	case GET_DRV_ERR_RPT_MSG:{ -			DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n"); -			/* copy driver error message to dsp */ -			dev->DrvMsgPend = 1; -			/* allow any outstanding ioctl to finish */ -			mdelay(10); -			status = -			    ft1000_read_register(dev, &tempword, -						 FT1000_REG_DOORBELL); -			if (tempword & FT1000_DB_DPRAM_TX) { -				mdelay(10); -				status = -				    ft1000_read_register(dev, &tempword, -							 FT1000_REG_DOORBELL); -				if (tempword & FT1000_DB_DPRAM_TX) -					mdelay(10); -			} - -			if ((tempword & FT1000_DB_DPRAM_TX) == 0) { -				/* Put message into Slow Queue -				 * Form Pseudo header -				 */ -				pmsg = (u16 *) &tempbuffer[0]; -				ppseudo_hdr = (struct pseudo_hdr *)pmsg; -				ppseudo_hdr->length = htons(0x0012); -				ppseudo_hdr->source = 0x10; -				ppseudo_hdr->destination = 0x20; -				ppseudo_hdr->portdest = 0; -				ppseudo_hdr->portsrc = 0; -				ppseudo_hdr->sh_str_id = 0; -				ppseudo_hdr->control = 0; -				ppseudo_hdr->rsvd1 = 0; -				ppseudo_hdr->rsvd2 = 0; -				ppseudo_hdr->qos_class = 0; -				/* Insert slow queue sequence number */ -				ppseudo_hdr->seq_num = info->squeseqnum++; -				/* Insert application id */ -				ppseudo_hdr->portsrc = 0; -				/* Calculate new checksum */ -				ppseudo_hdr->checksum = *pmsg++; -				for (i = 1; i < 7; i++) -					ppseudo_hdr->checksum ^= *pmsg++; - -				pmsg = (u16 *) &tempbuffer[16]; -				*pmsg++ = htons(RSP_DRV_ERR_RPT_MSG); -				*pmsg++ = htons(0x000e); -				*pmsg++ = htons(info->DSP_TIME[0]); -				*pmsg++ = htons(info->DSP_TIME[1]); -				*pmsg++ = htons(info->DSP_TIME[2]); -				*pmsg++ = htons(info->DSP_TIME[3]); -				convert.byte[0] = info->DspVer[0]; -				convert.byte[1] = info->DspVer[1]; -				*pmsg++ = convert.wrd; -				convert.byte[0] = info->DspVer[2]; -				convert.byte[1] = info->DspVer[3]; -				*pmsg++ = convert.wrd; -				*pmsg++ = htons(info->DrvErrNum); - -				card_send_command(dev, -						 (unsigned char *)&tempbuffer[0], -						 (u16) (0x0012 + PSEUDOSZ)); -				info->DrvErrNum = 0; -			} -			dev->DrvMsgPend = 0; - -			break; -		} - +		dev->DrvMsgPend = 0; +		break; +	}  	default:  		break;  	} -	status = STATUS_SUCCESS; +	status = 0;  out:  	kfree(cmdbuffer);  	DEBUG("return from ft1000_proc_drvmsg\n");  	return status;  } -int ft1000_poll(void* dev_id) +/* Check which application has registered for dsp broadcast messages */ +static int dsp_broadcast_msg_id(struct ft1000_usb *dev)  { -    struct ft1000_usb *dev = (struct ft1000_usb *)dev_id; -	struct ft1000_info *info = netdev_priv(dev->net); +	struct dpram_blk *pdpram_blk; +	unsigned long flags; +	int i; -    u16 tempword; -    u16 status; -    u16 size; -    int i; -    u16 data; -    u16 modulo; -    u16 portid; -    u16 nxtph; +	for (i = 0; i < MAX_NUM_APP; i++) { +		if ((dev->app_info[i].DspBCMsgFlag) +				&& (dev->app_info[i].fileobject) +				&& (dev->app_info[i].NumOfMsg +					< MAX_MSG_LIMIT)) { +			pdpram_blk = ft1000_get_buffer(&freercvpool); +			if (pdpram_blk == NULL) { +				DEBUG("Out of memory in free receive command pool\n"); +				dev->app_info[i].nRxMsgMiss++; +				return -1; +			} +			if (ft1000_receive_cmd(dev, pdpram_blk->pbuffer, +						MAX_CMD_SQSIZE)) { +				/* Put message into the +				 * appropriate application block +				 */ +				dev->app_info[i].nRxMsg++; +				spin_lock_irqsave(&free_buff_lock, flags); +				list_add_tail(&pdpram_blk->list, +						&dev->app_info[i] .app_sqlist); +				dev->app_info[i].NumOfMsg++; +				spin_unlock_irqrestore(&free_buff_lock, flags); +				wake_up_interruptible(&dev->app_info[i] +						.wait_dpram_msg); +			} else { +				dev->app_info[i].nRxMsgMiss++; +				ft1000_free_buffer(pdpram_blk, &freercvpool); +				DEBUG("pdpram_blk::ft1000_get_buffer NULL\n"); +				return -1; +			} +		} +	} +	return 0; +} + +static int handle_misc_portid(struct ft1000_usb *dev) +{  	struct dpram_blk *pdpram_blk; -	struct pseudo_hdr *ppseudo_hdr; -    unsigned long flags; - -    if (ft1000_chkcard(dev) == FALSE) { -        DEBUG("ft1000_poll::ft1000_chkcard: failed\n"); -        return STATUS_FAILURE; -    } - -    status = ft1000_read_register (dev, &tempword, FT1000_REG_DOORBELL); - -    if ( !status ) -    { - -        if (tempword & FT1000_DB_DPRAM_RX) { - -            status = ft1000_read_dpram16(dev, 0x200, (u8 *)&data, 0); -            size = ntohs(data) + 16 + 2; -            if (size % 4) { -                modulo = 4 - (size % 4); -                size = size + modulo; -            } -            status = ft1000_read_dpram16(dev, 0x201, (u8 *)&portid, 1); -            portid &= 0xff; - -            if (size < MAX_CMD_SQSIZE) { -                switch (portid) -                { -                    case DRIVERID: -                        DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n"); - -                        status = ft1000_proc_drvmsg (dev, size); -                        if (status != STATUS_SUCCESS ) -                            return status; -                        break; -                    case DSPBCMSGID: -                        // This is a dsp broadcast message -                        // Check which application has registered for dsp broadcast messages - -    	    	        for (i=0; i<MAX_NUM_APP; i++) { -        	           if ( (dev->app_info[i].DspBCMsgFlag) && (dev->app_info[i].fileobject) && -                                         (dev->app_info[i].NumOfMsg < MAX_MSG_LIMIT)  ) -			   { -			       nxtph = FT1000_DPRAM_RX_BASE + 2; -			       pdpram_blk = ft1000_get_buffer (&freercvpool); -			       if (pdpram_blk != NULL) { -			           if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) { -					ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer; -				       // Put message into the appropriate application block -				       dev->app_info[i].nRxMsg++; -				       spin_lock_irqsave(&free_buff_lock, flags); -				       list_add_tail(&pdpram_blk->list, &dev->app_info[i].app_sqlist); -				       dev->app_info[i].NumOfMsg++; -				       spin_unlock_irqrestore(&free_buff_lock, flags); -				       wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); -                                   } -                                   else { -				       dev->app_info[i].nRxMsgMiss++; -				       // Put memory back to free pool -				       ft1000_free_buffer(pdpram_blk, &freercvpool); -				       DEBUG("pdpram_blk::ft1000_get_buffer NULL\n"); -                                   } -                               } -                               else { -                                   DEBUG("Out of memory in free receive command pool\n"); -                                   dev->app_info[i].nRxMsgMiss++; -                               } -                           } -	                } -                        break; -                    default: -                        pdpram_blk = ft1000_get_buffer (&freercvpool); - -                        if (pdpram_blk != NULL) { -                           if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) { -				ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer; -                               // Search for correct application block -                               for (i=0; i<MAX_NUM_APP; i++) { -                                   if (dev->app_info[i].app_id == ppseudo_hdr->portdest) { -                                       break; -                                   } -                               } - -                               if (i == MAX_NUM_APP) { -                                   DEBUG("FT1000:ft1000_parse_dpram_msg: No application matching id = %d\n", ppseudo_hdr->portdest); -                                   // Put memory back to free pool -                                   ft1000_free_buffer(pdpram_blk, &freercvpool); -                               } -                               else { -                                   if (dev->app_info[i].NumOfMsg > MAX_MSG_LIMIT) { -	                               // Put memory back to free pool -	                               ft1000_free_buffer(pdpram_blk, &freercvpool); -                                   } -                                   else { -                                       dev->app_info[i].nRxMsg++; -                                       // Put message into the appropriate application block -                                       list_add_tail(&pdpram_blk->list, &dev->app_info[i].app_sqlist); -            			       dev->app_info[i].NumOfMsg++; -                                   } -                               } -                           } -                           else { -                               // Put memory back to free pool -                               ft1000_free_buffer(pdpram_blk, &freercvpool); -                           } -                        } -                        else { -                            DEBUG("Out of memory in free receive command pool\n"); -                        } -                        break; -                } -            } -            else { -                DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size); -            } -            status = ft1000_write_register (dev, FT1000_DB_DPRAM_RX, FT1000_REG_DOORBELL); -        } -        else if (tempword & FT1000_DSP_ASIC_RESET) { - -            // Let's reset the ASIC from the Host side as well -            status = ft1000_write_register (dev, ASIC_RESET_BIT, FT1000_REG_RESET); -            status = ft1000_read_register (dev, &tempword, FT1000_REG_RESET); -            i = 0; -            while (tempword & ASIC_RESET_BIT) { -                status = ft1000_read_register (dev, &tempword, FT1000_REG_RESET); -                msleep(10); -                i++; -                if (i==100) -                    break; -            } -            if (i==100) { -                DEBUG("Unable to reset ASIC\n"); -                return STATUS_SUCCESS; -            } -            msleep(10); -            // Program WMARK register -            status = ft1000_write_register (dev, 0x600, FT1000_REG_MAG_WATERMARK); -            // clear ASIC reset doorbell -            status = ft1000_write_register (dev, FT1000_DSP_ASIC_RESET, FT1000_REG_DOORBELL); -            msleep(10); -        } -        else if (tempword & FT1000_ASIC_RESET_REQ) { -            DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_ASIC_RESET_REQ\n"); - -            // clear ASIC reset request from DSP -            status = ft1000_write_register (dev, FT1000_ASIC_RESET_REQ, FT1000_REG_DOORBELL); -            status = ft1000_write_register (dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL); -            // copy dsp session record from Adapter block -            status = ft1000_write_dpram32 (dev, 0, (u8 *)&info->DSPSess.Rec[0], 1024); -            // Program WMARK register -            status = ft1000_write_register (dev, 0x600, FT1000_REG_MAG_WATERMARK); -            // ring doorbell to tell DSP that ASIC is out of reset -            status = ft1000_write_register (dev, FT1000_ASIC_RESET_DSP, FT1000_REG_DOORBELL); -        } -        else if (tempword & FT1000_DB_COND_RESET) { -            DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DB_COND_RESET\n"); - -	    if (dev->fAppMsgPend == 0) { -               // Reset ASIC and DSP - -                status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER0, (u8 *)&(info->DSP_TIME[0]), FT1000_MAG_DSP_TIMER0_INDX); -                status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER1, (u8 *)&(info->DSP_TIME[1]), FT1000_MAG_DSP_TIMER1_INDX); -                status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER2, (u8 *)&(info->DSP_TIME[2]), FT1000_MAG_DSP_TIMER2_INDX); -                status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER3, (u8 *)&(info->DSP_TIME[3]), FT1000_MAG_DSP_TIMER3_INDX); -                info->CardReady = 0; -                info->DrvErrNum = DSP_CONDRESET_INFO; -                DEBUG("ft1000_hw:DSP conditional reset requested\n"); -                info->ft1000_reset(dev->net); -            } -            else { -                dev->fProvComplete = 0; -                dev->fCondResetPend = 1; -            } - -            ft1000_write_register(dev, FT1000_DB_COND_RESET, FT1000_REG_DOORBELL); -        } - -    } - -    return STATUS_SUCCESS; +	int i; +	pdpram_blk = ft1000_get_buffer(&freercvpool); +	if (pdpram_blk == NULL) { +		DEBUG("Out of memory in free receive command pool\n"); +		return -1; +	} +	if (!ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE)) +		goto exit_failure; + +	/* Search for correct application block */ +	for (i = 0; i < MAX_NUM_APP; i++) { +		if (dev->app_info[i].app_id == ((struct pseudo_hdr *) +					pdpram_blk->pbuffer)->portdest) +			break; +	} +	if (i == MAX_NUM_APP) { +		DEBUG("FT1000:ft1000_parse_dpram_msg: No application matching id = %d\n", ((struct pseudo_hdr *)pdpram_blk->pbuffer)->portdest); +		goto exit_failure; +	} else if (dev->app_info[i].NumOfMsg > MAX_MSG_LIMIT) { +		goto exit_failure; +	} else { +		dev->app_info[i].nRxMsg++; +		/* Put message into the appropriate application block */ +		list_add_tail(&pdpram_blk->list, &dev->app_info[i].app_sqlist); +		dev->app_info[i].NumOfMsg++; +	} +	return 0; + +exit_failure: +	ft1000_free_buffer(pdpram_blk, &freercvpool); +	return -1; +} + +int ft1000_poll(void *dev_id) +{ +	struct ft1000_usb *dev = (struct ft1000_usb *)dev_id; +	struct ft1000_info *info = netdev_priv(dev->net); +	u16 tempword; +	int status; +	u16 size; +	int i; +	u16 data; +	u16 modulo; +	u16 portid; + +	if (ft1000_chkcard(dev) == FALSE) { +		DEBUG("ft1000_poll::ft1000_chkcard: failed\n"); +		return -1; +	} +	status = ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); +	if (!status) { +		if (tempword & FT1000_DB_DPRAM_RX) { +			status = ft1000_read_dpram16(dev, +					0x200, (u8 *)&data, 0); +			size = ntohs(data) + 16 + 2; +			if (size % 4) { +				modulo = 4 - (size % 4); +				size = size + modulo; +			} +			status = ft1000_read_dpram16(dev, 0x201, +					(u8 *)&portid, 1); +			portid &= 0xff; +			if (size < MAX_CMD_SQSIZE) { +				switch (portid) { +				case DRIVERID: +					DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n"); +					status = ft1000_proc_drvmsg(dev, size); +					if (status != 0) +						return status; +					break; +				case DSPBCMSGID: +					status = dsp_broadcast_msg_id(dev); +					break; +				default: +					status = handle_misc_portid(dev); +					break; +				} +			} else +				DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size); +			status = ft1000_write_register(dev, +					FT1000_DB_DPRAM_RX, +					FT1000_REG_DOORBELL); +		} else if (tempword & FT1000_DSP_ASIC_RESET) { +			/* Let's reset the ASIC from the Host side as well */ +			status = ft1000_write_register(dev, ASIC_RESET_BIT, +					FT1000_REG_RESET); +			status = ft1000_read_register(dev, &tempword, +					FT1000_REG_RESET); +			i = 0; +			while (tempword & ASIC_RESET_BIT) { +				status = ft1000_read_register(dev, &tempword, +						FT1000_REG_RESET); +				usleep_range(9000, 11000); +				i++; +				if (i == 100) +					break; +			} +			if (i == 100) { +				DEBUG("Unable to reset ASIC\n"); +				return 0; +			} +			usleep_range(9000, 11000); +			/* Program WMARK register */ +			status = ft1000_write_register(dev, 0x600, +					FT1000_REG_MAG_WATERMARK); +			/* clear ASIC reset doorbell */ +			status = ft1000_write_register(dev, +					FT1000_DSP_ASIC_RESET, +					FT1000_REG_DOORBELL); +			usleep_range(9000, 11000); +		} else if (tempword & FT1000_ASIC_RESET_REQ) { +			DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_ASIC_RESET_REQ\n"); +			/* clear ASIC reset request from DSP */ +			status = ft1000_write_register(dev, +					FT1000_ASIC_RESET_REQ, +					FT1000_REG_DOORBELL); +			status = ft1000_write_register(dev, HOST_INTF_BE, +					FT1000_REG_SUP_CTRL); +			/* copy dsp session record from Adapter block */ +			status = ft1000_write_dpram32(dev, 0, +					(u8 *)&info->DSPSess.Rec[0], 1024); +			status = ft1000_write_register(dev, 0x600, +					FT1000_REG_MAG_WATERMARK); +			/* ring doorbell to tell DSP that +			 * ASIC is out of reset +			 * */ +			status = ft1000_write_register(dev, +					FT1000_ASIC_RESET_DSP, +					FT1000_REG_DOORBELL); +		} else if (tempword & FT1000_DB_COND_RESET) { +			DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DB_COND_RESET\n"); +			if (!dev->fAppMsgPend) { +				/* Reset ASIC and DSP */ +				status = ft1000_read_dpram16(dev, +						FT1000_MAG_DSP_TIMER0, +						(u8 *)&(info->DSP_TIME[0]), +						FT1000_MAG_DSP_TIMER0_INDX); +				status = ft1000_read_dpram16(dev, +						FT1000_MAG_DSP_TIMER1, +						(u8 *)&(info->DSP_TIME[1]), +						FT1000_MAG_DSP_TIMER1_INDX); +				status = ft1000_read_dpram16(dev, +						FT1000_MAG_DSP_TIMER2, +						(u8 *)&(info->DSP_TIME[2]), +						FT1000_MAG_DSP_TIMER2_INDX); +				status = ft1000_read_dpram16(dev, +						FT1000_MAG_DSP_TIMER3, +						(u8 *)&(info->DSP_TIME[3]), +						FT1000_MAG_DSP_TIMER3_INDX); +				info->CardReady = 0; +				info->DrvErrNum = DSP_CONDRESET_INFO; +				DEBUG("ft1000_hw:DSP conditional reset requested\n"); +				info->ft1000_reset(dev->net); +			} else { +				dev->fProvComplete = false; +				dev->fCondResetPend = true; +			} +			ft1000_write_register(dev, FT1000_DB_COND_RESET, +					FT1000_REG_DOORBELL); +		} +	} +	return 0;  } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h index 24b8d77a132..cb644a58d9f 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h @@ -23,83 +23,101 @@  * History:  * 11/5/02    Whc                Created.  * -*---------------------------------------------------------------------------//--------------------------------------------------------------------------- +*---------------------------------------------------------------------------  */  #ifndef _FT1000IOCTLH_  #define _FT1000IOCTLH_ -typedef struct _IOCTL_GET_VER { -    unsigned long drv_ver; -} __attribute__ ((packed)) IOCTL_GET_VER, *PIOCTL_GET_VER; +struct IOCTL_GET_VER { +	unsigned long drv_ver; +} __packed;  /* Data structure for Dsp statistics */ -typedef struct _IOCTL_GET_DSP_STAT { -    unsigned char DspVer[DSPVERSZ];        /* DSP version number */ -    unsigned char HwSerNum[HWSERNUMSZ];    /* Hardware Serial Number */ -    unsigned char Sku[SKUSZ];              /* SKU */ -    unsigned char eui64[EUISZ];            /* EUI64 */ -    unsigned short ConStat;                /* Connection Status */ -                                /*    Bits 0-3 = Connection Status Field */ -                                /*               0000=Idle (Disconnect) */ -                                /*               0001=Searching */ -                                /*               0010=Active (Connected) */ -                                /*               0011=Waiting for L2 down */ -                                /*               0100=Sleep */ -    unsigned short LedStat;                /* Led Status */ -                                /*    Bits 0-3   = Signal Strength Field */ -                                /*                 0000 = -105dBm to -92dBm */ -                                /*                 0001 = -92dBm to -85dBm */ -                                /*                 0011 = -85dBm to -75dBm */ -                                /*                 0111 = -75dBm to -50dBm */ -                                /*                 1111 = -50dBm to 0dBm */ -                                /*    Bits 4-7   = Reserved */ -                                /*    Bits 8-11  = SNR Field */ -                                /*                 0000 = <2dB */ -                                /*                 0001 = 2dB to 8dB */ -                                /*                 0011 = 8dB to 15dB */ -                                /*                 0111 = 15dB to 22dB */ -                                /*                 1111 = >22dB */ -                                /*    Bits 12-15 = Reserved */ -    unsigned long nTxPkts;                /* Number of packets transmitted from host to dsp */ -    unsigned long nRxPkts;                /* Number of packets received from dsp to host */ -    unsigned long nTxBytes;               /* Number of bytes transmitted from host to dsp */ -    unsigned long nRxBytes;               /* Number of bytes received from dsp to host */ -    unsigned long ConTm;                  /* Current session connection time in seconds */ -    unsigned char CalVer[CALVERSZ];       /* Proprietary Calibration Version */ -    unsigned char CalDate[CALDATESZ];     /* Proprietary Calibration Date */ -} __attribute__ ((packed)) IOCTL_GET_DSP_STAT, *PIOCTL_GET_DSP_STAT; +struct IOCTL_GET_DSP_STAT { +	unsigned char DspVer[DSPVERSZ];        /* DSP version number */ +	unsigned char HwSerNum[HWSERNUMSZ];    /* Hardware Serial Number */ +	unsigned char Sku[SKUSZ];              /* SKU */ +	unsigned char eui64[EUISZ];            /* EUI64 */ +	unsigned short ConStat;                /* Connection Status */ +	/*    Bits 0-3 = Connection Status Field */ +	/*               0000=Idle (Disconnect) */ +	/*               0001=Searching */ +	/*               0010=Active (Connected) */ +	/*               0011=Waiting for L2 down */ +	/*               0100=Sleep */ +	unsigned short LedStat;                /* Led Status */ +	/*    Bits 0-3   = Signal Strength Field */ +	/*                 0000 = -105dBm to -92dBm */ +	/*                 0001 = -92dBm to -85dBm */ +	/*                 0011 = -85dBm to -75dBm */ +	/*                 0111 = -75dBm to -50dBm */ +	/*                 1111 = -50dBm to 0dBm */ +	/*    Bits 4-7   = Reserved */ +	/*    Bits 8-11  = SNR Field */ +	/*                 0000 = <2dB */ +	/*                 0001 = 2dB to 8dB */ +	/*                 0011 = 8dB to 15dB */ +	/*                 0111 = 15dB to 22dB */ +	/*                 1111 = >22dB */ +	/*    Bits 12-15 = Reserved */ +	unsigned long nTxPkts;                /* Number of packets transmitted +					       * from host to dsp +					       */ +	unsigned long nRxPkts;                /* Number of packets received from +					       * dsp to host +					       */ +	unsigned long nTxBytes;               /* Number of bytes transmitted +					       * from host to dsp +					       */ +	unsigned long nRxBytes;               /* Number of bytes received from +					       * dsp to host +					       */ +	unsigned long ConTm;                  /* Current session connection time +					       * in seconds +					       */ +	unsigned char CalVer[CALVERSZ];       /* Proprietary Calibration +					       * Version +					       */ +	unsigned char CalDate[CALDATESZ];     /* Proprietary Calibration Date */ +} __packed;  /* Data structure for Dual Ported RAM messaging between Host and Dsp */ -typedef struct _IOCTL_DPRAM_BLK { -    unsigned short total_len; +struct IOCTL_DPRAM_BLK { +	unsigned short total_len;  	struct pseudo_hdr pseudohdr; -    unsigned char buffer[1780]; -} __attribute__ ((packed)) IOCTL_DPRAM_BLK, *PIOCTL_DPRAM_BLK; +	unsigned char buffer[1780]; +} __packed; -typedef struct _IOCTL_DPRAM_COMMAND { -    unsigned short extra; -    IOCTL_DPRAM_BLK dpram_blk; -} __attribute__ ((packed)) IOCTL_DPRAM_COMMAND, *PIOCTL_DPRAM_COMMAND; +struct IOCTL_DPRAM_COMMAND { +	unsigned short extra; +	struct IOCTL_DPRAM_BLK dpram_blk; +} __packed;  /*  * Custom IOCTL command codes  */  #define FT1000_MAGIC_CODE      'F' -#define IOCTL_REGISTER_CMD					0 -#define IOCTL_SET_DPRAM_CMD					3 -#define IOCTL_GET_DPRAM_CMD					4 -#define IOCTL_GET_DSP_STAT_CMD      6 -#define IOCTL_GET_VER_CMD           7 -#define IOCTL_CONNECT               10 -#define IOCTL_DISCONNECT            11 +#define IOCTL_REGISTER_CMD	0 +#define IOCTL_SET_DPRAM_CMD	3 +#define IOCTL_GET_DPRAM_CMD	4 +#define IOCTL_GET_DSP_STAT_CMD	6 +#define IOCTL_GET_VER_CMD	7 +#define IOCTL_CONNECT		10 +#define IOCTL_DISCONNECT	11 -#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DSP_STAT_CMD, sizeof(IOCTL_GET_DSP_STAT) -#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, sizeof(IOCTL_GET_VER) -#define IOCTL_FT1000_CONNECT _IOW(FT1000_MAGIC_CODE, IOCTL_CONNECT, 0 -#define IOCTL_FT1000_DISCONNECT _IOW(FT1000_MAGIC_CODE, IOCTL_DISCONNECT, 0 -#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, sizeof(IOCTL_DPRAM_BLK) -#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, sizeof(IOCTL_DPRAM_BLK) -#define IOCTL_FT1000_REGISTER  _IOW(FT1000_MAGIC_CODE, IOCTL_REGISTER_CMD, sizeof(unsigned short *) -#endif /* _FT1000IOCTLH_ */ +#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE,      \ +				       IOCTL_GET_DSP_STAT_CMD, \ +				       struct IOCTL_GET_DSP_STAT) +#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, \ +				  struct IOCTL_GET_VER) +#define IOCTL_FT1000_CONNECT _IO(FT1000_MAGIC_CODE, IOCTL_CONNECT) +#define IOCTL_FT1000_DISCONNECT _IO(FT1000_MAGIC_CODE, IOCTL_DISCONNECT) +#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, \ +				    struct IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, \ +				    struct IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_REGISTER  _IOW(FT1000_MAGIC_CODE, IOCTL_REGISTER_CMD, \ +				    unsigned short *) +#endif /* _FT1000IOCTLH_ */ diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c index 5ead942be68..e89b5d2c8e6 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c @@ -32,29 +32,32 @@  #define seq_putx(m, message, size, var) \ -	seq_printf(m, message);	\ -	for(i = 0; i < (size - 1); i++) \ -		seq_printf(m, "%02x:", var[i]); \ -	seq_printf(m, "%02x\n", var[i]) +	do { \ +		seq_printf(m, message);	\ +		for (i = 0; i < (size - 1); i++) \ +			seq_printf(m, "%02x:", var[i]); \ +		seq_printf(m, "%02x\n", var[i]);	\ +	} while (0)  #define seq_putd(m, message, size, var) \ -	seq_printf(m, message); \ -	for(i = 0; i < (size - 1); i++) \ -		seq_printf(m, "%d.", var[i]); \ -	seq_printf(m, "%d\n", var[i]) - +	do { \ +		seq_printf(m, message); \ +		for (i = 0; i < (size - 1); i++) \ +			seq_printf(m, "%d.", var[i]); \ +		seq_printf(m, "%d\n", var[i]);	      \ +	} while (0)  #define FTNET_PROC init_net.proc_net -int ft1000_read_dpram16 (struct ft1000_usb *ft1000dev, u16 indx, +int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx,  			 u8 *buffer, u8 highlow);  static int ft1000ReadProc(struct seq_file *m, void *v)  { -	static const char *status[] = {  -		"Idle (Disconnect)",  +	static const char *status[] = { +		"Idle (Disconnect)",  		"Searching",  		"Active (Connected)",  		"Waiting for L2", @@ -127,10 +130,10 @@ static int ft1000ReadProc(struct seq_file *m, void *v)  	}  	seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n", -      		((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); +		((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60));  	seq_printf(m, "Connection Time[s]: %ld\n", delta);  	seq_printf(m, "Asic ID: %s\n", -      	(info->AsicID) == ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); +	(info->AsicID) == ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC");  	seq_putx(m, "SKU: ", SKUSZ, info->Sku);  	seq_putx(m, "EUI64: ", EUISZ, info->eui64);  	seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer); @@ -200,7 +203,7 @@ int ft1000_init_proc(struct net_device *dev)  	info->ft1000_proc_dir = proc_mkdir(FT1000_PROC_DIR, FTNET_PROC);  	if (info->ft1000_proc_dir == NULL) { -		printk(KERN_WARNING "Unable to create %s dir.\n", +		netdev_warn(dev, "Unable to create %s dir.\n",  			FT1000_PROC_DIR);  		goto fail;  	} @@ -210,7 +213,7 @@ int ft1000_init_proc(struct net_device *dev)  				 &ft1000_proc_fops, dev);  	if (!ft1000_proc_file) { -		printk(KERN_WARNING "Unable to create /proc entry.\n"); +		netdev_warn(dev, "Unable to create /proc entry.\n");  		goto fail_entry;  	} diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index 29a7cd23845..0a2544c7829 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -7,7 +7,6 @@   * $Id:   *====================================================   */ -#include <linux/init.h>  #include <linux/kernel.h>  #include <linux/module.h>  #include <linux/usb.h> @@ -36,7 +35,7 @@ static struct usb_device_id id_table[] = {  MODULE_DEVICE_TABLE(usb, id_table); -static bool gPollingfailed = FALSE; +static bool gPollingfailed;  static int ft1000_poll_thread(void *arg)  {  	int ret; @@ -45,13 +44,13 @@ static int ft1000_poll_thread(void *arg)  		msleep(10);  		if (!gPollingfailed) {  			ret = ft1000_poll(arg); -			if (ret != STATUS_SUCCESS) { +			if (ret != 0) {  				DEBUG("ft1000_poll_thread: polling failed\n"); -				gPollingfailed = TRUE; +				gPollingfailed = true;  			}  		}  	} -	return STATUS_SUCCESS; +	return 0;  }  static int ft1000_probe(struct usb_interface *interface, @@ -171,7 +170,7 @@ static int ft1000_probe(struct usb_interface *interface,  		goto err_load;  	} -	gPollingfailed = FALSE; +	gPollingfailed = false;  	ft1000dev->pPollThread =  	    kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll"); diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h index bd1da1f19cd..2d4b02e2382 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h @@ -11,29 +11,28 @@  #define PSEUDOSZ                16 -#define  SUCCESS             0x00 -  struct app_info_block {  	u32 nTxMsg;                    /* DPRAM msg sent to DSP with app_id */  	u32 nRxMsg;                    /* DPRAM msg rcv from dsp with app_id */ -	u32 nTxMsgReject;              /* DPRAM msg rejected due to DSP doorbell set */ +	u32 nTxMsgReject;              /* DPRAM msg rejected due to DSP doorbell +					* set +					*/  	u32 nRxMsgMiss;                /* DPRAM msg dropped due to overflow */  	struct fown_struct *fileobject;/* Application's file object */  	u16 app_id;                    /* Application id */  	int DspBCMsgFlag;  	int NumOfMsg;                   /* number of messages queued up */  	wait_queue_head_t wait_dpram_msg; -	struct list_head app_sqlist;   /* link list of msgs for applicaton on slow queue */ +	struct list_head app_sqlist;   /* link list of msgs for applicaton on +					* slow queue +					*/  } __packed; -#define DEBUG(args...) printk(KERN_INFO args) +#define DEBUG(args...) pr_info(args)  #define FALSE           0  #define TRUE            1 -#define STATUS_SUCCESS  0 -#define STATUS_FAILURE   0x1001 -  #define FT1000_STATUS_CLOSING  0x01  #define DSPBCMSGID              0x10 @@ -46,7 +45,9 @@ struct app_info_block {  /* MEMORY MAP FOR MAGNEMITE */  /* the indexes are swapped comparing to PCMCIA - is it OK or a bug? */  #undef FT1000_MAG_DSP_LED_INDX -#define FT1000_MAG_DSP_LED_INDX		0x1	/* dsp led status for PAD device */ +#define FT1000_MAG_DSP_LED_INDX		0x1	/* dsp led status for PAD +						 * device +						 */  #undef FT1000_MAG_DSP_CON_STATE_INDX  #define FT1000_MAG_DSP_CON_STATE_INDX	0x0	/* DSP Connection Status Info */ @@ -104,38 +105,39 @@ struct dpram_blk {  } __packed;  int ft1000_read_register(struct ft1000_usb *ft1000dev, -			u16 *Data, u16 nRegIndx); +			 u16 *Data, u16 nRegIndx);  int ft1000_write_register(struct ft1000_usb *ft1000dev, -			u16 value, u16 nRegIndx); +			  u16 value, u16 nRegIndx);  int ft1000_read_dpram32(struct ft1000_usb *ft1000dev,  			u16 indx, u8 *buffer, u16 cnt);  int ft1000_write_dpram32(struct ft1000_usb *ft1000dev, -			u16 indx, u8 *buffer, u16 cnt); +			 u16 indx, u8 *buffer, u16 cnt);  int ft1000_read_dpram16(struct ft1000_usb *ft1000dev,  			u16 indx, u8 *buffer, u8 highlow);  int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, -			u16 indx, u16 value, u8 highlow); +			 u16 indx, u16 value, u8 highlow);  int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, -			u16 indx, u8 *buffer); +			    u16 indx, u8 *buffer);  int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, -			u16 indx, u8 *buffer); +			     u16 indx, u8 *buffer);  extern void *pFileStart;  extern size_t FileLength;  extern int numofmsgbuf;  int ft1000_close(struct net_device *dev); -u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, +int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,  		u32  FileLength);  extern struct list_head freercvpool; -extern spinlock_t free_buff_lock;   /* lock to arbitrate free buffer list for receive command data */ +/* lock to arbitrate free buffer list for receive command data */ +extern spinlock_t free_buff_lock;  int ft1000_create_dev(struct ft1000_usb *dev);  void ft1000_destroy_dev(struct net_device *dev);  extern void card_send_command(struct ft1000_usb *ft1000dev, -				void *ptempbuffer, int size); +			      void *ptempbuffer, int size);  struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist);  void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist); @@ -144,12 +146,10 @@ int dsp_reload(struct ft1000_usb *ft1000dev);  int init_ft1000_netdev(struct ft1000_usb *ft1000dev);  struct usb_interface;  int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, -			struct usb_interface *intf); +		      struct usb_interface *intf);  int ft1000_poll(void *dev_id);  int ft1000_init_proc(struct net_device *dev);  void ft1000_cleanup_proc(struct ft1000_info *info); - - -#endif +#endif  /* _FT1000_USB_H_ */ diff --git a/drivers/staging/ft1000/ft1000.h b/drivers/staging/ft1000/ft1000.h index 175abfa7682..db57430f3b9 100644 --- a/drivers/staging/ft1000/ft1000.h +++ b/drivers/staging/ft1000/ft1000.h @@ -1,5 +1,6 @@  /* - * Common structures and definitions for FT1000 Flarion Flash OFDM PCMCIA and USB devices + * Common structures and definitions for FT1000 Flarion Flash OFDM PCMCIA and + * USB devices.   *   * Originally copyright (c) 2002 Flarion Technologies   * @@ -17,38 +18,70 @@  #define MAGNEMITE_ID	0x1a01	/* ASIC ID for Magnemite */  /* MEMORY MAP common to both ELECTRABUZZ and MAGNEMITE */ -#define	FT1000_REG_DPRAM_ADDR	0x000E	/* DPADR - Dual Port Ram Indirect Address Register */ +#define	FT1000_REG_DPRAM_ADDR	0x000E	/* DPADR - Dual Port Ram Indirect +					 * Address Register +					 */  #define	FT1000_REG_SUP_CTRL	0x0020	/* HCTR - Host Control Register */  #define	FT1000_REG_SUP_STAT	0x0022	/* HSTAT - Host Status Register */  #define	FT1000_REG_RESET	0x0024	/* HCTR - Host Control Register */ -#define	FT1000_REG_SUP_ISR	0x0026	/* HISR - Host Interrupt Status Register */ +#define	FT1000_REG_SUP_ISR	0x0026	/* HISR - Host Interrupt Status +					 * Register +					 */  #define	FT1000_REG_SUP_IMASK	0x0028	/* HIMASK - Host Interrupt Mask */  #define	FT1000_REG_DOORBELL	0x002a	/* DBELL - Door Bell Register */ -#define FT1000_REG_ASIC_ID	0x002e	/* ASICID - ASIC Identification Number */ +#define FT1000_REG_ASIC_ID	0x002e	/* ASICID - ASIC Identification +					 * Number +					 */  /* MEMORY MAP FOR ELECTRABUZZ ASIC */  #define FT1000_REG_UFIFO_STAT	0x0000	/* UFSR - Uplink FIFO status register */ -#define FT1000_REG_UFIFO_BEG	0x0002	/* UFBR	- Uplink FIFO beginning register */ +#define FT1000_REG_UFIFO_BEG	0x0002	/* UFBR	- Uplink FIFO beginning +					 * register +					 */  #define	FT1000_REG_UFIFO_MID	0x0004	/* UFMR	- Uplink FIFO middle register */  #define	FT1000_REG_UFIFO_END	0x0006	/* UFER	- Uplink FIFO end register */ -#define	FT1000_REG_DFIFO_STAT	0x0008	/* DFSR - Downlink FIFO status register */ +#define	FT1000_REG_DFIFO_STAT	0x0008	/* DFSR - Downlink FIFO status +					 * register +					 */  #define	FT1000_REG_DFIFO	0x000A	/* DFR - Downlink FIFO Register */ -#define	FT1000_REG_DPRAM_DATA	0x000C	/* DPRAM - Dual Port Indirect Data Register */ +#define	FT1000_REG_DPRAM_DATA	0x000C	/* DPRAM - Dual Port Indirect +					 * Data Register +					 */  #define	FT1000_REG_WATERMARK	0x0010	/* WMARK - Watermark Register */  /* MEMORY MAP FOR MAGNEMITE */ -#define FT1000_REG_MAG_UFDR	0x0000	/* UFDR - Uplink FIFO Data Register (32-bits) */ -#define FT1000_REG_MAG_UFDRL	0x0000	/* UFDRL - Uplink FIFO Data Register low-word (16-bits) */ -#define FT1000_REG_MAG_UFDRH	0x0002	/* UFDRH - Uplink FIFO Data Register high-word (16-bits) */ +#define FT1000_REG_MAG_UFDR	0x0000	/* UFDR - Uplink FIFO Data +					 * Register (32-bits) +					 */ +#define FT1000_REG_MAG_UFDRL	0x0000	/* UFDRL - Uplink FIFO Data +					 * Register low-word (16-bits) +					 */ +#define FT1000_REG_MAG_UFDRH	0x0002	/* UFDRH - Uplink FIFO Data Register +					 * high-word (16-bits) +					 */  #define FT1000_REG_MAG_UFER	0x0004	/* UFER - Uplink FIFO End Register */  #define FT1000_REG_MAG_UFSR	0x0006	/* UFSR - Uplink FIFO Status Register */ -#define FT1000_REG_MAG_DFR	0x0008	/* DFR - Downlink FIFO Register (32-bits) */ -#define FT1000_REG_MAG_DFRL	0x0008	/* DFRL - Downlink FIFO Register low-word (16-bits) */ -#define FT1000_REG_MAG_DFRH	0x000a	/* DFRH - Downlink FIFO Register high-word (16-bits) */ -#define FT1000_REG_MAG_DFSR	0x000c	/* DFSR - Downlink FIFO Status Register */ -#define FT1000_REG_MAG_DPDATA	0x0010	/* DPDATA - Dual Port RAM Indirect Data Register (32-bits) */ -#define FT1000_REG_MAG_DPDATAL	0x0010	/* DPDATAL - Dual Port RAM Indirect Data Register low-word (16-bits) */ -#define FT1000_REG_MAG_DPDATAH	0x0012	/* DPDATAH - Dual Port RAM Indirect Data Register high-word (16-bits) */ +#define FT1000_REG_MAG_DFR	0x0008	/* DFR - Downlink FIFO Register +					 * (32-bits) +					 */ +#define FT1000_REG_MAG_DFRL	0x0008	/* DFRL - Downlink FIFO Register +					 * low-word (16-bits) +					 */ +#define FT1000_REG_MAG_DFRH	0x000a	/* DFRH - Downlink FIFO Register +					 * high-word (16-bits) +					 */ +#define FT1000_REG_MAG_DFSR	0x000c	/* DFSR - Downlink FIFO Status +					 * Register +					 */ +#define FT1000_REG_MAG_DPDATA	0x0010	/* DPDATA - Dual Port RAM Indirect +					 * Data Register (32-bits) +					 */ +#define FT1000_REG_MAG_DPDATAL	0x0010	/* DPDATAL - Dual Port RAM Indirect +					 * Data Register low-word (16-bits) +					 */ +#define FT1000_REG_MAG_DPDATAH	0x0012	/* DPDATAH - Dual Port RAM Indirect Data +					 * Register high-word (16-bits) +					 */  #define	FT1000_REG_MAG_WATERMARK 0x002c	/* WMARK - Watermark Register */  #define FT1000_REG_MAG_VERSION	0x0030	/* LLC Version */ @@ -57,7 +90,9 @@  #define FT1000_DPRAM_RX_BASE	0x0800	/* PC Card to Host Messaging Area */  #define FT1000_FIFO_LEN		0x07FC	/* total length for DSP FIFO tracking */  #define FT1000_HI_HO		0x07FE	/* heartbeat with HI/HO */ -#define FT1000_DSP_STATUS	0x0FFE	/* dsp status - non-zero is a request to reset dsp */ +#define FT1000_DSP_STATUS	0x0FFE	/* dsp status - non-zero is a request +					 * to reset dsp +					 */  #define FT1000_DSP_LED		0x0FFA	/* dsp led status for PAD device */  #define FT1000_DSP_CON_STATE	0x0FF8	/* DSP Connection Status Info */  #define FT1000_DPRAM_FEFE	0x0002	/* location for dsp ready indicator */ @@ -67,26 +102,48 @@  #define FT1000_DSP_TIMER3	0x1FF6	/* Timer Field from Basestation */  /* Reserved Dual Port RAM offsets for Magnemite */ -#define FT1000_DPRAM_MAG_TX_BASE	0x0000	/* Host to PC Card Messaging Area */ -#define FT1000_DPRAM_MAG_RX_BASE	0x0200	/* PC Card to Host Messaging Area */ +#define FT1000_DPRAM_MAG_TX_BASE	0x0000	/* Host to PC Card +						 * Messaging Area +						 */ +#define FT1000_DPRAM_MAG_RX_BASE	0x0200	/* PC Card to Host +						 * Messaging Area +						 */ -#define FT1000_MAG_FIFO_LEN		0x1FF	/* total length for DSP FIFO tracking */ +#define FT1000_MAG_FIFO_LEN		0x1FF	/* total length for DSP +						 * FIFO tracking +						 */  #define FT1000_MAG_FIFO_LEN_INDX	0x1	/* low-word index */  #define FT1000_MAG_HI_HO		0x1FF	/* heartbeat with HI/HO */  #define FT1000_MAG_HI_HO_INDX		0x0	/* high-word index */ -#define FT1000_MAG_DSP_LED		0x3FE	/* dsp led status for PAD device */ -#define FT1000_MAG_DSP_LED_INDX		0x0	/* dsp led status for PAD device */ +#define FT1000_MAG_DSP_LED		0x3FE	/* dsp led status for +						 * PAD device +						 */ +#define FT1000_MAG_DSP_LED_INDX		0x0	/* dsp led status for +						 * PAD device +						 */  #define FT1000_MAG_DSP_CON_STATE	0x3FE	/* DSP Connection Status Info */  #define FT1000_MAG_DSP_CON_STATE_INDX	0x1	/* DSP Connection Status Info */ -#define FT1000_MAG_DPRAM_FEFE		0x000	/* location for dsp ready indicator */ -#define FT1000_MAG_DPRAM_FEFE_INDX	0x0	/* location for dsp ready indicator */ -#define FT1000_MAG_DSP_TIMER0		0x3FC	/* Timer Field from Basestation */ +#define FT1000_MAG_DPRAM_FEFE		0x000	/* location for dsp ready +						 * indicator +						 */ +#define FT1000_MAG_DPRAM_FEFE_INDX	0x0	/* location for dsp ready +						 * indicator +						 */ +#define FT1000_MAG_DSP_TIMER0		0x3FC	/* Timer Field from +						 * Basestation +						 */  #define FT1000_MAG_DSP_TIMER0_INDX	0x1 -#define FT1000_MAG_DSP_TIMER1		0x3FC	/* Timer Field from Basestation */ +#define FT1000_MAG_DSP_TIMER1		0x3FC	/* Timer Field from +						 * Basestation +						 */  #define FT1000_MAG_DSP_TIMER1_INDX	0x0 -#define FT1000_MAG_DSP_TIMER2		0x3FD	/* Timer Field from Basestation */ +#define FT1000_MAG_DSP_TIMER2		0x3FD	/* Timer Field from +						 * Basestation +						 */  #define FT1000_MAG_DSP_TIMER2_INDX	0x1 -#define FT1000_MAG_DSP_TIMER3		0x3FD	/* Timer Field from Basestation */ +#define FT1000_MAG_DSP_TIMER3		0x3FD	/* Timer Field from +						 * Basestation +						 */  #define FT1000_MAG_DSP_TIMER3_INDX	0x0  #define FT1000_MAG_TOTAL_LEN		0x200  #define FT1000_MAG_TOTAL_LEN_INDX	0x1 @@ -99,24 +156,38 @@  #define HOST_INTF_BE	0x1	/* Host interface big endian mode */  /* FT1000 to Host Doorbell assignments */ -#define FT1000_DB_DPRAM_RX	0x0001	/* this value indicates that DSP has data for host in DPRAM */ +#define FT1000_DB_DPRAM_RX	0x0001	/* this value indicates that DSP +					 * has data for host in DPRAM +					 */  #define FT1000_DB_DNLD_RX	0x0002	/* Downloader handshake doorbell */ -#define FT1000_ASIC_RESET_REQ	0x0004	/* DSP requesting host to reset the ASIC */ -#define FT1000_DSP_ASIC_RESET	0x0008	/* DSP indicating host that it will reset the ASIC */ +#define FT1000_ASIC_RESET_REQ	0x0004	/* DSP requesting host to +					 * reset the ASIC +					 */ +#define FT1000_DSP_ASIC_RESET	0x0008	/* DSP indicating host that +					 * it will reset the ASIC +					 */  #define FT1000_DB_COND_RESET	0x0010	/* DSP request for a card reset. */  /* Host to FT1000 Doorbell assignments */ -#define FT1000_DB_DPRAM_TX	0x0100	/* this value indicates that host has data for DSP in DPRAM. */ +#define FT1000_DB_DPRAM_TX	0x0100	/* this value indicates that host +					 * has data for DSP in DPRAM. +					 */  #define FT1000_DB_DNLD_TX	0x0200	/* Downloader handshake doorbell */  #define FT1000_ASIC_RESET_DSP	0x0400	/* Responds to FT1000_ASIC_RESET_REQ */ -#define FT1000_DB_HB		0x1000	/* Indicates that supervisor has a heartbeat message for DSP. */ +#define FT1000_DB_HB		0x1000	/* Indicates that supervisor has a +					 * heartbeat message for DSP. +					 */  #define hi			0x6869	/* PC Card heartbeat values */  #define ho			0x686f	/* PC Card heartbeat values */  /* Magnemite specific defines */ -#define hi_mag			0x6968	/* Byte swap hi to avoid additional system call */ -#define ho_mag			0x6f68	/* Byte swap ho to avoid additional system call */ +#define hi_mag			0x6968	/* Byte swap hi to avoid +					 * additional system call +					 */ +#define ho_mag			0x6f68	/* Byte swap ho to avoid +					 * additional system call +					 */  /* Bit field definitions for Host Interrupt Status Register */  /* Indicate the cause of an interrupt. */ @@ -133,13 +204,19 @@  #define ISR_MASK_RCV		0x0004	/* Downlink Packet available mask */  #define ISR_MASK_WATERMARK	0x0008	/* Watermark interrupt mask */  #define ISR_MASK_ALL		0xffff	/* Mask all interrupts */ -/* Default interrupt mask (Enable Doorbell pending and Packet available interrupts) */ +/* Default interrupt mask + * (Enable Doorbell pending and Packet available interrupts) + */  #define ISR_DEFAULT_MASK	0x7ff9  /* Bit field definition for Host Control Register */ -#define DSP_RESET_BIT		0x0001	/* Bit field to control dsp reset state */ +#define DSP_RESET_BIT		0x0001	/* Bit field to control +					 * dsp reset state +					 */  					/* (0 = out of reset 1 = reset) */ -#define ASIC_RESET_BIT		0x0002	/* Bit field to control ASIC reset state */ +#define ASIC_RESET_BIT		0x0002	/* Bit field to control +					 * ASIC reset state +					 */  					/* (0 = out of reset 1 = reset) */  #define DSP_UNENCRYPTED		0x0004  #define DSP_ENCRYPTED		0x0008 @@ -195,7 +272,9 @@ struct pseudo_hdr {  	unsigned char	source;		/* hardware source id */  					/*    Host = 0x10 */  					/*    Dsp  = 0x20 */ -	unsigned char	destination;	/* hardware destination id (refer to source) */ +	unsigned char	destination;	/* hardware destination id +					 * (refer to source) +					 */  	unsigned char	portdest;	/* software destination port id */  					/*    Host = 0x00 */  					/*    Applicaton Broadcast = 0x10 */ @@ -204,7 +283,9 @@ struct pseudo_hdr {  					/*    Dsp Airlink = 0x90 */  					/*    Dsp Loader = 0xa0 */  					/*    Dsp MIP = 0xb0 */ -	unsigned char	portsrc;	/* software source port id (refer to portdest) */ +	unsigned char	portsrc;	/* software source port id +					 * (refer to portdest) +					 */  	unsigned short	sh_str_id;	/* not used */  	unsigned char	control;	/* not used */  	unsigned char	rsvd1;  | 
