linux/drivers/net/ethernet/marvell/pxa168_eth.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * PXA168 ethernet driver.
 * Most of the code is derived from mv643xx ethernet driver.
 *
 * Copyright (C) 2010 Marvell International Ltd.
 *		Sachin Sanap <[email protected]>
 *		Zhangfei Gao <[email protected]>
 *		Philip Rakity <[email protected]>
 *		Mark Brown <[email protected]>
 */

#include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/in.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/ip.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/pxa168_eth.h>
#include <linux/tcp.h>
#include <linux/types.h>
#include <linux/udp.h>
#include <linux/workqueue.h>
#include <linux/pgtable.h>

#include <asm/cacheflush.h>

#define DRIVER_NAME
#define DRIVER_VERSION

/*
 * Registers
 */

#define PHY_ADDRESS
#define SMI
#define PORT_CONFIG
#define PORT_CONFIG_EXT
#define PORT_COMMAND
#define PORT_STATUS
#define HTPR
#define MAC_ADDR_LOW
#define MAC_ADDR_HIGH
#define SDMA_CONFIG
#define SDMA_CMD
#define INT_CAUSE
#define INT_W_CLEAR
#define INT_MASK
#define ETH_F_RX_DESC_0
#define ETH_C_RX_DESC_0
#define ETH_C_TX_DESC_1

/* smi register */
#define SMI_BUSY
#define SMI_R_VALID
#define SMI_OP_W
#define SMI_OP_R

#define PHY_WAIT_ITERATIONS

#define PXA168_ETH_PHY_ADDR_DEFAULT
/* RX & TX descriptor command */
#define BUF_OWNED_BY_DMA

/* RX descriptor status */
#define RX_EN_INT
#define RX_FIRST_DESC
#define RX_LAST_DESC
#define RX_ERROR

/* TX descriptor command */
#define TX_EN_INT
#define TX_GEN_CRC
#define TX_ZERO_PADDING
#define TX_FIRST_DESC
#define TX_LAST_DESC
#define TX_ERROR

/* SDMA_CMD */
#define SDMA_CMD_AT
#define SDMA_CMD_TXDL
#define SDMA_CMD_TXDH
#define SDMA_CMD_AR
#define SDMA_CMD_ERD

/* Bit definitions of the Port Config Reg */
#define PCR_DUPLEX_FULL
#define PCR_HS
#define PCR_EN
#define PCR_PM

/* Bit definitions of the Port Config Extend Reg */
#define PCXR_2BSM
#define PCXR_DSCP_EN
#define PCXR_RMII_EN
#define PCXR_AN_SPEED_DIS
#define PCXR_SPEED_100
#define PCXR_MFL_1518
#define PCXR_MFL_1536
#define PCXR_MFL_2048
#define PCXR_MFL_64K
#define PCXR_FLOWCTL_DIS
#define PCXR_FLP
#define PCXR_AN_FLOWCTL_DIS
#define PCXR_AN_DUPLEX_DIS
#define PCXR_PRIO_TX_OFF
#define PCXR_TX_HIGH_PRI

/* Bit definitions of the SDMA Config Reg */
#define SDCR_BSZ_OFF
#define SDCR_BSZ8
#define SDCR_BSZ4
#define SDCR_BSZ2
#define SDCR_BSZ1
#define SDCR_BLMR
#define SDCR_BLMT
#define SDCR_RIFB
#define SDCR_RC_OFF
#define SDCR_RC_MAX_RETRANS

/*
 * Bit definitions of the Interrupt Cause Reg
 * and Interrupt MASK Reg is the same
 */
#define ICR_RXBUF
#define ICR_TXBUF_H
#define ICR_TXBUF_L
#define ICR_TXEND_H
#define ICR_TXEND_L
#define ICR_RXERR
#define ICR_TXERR_H
#define ICR_TXERR_L
#define ICR_TX_UDR
#define ICR_MII_CH

#define ALL_INTS

#define ETH_HW_IP_ALIGN

#define NUM_RX_DESCS
#define NUM_TX_DESCS

#define HASH_ADD
#define HASH_DELETE
#define HASH_ADDR_TABLE_SIZE
#define HOP_NUMBER

/* Bit definitions for Port status */
#define PORT_SPEED_100
#define FULL_DUPLEX
#define FLOW_CONTROL_DISABLED
#define LINK_UP

/* Bit definitions for work to be done */
#define WORK_TX_DONE

/*
 * Misc definitions.
 */
#define SKB_DMA_REALIGN

struct rx_desc {};

struct tx_desc {};

struct pxa168_eth_private {};

struct addr_table_entry {};

/* Bit fields of a Hash Table Entry */
enum hash_table_entry {};

static int pxa168_init_hw(struct pxa168_eth_private *pep);
static int pxa168_init_phy(struct net_device *dev);
static void eth_port_reset(struct net_device *dev);
static void eth_port_start(struct net_device *dev);
static int pxa168_eth_open(struct net_device *dev);
static int pxa168_eth_stop(struct net_device *dev);

static inline u32 rdl(struct pxa168_eth_private *pep, int offset)
{}

static inline void wrl(struct pxa168_eth_private *pep, int offset, u32 data)
{}

