linux/drivers/net/ethernet/8390/pcnet_cs.c

// SPDX-License-Identifier: GPL-1.0+
/*======================================================================

    A PCMCIA ethernet driver for NS8390-based cards

    This driver supports the D-Link DE-650 and Linksys EthernetCard
    cards, the newer D-Link and Linksys combo cards, Accton EN2212
    cards, the RPTI EP400, and the PreMax PE-200 in non-shared-memory
    mode, and the IBM Credit Card Adapter, the NE4100, the Thomas
    Conrad ethernet card, and the Kingston KNE-PCM/x in shared-memory
    mode.  It will also handle the Socket EA card in either mode.

    Copyright (C) 1999 David A. Hinds -- [email protected]

    pcnet_cs.c 1.153 2003/11/09 18:53:09

    The network driver code is based on Donald Becker's NE2000 code:

    Written 1992,1993 by Donald Becker.
    Copyright 1993 United States Government as represented by the
    Director, National Security Agency.
    Donald Becker may be reached at [email protected]

    Based also on Keith Moore's changes to Don Becker's code, for IBM
    CCAE support.  Drivers merged back together, and shared-memory
    Socket EA support added, by Ken Raeburn, September 1995.

======================================================================*/

#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/ptrace.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/log2.h>
#include <linux/etherdevice.h>
#include <linux/mii.h>
#include "8390.h"

#include <pcmcia/cistpl.h>
#include <pcmcia/ciscode.h>
#include <pcmcia/ds.h>
#include <pcmcia/cisreg.h>

#include <asm/io.h>
#include <asm/byteorder.h>
#include <linux/uaccess.h>

#define PCNET_CMD
#define PCNET_DATAPORT
#define PCNET_RESET
#define PCNET_MISC

#define PCNET_START_PG
#define PCNET_STOP_PG

/* Socket EA cards have a larger packet buffer */
#define SOCKET_START_PG
#define SOCKET_STOP_PG

#define PCNET_RDC_TIMEOUT

static const char *if_names[] =;

/*====================================================================*/

/* Module parameters */

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

#define INT_MODULE_PARM(n, v)

INT_MODULE_PARM(if_port,	1);	/* Transceiver type */
INT_MODULE_PARM(use_big_buf,	1);	/* use 64K packet buffer? */
INT_MODULE_PARM(mem_speed,	0);	/* shared mem speed, in ns */
INT_MODULE_PARM(delay_output,	0);	/* pause after xmit? */
INT_MODULE_PARM(delay_time,	4);	/* in usec */
INT_MODULE_PARM(use_shmem,	-1);	/* use shared memory? */
INT_MODULE_PARM(full_duplex,	0);	/* full duplex? */

/* Ugh!  Let the user hardwire the hardware address for queer cards */
static int hw_addr[6] =;
module_param_array();

/*====================================================================*/

static void mii_phy_probe(struct net_device *dev);
static int pcnet_config(struct pcmcia_device *link);
static void pcnet_release(struct pcmcia_device *link);
static int pcnet_open(struct net_device *dev);
static int pcnet_close(struct net_device *dev);
static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static irqreturn_t ei_irq_wrapper(int irq, void *dev_id);
static void ei_watchdog(struct timer_list *t);
static void pcnet_reset_8390(struct net_device *dev);
static int set_config(struct net_device *dev, struct ifmap *map);
static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
			      int stop_pg, int cm_offset);
static int setup_dma_config(struct pcmcia_device *link, int start_pg,
			    int stop_pg);

static void pcnet_detach(struct pcmcia_device *p_dev);

/*====================================================================*/

struct hw_info {};

#define DELAY_OUTPUT
#define HAS_MISC_REG
#define USE_BIG_BUF
#define HAS_IBM_MISC
#define IS_DL10019
#define IS_DL10022
#define HAS_MII
#define USE_SHMEM

#define AM79C9XX_HOME_PHY
#define AM79C9XX_ETH_PHY
#define MII_PHYID_REV_MASK
#define MII_PHYID_REG1
#define MII_PHYID_REG2

static struct hw_info hw_info[] =;

#define NR_INFO

static struct hw_info default_info =;
static struct hw_info dl10019_info =;
static struct hw_info dl10022_info =;

struct pcnet_dev {};

static inline struct pcnet_dev *PRIV(struct net_device *dev)
{}

static const struct net_device_ops pcnet_netdev_ops =;

static int pcnet_probe(struct pcmcia_device *link)
{} /* pcnet_attach */

static void pcnet_detach(struct pcmcia_device *link)
{} /* pcnet_detach */

/*======================================================================

    This probes for a card's hardware address, for card types that
    encode this information in their CIS.

======================================================================*/

static struct hw_info *get_hwinfo(struct pcmcia_device *link)
{} /* get_hwinfo */

/*======================================================================

    This probes for a card's hardware address by reading the PROM.
    It checks the address against a list of known types, then falls
    back to a simple NE2000 clone signature check.

======================================================================*/

static struct hw_info *get_prom(struct pcmcia_device *link)
{} /* get_prom */

