linux/drivers/net/ethernet/wiznet/w5100.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Ethernet driver for the WIZnet W5100 chip.
 *
 * Copyright (C) 2006-2008 WIZnet Co.,Ltd.
 * Copyright (C) 2012 Mike Sinkovsky <[email protected]>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/platform_device.h>
#include <linux/platform_data/wiznet.h>
#include <linux/ethtool.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/gpio.h>

#include "w5100.h"

#define DRV_NAME
#define DRV_VERSION

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

/*
 * W5100/W5200/W5500 common registers
 */
#define W5100_COMMON_REGS
#define W5100_MR
#define MR_RST
#define MR_PB
#define MR_AI
#define MR_IND
#define W5100_SHAR
#define W5100_IR
#define W5100_COMMON_REGS_LEN

#define W5100_Sn_MR
#define W5100_Sn_CR
#define W5100_Sn_IR
#define W5100_Sn_SR
#define W5100_Sn_TX_FSR
#define W5100_Sn_TX_RD
#define W5100_Sn_TX_WR
#define W5100_Sn_RX_RSR
#define W5100_Sn_RX_RD

#define S0_REGS(priv)

#define W5100_S0_MR(priv)
#define S0_MR_MACRAW
#define S0_MR_MF
#define W5500_S0_MR_MF
#define W5100_S0_CR(priv)
#define S0_CR_OPEN
#define S0_CR_CLOSE
#define S0_CR_SEND
#define S0_CR_RECV
#define W5100_S0_IR(priv)
#define S0_IR_SENDOK
#define S0_IR_RECV
#define W5100_S0_SR(priv)
#define S0_SR_MACRAW
#define W5100_S0_TX_FSR(priv)
#define W5100_S0_TX_RD(priv)
#define W5100_S0_TX_WR(priv)
#define W5100_S0_RX_RSR(priv)
#define W5100_S0_RX_RD(priv)

#define W5100_S0_REGS_LEN

/*
 * W5100 and W5200 common registers
 */
#define W5100_IMR
#define IR_S0
#define W5100_RTR
#define RTR_DEFAULT

/*
 * W5100 specific register and memory
 */
#define W5100_RMSR
#define W5100_TMSR

#define W5100_S0_REGS

#define W5100_TX_MEM_START
#define W5100_TX_MEM_SIZE
#define W5100_RX_MEM_START
#define W5100_RX_MEM_SIZE

/*
 * W5200 specific register and memory
 */
#define W5200_S0_REGS

#define W5200_Sn_RXMEM_SIZE(n)
#define W5200_Sn_TXMEM_SIZE(n)

#define W5200_TX_MEM_START
#define W5200_TX_MEM_SIZE
#define W5200_RX_MEM_START
#define W5200_RX_MEM_SIZE

/*
 * W5500 specific register and memory
 *
 * W5500 register and memory are organized by multiple blocks.  Each one is
 * selected by 16bits offset address and 5bits block select bits.  So we
 * encode it into 32bits address. (lower 16bits is offset address and
 * upper 16bits is block select bits)
 */
#define W5500_SIMR
#define W5500_RTR

#define W5500_S0_REGS

#define W5500_Sn_RXMEM_SIZE(n)
#define W5500_Sn_TXMEM_SIZE(n)

#define W5500_TX_MEM_START
#define W5500_TX_MEM_SIZE
#define W5500_RX_MEM_START
#define W5500_RX_MEM_SIZE

/*
 * Device driver private data structure
 */

struct w5100_priv {};

/************************************************************************
 *
 *  Lowlevel I/O functions
 *
 ***********************************************************************/

struct w5100_mmio_priv {};

static inline struct w5100_mmio_priv *w5100_mmio_priv(struct net_device *dev)
{}

static inline void __iomem *w5100_mmio(struct net_device *ndev)
{}

/*
 * In direct address mode host system can directly access W5100 registers
 * after mapping to Memory-Mapped I/O space.
 *
 * 0x8000 bytes are required for memory space.
 */
static inline int w5100_read_direct(struct net_device *ndev, u32 addr)
{}

static inline int __w5100_write_direct(struct net_device *ndev, u32 addr,
				       u8 data)
{}

static inline int w5100_write_direct(struct net_device *ndev, u32 addr, u8 data)
{}

