linux/drivers/net/ethernet/davicom/dm9051.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2022 Davicom Semiconductor,Inc.
 * Davicom DM9051 SPI Fast Ethernet Linux driver
 */

#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/irq.h>
#include <linux/mii.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <linux/regmap.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/spi/spi.h>
#include <linux/types.h>

#include "dm9051.h"

#define DRVNAME_9051

/**
 * struct rx_ctl_mach - rx activities record
 * @status_err_counter: rx status error counter
 * @large_err_counter: rx get large packet length error counter
 * @rx_err_counter: receive packet error counter
 * @tx_err_counter: transmit packet error counter
 * @fifo_rst_counter: reset operation counter
 *
 * To keep track for the driver operation statistics
 */
struct rx_ctl_mach {};

/**
 * struct dm9051_rxctrl - dm9051 driver rx control
 * @hash_table: Multicast hash-table data
 * @rcr_all: KS_RXCR1 register setting
 *
 * The settings needs to control the receive filtering
 * such as the multicast hash-filter and the receive register settings
 */
struct dm9051_rxctrl {};

/**
 * struct dm9051_rxhdr - rx packet data header
 * @headbyte: lead byte equal to 0x01 notifies a valid packet
 * @status: status bits for the received packet
 * @rxlen: packet length
 *
 * The Rx packed, entered into the FIFO memory, start with these
 * four bytes which is the Rx header, followed by the ethernet
 * packet data and ends with an appended 4-byte CRC data.
 * Both Rx packet and CRC data are for check purpose and finally
 * are dropped by this driver
 */
struct dm9051_rxhdr {};

/**
 * struct board_info - maintain the saved data
 * @spidev: spi device structure
 * @ndev: net device structure
 * @mdiobus: mii bus structure
 * @phydev: phy device structure
 * @txq: tx queue structure
 * @regmap_dm: regmap for register read/write
 * @regmap_dmbulk: extra regmap for bulk read/write
 * @rxctrl_work: Work queue for updating RX mode and multicast lists
 * @tx_work: Work queue for tx packets
 * @pause: ethtool pause parameter structure
 * @spi_lockm: between threads lock structure
 * @reg_mutex: regmap access lock structure
 * @bc: rx control statistics structure
 * @rxhdr: rx header structure
 * @rctl: rx control setting structure
 * @msg_enable: message level value
 * @imr_all: to store operating imr value for register DM9051_IMR
 * @lcr_all: to store operating rcr value for register DM9051_LMCR
 *
 * The saved data variables, keep up to date for retrieval back to use
 */
struct board_info {};

static int dm9051_set_reg(struct board_info *db, unsigned int reg, unsigned int val)
{}

static int dm9051_update_bits(struct board_info *db, unsigned int reg, unsigned int mask,
			      unsigned int val)
{}

/* skb buffer exhausted, just discard the received data
 */
static int dm9051_dumpblk(struct board_info *db, u8 reg, size_t count)
{}

static int dm9051_set_regs(struct board_info *db, unsigned int reg, const void *val,
			   size_t val_count)
{}

static int dm9051_get_regs(struct board_info *db, unsigned int reg, void *val,
			   size_t val_count)
{}

static int dm9051_write_mem(struct board_info *db, unsigned int reg, const void *buff,
			    size_t len)
{}

static int dm9051_read_mem(struct board_info *db, unsigned int reg, void *buff,
			   size_t len)
{}

/* waiting tx-end rather than tx-req
 * got faster
 */
static int dm9051_nsr_poll(struct board_info *db)
{}

static int dm9051_epcr_poll(struct board_info *db)
{}

static int dm9051_irq_flag(struct board_info *db)
{}

static unsigned int dm9051_intcr_value(struct board_info *db)
{}

static int dm9051_set_fcr(struct board_info *db)
{}

static int dm9051_set_recv(struct board_info *db)
{}

static int dm9051_core_reset(struct board_info *db)
{}

static int dm9051_update_fcr(struct board_info *db)
{}

static int dm9051_disable_interrupt(struct board_info *db)
{}

static int dm9051_enable_interrupt(struct board_info *db)
{}

static int dm9051_stop_mrcmd(struct board_info *db)
{}

static int dm9051_clear_interrupt(struct board_info *db)
{}

