2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* Linux ARCnet driver - COM20020 PCI support
|
|
|
|
* Contemporary Controls PCI20 and SOHARD SH-ARC PCI
|
|
|
|
*
|
|
|
|
* Written 1994-1999 by Avery Pennarun,
|
|
|
|
* based on an ISA version by David Woodhouse.
|
|
|
|
* Written 1999-2000 by Martin Mares <mj@ucw.cz>.
|
|
|
|
* Derived from skeleton.c by Donald Becker.
|
|
|
|
*
|
|
|
|
* Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
|
|
|
|
* for sponsoring the further development of this driver.
|
|
|
|
*
|
|
|
|
* **********************
|
|
|
|
*
|
|
|
|
* The original copyright of skeleton.c was as follows:
|
|
|
|
*
|
|
|
|
* skeleton.c Written 1993 by Donald Becker.
|
|
|
|
* Copyright 1993 United States Government as represented by the
|
|
|
|
* Director, National Security Agency. This software may only be used
|
|
|
|
* and distributed according to the terms of the GNU General Public License as
|
|
|
|
* modified by SRC, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
* **********************
|
|
|
|
*
|
|
|
|
* For more details, see drivers/net/arcnet.c
|
|
|
|
*
|
|
|
|
* **********************
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/init.h>
|
2011-06-06 10:43:46 +00:00
|
|
|
#include <linux/interrupt.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/arcdevice.h>
|
|
|
|
#include <linux/com20020.h>
|
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define VERSION "arcnet: COM20020 PCI support\n"
|
|
|
|
|
|
|
|
/* Module parameters */
|
|
|
|
|
|
|
|
static int node;
|
|
|
|
static char device[9]; /* use eg. device="arc1" to change name */
|
|
|
|
static int timeout = 3;
|
|
|
|
static int backplane;
|
|
|
|
static int clockp;
|
|
|
|
static int clockm;
|
|
|
|
|
|
|
|
module_param(node, int, 0);
|
|
|
|
module_param_string(device, device, sizeof(device), 0);
|
|
|
|
module_param(timeout, int, 0);
|
|
|
|
module_param(backplane, int, 0);
|
|
|
|
module_param(clockp, int, 0);
|
|
|
|
module_param(clockm, int, 0);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2012-12-03 09:22:43 -05:00
|
|
|
static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2014-09-29 11:55:36 +02:00
|
|
|
struct com20020_pci_channel_map *cm;
|
|
|
|
struct com20020_pci_card_info *ci;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct net_device *dev;
|
|
|
|
struct arcnet_local *lp;
|
|
|
|
int ioaddr, err;
|
|
|
|
|
|
|
|
if (pci_enable_device(pdev))
|
|
|
|
return -EIO;
|
|
|
|
dev = alloc_arcdev(device);
|
|
|
|
if (!dev)
|
|
|
|
return -ENOMEM;
|
2009-01-09 13:01:10 +00:00
|
|
|
|
|
|
|
dev->netdev_ops = &com20020_netdev_ops;
|
|
|
|
|
2014-09-29 11:55:36 +02:00
|
|
|
ci = (struct com20020_pci_card_info *)id->driver_data;
|
|
|
|
|
2008-11-12 23:37:49 -08:00
|
|
|
lp = netdev_priv(dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
pci_set_drvdata(pdev, dev);
|
|
|
|
|
2014-09-29 11:55:36 +02:00
|
|
|
cm = &ci->chan_map_tbl[0];
|
|
|
|
BUGMSG(D_NORMAL, "%s Controls\n", ci->name);
|
|
|
|
ioaddr = pci_resource_start(pdev, cm->bar);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com20020-pci")) {
|
|
|
|
BUGMSG(D_INIT, "IO region %xh-%xh already allocated.\n",
|
|
|
|
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
|
|
|
|
err = -EBUSY;
|
|
|
|
goto out_dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dummy access after Reset
|
|
|
|
// ARCNET controller needs this access to detect bustype
|
|
|
|
outb(0x00,ioaddr+1);
|
|
|
|
inb(ioaddr+1);
|
|
|
|
|
|
|
|
dev->base_addr = ioaddr;
|
|
|
|
dev->irq = pdev->irq;
|
|
|
|
dev->dev_addr[0] = node;
|
|
|
|
lp->card_name = "PCI COM20020";
|
2014-09-29 11:55:36 +02:00
|
|
|
lp->card_flags = ci->flags;
|
2005-04-16 15:20:36 -07:00
|
|
|
lp->backplane = backplane;
|
|
|
|
lp->clockp = clockp & 7;
|
|
|
|
lp->clockm = clockm & 3;
|
|
|
|
lp->timeout = timeout;
|
|
|
|
lp->hw.owner = THIS_MODULE;
|
|
|
|
|
|
|
|
if (ASTATUS() == 0xFF) {
|
|
|
|
BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, "
|
|
|
|
"but seems empty!\n", ioaddr);
|
|
|
|
err = -EIO;
|
|
|
|
goto out_port;
|
|
|
|
}
|
|
|
|
if (com20020_check(dev)) {
|
|
|
|
err = -EIO;
|
|
|
|
goto out_port;
|
|
|
|
}
|
|
|
|
|
2006-07-01 19:29:39 -07:00
|
|
|
if ((err = com20020_found(dev, IRQF_SHARED)) != 0)
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out_port;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_port:
|
|
|
|
release_region(ioaddr, ARCNET_TOTAL_SIZE);
|
|
|
|
out_dev:
|
|
|
|
free_netdev(dev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-12-03 09:22:43 -05:00
|
|
|
static void com20020pci_remove(struct pci_dev *pdev)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
struct net_device *dev = pci_get_drvdata(pdev);
|
|
|
|
unregister_netdev(dev);
|
|
|
|
free_irq(dev->irq, dev);
|
|
|
|
release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
|
|
|
|
free_netdev(dev);
|
|
|
|
}
|
|
|
|
|
2014-09-29 11:55:36 +02:00
|
|
|
static struct com20020_pci_card_info card_info_10mbit = {
|
|
|
|
.name = "ARC-PCI",
|
|
|
|
.devcount = 1,
|
|
|
|
.chan_map_tbl = {
|
|
|
|
{ 2, 0x00, 0x08 },
|
|
|
|
},
|
|
|
|
.flags = ARC_CAN_10MBIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct com20020_pci_card_info card_info_5mbit = {
|
|
|
|
.name = "ARC-PCI",
|
|
|
|
.devcount = 1,
|
|
|
|
.chan_map_tbl = {
|
|
|
|
{ 2, 0x00, 0x08 },
|
|
|
|
},
|
|
|
|
.flags = ARC_IS_5MBIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct com20020_pci_card_info card_info_sohard = {
|
|
|
|
.name = "PLX-PCI",
|
|
|
|
.devcount = 1,
|
|
|
|
/* SOHARD needs PCI base addr 4 */
|
|
|
|
.chan_map_tbl = {
|
|
|
|
{4, 0x00, 0x08},
|
|
|
|
},
|
|
|
|
.flags = ARC_CAN_10MBIT,
|
|
|
|
};
|
|
|
|
|
2014-08-08 15:56:03 +02:00
|
|
|
static const struct pci_device_id com20020pci_id_table[] = {
|
2014-09-29 11:55:36 +02:00
|
|
|
{
|
|
|
|
0x1571, 0xa001,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa002,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa003,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa004,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa005,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa006,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa007,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa008,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa009,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_5mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa00a,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_5mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa00b,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_5mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa00c,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_5mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa00d,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_5mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa00e,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_5mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa201,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa202,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa203,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa204,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa205,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x1571, 0xa206,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x10B5, 0x9030,
|
|
|
|
0x10B5, 0x2978,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_sohard
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x10B5, 0x9050,
|
|
|
|
0x10B5, 0x2273,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_sohard
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x14BA, 0x6000,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x10B5, 0x2200,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
0, 0,
|
|
|
|
(kernel_ulong_t)&card_info_10mbit
|
|
|
|
},
|
|
|
|
{ 0, }
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, com20020pci_id_table);
|
|
|
|
|
|
|
|
static struct pci_driver com20020pci_driver = {
|
|
|
|
.name = "com20020",
|
|
|
|
.id_table = com20020pci_id_table,
|
|
|
|
.probe = com20020pci_probe,
|
2012-12-03 09:22:43 -05:00
|
|
|
.remove = com20020pci_remove,
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init com20020pci_init(void)
|
|
|
|
{
|
|
|
|
BUGLVL(D_NORMAL) printk(VERSION);
|
2006-08-19 17:48:59 -04:00
|
|
|
return pci_register_driver(&com20020pci_driver);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit com20020pci_cleanup(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&com20020pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(com20020pci_init)
|
|
|
|
module_exit(com20020pci_cleanup)
|