static int w5100_read16_direct(struct net_device *ndev, u32 addr)
{}

static int w5100_write16_direct(struct net_device *ndev, u32 addr, u16 data)
{}

static int w5100_readbulk_direct(struct net_device *ndev, u32 addr, u8 *buf,
				 int len)
{}

static int w5100_writebulk_direct(struct net_device *ndev, u32 addr,
				  const u8 *buf, int len)
{}

static int w5100_mmio_init(struct net_device *ndev)
{}

static const struct w5100_ops w5100_mmio_direct_ops =;

/*
 * In indirect address mode host system indirectly accesses registers by
 * using Indirect Mode Address Register (IDM_AR) and Indirect Mode Data
 * Register (IDM_DR), which are directly mapped to Memory-Mapped I/O space.
 * Mode Register (MR) is directly accessible.
 *
 * Only 0x04 bytes are required for memory space.
 */
#define W5100_IDM_AR
#define W5100_IDM_DR

static int w5100_read_indirect(struct net_device *ndev, u32 addr)
{}

static int w5100_write_indirect(struct net_device *ndev, u32 addr, u8 data)
{}

static int w5100_read16_indirect(struct net_device *ndev, u32 addr)
{}

static int w5100_write16_indirect(struct net_device *ndev, u32 addr, u16 data)
{}

static int w5100_readbulk_indirect(struct net_device *ndev, u32 addr, u8 *buf,
				   int len)
{}

static int w5100_writebulk_indirect(struct net_device *ndev, u32 addr,
				    const u8 *buf, int len)
{}

static int w5100_reset_indirect(struct net_device *ndev)
{}

static const struct w5100_ops w5100_mmio_indirect_ops =;

#if defined(CONFIG_WIZNET_BUS_DIRECT)

static int w5100_read(struct w5100_priv *priv, u32 addr)
{
	return w5100_read_direct(priv->ndev, addr);
}

static int w5100_write(struct w5100_priv *priv, u32 addr, u8 data)
{
	return w5100_write_direct(priv->ndev, addr, data);
}

static int w5100_read16(struct w5100_priv *priv, u32 addr)
{
	return w5100_read16_direct(priv->ndev, addr);
}

static int w5100_write16(struct w5100_priv *priv, u32 addr, u16 data)
{
	return w5100_write16_direct(priv->ndev, addr, data);
}

static int w5100_readbulk(struct w5100_priv *priv, u32 addr, u8 *buf, int len)
{
	return w5100_readbulk_direct(priv->ndev, addr, buf, len);
}

static int w5100_writebulk(struct w5100_priv *priv, u32 addr, const u8 *buf,
			   int len)
{
	return w5100_writebulk_direct(priv->ndev, addr, buf, len);
}

#elif defined(CONFIG_WIZNET_BUS_INDIRECT)

static int w5100_read(struct w5100_priv *priv, u32 addr)
{
	return w5100_read_indirect(priv->ndev, addr);
}

static int w5100_write(struct w5100_priv *priv, u32 addr, u8 data)
{
	return w5100_write_indirect(priv->ndev, addr, data);
}

static int w5100_read16(struct w5100_priv *priv, u32 addr)
{
	return w5100_read16_indirect(priv->ndev, addr);
}

static int w5100_write16(struct w5100_priv *priv, u32 addr, u16 data)
{
	return w5100_write16_indirect(priv->ndev, addr, data);
}

static int w5100_readbulk(struct w5100_priv *priv, u32 addr, u8 *buf, int len)
{
	return w5100_readbulk_indirect(priv->ndev, addr, buf, len);
}

static int w5100_writebulk(struct w5100_priv *priv, u32 addr, const u8 *buf,
			   int len)
{
	return w5100_writebulk_indirect(priv->ndev, addr, buf, len);
}

#else /* CONFIG_WIZNET_BUS_ANY */

static int w5100_read(struct w5100_priv *priv, u32 addr)
{}

static int w5100_write(struct w5100_priv *priv, u32 addr, u8 data)
{}

static int w5100_read16(struct w5100_priv *priv, u32 addr)
{}

static int w5100_write16(struct w5100_priv *priv, u32 addr, u16 data)
{}