static int dm9051_eeprom_read(struct board_info *db, int offset, u8 *to)
{}

static int dm9051_eeprom_write(struct board_info *db, int offset, u8 *data)
{}

static int dm9051_phyread(void *context, unsigned int reg, unsigned int *val)
{}

static int dm9051_phywrite(void *context, unsigned int reg, unsigned int val)
{}

static int dm9051_mdio_read(struct mii_bus *bus, int addr, int regnum)
{}

static int dm9051_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
{}

static void dm9051_reg_lock_mutex(void *dbcontext)
{}

static void dm9051_reg_unlock_mutex(void *dbcontext)
{}

static struct regmap_config regconfigdm =;

static struct regmap_config regconfigdmbulk =;

static int dm9051_map_init(struct spi_device *spi, struct board_info *db)
{}

static int dm9051_map_chipid(struct board_info *db)
{}

/* Read DM9051_PAR registers which is the mac address loaded from EEPROM while power-on
 */
static int dm9051_map_etherdev_par(struct net_device *ndev, struct board_info *db)
{}

/* ethtool-ops
 */
static void dm9051_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{}

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

static u32 dm9051_get_msglevel(struct net_device *ndev)
{}

static int dm9051_get_eeprom_len(struct net_device *dev)
{}

static int dm9051_get_eeprom(struct net_device *ndev,
			     struct ethtool_eeprom *ee, u8 *data)
{}

static int dm9051_set_eeprom(struct net_device *ndev,
			     struct ethtool_eeprom *ee, u8 *data)
{}

static void dm9051_get_pauseparam(struct net_device *ndev,
				  struct ethtool_pauseparam *pause)
{}

static int dm9051_set_pauseparam(struct net_device *ndev,
				 struct ethtool_pauseparam *pause)
{}

static const struct ethtool_ops dm9051_ethtool_ops =;

static int dm9051_all_start(struct board_info *db)
{}

static int dm9051_all_stop(struct board_info *db)
{}

/* fifo reset while rx error found
 */
static int dm9051_all_restart(struct board_info *db)
{}

/* read packets from the fifo memory
 * return value,
 *  > 0 - read packet number, caller can repeat the rx operation
 *    0 - no error, caller need stop further rx operation
 *  -EBUSY - read data error, caller escape from rx operation
 */
static int dm9051_loop_rx(struct board_info *db)
{}

/* transmit a packet,
 * return value,
 *   0 - succeed
 *  -ETIMEDOUT - timeout error
 */
static int dm9051_single_tx(struct board_info *db, u8 *buff, unsigned int len)
{}

static int dm9051_loop_tx(struct board_info *db)
{}

static irqreturn_t dm9051_rx_threaded_irq(int irq, void *pw)
{}

static void dm9051_tx_delay(struct work_struct *work)
{}

static void dm9051_rxctl_delay(struct work_struct *work)
{}

/* Open network device
 * Called when the network device is marked active, such as a user executing
 * 'ifconfig up' on the device
 */
static int dm9051_open(struct net_device *ndev)
{}

/* Close network device
 * Called to close down a network device which has been active. Cancel any
 * work, shutdown the RX and TX process and then place the chip into a low
 * power state while it is not being used
 */
static int dm9051_stop(struct net_device *ndev)
{}

/* event: play a schedule starter in condition
 */
static netdev_tx_t dm9051_start_xmit(struct sk_buff *skb, struct net_device *ndev)
{}

/* event: play with a schedule starter
 */
static void dm9051_set_rx_mode(struct net_device *ndev)
{}

/* event: write into the mac registers and eeprom directly
 */
static int dm9051_set_mac_address(struct net_device *ndev, void *p)
{}

static const struct net_device_ops dm9051_netdev_ops =;

static void dm9051_operation_clear(struct board_info *db)
{}

static int dm9051_mdio_register(struct board_info *db)
{}

static void dm9051_handle_link_change(struct net_device *ndev)
{}

/* phy connect as poll mode
 */
static int dm9051_phy_connect(struct board_info *db)
{}

static int dm9051_probe(struct spi_device *spi)
{}

static void dm9051_drv_remove(struct spi_device *spi)
{}

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

static const struct spi_device_id dm9051_id_table[] =;

static struct spi_driver dm9051_driver =;
module_spi_driver();

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