/*======================================================================

    For DL10019 based cards, like the Linksys EtherFast

======================================================================*/

static struct hw_info *get_dl10019(struct pcmcia_device *link)
{}

/*======================================================================

    For Asix AX88190 based cards

======================================================================*/

static struct hw_info *get_ax88190(struct pcmcia_device *link)
{}

/*======================================================================

    This should be totally unnecessary... but when we can't figure
    out the hardware address any other way, we'll let the user hard
    wire it when the module is initialized.

======================================================================*/

static struct hw_info *get_hwired(struct pcmcia_device *link)
{} /* get_hwired */

static int try_io_port(struct pcmcia_device *link)
{}

static int pcnet_confcheck(struct pcmcia_device *p_dev, void *priv_data)
{}

static struct hw_info *pcnet_try_config(struct pcmcia_device *link,
					int *has_shmem, int try)
{}

static int pcnet_config(struct pcmcia_device *link)
{} /* pcnet_config */

static void pcnet_release(struct pcmcia_device *link)
{}

static int pcnet_suspend(struct pcmcia_device *link)
{}

static int pcnet_resume(struct pcmcia_device *link)
{}


/*======================================================================

    MII interface support for DL10019 and DL10022 based cards

    On the DL10019, the MII IO direction bit is 0x10; on the DL10022
    it is 0x20.  Setting both bits seems to work on both card types.

======================================================================*/

#define DLINK_GPIO
#define DLINK_DIAG
#define DLINK_EEPROM

#define MDIO_SHIFT_CLK
#define MDIO_DATA_OUT
#define MDIO_DIR_WRITE
#define MDIO_DATA_WRITE0
#define MDIO_DATA_WRITE1
#define MDIO_DATA_READ
#define MDIO_MASK

static void mdio_sync(unsigned int addr)
{}

static int mdio_read(unsigned int addr, int phy_id, int loc)
{}

static void mdio_write(unsigned int addr, int phy_id, int loc, int value)
{}

/*======================================================================

    EEPROM access routines for DL10019 and DL10022 based cards

======================================================================*/

#define EE_EEP
#define EE_ASIC
#define EE_CS
#define EE_CK
#define EE_DO
#define EE_DI
#define EE_ADOT
#define EE_READ_CMD

#define DL19FDUPLX

static int read_eeprom(unsigned int ioaddr, int location)
{}

/*
    The internal ASIC registers can be changed by EEPROM READ access
    with EE_ASIC bit set.
    In ASIC mode, EE_ADOT is used to output the data to the ASIC.
*/

static void write_asic(unsigned int ioaddr, int location, short asic_data)
{}

/*====================================================================*/

static void set_misc_reg(struct net_device *dev)
{}

/*====================================================================*/

static void mii_phy_probe(struct net_device *dev)
{}

static int pcnet_open(struct net_device *dev)
{} /* pcnet_open */

/*====================================================================*/

static int pcnet_close(struct net_device *dev)
{} /* pcnet_close */

/*======================================================================

    Hard reset the card.  This used to pause for the same period that
    a 8390 reset command required, but that shouldn't be necessary.

======================================================================*/

static void pcnet_reset_8390(struct net_device *dev)
{} /* pcnet_reset_8390 */

/*====================================================================*/

static int set_config(struct net_device *dev, struct ifmap *map)
{}

/*====================================================================*/

static irqreturn_t ei_irq_wrapper(int irq, void *dev_id)
{}

static void ei_watchdog(struct timer_list *t)
{}

/*====================================================================*/


static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{}

/*====================================================================*/

static void dma_get_8390_hdr(struct net_device *dev,
			     struct e8390_pkt_hdr *hdr,
			     int ring_page)
{}

/*====================================================================*/

static void dma_block_input(struct net_device *dev, int count,
			    struct sk_buff *skb, int ring_offset)
{} /* dma_block_input */

/*====================================================================*/

static void dma_block_output(struct net_device *dev, int count,
			     const u_char *buf, const int start_page)
{}

/*====================================================================*/

static int setup_dma_config(struct pcmcia_device *link, int start_pg,
			    int stop_pg)
{}

/*====================================================================*/

static void copyin(void *dest, void __iomem *src, int c)
{}

static void copyout(void __iomem *dest, const void *src, int c)
{}

/*====================================================================*/

static void shmem_get_8390_hdr(struct net_device *dev,
			       struct e8390_pkt_hdr *hdr,
			       int ring_page)
{}

/*====================================================================*/

static void shmem_block_input(struct net_device *dev, int count,
			      struct sk_buff *skb, int ring_offset)
{}

/*====================================================================*/

static void shmem_block_output(struct net_device *dev, int count,
			       const u_char *buf, const int start_page)
{}

/*====================================================================*/

static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
			      int stop_pg, int cm_offset)
{}

/*====================================================================*/

static const struct pcmcia_device_id pcnet_ids[] =;
MODULE_DEVICE_TABLE(pcmcia, pcnet_ids);
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();

static struct pcmcia_driver pcnet_driver =;
module_pcmcia_driver();