/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2004-2013 Synopsys, Inc. (www.synopsys.com) * * Registers and bits definitions of ARC EMAC */ #ifndef ARC_EMAC_H #define ARC_EMAC_H #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/netdevice.h> #include <linux/phy.h> #include <linux/clk.h> /* STATUS and ENABLE Register bit masks */ #define TXINT_MASK … #define RXINT_MASK … #define ERR_MASK … #define TXCH_MASK … #define MSER_MASK … #define RXCR_MASK … #define RXFR_MASK … #define RXFL_MASK … #define MDIO_MASK … #define TXPL_MASK … /* CONTROL Register bit masks */ #define EN_MASK … #define TXRN_MASK … #define RXRN_MASK … #define DSBC_MASK … #define ENFL_MASK … #define PROM_MASK … /* Buffer descriptor INFO bit masks */ #define OWN_MASK … #define FIRST_MASK … #define LAST_MASK … #define LEN_MASK … #define CRLS … #define DEFR … #define DROP … #define RTRY … #define LTCL … #define UFLO … #define FOR_EMAC … #define FOR_CPU … /* ARC EMAC register set combines entries for MAC and MDIO */ enum { … }; #define TX_TIMEOUT … #define ARC_EMAC_NAPI_WEIGHT … #define EMAC_BUFFER_SIZE … /** * struct arc_emac_bd - EMAC buffer descriptor (BD). * * @info: Contains status information on the buffer itself. * @data: 32-bit byte addressable pointer to the packet data. */ struct arc_emac_bd { … }; /* Number of Rx/Tx BD's */ #define RX_BD_NUM … #define TX_BD_NUM … #define RX_RING_SZ … #define TX_RING_SZ … /** * struct buffer_state - Stores Rx/Tx buffer state. * @sk_buff: Pointer to socket buffer. * @addr: Start address of DMA-mapped memory region. * @len: Length of DMA-mapped memory region. */ struct buffer_state { … }; struct arc_emac_mdio_bus_data { … }; /** * struct arc_emac_priv - Storage of EMAC's private information. * @dev: Pointer to the current device. * @phy_dev: Pointer to attached PHY device. * @bus: Pointer to the current MII bus. * @regs: Base address of EMAC memory-mapped control registers. * @napi: Structure for NAPI. * @rxbd: Pointer to Rx BD ring. * @txbd: Pointer to Tx BD ring. * @rxbd_dma: DMA handle for Rx BD ring. * @txbd_dma: DMA handle for Tx BD ring. * @rx_buff: Storage for Rx buffers states. * @tx_buff: Storage for Tx buffers states. * @txbd_curr: Index of Tx BD to use on the next "ndo_start_xmit". * @txbd_dirty: Index of Tx BD to free on the next Tx interrupt. * @last_rx_bd: Index of the last Rx BD we've got from EMAC. * @link: PHY's last seen link state. * @duplex: PHY's last set duplex mode. * @speed: PHY's last set speed. */ struct arc_emac_priv { … }; /** * arc_reg_set - Sets EMAC register with provided value. * @priv: Pointer to ARC EMAC private data structure. * @reg: Register offset from base address. * @value: Value to set in register. */ static inline void arc_reg_set(struct arc_emac_priv *priv, int reg, int value) { … } /** * arc_reg_get - Gets value of specified EMAC register. * @priv: Pointer to ARC EMAC private data structure. * @reg: Register offset from base address. * * returns: Value of requested register. */ static inline unsigned int arc_reg_get(struct arc_emac_priv *priv, int reg) { … } /** * arc_reg_or - Applies mask to specified EMAC register - ("reg" | "mask"). * @priv: Pointer to ARC EMAC private data structure. * @reg: Register offset from base address. * @mask: Mask to apply to specified register. * * This function reads initial register value, then applies provided mask * to it and then writes register back. */ static inline void arc_reg_or(struct arc_emac_priv *priv, int reg, int mask) { … } /** * arc_reg_clr - Applies mask to specified EMAC register - ("reg" & ~"mask"). * @priv: Pointer to ARC EMAC private data structure. * @reg: Register offset from base address. * @mask: Mask to apply to specified register. * * This function reads initial register value, then applies provided mask * to it and then writes register back. */ static inline void arc_reg_clr(struct arc_emac_priv *priv, int reg, int mask) { … } int arc_mdio_probe(struct arc_emac_priv *priv); int arc_mdio_remove(struct arc_emac_priv *priv); int arc_emac_probe(struct net_device *ndev, int interface); void arc_emac_remove(struct net_device *ndev); #endif /* ARC_EMAC_H */