2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-16 22:20:36 +00:00
|
|
|
/* sb1000.c: A General Instruments SB1000 driver for linux. */
|
|
|
|
/*
|
|
|
|
Written 1998 by Franco Venturi.
|
|
|
|
|
|
|
|
Copyright 1998 by Franco Venturi.
|
|
|
|
Copyright 1994,1995 by Donald Becker.
|
|
|
|
Copyright 1993 United States Government as represented by the
|
|
|
|
Director, National Security Agency.
|
|
|
|
|
|
|
|
This driver is for the General Instruments SB1000 (internal SURFboard)
|
|
|
|
|
|
|
|
The author may be reached as fventuri@mediaone.net
|
|
|
|
|
|
|
|
|
|
|
|
Changes:
|
|
|
|
|
|
|
|
981115 Steven Hirsch <shirsch@adelphia.net>
|
|
|
|
|
|
|
|
Linus changed the timer interface. Should work on all recent
|
|
|
|
development kernels.
|
|
|
|
|
|
|
|
980608 Steven Hirsch <shirsch@adelphia.net>
|
|
|
|
|
|
|
|
Small changes to make it work with 2.1.x kernels. Hopefully,
|
|
|
|
nothing major will change before official release of Linux 2.2.
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
Merged with 2.2 - Alan Cox
|
|
|
|
*/
|
|
|
|
|
|
|
|
static char version[] = "sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net)\n";
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
2009-10-07 13:09:06 +00:00
|
|
|
#include <linux/sched.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/if_cablemodem.h> /* for SIOGCM/SIOSCM stuff */
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/delay.h> /* for udelay() */
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/pnp.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/bitops.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/gfp.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/processor.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#ifdef SB1000_DEBUG
|
|
|
|
static int sb1000_debug = SB1000_DEBUG;
|
|
|
|
#else
|
2006-03-04 02:33:57 +00:00
|
|
|
static const int sb1000_debug = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static const int SB1000_IO_EXTENT = 8;
|
|
|
|
/* SB1000 Maximum Receive Unit */
|
|
|
|
static const int SB1000_MRU = 1500; /* octects */
|
|
|
|
|
|
|
|
#define NPIDS 4
|
|
|
|
struct sb1000_private {
|
|
|
|
struct sk_buff *rx_skb[NPIDS];
|
|
|
|
short rx_dlen[NPIDS];
|
|
|
|
unsigned int rx_frames;
|
|
|
|
short rx_error_count;
|
|
|
|
short rx_error_dpc_count;
|
|
|
|
unsigned char rx_session_id[NPIDS];
|
|
|
|
unsigned char rx_frame_id[NPIDS];
|
|
|
|
unsigned char rx_pkt_type[NPIDS];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* prototypes for Linux interface */
|
|
|
|
extern int sb1000_probe(struct net_device *dev);
|
|
|
|
static int sb1000_open(struct net_device *dev);
|
|
|
|
static int sb1000_dev_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd);
|
2009-08-31 19:50:58 +00:00
|
|
|
static netdev_tx_t sb1000_start_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev);
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t sb1000_interrupt(int irq, void *dev_id);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int sb1000_close(struct net_device *dev);
|
|
|
|
|
|
|
|
|
|
|
|
/* SB1000 hardware routines to be used during open/configuration phases */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int card_wait_for_busy_clear(const int ioaddr[],
|
2005-04-16 22:20:36 +00:00
|
|
|
const char* name);
|
2008-03-30 23:02:43 +00:00
|
|
|
static int card_wait_for_ready(const int ioaddr[], const char* name,
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char in[]);
|
2006-01-14 21:20:43 +00:00
|
|
|
static int card_send_command(const int ioaddr[], const char* name,
|
2005-04-16 22:20:36 +00:00
|
|
|
const unsigned char out[], unsigned char in[]);
|
|
|
|
|
|
|
|
/* SB1000 hardware routines to be used during frame rx interrupt */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int sb1000_wait_for_ready(const int ioaddr[], const char* name);
|
|
|
|
static int sb1000_wait_for_ready_clear(const int ioaddr[],
|
2005-04-16 22:20:36 +00:00
|
|
|
const char* name);
|
2008-03-30 23:02:43 +00:00
|
|
|
static void sb1000_send_command(const int ioaddr[], const char* name,
|
2005-04-16 22:20:36 +00:00
|
|
|
const unsigned char out[]);
|
2008-03-30 23:02:43 +00:00
|
|
|
static void sb1000_read_status(const int ioaddr[], unsigned char in[]);
|
|
|
|
static void sb1000_issue_read_command(const int ioaddr[],
|
2005-04-16 22:20:36 +00:00
|
|
|
const char* name);
|
|
|
|
|
|
|
|
/* SB1000 commands for open/configuration */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int sb1000_reset(const int ioaddr[], const char* name);
|
|
|
|
static int sb1000_check_CRC(const int ioaddr[], const char* name);
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline int sb1000_start_get_set_command(const int ioaddr[],
|
|
|
|
const char* name);
|
2008-03-30 23:02:43 +00:00
|
|
|
static int sb1000_end_get_set_command(const int ioaddr[],
|
2005-04-16 22:20:36 +00:00
|
|
|
const char* name);
|
2008-03-30 23:02:43 +00:00
|
|
|
static int sb1000_activate(const int ioaddr[], const char* name);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int sb1000_get_firmware_version(const int ioaddr[],
|
|
|
|
const char* name, unsigned char version[], int do_end);
|
|
|
|
static int sb1000_get_frequency(const int ioaddr[], const char* name,
|
|
|
|
int* frequency);
|
|
|
|
static int sb1000_set_frequency(const int ioaddr[], const char* name,
|
|
|
|
int frequency);
|
|
|
|
static int sb1000_get_PIDs(const int ioaddr[], const char* name,
|
|
|
|
short PID[]);
|
|
|
|
static int sb1000_set_PIDs(const int ioaddr[], const char* name,
|
|
|
|
const short PID[]);
|
|
|
|
|
|
|
|
/* SB1000 commands for frame rx interrupt */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int sb1000_rx(struct net_device *dev);
|
|
|
|
static void sb1000_error_dpc(struct net_device *dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static const struct pnp_device_id sb1000_pnp_ids[] = {
|
|
|
|
{ "GIC1000", 0 },
|
|
|
|
{ "", 0 }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pnp, sb1000_pnp_ids);
|
|
|
|
|
2009-01-08 01:56:54 +00:00
|
|
|
static const struct net_device_ops sb1000_netdev_ops = {
|
|
|
|
.ndo_open = sb1000_open,
|
|
|
|
.ndo_start_xmit = sb1000_start_xmit,
|
|
|
|
.ndo_do_ioctl = sb1000_dev_ioctl,
|
|
|
|
.ndo_stop = sb1000_close,
|
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int
|
|
|
|
sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id)
|
|
|
|
{
|
|
|
|
struct net_device *dev;
|
|
|
|
unsigned short ioaddr[2], irq;
|
|
|
|
unsigned int serial_number;
|
|
|
|
int error = -ENODEV;
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (pnp_device_attach(pdev) < 0)
|
|
|
|
return -ENODEV;
|
|
|
|
if (pnp_activate_dev(pdev) < 0)
|
|
|
|
goto out_detach;
|
|
|
|
|
|
|
|
if (!pnp_port_valid(pdev, 0) || !pnp_port_valid(pdev, 1))
|
|
|
|
goto out_disable;
|
|
|
|
if (!pnp_irq_valid(pdev, 0))
|
|
|
|
goto out_disable;
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
serial_number = pdev->card->serial;
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
ioaddr[0] = pnp_port_start(pdev, 0);
|
|
|
|
ioaddr[1] = pnp_port_start(pdev, 0);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
irq = pnp_irq(pdev, 0);
|
|
|
|
|
|
|
|
if (!request_region(ioaddr[0], 16, "sb1000"))
|
|
|
|
goto out_disable;
|
|
|
|
if (!request_region(ioaddr[1], 16, "sb1000"))
|
|
|
|
goto out_release_region0;
|
|
|
|
|
|
|
|
dev = alloc_etherdev(sizeof(struct sb1000_private));
|
|
|
|
if (!dev) {
|
|
|
|
error = -ENOMEM;
|
|
|
|
goto out_release_regions;
|
|
|
|
}
|
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
dev->base_addr = ioaddr[0];
|
|
|
|
/* mem_start holds the second I/O address */
|
|
|
|
dev->mem_start = ioaddr[1];
|
|
|
|
dev->irq = irq;
|
|
|
|
|
|
|
|
if (sb1000_debug > 0)
|
|
|
|
printk(KERN_NOTICE "%s: sb1000 at (%#3.3lx,%#3.3lx), "
|
|
|
|
"S/N %#8.8x, IRQ %d.\n", dev->name, dev->base_addr,
|
|
|
|
dev->mem_start, serial_number, dev->irq);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The SB1000 is an rx-only cable modem device. The uplink is a modem
|
|
|
|
* and we do not want to arp on it.
|
|
|
|
*/
|
|
|
|
dev->flags = IFF_POINTOPOINT|IFF_NOARP;
|
|
|
|
|
|
|
|
SET_NETDEV_DEV(dev, &pdev->dev);
|
|
|
|
|
|
|
|
if (sb1000_debug > 0)
|
|
|
|
printk(KERN_NOTICE "%s", version);
|
|
|
|
|
2009-01-08 01:56:54 +00:00
|
|
|
dev->netdev_ops = &sb1000_netdev_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* hardware address is 0:0:serial_number */
|
|
|
|
dev->dev_addr[2] = serial_number >> 24 & 0xff;
|
|
|
|
dev->dev_addr[3] = serial_number >> 16 & 0xff;
|
|
|
|
dev->dev_addr[4] = serial_number >> 8 & 0xff;
|
|
|
|
dev->dev_addr[5] = serial_number >> 0 & 0xff;
|
|
|
|
|
|
|
|
pnp_set_drvdata(pdev, dev);
|
|
|
|
|
|
|
|
error = register_netdev(dev);
|
|
|
|
if (error)
|
|
|
|
goto out_free_netdev;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_free_netdev:
|
|
|
|
free_netdev(dev);
|
|
|
|
out_release_regions:
|
|
|
|
release_region(ioaddr[1], 16);
|
|
|
|
out_release_region0:
|
|
|
|
release_region(ioaddr[0], 16);
|
|
|
|
out_disable:
|
|
|
|
pnp_disable_dev(pdev);
|
|
|
|
out_detach:
|
|
|
|
pnp_device_detach(pdev);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sb1000_remove_one(struct pnp_dev *pdev)
|
|
|
|
{
|
|
|
|
struct net_device *dev = pnp_get_drvdata(pdev);
|
|
|
|
|
|
|
|
unregister_netdev(dev);
|
|
|
|
release_region(dev->base_addr, 16);
|
|
|
|
release_region(dev->mem_start, 16);
|
|
|
|
free_netdev(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pnp_driver sb1000_driver = {
|
|
|
|
.name = "sb1000",
|
|
|
|
.id_table = sb1000_pnp_ids,
|
|
|
|
.probe = sb1000_probe_one,
|
|
|
|
.remove = sb1000_remove_one,
|
|
|
|
};
|
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* SB1000 hardware routines to be used during open/configuration phases
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const int TimeOutJiffies = (875 * HZ) / 100;
|
|
|
|
|
|
|
|
/* Card Wait For Busy Clear (cannot be used during an interrupt) */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
card_wait_for_busy_clear(const int ioaddr[], const char* name)
|
|
|
|
{
|
|
|
|
unsigned char a;
|
|
|
|
unsigned long timeout;
|
|
|
|
|
|
|
|
a = inb(ioaddr[0] + 7);
|
|
|
|
timeout = jiffies + TimeOutJiffies;
|
|
|
|
while (a & 0x80 || a & 0x40) {
|
|
|
|
/* a little sleep */
|
|
|
|
yield();
|
|
|
|
|
|
|
|
a = inb(ioaddr[0] + 7);
|
|
|
|
if (time_after_eq(jiffies, timeout)) {
|
|
|
|
printk(KERN_WARNING "%s: card_wait_for_busy_clear timeout\n",
|
|
|
|
name);
|
|
|
|
return -ETIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Card Wait For Ready (cannot be used during an interrupt) */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
card_wait_for_ready(const int ioaddr[], const char* name, unsigned char in[])
|
|
|
|
{
|
|
|
|
unsigned char a;
|
|
|
|
unsigned long timeout;
|
|
|
|
|
|
|
|
a = inb(ioaddr[1] + 6);
|
|
|
|
timeout = jiffies + TimeOutJiffies;
|
|
|
|
while (a & 0x80 || !(a & 0x40)) {
|
|
|
|
/* a little sleep */
|
|
|
|
yield();
|
|
|
|
|
|
|
|
a = inb(ioaddr[1] + 6);
|
|
|
|
if (time_after_eq(jiffies, timeout)) {
|
|
|
|
printk(KERN_WARNING "%s: card_wait_for_ready timeout\n",
|
|
|
|
name);
|
|
|
|
return -ETIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
in[1] = inb(ioaddr[0] + 1);
|
|
|
|
in[2] = inb(ioaddr[0] + 2);
|
|
|
|
in[3] = inb(ioaddr[0] + 3);
|
|
|
|
in[4] = inb(ioaddr[0] + 4);
|
|
|
|
in[0] = inb(ioaddr[0] + 5);
|
|
|
|
in[6] = inb(ioaddr[0] + 6);
|
|
|
|
in[5] = inb(ioaddr[1] + 6);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Card Send Command (cannot be used during an interrupt) */
|
2006-01-14 21:20:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
card_send_command(const int ioaddr[], const char* name,
|
|
|
|
const unsigned char out[], unsigned char in[])
|
|
|
|
{
|
2019-04-17 20:51:56 +00:00
|
|
|
int status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if ((status = card_wait_for_busy_clear(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
outb(0xa0, ioaddr[0] + 6);
|
|
|
|
outb(out[2], ioaddr[0] + 1);
|
|
|
|
outb(out[3], ioaddr[0] + 2);
|
|
|
|
outb(out[4], ioaddr[0] + 3);
|
|
|
|
outb(out[5], ioaddr[0] + 4);
|
|
|
|
outb(out[1], ioaddr[0] + 5);
|
|
|
|
outb(0xa0, ioaddr[0] + 6);
|
|
|
|
outb(out[0], ioaddr[0] + 7);
|
|
|
|
if (out[0] != 0x20 && out[0] != 0x30) {
|
|
|
|
if ((status = card_wait_for_ready(ioaddr, name, in)))
|
|
|
|
return status;
|
|
|
|
inb(ioaddr[0] + 7);
|
|
|
|
if (sb1000_debug > 3)
|
|
|
|
printk(KERN_DEBUG "%s: card_send_command "
|
|
|
|
"out: %02x%02x%02x%02x%02x%02x "
|
|
|
|
"in: %02x%02x%02x%02x%02x%02x%02x\n", name,
|
|
|
|
out[0], out[1], out[2], out[3], out[4], out[5],
|
|
|
|
in[0], in[1], in[2], in[3], in[4], in[5], in[6]);
|
|
|
|
} else {
|
|
|
|
if (sb1000_debug > 3)
|
|
|
|
printk(KERN_DEBUG "%s: card_send_command "
|
|
|
|
"out: %02x%02x%02x%02x%02x%02x\n", name,
|
|
|
|
out[0], out[1], out[2], out[3], out[4], out[5]);
|
|
|
|
}
|
|
|
|
|
2019-04-17 20:51:56 +00:00
|
|
|
if (out[1] != 0x1b) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (out[0] >= 0x80 && in[0] != (out[1] | 0x80))
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* SB1000 hardware routines to be used during frame rx interrupt
|
|
|
|
*/
|
|
|
|
static const int Sb1000TimeOutJiffies = 7 * HZ;
|
|
|
|
|
|
|
|
/* Card Wait For Ready (to be used during frame rx) */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_wait_for_ready(const int ioaddr[], const char* name)
|
|
|
|
{
|
|
|
|
unsigned long timeout;
|
|
|
|
|
|
|
|
timeout = jiffies + Sb1000TimeOutJiffies;
|
|
|
|
while (inb(ioaddr[1] + 6) & 0x80) {
|
|
|
|
if (time_after_eq(jiffies, timeout)) {
|
|
|
|
printk(KERN_WARNING "%s: sb1000_wait_for_ready timeout\n",
|
|
|
|
name);
|
|
|
|
return -ETIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
timeout = jiffies + Sb1000TimeOutJiffies;
|
|
|
|
while (!(inb(ioaddr[1] + 6) & 0x40)) {
|
|
|
|
if (time_after_eq(jiffies, timeout)) {
|
|
|
|
printk(KERN_WARNING "%s: sb1000_wait_for_ready timeout\n",
|
|
|
|
name);
|
|
|
|
return -ETIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inb(ioaddr[0] + 7);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Card Wait For Ready Clear (to be used during frame rx) */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_wait_for_ready_clear(const int ioaddr[], const char* name)
|
|
|
|
{
|
|
|
|
unsigned long timeout;
|
|
|
|
|
|
|
|
timeout = jiffies + Sb1000TimeOutJiffies;
|
|
|
|
while (inb(ioaddr[1] + 6) & 0x80) {
|
|
|
|
if (time_after_eq(jiffies, timeout)) {
|
|
|
|
printk(KERN_WARNING "%s: sb1000_wait_for_ready_clear timeout\n",
|
|
|
|
name);
|
|
|
|
return -ETIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
timeout = jiffies + Sb1000TimeOutJiffies;
|
|
|
|
while (inb(ioaddr[1] + 6) & 0x40) {
|
|
|
|
if (time_after_eq(jiffies, timeout)) {
|
|
|
|
printk(KERN_WARNING "%s: sb1000_wait_for_ready_clear timeout\n",
|
|
|
|
name);
|
|
|
|
return -ETIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Card Send Command (to be used during frame rx) */
|
2008-03-30 23:02:43 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_send_command(const int ioaddr[], const char* name,
|
|
|
|
const unsigned char out[])
|
|
|
|
{
|
|
|
|
outb(out[2], ioaddr[0] + 1);
|
|
|
|
outb(out[3], ioaddr[0] + 2);
|
|
|
|
outb(out[4], ioaddr[0] + 3);
|
|
|
|
outb(out[5], ioaddr[0] + 4);
|
|
|
|
outb(out[1], ioaddr[0] + 5);
|
|
|
|
outb(out[0], ioaddr[0] + 7);
|
|
|
|
if (sb1000_debug > 3)
|
|
|
|
printk(KERN_DEBUG "%s: sb1000_send_command out: %02x%02x%02x%02x"
|
|
|
|
"%02x%02x\n", name, out[0], out[1], out[2], out[3], out[4], out[5]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Card Read Status (to be used during frame rx) */
|
2008-03-30 23:02:43 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_read_status(const int ioaddr[], unsigned char in[])
|
|
|
|
{
|
|
|
|
in[1] = inb(ioaddr[0] + 1);
|
|
|
|
in[2] = inb(ioaddr[0] + 2);
|
|
|
|
in[3] = inb(ioaddr[0] + 3);
|
|
|
|
in[4] = inb(ioaddr[0] + 4);
|
|
|
|
in[0] = inb(ioaddr[0] + 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Issue Read Command (to be used during frame rx) */
|
2008-03-30 23:02:43 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_issue_read_command(const int ioaddr[], const char* name)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x20, 0x00, 0x00, 0x01, 0x00, 0x00};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sb1000_wait_for_ready_clear(ioaddr, name);
|
|
|
|
outb(0xa0, ioaddr[0] + 6);
|
|
|
|
sb1000_send_command(ioaddr, name, Command0);
|
|
|
|
}
|
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* SB1000 commands for open/configuration
|
|
|
|
*/
|
|
|
|
/* reset SB1000 card */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_reset(const int ioaddr[], const char* name)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
int port, status;
|
|
|
|
|
|
|
|
port = ioaddr[1] + 6;
|
|
|
|
outb(0x4, port);
|
|
|
|
inb(port);
|
|
|
|
udelay(1000);
|
|
|
|
outb(0x0, port);
|
|
|
|
inb(port);
|
2005-06-20 21:54:27 +00:00
|
|
|
ssleep(1);
|
2005-04-16 22:20:36 +00:00
|
|
|
outb(0x4, port);
|
|
|
|
inb(port);
|
|
|
|
udelay(1000);
|
|
|
|
outb(0x0, port);
|
|
|
|
inb(port);
|
|
|
|
udelay(0);
|
|
|
|
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command0, st)))
|
|
|
|
return status;
|
|
|
|
if (st[3] != 0xf0)
|
|
|
|
return -EIO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check SB1000 firmware CRC */
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_check_CRC(const int ioaddr[], const char* name)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x1f, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
2019-04-17 20:51:56 +00:00
|
|
|
int status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* check CRC */
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command0, st)))
|
|
|
|
return status;
|
|
|
|
if (st[1] != st[3] || st[2] != st[4])
|
|
|
|
return -EIO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
sb1000_start_get_set_command(const int ioaddr[], const char* name)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x1b, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
|
|
|
|
return card_send_command(ioaddr, name, Command0, st);
|
|
|
|
}
|
|
|
|
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_end_get_set_command(const int ioaddr[], const char* name)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x1b, 0x02, 0x00, 0x00, 0x00};
|
|
|
|
static const unsigned char Command1[6] = {0x20, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command0, st)))
|
|
|
|
return status;
|
|
|
|
return card_send_command(ioaddr, name, Command1, st);
|
|
|
|
}
|
|
|
|
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_activate(const int ioaddr[], const char* name)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
static const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
int status;
|
|
|
|
|
2005-06-20 21:54:27 +00:00
|
|
|
ssleep(1);
|
2019-01-17 00:35:43 +00:00
|
|
|
status = card_send_command(ioaddr, name, Command0, st);
|
|
|
|
if (status)
|
2005-04-16 22:20:36 +00:00
|
|
|
return status;
|
2019-01-17 00:35:43 +00:00
|
|
|
status = card_send_command(ioaddr, name, Command1, st);
|
|
|
|
if (status)
|
2005-04-16 22:20:36 +00:00
|
|
|
return status;
|
|
|
|
if (st[3] != 0xf1) {
|
2019-01-17 00:35:43 +00:00
|
|
|
status = sb1000_start_get_set_command(ioaddr, name);
|
|
|
|
if (status)
|
2005-04-16 22:20:36 +00:00
|
|
|
return status;
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
udelay(1000);
|
2019-01-17 00:35:43 +00:00
|
|
|
return sb1000_start_get_set_command(ioaddr, name);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get SB1000 firmware version */
|
|
|
|
static int
|
|
|
|
sb1000_get_firmware_version(const int ioaddr[], const char* name,
|
|
|
|
unsigned char version[], int do_end)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x23, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if ((status = sb1000_start_get_set_command(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command0, st)))
|
|
|
|
return status;
|
|
|
|
if (st[0] != 0xa3)
|
|
|
|
return -EIO;
|
|
|
|
version[0] = st[1];
|
|
|
|
version[1] = st[2];
|
|
|
|
if (do_end)
|
|
|
|
return sb1000_end_get_set_command(ioaddr, name);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get SB1000 frequency */
|
|
|
|
static int
|
|
|
|
sb1000_get_frequency(const int ioaddr[], const char* name, int* frequency)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
int status;
|
|
|
|
|
|
|
|
udelay(1000);
|
|
|
|
if ((status = sb1000_start_get_set_command(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command0, st)))
|
|
|
|
return status;
|
|
|
|
*frequency = ((st[1] << 8 | st[2]) << 8 | st[3]) << 8 | st[4];
|
|
|
|
return sb1000_end_get_set_command(ioaddr, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set SB1000 frequency */
|
|
|
|
static int
|
|
|
|
sb1000_set_frequency(const int ioaddr[], const char* name, int frequency)
|
|
|
|
{
|
|
|
|
unsigned char st[7];
|
|
|
|
int status;
|
|
|
|
unsigned char Command0[6] = {0x80, 0x29, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
const int FrequencyLowerLimit = 57000;
|
|
|
|
const int FrequencyUpperLimit = 804000;
|
|
|
|
|
|
|
|
if (frequency < FrequencyLowerLimit || frequency > FrequencyUpperLimit) {
|
|
|
|
printk(KERN_ERR "%s: frequency chosen (%d kHz) is not in the range "
|
|
|
|
"[%d,%d] kHz\n", name, frequency, FrequencyLowerLimit,
|
|
|
|
FrequencyUpperLimit);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
udelay(1000);
|
|
|
|
if ((status = sb1000_start_get_set_command(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
Command0[5] = frequency & 0xff;
|
|
|
|
frequency >>= 8;
|
|
|
|
Command0[4] = frequency & 0xff;
|
|
|
|
frequency >>= 8;
|
|
|
|
Command0[3] = frequency & 0xff;
|
|
|
|
frequency >>= 8;
|
|
|
|
Command0[2] = frequency & 0xff;
|
|
|
|
return card_send_command(ioaddr, name, Command0, st);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get SB1000 PIDs */
|
|
|
|
static int
|
|
|
|
sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[])
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x40, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
static const unsigned char Command1[6] = {0x80, 0x41, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
static const unsigned char Command2[6] = {0x80, 0x42, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
static const unsigned char Command3[6] = {0x80, 0x43, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
int status;
|
|
|
|
|
|
|
|
udelay(1000);
|
|
|
|
if ((status = sb1000_start_get_set_command(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command0, st)))
|
|
|
|
return status;
|
|
|
|
PID[0] = st[1] << 8 | st[2];
|
|
|
|
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command1, st)))
|
|
|
|
return status;
|
|
|
|
PID[1] = st[1] << 8 | st[2];
|
|
|
|
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command2, st)))
|
|
|
|
return status;
|
|
|
|
PID[2] = st[1] << 8 | st[2];
|
|
|
|
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command3, st)))
|
|
|
|
return status;
|
|
|
|
PID[3] = st[1] << 8 | st[2];
|
|
|
|
|
|
|
|
return sb1000_end_get_set_command(ioaddr, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set SB1000 PIDs */
|
|
|
|
static int
|
|
|
|
sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[])
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command4[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char st[7];
|
|
|
|
short p;
|
|
|
|
int status;
|
|
|
|
unsigned char Command0[6] = {0x80, 0x31, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
unsigned char Command1[6] = {0x80, 0x32, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
unsigned char Command2[6] = {0x80, 0x33, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
unsigned char Command3[6] = {0x80, 0x34, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
udelay(1000);
|
|
|
|
if ((status = sb1000_start_get_set_command(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
p = PID[0];
|
|
|
|
Command0[3] = p & 0xff;
|
|
|
|
p >>= 8;
|
|
|
|
Command0[2] = p & 0xff;
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command0, st)))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
p = PID[1];
|
|
|
|
Command1[3] = p & 0xff;
|
|
|
|
p >>= 8;
|
|
|
|
Command1[2] = p & 0xff;
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command1, st)))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
p = PID[2];
|
|
|
|
Command2[3] = p & 0xff;
|
|
|
|
p >>= 8;
|
|
|
|
Command2[2] = p & 0xff;
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command2, st)))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
p = PID[3];
|
|
|
|
Command3[3] = p & 0xff;
|
|
|
|
p >>= 8;
|
|
|
|
Command3[2] = p & 0xff;
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command3, st)))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
if ((status = card_send_command(ioaddr, name, Command4, st)))
|
|
|
|
return status;
|
|
|
|
return sb1000_end_get_set_command(ioaddr, name);
|
|
|
|
}
|
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2008-03-30 23:02:43 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_print_status_buffer(const char* name, unsigned char st[],
|
|
|
|
unsigned char buffer[], int size)
|
|
|
|
{
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
printk(KERN_DEBUG "%s: status: %02x %02x\n", name, st[0], st[1]);
|
|
|
|
if (buffer[24] == 0x08 && buffer[25] == 0x00 && buffer[26] == 0x45) {
|
|
|
|
printk(KERN_DEBUG "%s: length: %d protocol: %d from: %d.%d.%d.%d:%d "
|
|
|
|
"to %d.%d.%d.%d:%d\n", name, buffer[28] << 8 | buffer[29],
|
|
|
|
buffer[35], buffer[38], buffer[39], buffer[40], buffer[41],
|
|
|
|
buffer[46] << 8 | buffer[47],
|
|
|
|
buffer[42], buffer[43], buffer[44], buffer[45],
|
|
|
|
buffer[48] << 8 | buffer[49]);
|
|
|
|
} else {
|
|
|
|
for (i = 0, k = 0; i < (size + 7) / 8; i++) {
|
|
|
|
printk(KERN_DEBUG "%s: %s", name, i ? " " : "buffer:");
|
|
|
|
for (j = 0; j < 8 && k < size; j++, k++)
|
|
|
|
printk(" %02x", buffer[k]);
|
|
|
|
printk("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SB1000 commands for frame rx interrupt
|
|
|
|
*/
|
|
|
|
/* receive a single frame and assemble datagram
|
|
|
|
* (this is the heart of the interrupt routine)
|
|
|
|
*/
|
2008-03-30 23:02:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_rx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
|
|
|
|
#define FRAMESIZE 184
|
|
|
|
unsigned char st[2], buffer[FRAMESIZE], session_id, frame_id;
|
|
|
|
short dlen;
|
|
|
|
int ioaddr, ns;
|
|
|
|
unsigned int skbsize;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct sb1000_private *lp = netdev_priv(dev);
|
2007-10-04 00:41:50 +00:00
|
|
|
struct net_device_stats *stats = &dev->stats;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* SB1000 frame constants */
|
|
|
|
const int FrameSize = FRAMESIZE;
|
|
|
|
const int NewDatagramHeaderSkip = 8;
|
|
|
|
const int NewDatagramHeaderSize = NewDatagramHeaderSkip + 18;
|
|
|
|
const int NewDatagramDataSize = FrameSize - NewDatagramHeaderSize;
|
|
|
|
const int ContDatagramHeaderSkip = 7;
|
|
|
|
const int ContDatagramHeaderSize = ContDatagramHeaderSkip + 1;
|
|
|
|
const int ContDatagramDataSize = FrameSize - ContDatagramHeaderSize;
|
|
|
|
const int TrailerSize = 4;
|
|
|
|
|
|
|
|
ioaddr = dev->base_addr;
|
|
|
|
|
|
|
|
insw(ioaddr, (unsigned short*) st, 1);
|
|
|
|
#ifdef XXXDEBUG
|
|
|
|
printk("cm0: received: %02x %02x\n", st[0], st[1]);
|
|
|
|
#endif /* XXXDEBUG */
|
|
|
|
lp->rx_frames++;
|
|
|
|
|
|
|
|
/* decide if it is a good or bad frame */
|
|
|
|
for (ns = 0; ns < NPIDS; ns++) {
|
|
|
|
session_id = lp->rx_session_id[ns];
|
|
|
|
frame_id = lp->rx_frame_id[ns];
|
|
|
|
if (st[0] == session_id) {
|
|
|
|
if (st[1] == frame_id || (!frame_id && (st[1] & 0xf0) == 0x30)) {
|
|
|
|
goto good_frame;
|
|
|
|
} else if ((st[1] & 0xf0) == 0x30 && (st[0] & 0x40)) {
|
|
|
|
goto skipped_frame;
|
|
|
|
} else {
|
|
|
|
goto bad_frame;
|
|
|
|
}
|
|
|
|
} else if (st[0] == (session_id | 0x40)) {
|
|
|
|
if ((st[1] & 0xf0) == 0x30) {
|
|
|
|
goto skipped_frame;
|
|
|
|
} else {
|
|
|
|
goto bad_frame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto bad_frame;
|
|
|
|
|
|
|
|
skipped_frame:
|
|
|
|
stats->rx_frame_errors++;
|
|
|
|
skb = lp->rx_skb[ns];
|
|
|
|
if (sb1000_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: missing frame(s): got %02x %02x "
|
|
|
|
"expecting %02x %02x\n", dev->name, st[0], st[1],
|
|
|
|
skb ? session_id : session_id | 0x40, frame_id);
|
|
|
|
if (skb) {
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
skb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
good_frame:
|
|
|
|
lp->rx_frame_id[ns] = 0x30 | ((st[1] + 1) & 0x0f);
|
|
|
|
/* new datagram */
|
|
|
|
if (st[0] & 0x40) {
|
|
|
|
/* get data length */
|
|
|
|
insw(ioaddr, buffer, NewDatagramHeaderSize / 2);
|
|
|
|
#ifdef XXXDEBUG
|
|
|
|
printk("cm0: IP identification: %02x%02x fragment offset: %02x%02x\n", buffer[30], buffer[31], buffer[32], buffer[33]);
|
|
|
|
#endif /* XXXDEBUG */
|
|
|
|
if (buffer[0] != NewDatagramHeaderSkip) {
|
|
|
|
if (sb1000_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: new datagram header skip error: "
|
|
|
|
"got %02x expecting %02x\n", dev->name, buffer[0],
|
|
|
|
NewDatagramHeaderSkip);
|
|
|
|
stats->rx_length_errors++;
|
|
|
|
insw(ioaddr, buffer, NewDatagramDataSize / 2);
|
|
|
|
goto bad_frame_next;
|
|
|
|
}
|
|
|
|
dlen = ((buffer[NewDatagramHeaderSkip + 3] & 0x0f) << 8 |
|
|
|
|
buffer[NewDatagramHeaderSkip + 4]) - 17;
|
|
|
|
if (dlen > SB1000_MRU) {
|
|
|
|
if (sb1000_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: datagram length (%d) greater "
|
|
|
|
"than MRU (%d)\n", dev->name, dlen, SB1000_MRU);
|
|
|
|
stats->rx_length_errors++;
|
|
|
|
insw(ioaddr, buffer, NewDatagramDataSize / 2);
|
|
|
|
goto bad_frame_next;
|
|
|
|
}
|
|
|
|
lp->rx_dlen[ns] = dlen;
|
|
|
|
/* compute size to allocate for datagram */
|
|
|
|
skbsize = dlen + FrameSize;
|
|
|
|
if ((skb = alloc_skb(skbsize, GFP_ATOMIC)) == NULL) {
|
|
|
|
if (sb1000_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: can't allocate %d bytes long "
|
|
|
|
"skbuff\n", dev->name, skbsize);
|
|
|
|
stats->rx_dropped++;
|
|
|
|
insw(ioaddr, buffer, NewDatagramDataSize / 2);
|
|
|
|
goto dropped_frame;
|
|
|
|
}
|
|
|
|
skb->dev = dev;
|
2007-03-19 22:30:44 +00:00
|
|
|
skb_reset_mac_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
skb->protocol = (unsigned short) buffer[NewDatagramHeaderSkip + 16];
|
|
|
|
insw(ioaddr, skb_put(skb, NewDatagramDataSize),
|
|
|
|
NewDatagramDataSize / 2);
|
|
|
|
lp->rx_skb[ns] = skb;
|
|
|
|
} else {
|
|
|
|
/* continuation of previous datagram */
|
|
|
|
insw(ioaddr, buffer, ContDatagramHeaderSize / 2);
|
|
|
|
if (buffer[0] != ContDatagramHeaderSkip) {
|
|
|
|
if (sb1000_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: cont datagram header skip error: "
|
|
|
|
"got %02x expecting %02x\n", dev->name, buffer[0],
|
|
|
|
ContDatagramHeaderSkip);
|
|
|
|
stats->rx_length_errors++;
|
|
|
|
insw(ioaddr, buffer, ContDatagramDataSize / 2);
|
|
|
|
goto bad_frame_next;
|
|
|
|
}
|
|
|
|
skb = lp->rx_skb[ns];
|
|
|
|
insw(ioaddr, skb_put(skb, ContDatagramDataSize),
|
|
|
|
ContDatagramDataSize / 2);
|
|
|
|
dlen = lp->rx_dlen[ns];
|
|
|
|
}
|
|
|
|
if (skb->len < dlen + TrailerSize) {
|
|
|
|
lp->rx_session_id[ns] &= ~0x40;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* datagram completed: send to upper level */
|
|
|
|
skb_trim(skb, dlen);
|
|
|
|
netif_rx(skb);
|
|
|
|
stats->rx_bytes+=dlen;
|
|
|
|
stats->rx_packets++;
|
|
|
|
lp->rx_skb[ns] = NULL;
|
|
|
|
lp->rx_session_id[ns] |= 0x40;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
bad_frame:
|
|
|
|
insw(ioaddr, buffer, FrameSize / 2);
|
|
|
|
if (sb1000_debug > 1)
|
|
|
|
printk(KERN_WARNING "%s: frame error: got %02x %02x\n",
|
|
|
|
dev->name, st[0], st[1]);
|
|
|
|
stats->rx_frame_errors++;
|
|
|
|
bad_frame_next:
|
|
|
|
if (sb1000_debug > 2)
|
|
|
|
sb1000_print_status_buffer(dev->name, st, buffer, FrameSize);
|
|
|
|
dropped_frame:
|
|
|
|
stats->rx_errors++;
|
|
|
|
if (ns < NPIDS) {
|
|
|
|
if ((skb = lp->rx_skb[ns])) {
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
lp->rx_skb[ns] = NULL;
|
|
|
|
}
|
|
|
|
lp->rx_session_id[ns] |= 0x40;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-03-30 23:02:43 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_error_dpc(struct net_device *dev)
|
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x26, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
char *name;
|
|
|
|
unsigned char st[5];
|
|
|
|
int ioaddr[2];
|
|
|
|
struct sb1000_private *lp = netdev_priv(dev);
|
|
|
|
const int ErrorDpcCounterInitialize = 200;
|
|
|
|
|
|
|
|
ioaddr[0] = dev->base_addr;
|
|
|
|
/* mem_start holds the second I/O address */
|
|
|
|
ioaddr[1] = dev->mem_start;
|
|
|
|
name = dev->name;
|
|
|
|
|
|
|
|
sb1000_wait_for_ready_clear(ioaddr, name);
|
|
|
|
sb1000_send_command(ioaddr, name, Command0);
|
|
|
|
sb1000_wait_for_ready(ioaddr, name);
|
|
|
|
sb1000_read_status(ioaddr, st);
|
|
|
|
if (st[1] & 0x10)
|
|
|
|
lp->rx_error_dpc_count = ErrorDpcCounterInitialize;
|
|
|
|
}
|
|
|
|
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Linux interface functions
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sb1000_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
int ioaddr[2], status;
|
|
|
|
struct sb1000_private *lp = netdev_priv(dev);
|
|
|
|
const unsigned short FirmwareVersion[] = {0x01, 0x01};
|
|
|
|
|
|
|
|
ioaddr[0] = dev->base_addr;
|
|
|
|
/* mem_start holds the second I/O address */
|
|
|
|
ioaddr[1] = dev->mem_start;
|
|
|
|
name = dev->name;
|
|
|
|
|
|
|
|
/* initialize sb1000 */
|
|
|
|
if ((status = sb1000_reset(ioaddr, name)))
|
|
|
|
return status;
|
2005-06-20 21:54:27 +00:00
|
|
|
ssleep(1);
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((status = sb1000_check_CRC(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
/* initialize private data before board can catch interrupts */
|
|
|
|
lp->rx_skb[0] = NULL;
|
|
|
|
lp->rx_skb[1] = NULL;
|
|
|
|
lp->rx_skb[2] = NULL;
|
|
|
|
lp->rx_skb[3] = NULL;
|
|
|
|
lp->rx_dlen[0] = 0;
|
|
|
|
lp->rx_dlen[1] = 0;
|
|
|
|
lp->rx_dlen[2] = 0;
|
|
|
|
lp->rx_dlen[3] = 0;
|
|
|
|
lp->rx_frames = 0;
|
|
|
|
lp->rx_error_count = 0;
|
|
|
|
lp->rx_error_dpc_count = 0;
|
|
|
|
lp->rx_session_id[0] = 0x50;
|
2010-10-26 00:25:34 +00:00
|
|
|
lp->rx_session_id[1] = 0x48;
|
|
|
|
lp->rx_session_id[2] = 0x44;
|
|
|
|
lp->rx_session_id[3] = 0x42;
|
2005-04-16 22:20:36 +00:00
|
|
|
lp->rx_frame_id[0] = 0;
|
|
|
|
lp->rx_frame_id[1] = 0;
|
|
|
|
lp->rx_frame_id[2] = 0;
|
|
|
|
lp->rx_frame_id[3] = 0;
|
2009-11-19 07:29:17 +00:00
|
|
|
if (request_irq(dev->irq, sb1000_interrupt, 0, "sb1000", dev)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb1000_debug > 2)
|
|
|
|
printk(KERN_DEBUG "%s: Opening, IRQ %d\n", name, dev->irq);
|
|
|
|
|
|
|
|
/* Activate board and check firmware version */
|
|
|
|
udelay(1000);
|
|
|
|
if ((status = sb1000_activate(ioaddr, name)))
|
|
|
|
return status;
|
|
|
|
udelay(0);
|
|
|
|
if ((status = sb1000_get_firmware_version(ioaddr, name, version, 0)))
|
|
|
|
return status;
|
|
|
|
if (version[0] != FirmwareVersion[0] || version[1] != FirmwareVersion[1])
|
|
|
|
printk(KERN_WARNING "%s: found firmware version %x.%02x "
|
|
|
|
"(should be %x.%02x)\n", name, version[0], version[1],
|
|
|
|
FirmwareVersion[0], FirmwareVersion[1]);
|
|
|
|
|
|
|
|
|
|
|
|
netif_start_queue(dev);
|
|
|
|
return 0; /* Always succeed */
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sb1000_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|
|
|
{
|
|
|
|
char* name;
|
|
|
|
unsigned char version[2];
|
|
|
|
short PID[4];
|
|
|
|
int ioaddr[2], status, frequency;
|
|
|
|
unsigned int stats[5];
|
|
|
|
struct sb1000_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (!(dev && dev->flags & IFF_UP))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
ioaddr[0] = dev->base_addr;
|
|
|
|
/* mem_start holds the second I/O address */
|
|
|
|
ioaddr[1] = dev->mem_start;
|
|
|
|
name = dev->name;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SIOCGCMSTATS: /* get statistics */
|
2007-10-04 00:41:50 +00:00
|
|
|
stats[0] = dev->stats.rx_bytes;
|
2005-04-16 22:20:36 +00:00
|
|
|
stats[1] = lp->rx_frames;
|
2007-10-04 00:41:50 +00:00
|
|
|
stats[2] = dev->stats.rx_packets;
|
|
|
|
stats[3] = dev->stats.rx_errors;
|
|
|
|
stats[4] = dev->stats.rx_dropped;
|
2005-04-16 22:20:36 +00:00
|
|
|
if(copy_to_user(ifr->ifr_data, stats, sizeof(stats)))
|
|
|
|
return -EFAULT;
|
|
|
|
status = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCGCMFIRMWARE: /* get firmware version */
|
|
|
|
if ((status = sb1000_get_firmware_version(ioaddr, name, version, 1)))
|
|
|
|
return status;
|
|
|
|
if(copy_to_user(ifr->ifr_data, version, sizeof(version)))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCGCMFREQUENCY: /* get frequency */
|
|
|
|
if ((status = sb1000_get_frequency(ioaddr, name, &frequency)))
|
|
|
|
return status;
|
|
|
|
if(put_user(frequency, (int __user *) ifr->ifr_data))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCSCMFREQUENCY: /* set frequency */
|
|
|
|
if (!capable(CAP_NET_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
if(get_user(frequency, (int __user *) ifr->ifr_data))
|
|
|
|
return -EFAULT;
|
|
|
|
if ((status = sb1000_set_frequency(ioaddr, name, frequency)))
|
|
|
|
return status;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCGCMPIDS: /* get PIDs */
|
|
|
|
if ((status = sb1000_get_PIDs(ioaddr, name, PID)))
|
|
|
|
return status;
|
|
|
|
if(copy_to_user(ifr->ifr_data, PID, sizeof(PID)))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCSCMPIDS: /* set PIDs */
|
|
|
|
if (!capable(CAP_NET_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
if(copy_from_user(PID, ifr->ifr_data, sizeof(PID)))
|
|
|
|
return -EFAULT;
|
|
|
|
if ((status = sb1000_set_PIDs(ioaddr, name, PID)))
|
|
|
|
return status;
|
|
|
|
/* set session_id, frame_id and pkt_type too */
|
|
|
|
lp->rx_session_id[0] = 0x50 | (PID[0] & 0x0f);
|
|
|
|
lp->rx_session_id[1] = 0x48;
|
|
|
|
lp->rx_session_id[2] = 0x44;
|
|
|
|
lp->rx_session_id[3] = 0x42;
|
|
|
|
lp->rx_frame_id[0] = 0;
|
|
|
|
lp->rx_frame_id[1] = 0;
|
|
|
|
lp->rx_frame_id[2] = 0;
|
|
|
|
lp->rx_frame_id[3] = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
status = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* transmit function: do nothing since SB1000 can't send anything out */
|
2009-08-31 19:50:58 +00:00
|
|
|
static netdev_tx_t
|
2005-04-16 22:20:36 +00:00
|
|
|
sb1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
|
|
|
printk(KERN_WARNING "%s: trying to transmit!!!\n", dev->name);
|
|
|
|
/* sb1000 can't xmit datagrams */
|
|
|
|
dev_kfree_skb(skb);
|
2009-06-23 06:03:08 +00:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SB1000 interrupt handler. */
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t sb1000_interrupt(int irq, void *dev_id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-03-30 23:13:00 +00:00
|
|
|
static const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
static const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
char *name;
|
|
|
|
unsigned char st;
|
|
|
|
int ioaddr[2];
|
2006-10-06 18:56:04 +00:00
|
|
|
struct net_device *dev = dev_id;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sb1000_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
const int MaxRxErrorCount = 6;
|
|
|
|
|
|
|
|
ioaddr[0] = dev->base_addr;
|
|
|
|
/* mem_start holds the second I/O address */
|
|
|
|
ioaddr[1] = dev->mem_start;
|
|
|
|
name = dev->name;
|
|
|
|
|
|
|
|
/* is it a good interrupt? */
|
|
|
|
st = inb(ioaddr[1] + 6);
|
|
|
|
if (!(st & 0x08 && st & 0x20)) {
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb1000_debug > 3)
|
|
|
|
printk(KERN_DEBUG "%s: entering interrupt\n", dev->name);
|
|
|
|
|
|
|
|
st = inb(ioaddr[0] + 7);
|
|
|
|
if (sb1000_rx(dev))
|
|
|
|
lp->rx_error_count++;
|
|
|
|
#ifdef SB1000_DELAY
|
|
|
|
udelay(SB1000_DELAY);
|
|
|
|
#endif /* SB1000_DELAY */
|
|
|
|
sb1000_issue_read_command(ioaddr, name);
|
|
|
|
if (st & 0x01) {
|
|
|
|
sb1000_error_dpc(dev);
|
|
|
|
sb1000_issue_read_command(ioaddr, name);
|
|
|
|
}
|
|
|
|
if (lp->rx_error_dpc_count && !(--lp->rx_error_dpc_count)) {
|
|
|
|
sb1000_wait_for_ready_clear(ioaddr, name);
|
|
|
|
sb1000_send_command(ioaddr, name, Command0);
|
|
|
|
sb1000_wait_for_ready(ioaddr, name);
|
|
|
|
sb1000_issue_read_command(ioaddr, name);
|
|
|
|
}
|
|
|
|
if (lp->rx_error_count >= MaxRxErrorCount) {
|
|
|
|
sb1000_wait_for_ready_clear(ioaddr, name);
|
|
|
|
sb1000_send_command(ioaddr, name, Command1);
|
|
|
|
sb1000_wait_for_ready(ioaddr, name);
|
|
|
|
sb1000_issue_read_command(ioaddr, name);
|
|
|
|
lp->rx_error_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sb1000_close(struct net_device *dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int ioaddr[2];
|
|
|
|
struct sb1000_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (sb1000_debug > 2)
|
|
|
|
printk(KERN_DEBUG "%s: Shutting down sb1000.\n", dev->name);
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
ioaddr[0] = dev->base_addr;
|
|
|
|
/* mem_start holds the second I/O address */
|
|
|
|
ioaddr[1] = dev->mem_start;
|
|
|
|
|
|
|
|
free_irq(dev->irq, dev);
|
|
|
|
/* If we don't do this, we can't re-insmod it later. */
|
|
|
|
release_region(ioaddr[1], SB1000_IO_EXTENT);
|
|
|
|
release_region(ioaddr[0], SB1000_IO_EXTENT);
|
|
|
|
|
|
|
|
/* free rx_skb's if needed */
|
|
|
|
for (i=0; i<4; i++) {
|
|
|
|
if (lp->rx_skb[i]) {
|
|
|
|
dev_kfree_skb(lp->rx_skb[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Franco Venturi <fventuri@mediaone.net>");
|
|
|
|
MODULE_DESCRIPTION("General Instruments SB1000 driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2015-03-16 20:46:35 +00:00
|
|
|
module_pnp_driver(sb1000_driver);
|