static void abort_dma(struct pxa168_eth_private *pep)
{}

static void rxq_refill(struct net_device *dev)
{}

static inline void rxq_refill_timer_wrapper(struct timer_list *t)
{}

static inline u8 flip_8_bits(u8 x)
{}

static void nibble_swap_every_byte(unsigned char *mac_addr)
{}

static void inverse_every_nibble(unsigned char *mac_addr)
{}

/*
 * ----------------------------------------------------------------------------
 * This function will calculate the hash function of the address.
 * Inputs
 * mac_addr_orig    - MAC address.
 * Outputs
 * return the calculated entry.
 */
static u32 hash_function(const unsigned char *mac_addr_orig)
{}

/*
 * ----------------------------------------------------------------------------
 * This function will add/del an entry to the address table.
 * Inputs
 * pep - ETHERNET .
 * mac_addr - MAC address.
 * skip - if 1, skip this address.Used in case of deleting an entry which is a
 *	  part of chain in the hash table.We can't just delete the entry since
 *	  that will break the chain.We need to defragment the tables time to
 *	  time.
 * rd   - 0 Discard packet upon match.
 *	- 1 Receive packet upon match.
 * Outputs
 * address table entry is added/deleted.
 * 0 if success.
 * -ENOSPC if table full
 */
static int add_del_hash_entry(struct pxa168_eth_private *pep,
			      const unsigned char *mac_addr,
			      u32 rd, u32 skip, int del)
{}

/*
 * ----------------------------------------------------------------------------
 *  Create an addressTable entry from MAC address info
 *  found in the specifed net_device struct
 *
 *  Input : pointer to ethernet interface network device structure
 *  Output : N/A
 */
static void update_hash_table_mac_address(struct pxa168_eth_private *pep,
					  unsigned char *oaddr,
					  const unsigned char *addr)
{}

static int init_hash_table(struct pxa168_eth_private *pep)
{}

static void pxa168_eth_set_rx_mode(struct net_device *dev)
{}

static void pxa168_eth_get_mac_address(struct net_device *dev,
				       unsigned char *addr)
{}

static int pxa168_eth_set_mac_address(struct net_device *dev, void *addr)
{}

static void eth_port_start(struct net_device *dev)
{}

static void eth_port_reset(struct net_device *dev)
{}

/*
 * txq_reclaim - Free the tx desc data for completed descriptors
 * If force is non-zero, frees uncompleted descriptors as well
 */
static int txq_reclaim(struct net_device *dev, int force)
{}

static void pxa168_eth_tx_timeout(struct net_device *dev, unsigned int txqueue)
{}

static void pxa168_eth_tx_timeout_task(struct work_struct *work)
{}

static int rxq_process(struct net_device *dev, int budget)
{}

static int pxa168_eth_collect_events(struct pxa168_eth_private *pep,
				     struct net_device *dev)
{}

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

static void pxa168_eth_recalc_skb_size(struct pxa168_eth_private *pep)
{}

static int set_port_config_ext(struct pxa168_eth_private *pep)
{}

static void pxa168_eth_adjust_link(struct net_device *dev)
{}

static int pxa168_init_phy(struct net_device *dev)
{}

static int pxa168_init_hw(struct pxa168_eth_private *pep)
{}

static int rxq_init(struct net_device *dev)
{}

static void rxq_deinit(struct net_device *dev)
{}

static int txq_init(struct net_device *dev)
{}

static void txq_deinit(struct net_device *dev)
{}

static int pxa168_eth_open(struct net_device *dev)
{}

static int pxa168_eth_stop(struct net_device *dev)
{}

static int pxa168_eth_change_mtu(struct net_device *dev, int mtu)
{}

static int eth_alloc_tx_desc_index(struct pxa168_eth_private *pep)
{}

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

static netdev_tx_t
pxa168_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
{}

static int smi_wait_ready(struct pxa168_eth_private *pep)
{}

static int pxa168_smi_read(struct mii_bus *bus, int phy_addr, int regnum)
{}

static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum,
			    u16 value)
{}

#ifdef CONFIG_NET_POLL_CONTROLLER
static void pxa168_eth_netpoll(struct net_device *dev)
{}
#endif

static void pxa168_get_drvinfo(struct net_device *dev,
			       struct ethtool_drvinfo *info)
{}

static const struct ethtool_ops pxa168_ethtool_ops =;

static const struct net_device_ops pxa168_eth_netdev_ops =;

static int pxa168_eth_probe(struct platform_device *pdev)
{}

static void pxa168_eth_remove(struct platform_device *pdev)
{}

static void pxa168_eth_shutdown(struct platform_device *pdev)
{}

#ifdef CONFIG_PM
static int pxa168_eth_resume(struct platform_device *pdev)
{}

static int pxa168_eth_suspend(struct platform_device *pdev, pm_message_t state)
{}

#else
#define pxa168_eth_resume
#define pxa168_eth_suspend
#endif

static const struct of_device_id pxa168_eth_of_match[] =;
MODULE_DEVICE_TABLE(of, pxa168_eth_of_match);

static struct platform_driver pxa168_eth_driver =;

module_platform_driver();

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