static int w5100_readbulk(struct w5100_priv *priv, u32 addr, u8 *buf, int len)
{}

static int w5100_writebulk(struct w5100_priv *priv, u32 addr, const u8 *buf,
			   int len)
{}

#endif

static int w5100_readbuf(struct w5100_priv *priv, u16 offset, u8 *buf, int len)
{}

static int w5100_writebuf(struct w5100_priv *priv, u16 offset, const u8 *buf,
			  int len)
{}

static int w5100_reset(struct w5100_priv *priv)
{}

static int w5100_command(struct w5100_priv *priv, u16 cmd)
{}

static void w5100_write_macaddr(struct w5100_priv *priv)
{}

static void w5100_socket_intr_mask(struct w5100_priv *priv, u8 mask)
{}

static void w5100_enable_intr(struct w5100_priv *priv)
{}

static void w5100_disable_intr(struct w5100_priv *priv)
{}

static void w5100_memory_configure(struct w5100_priv *priv)
{}

static void w5200_memory_configure(struct w5100_priv *priv)
{}

static void w5500_memory_configure(struct w5100_priv *priv)
{}

static int w5100_hw_reset(struct w5100_priv *priv)
{}

static void w5100_hw_start(struct w5100_priv *priv)
{}

static void w5100_hw_close(struct w5100_priv *priv)
{}

/***********************************************************************
 *
 *   Device driver functions / callbacks
 *
 ***********************************************************************/

static void w5100_get_drvinfo(struct net_device *ndev,
			      struct ethtool_drvinfo *info)
{}

static u32 w5100_get_link(struct net_device *ndev)
{}

static u32 w5100_get_msglevel(struct net_device *ndev)
{}

static void w5100_set_msglevel(struct net_device *ndev, u32 value)
{}

static int w5100_get_regs_len(struct net_device *ndev)
{}

static void w5100_get_regs(struct net_device *ndev,
			   struct ethtool_regs *regs, void *buf)
{}

static void w5100_restart(struct net_device *ndev)
{}

static void w5100_restart_work(struct work_struct *work)
{}

static void w5100_tx_timeout(struct net_device *ndev, unsigned int txqueue)
{}

static void w5100_tx_skb(struct net_device *ndev, struct sk_buff *skb)
{}

static void w5100_tx_work(struct work_struct *work)
{}

static netdev_tx_t w5100_start_tx(struct sk_buff *skb, struct net_device *ndev)
{}

static struct sk_buff *w5100_rx_skb(struct net_device *ndev)
{}

static void w5100_rx_work(struct work_struct *work)
{}

static int w5100_napi_poll(struct napi_struct *napi, int budget)
{}

static irqreturn_t w5100_interrupt(int irq, void *ndev_instance)
{}

static irqreturn_t w5100_detect_link(int irq, void *ndev_instance)
{}

static void w5100_setrx_work(struct work_struct *work)
{}

static void w5100_set_rx_mode(struct net_device *ndev)
{}

static int w5100_set_macaddr(struct net_device *ndev, void *addr)
{}

static int w5100_open(struct net_device *ndev)
{}

static int w5100_stop(struct net_device *ndev)
{}

static const struct ethtool_ops w5100_ethtool_ops =;

static const struct net_device_ops w5100_netdev_ops =;

static int w5100_mmio_probe(struct platform_device *pdev)
{}

static void w5100_mmio_remove(struct platform_device *pdev)
{}

void *w5100_ops_priv(const struct net_device *ndev)
{}
EXPORT_SYMBOL_GPL();

int w5100_probe(struct device *dev, const struct w5100_ops *ops,
		int sizeof_ops_priv, const void *mac_addr, int irq,
		int link_gpio)
{}
EXPORT_SYMBOL_GPL();

void w5100_remove(struct device *dev)
{}
EXPORT_SYMBOL_GPL();

#ifdef CONFIG_PM_SLEEP
static int w5100_suspend(struct device *dev)
{}

static int w5100_resume(struct device *dev)
{}
#endif /* CONFIG_PM_SLEEP */

SIMPLE_DEV_PM_OPS(w5100_pm_ops, w5100_suspend, w5100_resume);
EXPORT_SYMBOL_GPL();

static struct platform_driver w5100_mmio_driver =;
module_platform_driver();