/*
* Micrel KS8695 (Centaur) Ethernet.
*
* 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.
*
* Copyright 2008 Simtec Electronics
* Daniel Silverstone <dsilvers@simtec.co.uk>
* Vincent Sanders <vince@simtec.co.uk>
*/
#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/ioport.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/interrupt.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/crc32.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <asm/irq.h>
#include <mach/regs-switch.h>
#include <mach/regs-misc.h>
#include <asm/mach/irq.h>
#include <mach/regs-irq.h>
#include "ks8695net.h"
#define MODULENAME "ks8695_ether"
#define MODULEVERSION "1.02"
/*
* Transmit and device reset timeout, default 5 seconds.
*/
static int watchdog = 5000;
/* Hardware structures */
/**
* struct rx_ring_desc - Receive descriptor ring element
* @status: The status of the descriptor element (E.g. who owns it)
* @length: The number of bytes in the block pointed to by data_ptr
* @data_ptr: The physical address of the data block to receive into
* @next_desc: The physical address of the next descriptor element.
*/
struct rx_ring_desc {
__le32 status;
__le32 length;
__le32 data_ptr;
__le32 next_desc;
};
/**
* struct tx_ring_desc - Transmit descriptor ring element
* @owner: Who owns the descriptor
* @status: The number of bytes in the block pointed to by data_ptr
* @data_ptr: The physical address of the data block to receive into
* @next_desc: The physical address of the next descriptor element.
*/
struct tx_ring_desc {
__le32 owner;
__le32 status;
__le32 data_ptr;
__le32 next_desc;
};
/**
* struct ks8695_skbuff - sk_buff wrapper for rx/tx rings.
* @skb: The buffer in the ring
* @dma_ptr: The mapped DMA pointer of the buffer
* @length: The number of bytes mapped to dma_ptr
*/
struct ks8695_skbuff {
struct sk_buff *skb;
dma_addr_t dma_ptr;
u32 length;
};
/* Private device structure */
#define MAX_TX_DESC 8
#define MAX_TX_DESC_MASK 0x7
#define MAX_RX_DESC 16
#define MAX_RX_DESC_MASK 0xf
/*napi_weight have better more than rx DMA buffers*/
#define NAPI_WEIGHT 64
#define MAX_RXBUF_SIZE 0x700
#define TX_RING_DMA_SIZE (sizeof(struct tx_ring_desc) * MAX_TX_DESC)
#define RX_RING_DMA_SIZE (sizeof(struct rx_ring_desc) * MAX_RX_DESC)
#define RING_DMA_SIZE (TX_RING_DMA_SIZE + RX_RING_D