add new driver for broadcom BCM4401 chipset (as seen on recent dell
laptops) written by Cliff Wright <cliff@snipe444.org> and tested by yours truly. XXX: missing mcast filter support. thanks cliff!
This commit is contained in:
parent
e257c8b61f
commit
871eae696e
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.pci,v 1.193 2003/09/25 15:58:14 pooka Exp $
|
||||
# $NetBSD: files.pci,v 1.194 2003/09/27 13:13:28 mrg Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent PCI code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
|
@ -608,3 +608,8 @@ attach skc at pci
|
|||
device sk: ether, ifnet, arp, mii
|
||||
attach sk at skc
|
||||
file dev/pci/if_sk.c skc | sk
|
||||
|
||||
# Broadcom 4401 10/100 Ethernet
|
||||
device bce: ether, ifnet, arp, mii
|
||||
attach bce at pci
|
||||
file dev/pci/if_bce.c bce
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,208 @@
|
|||
/* $NetBSD: if_bcereg.h,v 1.1 2003/09/27 13:13:28 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Clifford Wright. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Broadcom BCM440x */
|
||||
|
||||
/* PCI registers defined in the PCI 2.2 spec. */
|
||||
#define BCE_PCI_BAR0 0x10
|
||||
|
||||
/* Sonics SB register access */
|
||||
#define BCE_REG_WIN 0x80
|
||||
#define BCE_SONICS_WIN 0x18002000
|
||||
|
||||
/* Sonics PCI control */
|
||||
#define BCE_SPCI_TR2 0x0108 /* Sonics to PCI translation
|
||||
* 2 */
|
||||
/* bit defines */
|
||||
#define SBTOPCI_PREF 0x4 /* prefetch enable */
|
||||
#define SBTOPCI_BURST 0x8 /* burst enable */
|
||||
#define BCE_SBINTVEC 0x0f94
|
||||
/* interrupt bits */
|
||||
#define SBIV_ENET0 0x02 /* enable for enet 0 */
|
||||
#define SBIV_ENET1 0x40 /* enable for enet 1 */
|
||||
|
||||
|
||||
/* Host Interface Registers */
|
||||
|
||||
#define BCE_DEVCTL 0x0000 /* device control */
|
||||
/* device control bits */
|
||||
#define BCE_DC_IP 0x00000400 /* internal phy present */
|
||||
#define BCE_DC_ER 0x00008000 /* ephy reset */
|
||||
/* Interrupt Control */
|
||||
#define BCE_INT_STS 0x0020
|
||||
#define BCE_INT_MASK 0x0024
|
||||
/* bits for both status, and mask */
|
||||
#define I_TO 0x00000080 /* general timeout */
|
||||
#define I_PC 0x00000400 /* descriptor error */
|
||||
#define I_PD 0x00000800 /* data error */
|
||||
#define I_DE 0x00001000 /* desc. protocol error */
|
||||
#define I_RU 0x00002000 /* rx desc. underflow */
|
||||
#define I_RO 0x00004000 /* rx fifo overflow */
|
||||
#define I_XU 0x00008000 /* tx fifo underflow */
|
||||
#define I_RI 0x00010000 /* receive interrupt */
|
||||
#define I_XI 0x01000000 /* transmit interrupt */
|
||||
|
||||
/* Ethernet MAC Control */
|
||||
#define BCE_MACCTL 0x00A8 /* ethernet mac control */
|
||||
/* mac control bits */
|
||||
#define BCE_EMC_CG 0x00000001 /* crc32 generation */
|
||||
|
||||
/* DMA Interrupt control */
|
||||
#define BCE_DMAI_CTL 0x0100
|
||||
|
||||
/* DMA registers */
|
||||
#define BCE_DMA_TXCTL 0x0200 /* transmit control */
|
||||
/* transmit control bits */
|
||||
#define XC_XE 0x1 /* transmit enable */
|
||||
#define XC_LE 0x4 /* loopback enable */
|
||||
#define BCE_DMA_TXADDR 0x0204 /* tx ring base address */
|
||||
#define BCE_DMA_DPTR 0x0208 /* last tx descriptor */
|
||||
#define BCE_DMA_TXSTATUS 0x020C /* active desc, etc */
|
||||
#define BCE_DMA_RXCTL 0x0210 /* enable, etc */
|
||||
#define BCE_DMA_RXADDR 0x0214 /* rx ring base address */
|
||||
#define BCE_DMA_RXDPTR 0x0218 /* last descriptor */
|
||||
#define BCE_DMA_RXSTATUS 0x021C /* active desc, etc */
|
||||
/* receive status bits */
|
||||
#define RS_CD_MASK 0x0fff /* current descriptor pointer */
|
||||
|
||||
/* Ethernet MAC control registers */
|
||||
#define BCE_RX_CTL 0x0400 /* receive config */
|
||||
/* config bits */
|
||||
#define ERC_DB 0x00000001 /* disable broadcast */
|
||||
#define ERC_AM 0x00000002 /* rx all multicast */
|
||||
#define ERC_PE 0x00000008 /* promiscuous enable */
|
||||
|
||||
#define BCE_RX_MAX 0x0404 /* max packet length */
|
||||
#define BCE_TX_MAX 0x0408
|
||||
#define BCE_MI_CTL 0x0410
|
||||
#define BCE_MI_COMM 0x0414
|
||||
#define BCE_MI_STS 0x041C
|
||||
/* mii status bits */
|
||||
#define BCE_MIINTR 0x00000001 /* mii mdio interrupt */
|
||||
|
||||
#define BCE_FILT_LOW 0x0420 /* mac low 4 bytes */
|
||||
#define BCE_FILT_HI 0x0424 /* mac hi 2 bytes */
|
||||
#define BCE_FILT_CTL 0x0428 /* packet filter ctrl */
|
||||
#define BCE_ENET_CTL 0x042C
|
||||
/* bits for mac control */
|
||||
#define EC_EE 0x00000001 /* emac enable */
|
||||
#define EC_ED 0x00000002 /* disable emac */
|
||||
#define EC_ES 0x00000004 /* soft reset emac */
|
||||
#define EC_EP 0x00000008 /* external phy */
|
||||
#define BCE_TX_CTL 0x0430
|
||||
/* bits for transmit control */
|
||||
#define EXC_FD 0x00000001 /* full duplex */
|
||||
#define BCE_TX_WATER 0x0434 /* tx watermark */
|
||||
|
||||
/* statistics counters */
|
||||
#define BCE_RX_PKTS 0x058C
|
||||
|
||||
/* SiliconBackplane registers */
|
||||
#define BCE_SBIMSTATE 0x0f90
|
||||
#define BCE_SBTMSTATELOW 0x0f98
|
||||
#define BCE_SBTMSTATEHI 0x0f9C
|
||||
#define SBTML_RESET 0x1 /* reset */
|
||||
#define SBTML_REJ 0x2 /* reject */
|
||||
#define SBTML_CLK 0x10000 /* clock enable */
|
||||
#define SBTML_FGC 0x20000 /* force gated clocks on */
|
||||
|
||||
/* MI communication register */
|
||||
#define BCE_MICOMM_DATA 0x0000FFFF
|
||||
|
||||
|
||||
#define BCE_MIREG(x) ((x & 0x1F) << 18)
|
||||
#define BCE_MIPHY(x) ((x & 0x1F) << 23)
|
||||
|
||||
/* transmit buffer max frags allowed */
|
||||
#define BCE_NTXFRAGS 16
|
||||
|
||||
/* ring descriptor */
|
||||
struct bce_dma_slot {
|
||||
unsigned long ctrl;
|
||||
unsigned long addr;
|
||||
};
|
||||
#define CTRL_BC_MASK 0x1fff /* buffer byte count */
|
||||
#define CTRL_EOT 0x10000000 /* end of descriptor table */
|
||||
#define CTRL_IOC 0x20000000 /* interrupt on completion */
|
||||
#define CTRL_EOF 0x40000000 /* end of frame */
|
||||
#define CTRL_SOF 0x80000000 /* start of frame */
|
||||
|
||||
/* Packet status is returned in a pre-packet header */
|
||||
struct rx_pph {
|
||||
unsigned short len;
|
||||
unsigned short flags;
|
||||
unsigned short pad[12];
|
||||
};
|
||||
|
||||
/* packet status flags bits */
|
||||
#define RXF_NO 0x8 /* odd number of nibbles */
|
||||
#define RXF_RXER 0x4 /* receive symbol error */
|
||||
#define RXF_CRC 0x2 /* crc error */
|
||||
#define RXF_OV 0x1 /* fifo overflow */
|
||||
|
||||
/* number of descriptors used in a ring */
|
||||
#define BCE_NRXDESC 128
|
||||
#define BCE_NTXDESC 128
|
||||
|
||||
/*
|
||||
* Mbuf pointers. We need these to keep track of the virtual addresses
|
||||
* of our mbuf chains since we can only convert from physical to virtual,
|
||||
* not the other way around.
|
||||
*/
|
||||
struct bce_chain_data {
|
||||
struct mbuf *bce_tx_chain[BCE_NTXDESC];
|
||||
struct mbuf *bce_rx_chain[BCE_NRXDESC];
|
||||
bus_dmamap_t bce_tx_map[BCE_NTXDESC];
|
||||
bus_dmamap_t bce_rx_map[BCE_NRXDESC];
|
||||
};
|
||||
|
||||
#define BCE_TIMEOUT 100 /* # 10us for mii read/write */
|
||||
|
||||
struct bce_softc {
|
||||
struct device bce_dev;
|
||||
struct ethercom ethercom; /* interface info */
|
||||
bus_space_handle_t bce_bhandle;
|
||||
bus_space_tag_t bce_btag;
|
||||
void *bce_intrhand;
|
||||
struct pci_attach_args bce_pa;
|
||||
struct mii_data bce_mii;
|
||||
u_int32_t bce_phy;/* eeprom indicated phy */
|
||||
struct ifmedia bce_ifmedia; /* media info *//* Check */
|
||||
bus_dma_tag_t bce_dmatag;
|
||||
u_int8_t enaddr[ETHER_ADDR_LEN];
|
||||
struct bce_dma_slot *bce_rx_ring; /* receive ring */
|
||||
struct bce_dma_slot *bce_tx_ring; /* transmit ring */
|
||||
struct bce_chain_data bce_cdata; /* mbufs */
|
||||
bus_dmamap_t bce_ring_map;
|
||||
u_int32_t bce_rxin; /* last rx descriptor seen */
|
||||
u_int32_t bce_txin; /* last tx descriptor seen */
|
||||
int bce_txsfree; /* no. tx slots available */
|
||||
int bce_txsnext; /* next available tx slot */
|
||||
struct callout bce_timeout;
|
||||
};
|
Loading…
Reference in New Issue