/*
* drivers/net/ether00.c
*
* Copyright (C) 2001 Altera Corporation
*
* 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
*/
/* includes */
#include <linux/config.h>
#include <linux/pci.h>
#include <linux/sched.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/etherdevice.h>
#include <linux/module.h>
#include <linux/tqueue.h>
#include <linux/mtd/mtd.h>
#include <linux/pld/pld_hotswap.h>
#include <asm/arch/excalibur.h>
#include <asm/arch/hardware.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/sizes.h>
#include <asm/arch/ether00.h>
#include <asm/arch/tdkphy.h>
MODULE_AUTHOR("Clive Davies");
MODULE_DESCRIPTION("Altera Ether00 IP core driver");
MODULE_LICENSE("GPL");
#define PKT_BUF_SZ 1540 /* Size of each rx buffer */
#define ETH_NR 4 /* Number of MACs this driver supports */
#define DEBUG(x)
#define __dma_va(x) (unsigned int)((unsigned int)priv->dma_data+(((unsigned int)(x))&(EXC_SPSRAM_BLOCK0_SIZE-1)))
#define __dma_pa(x) (unsigned int)(EXC_SPSRAM_BLOCK0_BASE+(((unsigned int)(x))-(unsigned int)priv->dma_data))
#define ETHER00_BASE 0
#define ETHER00_TYPE
#define ETHER00_NAME "ether00"
#define MAC_REG_SIZE 0x400 /* size of MAC register area */
/* typedefs */
/* The definition of the driver control structure */
#define RX_NUM_BUFF 10
#define RX_NUM_FDESC 10
#define TX_NUM_FDESC 10
struct tx_fda_ent{
FDA_DESC fd;
BUF_DESC bd;
BUF_DESC pad;
};
struct rx_fda_ent{
FDA_DESC fd;
BUF_DESC bd;
BUF_DESC pad;
};
struct rx_blist_ent{
FDA_DESC fd;
BUF_DESC bd;
BUF_DESC pad;
};
struct net_priv
{
struct net_device_stats stats;
struct sk_buff* skb;
void* dma_data;
struct rx_blist_ent* rx_blist_vp;
struct rx_fda_ent* rx_fda_ptr;
struct tx_fda_ent* tx_fdalist_vp;
struct tq_struct tq_memupdate;
unsigned char memupdate_scheduled;
unsigned char rx_disabled;
unsigned char queue_stopped;
spinlock_t rx_lock;
};
static const char vendor_id[2]={0x07,0xed};
#ifdef ETHER00_DEBUG
/* Dump (most) registers for debugging puposes */
static void dump_regs(struct net_device *dev){
struct net_priv* priv=dev->priv;
unsigned int* i;
printk("\n RX free descriptor area:\n");
for(i=(unsigned int*)priv->rx_fda_ptr;
i<((unsigned int*)(priv->rx_fda_ptr+RX_NUM_FDESC));){
printk("%#8x %#8x %#8x %#8x\n",*i,*(i+1),*(i+2),*(i+3));
i+=4;
}
printk("\n RX buffer list:\n");
for(i=(unsigned int*)priv->rx_blist_vp;
i<((unsigned int*)(priv->rx_blist_vp+RX_NUM_BUFF));){
printk("%#8x %#8x %#8x %#8x\n",*i,*(i+1),*(i+2),*(i+3));
i+=4;
}
printk("\n TX frame descriptor list:\n");
for(i=(unsigned int*)priv->tx_fdalist_vp;
i<((unsigned int*)(priv->tx_fdalist_vp+TX_NUM_FDESC));){
printk("%#8x %#8x %#8x %#8x\n",*i,*(i+1),*(i+2),*(i+3));
i+=4;
}
printk("\ndma ctl=%#x\n",readw(ETHER_DMA_CTL(dev->base_addr)));
printk("txfrmptr=%#x\n",readw(ETHER_TXFRMPTR(dev->base_addr)));
printk("txthrsh=%#x\n",readw(ETHER_TXTHRSH(dev->base_addr)));
printk("txpollctr=%#x\n",readw(ETHER_TXPOLLCTR(dev->base_addr)));
printk("blfrmptr=%#x\n",readw(ETHER_BLFRMPTR(dev->base_addr)));
printk("rxfragsize=%#x\n",readw(ETHER_RXFRAGSIZE(dev->base_addr)));
printk("tx_int_en=%#x\n",readw(ETHER_INT_EN(dev->base_addr)));
printk("fda_bas=%#x\n",readw(ETHER_FDA_BAS(dev->base_addr)));
printk("fda_lim=%#x\n",readw(ETHER_FDA_LIM(dev->base_addr)));
printk("int_src=%#x\n",readw(ETHER_INT_SRC(dev->base_addr)));
printk("pausecnt=%#x\n",readw(ETHER_PAUSECNT(dev->base_addr)));
printk("rempaucnt=%#x\n",readw(ETHER_REMPAUCNT(dev->base_addr)));
printk("txconfrmstat=%#x\n",readw(ETHER_TXCONFRMSTAT(dev->base_addr)));
printk("mac_ctl=%#x\n",readw(ETHER_MAC_CTL(dev->base_addr)));
printk("arc_ctl=%#x\n",readw(ETHER_ARC_CTL(dev->base_addr)));
printk("tx_ctl=%#x\n",readw(ETHER_TX_CTL(dev->base_addr)));