18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Definitions for Xilinx Axi Ethernet device driver.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2009 Secret Lab Technologies, Ltd.
68c2ecf20Sopenharmony_ci * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef XILINX_AXIENET_H
108c2ecf20Sopenharmony_ci#define XILINX_AXIENET_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
138c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
148c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
158c2ecf20Sopenharmony_ci#include <linux/if_vlan.h>
168c2ecf20Sopenharmony_ci#include <linux/phylink.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* Packet size info */
198c2ecf20Sopenharmony_ci#define XAE_HDR_SIZE			14 /* Size of Ethernet header */
208c2ecf20Sopenharmony_ci#define XAE_TRL_SIZE			 4 /* Size of Ethernet trailer (FCS) */
218c2ecf20Sopenharmony_ci#define XAE_MTU			      1500 /* Max MTU of an Ethernet frame */
228c2ecf20Sopenharmony_ci#define XAE_JUMBO_MTU		      9000 /* Max MTU of a jumbo Eth. frame */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define XAE_MAX_FRAME_SIZE	 (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
258c2ecf20Sopenharmony_ci#define XAE_MAX_VLAN_FRAME_SIZE  (XAE_MTU + VLAN_ETH_HLEN + XAE_TRL_SIZE)
268c2ecf20Sopenharmony_ci#define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Configuration options */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/* Accept all incoming packets. Default: disabled (cleared) */
318c2ecf20Sopenharmony_ci#define XAE_OPTION_PROMISC			(1 << 0)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* Jumbo frame support for Tx & Rx. Default: disabled (cleared) */
348c2ecf20Sopenharmony_ci#define XAE_OPTION_JUMBO			(1 << 1)
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* VLAN Rx & Tx frame support. Default: disabled (cleared) */
378c2ecf20Sopenharmony_ci#define XAE_OPTION_VLAN				(1 << 2)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* Enable recognition of flow control frames on Rx. Default: enabled (set) */
408c2ecf20Sopenharmony_ci#define XAE_OPTION_FLOW_CONTROL			(1 << 4)
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not
438c2ecf20Sopenharmony_ci * stripped. Default: disabled (set)
448c2ecf20Sopenharmony_ci */
458c2ecf20Sopenharmony_ci#define XAE_OPTION_FCS_STRIP			(1 << 5)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci/* Generate FCS field and add PAD automatically for outgoing frames.
488c2ecf20Sopenharmony_ci * Default: enabled (set)
498c2ecf20Sopenharmony_ci */
508c2ecf20Sopenharmony_ci#define XAE_OPTION_FCS_INSERT			(1 << 6)
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* Enable Length/Type error checking for incoming frames. When this option is
538c2ecf20Sopenharmony_ci * set, the MAC will filter frames that have a mismatched type/length field
548c2ecf20Sopenharmony_ci * and if XAE_OPTION_REPORT_RXERR is set, the user is notified when these
558c2ecf20Sopenharmony_ci * types of frames are encountered. When this option is cleared, the MAC will
568c2ecf20Sopenharmony_ci * allow these types of frames to be received. Default: enabled (set)
578c2ecf20Sopenharmony_ci */
588c2ecf20Sopenharmony_ci#define XAE_OPTION_LENTYPE_ERR			(1 << 7)
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* Enable the transmitter. Default: enabled (set) */
618c2ecf20Sopenharmony_ci#define XAE_OPTION_TXEN				(1 << 11)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/*  Enable the receiver. Default: enabled (set) */
648c2ecf20Sopenharmony_ci#define XAE_OPTION_RXEN				(1 << 12)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/*  Default options set when device is initialized or reset */
678c2ecf20Sopenharmony_ci#define XAE_OPTION_DEFAULTS				   \
688c2ecf20Sopenharmony_ci				(XAE_OPTION_TXEN |	   \
698c2ecf20Sopenharmony_ci				 XAE_OPTION_FLOW_CONTROL | \
708c2ecf20Sopenharmony_ci				 XAE_OPTION_RXEN)
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Axi DMA Register definitions */
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define XAXIDMA_TX_CR_OFFSET	0x00000000 /* Channel control */
758c2ecf20Sopenharmony_ci#define XAXIDMA_TX_SR_OFFSET	0x00000004 /* Status */
768c2ecf20Sopenharmony_ci#define XAXIDMA_TX_CDESC_OFFSET	0x00000008 /* Current descriptor pointer */
778c2ecf20Sopenharmony_ci#define XAXIDMA_TX_TDESC_OFFSET	0x00000010 /* Tail descriptor pointer */
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define XAXIDMA_RX_CR_OFFSET	0x00000030 /* Channel control */
808c2ecf20Sopenharmony_ci#define XAXIDMA_RX_SR_OFFSET	0x00000034 /* Status */
818c2ecf20Sopenharmony_ci#define XAXIDMA_RX_CDESC_OFFSET	0x00000038 /* Current descriptor pointer */
828c2ecf20Sopenharmony_ci#define XAXIDMA_RX_TDESC_OFFSET	0x00000040 /* Tail descriptor pointer */
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define XAXIDMA_CR_RUNSTOP_MASK	0x00000001 /* Start/stop DMA channel */
858c2ecf20Sopenharmony_ci#define XAXIDMA_CR_RESET_MASK	0x00000004 /* Reset DMA engine */
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define XAXIDMA_SR_HALT_MASK	0x00000001 /* Indicates DMA channel halted */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define XAXIDMA_BD_NDESC_OFFSET		0x00 /* Next descriptor pointer */
908c2ecf20Sopenharmony_ci#define XAXIDMA_BD_BUFA_OFFSET		0x08 /* Buffer address */
918c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_LEN_OFFSET	0x18 /* Control/buffer length */
928c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_OFFSET		0x1C /* Status */
938c2ecf20Sopenharmony_ci#define XAXIDMA_BD_USR0_OFFSET		0x20 /* User IP specific word0 */
948c2ecf20Sopenharmony_ci#define XAXIDMA_BD_USR1_OFFSET		0x24 /* User IP specific word1 */
958c2ecf20Sopenharmony_ci#define XAXIDMA_BD_USR2_OFFSET		0x28 /* User IP specific word2 */
968c2ecf20Sopenharmony_ci#define XAXIDMA_BD_USR3_OFFSET		0x2C /* User IP specific word3 */
978c2ecf20Sopenharmony_ci#define XAXIDMA_BD_USR4_OFFSET		0x30 /* User IP specific word4 */
988c2ecf20Sopenharmony_ci#define XAXIDMA_BD_ID_OFFSET		0x34 /* Sw ID */
998c2ecf20Sopenharmony_ci#define XAXIDMA_BD_HAS_STSCNTRL_OFFSET	0x38 /* Whether has stscntrl strm */
1008c2ecf20Sopenharmony_ci#define XAXIDMA_BD_HAS_DRE_OFFSET	0x3C /* Whether has DRE */
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define XAXIDMA_BD_HAS_DRE_SHIFT	8 /* Whether has DRE shift */
1038c2ecf20Sopenharmony_ci#define XAXIDMA_BD_HAS_DRE_MASK		0xF00 /* Whether has DRE mask */
1048c2ecf20Sopenharmony_ci#define XAXIDMA_BD_WORDLEN_MASK		0xFF /* Whether has DRE mask */
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_LENGTH_MASK	0x007FFFFF /* Requested len */
1078c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_TXSOF_MASK	0x08000000 /* First tx packet */
1088c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_TXEOF_MASK	0x04000000 /* Last tx packet */
1098c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_ALL_MASK	0x0C000000 /* All control bits */
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define XAXIDMA_DELAY_MASK		0xFF000000 /* Delay timeout counter */
1128c2ecf20Sopenharmony_ci#define XAXIDMA_COALESCE_MASK		0x00FF0000 /* Coalesce counter */
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define XAXIDMA_DELAY_SHIFT		24
1158c2ecf20Sopenharmony_ci#define XAXIDMA_COALESCE_SHIFT		16
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define XAXIDMA_IRQ_IOC_MASK		0x00001000 /* Completion intr */
1188c2ecf20Sopenharmony_ci#define XAXIDMA_IRQ_DELAY_MASK		0x00002000 /* Delay interrupt */
1198c2ecf20Sopenharmony_ci#define XAXIDMA_IRQ_ERROR_MASK		0x00004000 /* Error interrupt */
1208c2ecf20Sopenharmony_ci#define XAXIDMA_IRQ_ALL_MASK		0x00007000 /* All interrupts */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci/* Default TX/RX Threshold and waitbound values for SGDMA mode */
1238c2ecf20Sopenharmony_ci#define XAXIDMA_DFT_TX_THRESHOLD	24
1248c2ecf20Sopenharmony_ci#define XAXIDMA_DFT_TX_WAITBOUND	254
1258c2ecf20Sopenharmony_ci#define XAXIDMA_DFT_RX_THRESHOLD	24
1268c2ecf20Sopenharmony_ci#define XAXIDMA_DFT_RX_WAITBOUND	254
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_TXSOF_MASK	0x08000000 /* First tx packet */
1298c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_TXEOF_MASK	0x04000000 /* Last tx packet */
1308c2ecf20Sopenharmony_ci#define XAXIDMA_BD_CTRL_ALL_MASK	0x0C000000 /* All control bits */
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_ACTUAL_LEN_MASK	0x007FFFFF /* Actual len */
1338c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_COMPLETE_MASK	0x80000000 /* Completed */
1348c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_DEC_ERR_MASK	0x40000000 /* Decode error */
1358c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_SLV_ERR_MASK	0x20000000 /* Slave error */
1368c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_INT_ERR_MASK	0x10000000 /* Internal err */
1378c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_ALL_ERR_MASK	0x70000000 /* All errors */
1388c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_RXSOF_MASK	0x08000000 /* First rx pkt */
1398c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_RXEOF_MASK	0x04000000 /* Last rx pkt */
1408c2ecf20Sopenharmony_ci#define XAXIDMA_BD_STS_ALL_MASK		0xFC000000 /* All status bits */
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#define XAXIDMA_BD_MINIMUM_ALIGNMENT	0x40
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* Axi Ethernet registers definition */
1458c2ecf20Sopenharmony_ci#define XAE_RAF_OFFSET		0x00000000 /* Reset and Address filter */
1468c2ecf20Sopenharmony_ci#define XAE_TPF_OFFSET		0x00000004 /* Tx Pause Frame */
1478c2ecf20Sopenharmony_ci#define XAE_IFGP_OFFSET		0x00000008 /* Tx Inter-frame gap adjustment*/
1488c2ecf20Sopenharmony_ci#define XAE_IS_OFFSET		0x0000000C /* Interrupt status */
1498c2ecf20Sopenharmony_ci#define XAE_IP_OFFSET		0x00000010 /* Interrupt pending */
1508c2ecf20Sopenharmony_ci#define XAE_IE_OFFSET		0x00000014 /* Interrupt enable */
1518c2ecf20Sopenharmony_ci#define XAE_TTAG_OFFSET		0x00000018 /* Tx VLAN TAG */
1528c2ecf20Sopenharmony_ci#define XAE_RTAG_OFFSET		0x0000001C /* Rx VLAN TAG */
1538c2ecf20Sopenharmony_ci#define XAE_UAWL_OFFSET		0x00000020 /* Unicast address word lower */
1548c2ecf20Sopenharmony_ci#define XAE_UAWU_OFFSET		0x00000024 /* Unicast address word upper */
1558c2ecf20Sopenharmony_ci#define XAE_TPID0_OFFSET	0x00000028 /* VLAN TPID0 register */
1568c2ecf20Sopenharmony_ci#define XAE_TPID1_OFFSET	0x0000002C /* VLAN TPID1 register */
1578c2ecf20Sopenharmony_ci#define XAE_PPST_OFFSET		0x00000030 /* PCS PMA Soft Temac Status Reg */
1588c2ecf20Sopenharmony_ci#define XAE_RCW0_OFFSET		0x00000400 /* Rx Configuration Word 0 */
1598c2ecf20Sopenharmony_ci#define XAE_RCW1_OFFSET		0x00000404 /* Rx Configuration Word 1 */
1608c2ecf20Sopenharmony_ci#define XAE_TC_OFFSET		0x00000408 /* Tx Configuration */
1618c2ecf20Sopenharmony_ci#define XAE_FCC_OFFSET		0x0000040C /* Flow Control Configuration */
1628c2ecf20Sopenharmony_ci#define XAE_EMMC_OFFSET		0x00000410 /* EMAC mode configuration */
1638c2ecf20Sopenharmony_ci#define XAE_PHYC_OFFSET		0x00000414 /* RGMII/SGMII configuration */
1648c2ecf20Sopenharmony_ci#define XAE_ID_OFFSET		0x000004F8 /* Identification register */
1658c2ecf20Sopenharmony_ci#define XAE_MDIO_MC_OFFSET	0x00000500 /* MII Management Config */
1668c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_OFFSET	0x00000504 /* MII Management Control */
1678c2ecf20Sopenharmony_ci#define XAE_MDIO_MWD_OFFSET	0x00000508 /* MII Management Write Data */
1688c2ecf20Sopenharmony_ci#define XAE_MDIO_MRD_OFFSET	0x0000050C /* MII Management Read Data */
1698c2ecf20Sopenharmony_ci#define XAE_UAW0_OFFSET		0x00000700 /* Unicast address word 0 */
1708c2ecf20Sopenharmony_ci#define XAE_UAW1_OFFSET		0x00000704 /* Unicast address word 1 */
1718c2ecf20Sopenharmony_ci#define XAE_FMI_OFFSET		0x00000708 /* Filter Mask Index */
1728c2ecf20Sopenharmony_ci#define XAE_AF0_OFFSET		0x00000710 /* Address Filter 0 */
1738c2ecf20Sopenharmony_ci#define XAE_AF1_OFFSET		0x00000714 /* Address Filter 1 */
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci#define XAE_TX_VLAN_DATA_OFFSET 0x00004000 /* TX VLAN data table address */
1768c2ecf20Sopenharmony_ci#define XAE_RX_VLAN_DATA_OFFSET 0x00008000 /* RX VLAN data table address */
1778c2ecf20Sopenharmony_ci#define XAE_MCAST_TABLE_OFFSET	0x00020000 /* Multicast table address */
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* Bit Masks for Axi Ethernet RAF register */
1808c2ecf20Sopenharmony_ci/* Reject receive multicast destination address */
1818c2ecf20Sopenharmony_ci#define XAE_RAF_MCSTREJ_MASK		0x00000002
1828c2ecf20Sopenharmony_ci/* Reject receive broadcast destination address */
1838c2ecf20Sopenharmony_ci#define XAE_RAF_BCSTREJ_MASK		0x00000004
1848c2ecf20Sopenharmony_ci#define XAE_RAF_TXVTAGMODE_MASK		0x00000018 /* Tx VLAN TAG mode */
1858c2ecf20Sopenharmony_ci#define XAE_RAF_RXVTAGMODE_MASK		0x00000060 /* Rx VLAN TAG mode */
1868c2ecf20Sopenharmony_ci#define XAE_RAF_TXVSTRPMODE_MASK	0x00000180 /* Tx VLAN STRIP mode */
1878c2ecf20Sopenharmony_ci#define XAE_RAF_RXVSTRPMODE_MASK	0x00000600 /* Rx VLAN STRIP mode */
1888c2ecf20Sopenharmony_ci#define XAE_RAF_NEWFNCENBL_MASK		0x00000800 /* New function mode */
1898c2ecf20Sopenharmony_ci/* Extended Multicast Filtering mode */
1908c2ecf20Sopenharmony_ci#define XAE_RAF_EMULTIFLTRENBL_MASK	0x00001000
1918c2ecf20Sopenharmony_ci#define XAE_RAF_STATSRST_MASK		0x00002000 /* Stats. Counter Reset */
1928c2ecf20Sopenharmony_ci#define XAE_RAF_RXBADFRMEN_MASK		0x00004000 /* Recv Bad Frame Enable */
1938c2ecf20Sopenharmony_ci#define XAE_RAF_TXVTAGMODE_SHIFT	3 /* Tx Tag mode shift bits */
1948c2ecf20Sopenharmony_ci#define XAE_RAF_RXVTAGMODE_SHIFT	5 /* Rx Tag mode shift bits */
1958c2ecf20Sopenharmony_ci#define XAE_RAF_TXVSTRPMODE_SHIFT	7 /* Tx strip mode shift bits*/
1968c2ecf20Sopenharmony_ci#define XAE_RAF_RXVSTRPMODE_SHIFT	9 /* Rx Strip mode shift bits*/
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/* Bit Masks for Axi Ethernet TPF and IFGP registers */
1998c2ecf20Sopenharmony_ci#define XAE_TPF_TPFV_MASK		0x0000FFFF /* Tx pause frame value */
2008c2ecf20Sopenharmony_ci/* Transmit inter-frame gap adjustment value */
2018c2ecf20Sopenharmony_ci#define XAE_IFGP0_IFGP_MASK		0x0000007F
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/* Bit Masks for Axi Ethernet IS, IE and IP registers, Same masks apply
2048c2ecf20Sopenharmony_ci * for all 3 registers.
2058c2ecf20Sopenharmony_ci */
2068c2ecf20Sopenharmony_ci/* Hard register access complete */
2078c2ecf20Sopenharmony_ci#define XAE_INT_HARDACSCMPLT_MASK	0x00000001
2088c2ecf20Sopenharmony_ci/* Auto negotiation complete */
2098c2ecf20Sopenharmony_ci#define XAE_INT_AUTONEG_MASK		0x00000002
2108c2ecf20Sopenharmony_ci#define XAE_INT_RXCMPIT_MASK		0x00000004 /* Rx complete */
2118c2ecf20Sopenharmony_ci#define XAE_INT_RXRJECT_MASK		0x00000008 /* Rx frame rejected */
2128c2ecf20Sopenharmony_ci#define XAE_INT_RXFIFOOVR_MASK		0x00000010 /* Rx fifo overrun */
2138c2ecf20Sopenharmony_ci#define XAE_INT_TXCMPIT_MASK		0x00000020 /* Tx complete */
2148c2ecf20Sopenharmony_ci#define XAE_INT_RXDCMLOCK_MASK		0x00000040 /* Rx Dcm Lock */
2158c2ecf20Sopenharmony_ci#define XAE_INT_MGTRDY_MASK		0x00000080 /* MGT clock Lock */
2168c2ecf20Sopenharmony_ci#define XAE_INT_PHYRSTCMPLT_MASK	0x00000100 /* Phy Reset complete */
2178c2ecf20Sopenharmony_ci#define XAE_INT_ALL_MASK		0x0000003F /* All the ints */
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci/* INT bits that indicate receive errors */
2208c2ecf20Sopenharmony_ci#define XAE_INT_RECV_ERROR_MASK				\
2218c2ecf20Sopenharmony_ci	(XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK)
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet VLAN TPID Word 0 register */
2248c2ecf20Sopenharmony_ci#define XAE_TPID_0_MASK		0x0000FFFF /* TPID 0 */
2258c2ecf20Sopenharmony_ci#define XAE_TPID_1_MASK		0xFFFF0000 /* TPID 1 */
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet VLAN TPID Word 1 register */
2288c2ecf20Sopenharmony_ci#define XAE_TPID_2_MASK		0x0000FFFF /* TPID 0 */
2298c2ecf20Sopenharmony_ci#define XAE_TPID_3_MASK		0xFFFF0000 /* TPID 1 */
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet RCW1 register */
2328c2ecf20Sopenharmony_ci#define XAE_RCW1_RST_MASK	0x80000000 /* Reset */
2338c2ecf20Sopenharmony_ci#define XAE_RCW1_JUM_MASK	0x40000000 /* Jumbo frame enable */
2348c2ecf20Sopenharmony_ci/* In-Band FCS enable (FCS not stripped) */
2358c2ecf20Sopenharmony_ci#define XAE_RCW1_FCS_MASK	0x20000000
2368c2ecf20Sopenharmony_ci#define XAE_RCW1_RX_MASK	0x10000000 /* Receiver enable */
2378c2ecf20Sopenharmony_ci#define XAE_RCW1_VLAN_MASK	0x08000000 /* VLAN frame enable */
2388c2ecf20Sopenharmony_ci/* Length/type field valid check disable */
2398c2ecf20Sopenharmony_ci#define XAE_RCW1_LT_DIS_MASK	0x02000000
2408c2ecf20Sopenharmony_ci/* Control frame Length check disable */
2418c2ecf20Sopenharmony_ci#define XAE_RCW1_CL_DIS_MASK	0x01000000
2428c2ecf20Sopenharmony_ci/* Pause frame source address bits [47:32]. Bits [31:0] are
2438c2ecf20Sopenharmony_ci * stored in register RCW0
2448c2ecf20Sopenharmony_ci */
2458c2ecf20Sopenharmony_ci#define XAE_RCW1_PAUSEADDR_MASK 0x0000FFFF
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet TC register */
2488c2ecf20Sopenharmony_ci#define XAE_TC_RST_MASK		0x80000000 /* Reset */
2498c2ecf20Sopenharmony_ci#define XAE_TC_JUM_MASK		0x40000000 /* Jumbo frame enable */
2508c2ecf20Sopenharmony_ci/* In-Band FCS enable (FCS not generated) */
2518c2ecf20Sopenharmony_ci#define XAE_TC_FCS_MASK		0x20000000
2528c2ecf20Sopenharmony_ci#define XAE_TC_TX_MASK		0x10000000 /* Transmitter enable */
2538c2ecf20Sopenharmony_ci#define XAE_TC_VLAN_MASK	0x08000000 /* VLAN frame enable */
2548c2ecf20Sopenharmony_ci/* Inter-frame gap adjustment enable */
2558c2ecf20Sopenharmony_ci#define XAE_TC_IFG_MASK		0x02000000
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet FCC register */
2588c2ecf20Sopenharmony_ci#define XAE_FCC_FCRX_MASK	0x20000000 /* Rx flow control enable */
2598c2ecf20Sopenharmony_ci#define XAE_FCC_FCTX_MASK	0x40000000 /* Tx flow control enable */
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet EMMC register */
2628c2ecf20Sopenharmony_ci#define XAE_EMMC_LINKSPEED_MASK	0xC0000000 /* Link speed */
2638c2ecf20Sopenharmony_ci#define XAE_EMMC_RGMII_MASK	0x20000000 /* RGMII mode enable */
2648c2ecf20Sopenharmony_ci#define XAE_EMMC_SGMII_MASK	0x10000000 /* SGMII mode enable */
2658c2ecf20Sopenharmony_ci#define XAE_EMMC_GPCS_MASK	0x08000000 /* 1000BaseX mode enable */
2668c2ecf20Sopenharmony_ci#define XAE_EMMC_HOST_MASK	0x04000000 /* Host interface enable */
2678c2ecf20Sopenharmony_ci#define XAE_EMMC_TX16BIT	0x02000000 /* 16 bit Tx client enable */
2688c2ecf20Sopenharmony_ci#define XAE_EMMC_RX16BIT	0x01000000 /* 16 bit Rx client enable */
2698c2ecf20Sopenharmony_ci#define XAE_EMMC_LINKSPD_10	0x00000000 /* Link Speed mask for 10 Mbit */
2708c2ecf20Sopenharmony_ci#define XAE_EMMC_LINKSPD_100	0x40000000 /* Link Speed mask for 100 Mbit */
2718c2ecf20Sopenharmony_ci#define XAE_EMMC_LINKSPD_1000	0x80000000 /* Link Speed mask for 1000 Mbit */
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet PHYC register */
2748c2ecf20Sopenharmony_ci#define XAE_PHYC_SGMIILINKSPEED_MASK	0xC0000000 /* SGMII link speed mask*/
2758c2ecf20Sopenharmony_ci#define XAE_PHYC_RGMIILINKSPEED_MASK	0x0000000C /* RGMII link speed */
2768c2ecf20Sopenharmony_ci#define XAE_PHYC_RGMIIHD_MASK		0x00000002 /* RGMII Half-duplex */
2778c2ecf20Sopenharmony_ci#define XAE_PHYC_RGMIILINK_MASK		0x00000001 /* RGMII link status */
2788c2ecf20Sopenharmony_ci#define XAE_PHYC_RGLINKSPD_10		0x00000000 /* RGMII link 10 Mbit */
2798c2ecf20Sopenharmony_ci#define XAE_PHYC_RGLINKSPD_100		0x00000004 /* RGMII link 100 Mbit */
2808c2ecf20Sopenharmony_ci#define XAE_PHYC_RGLINKSPD_1000		0x00000008 /* RGMII link 1000 Mbit */
2818c2ecf20Sopenharmony_ci#define XAE_PHYC_SGLINKSPD_10		0x00000000 /* SGMII link 10 Mbit */
2828c2ecf20Sopenharmony_ci#define XAE_PHYC_SGLINKSPD_100		0x40000000 /* SGMII link 100 Mbit */
2838c2ecf20Sopenharmony_ci#define XAE_PHYC_SGLINKSPD_1000		0x80000000 /* SGMII link 1000 Mbit */
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet MDIO interface MC register */
2868c2ecf20Sopenharmony_ci#define XAE_MDIO_MC_MDIOEN_MASK		0x00000040 /* MII management enable */
2878c2ecf20Sopenharmony_ci#define XAE_MDIO_MC_CLOCK_DIVIDE_MAX	0x3F	   /* Maximum MDIO divisor */
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet MDIO interface MCR register */
2908c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_PHYAD_MASK		0x1F000000 /* Phy Address Mask */
2918c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_PHYAD_SHIFT	24	   /* Phy Address Shift */
2928c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_REGAD_MASK		0x001F0000 /* Reg Address Mask */
2938c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_REGAD_SHIFT	16	   /* Reg Address Shift */
2948c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_OP_MASK		0x0000C000 /* Operation Code Mask */
2958c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_OP_SHIFT		13	   /* Operation Code Shift */
2968c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_OP_READ_MASK	0x00008000 /* Op Code Read Mask */
2978c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_OP_WRITE_MASK	0x00004000 /* Op Code Write Mask */
2988c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_INITIATE_MASK	0x00000800 /* Ready Mask */
2998c2ecf20Sopenharmony_ci#define XAE_MDIO_MCR_READY_MASK		0x00000080 /* Ready Mask */
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet MDIO interface MIS, MIP, MIE, MIC registers */
3028c2ecf20Sopenharmony_ci#define XAE_MDIO_INT_MIIM_RDY_MASK	0x00000001 /* MIIM Interrupt */
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet UAW1 register */
3058c2ecf20Sopenharmony_ci/* Station address bits [47:32]; Station address
3068c2ecf20Sopenharmony_ci * bits [31:0] are stored in register UAW0
3078c2ecf20Sopenharmony_ci */
3088c2ecf20Sopenharmony_ci#define XAE_UAW1_UNICASTADDR_MASK	0x0000FFFF
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci/* Bit masks for Axi Ethernet FMI register */
3118c2ecf20Sopenharmony_ci#define XAE_FMI_PM_MASK			0x80000000 /* Promis. mode enable */
3128c2ecf20Sopenharmony_ci#define XAE_FMI_IND_MASK		0x00000003 /* Index Mask */
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci#define XAE_MDIO_DIV_DFT		29 /* Default MDIO clock divisor */
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci/* Defines for different options for C_PHY_TYPE parameter in Axi Ethernet IP */
3178c2ecf20Sopenharmony_ci#define XAE_PHY_TYPE_MII		0
3188c2ecf20Sopenharmony_ci#define XAE_PHY_TYPE_GMII		1
3198c2ecf20Sopenharmony_ci#define XAE_PHY_TYPE_RGMII_1_3		2
3208c2ecf20Sopenharmony_ci#define XAE_PHY_TYPE_RGMII_2_0		3
3218c2ecf20Sopenharmony_ci#define XAE_PHY_TYPE_SGMII		4
3228c2ecf20Sopenharmony_ci#define XAE_PHY_TYPE_1000BASE_X		5
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci /* Total number of entries in the hardware multicast table. */
3258c2ecf20Sopenharmony_ci#define XAE_MULTICAST_CAM_TABLE_NUM	4
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci/* Axi Ethernet Synthesis features */
3288c2ecf20Sopenharmony_ci#define XAE_FEATURE_PARTIAL_RX_CSUM	(1 << 0)
3298c2ecf20Sopenharmony_ci#define XAE_FEATURE_PARTIAL_TX_CSUM	(1 << 1)
3308c2ecf20Sopenharmony_ci#define XAE_FEATURE_FULL_RX_CSUM	(1 << 2)
3318c2ecf20Sopenharmony_ci#define XAE_FEATURE_FULL_TX_CSUM	(1 << 3)
3328c2ecf20Sopenharmony_ci#define XAE_FEATURE_DMA_64BIT		(1 << 4)
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ci#define XAE_NO_CSUM_OFFLOAD		0
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci#define XAE_FULL_CSUM_STATUS_MASK	0x00000038
3378c2ecf20Sopenharmony_ci#define XAE_IP_UDP_CSUM_VALIDATED	0x00000003
3388c2ecf20Sopenharmony_ci#define XAE_IP_TCP_CSUM_VALIDATED	0x00000002
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci#define DELAY_OF_ONE_MILLISEC		1000
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci/**
3438c2ecf20Sopenharmony_ci * struct axidma_bd - Axi Dma buffer descriptor layout
3448c2ecf20Sopenharmony_ci * @next:         MM2S/S2MM Next Descriptor Pointer
3458c2ecf20Sopenharmony_ci * @next_msb:     MM2S/S2MM Next Descriptor Pointer (high 32 bits)
3468c2ecf20Sopenharmony_ci * @phys:         MM2S/S2MM Buffer Address
3478c2ecf20Sopenharmony_ci * @phys_msb:     MM2S/S2MM Buffer Address (high 32 bits)
3488c2ecf20Sopenharmony_ci * @reserved3:    Reserved and not used
3498c2ecf20Sopenharmony_ci * @reserved4:    Reserved and not used
3508c2ecf20Sopenharmony_ci * @cntrl:        MM2S/S2MM Control value
3518c2ecf20Sopenharmony_ci * @status:       MM2S/S2MM Status value
3528c2ecf20Sopenharmony_ci * @app0:         MM2S/S2MM User Application Field 0.
3538c2ecf20Sopenharmony_ci * @app1:         MM2S/S2MM User Application Field 1.
3548c2ecf20Sopenharmony_ci * @app2:         MM2S/S2MM User Application Field 2.
3558c2ecf20Sopenharmony_ci * @app3:         MM2S/S2MM User Application Field 3.
3568c2ecf20Sopenharmony_ci * @app4:         MM2S/S2MM User Application Field 4.
3578c2ecf20Sopenharmony_ci */
3588c2ecf20Sopenharmony_cistruct axidma_bd {
3598c2ecf20Sopenharmony_ci	u32 next;	/* Physical address of next buffer descriptor */
3608c2ecf20Sopenharmony_ci	u32 next_msb;	/* high 32 bits for IP >= v7.1, reserved on older IP */
3618c2ecf20Sopenharmony_ci	u32 phys;
3628c2ecf20Sopenharmony_ci	u32 phys_msb;	/* for IP >= v7.1, reserved for older IP */
3638c2ecf20Sopenharmony_ci	u32 reserved3;
3648c2ecf20Sopenharmony_ci	u32 reserved4;
3658c2ecf20Sopenharmony_ci	u32 cntrl;
3668c2ecf20Sopenharmony_ci	u32 status;
3678c2ecf20Sopenharmony_ci	u32 app0;
3688c2ecf20Sopenharmony_ci	u32 app1;	/* TX start << 16 | insert */
3698c2ecf20Sopenharmony_ci	u32 app2;	/* TX csum seed */
3708c2ecf20Sopenharmony_ci	u32 app3;
3718c2ecf20Sopenharmony_ci	u32 app4;   /* Last field used by HW */
3728c2ecf20Sopenharmony_ci	struct sk_buff *skb;
3738c2ecf20Sopenharmony_ci} __aligned(XAXIDMA_BD_MINIMUM_ALIGNMENT);
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci/**
3768c2ecf20Sopenharmony_ci * struct axienet_local - axienet private per device data
3778c2ecf20Sopenharmony_ci * @ndev:	Pointer for net_device to which it will be attached.
3788c2ecf20Sopenharmony_ci * @dev:	Pointer to device structure
3798c2ecf20Sopenharmony_ci * @phy_node:	Pointer to device node structure
3808c2ecf20Sopenharmony_ci * @mii_bus:	Pointer to MII bus structure
3818c2ecf20Sopenharmony_ci * @regs_start: Resource start for axienet device addresses
3828c2ecf20Sopenharmony_ci * @regs:	Base address for the axienet_local device address space
3838c2ecf20Sopenharmony_ci * @dma_regs:	Base address for the axidma device address space
3848c2ecf20Sopenharmony_ci * @dma_err_tasklet: Tasklet structure to process Axi DMA errors
3858c2ecf20Sopenharmony_ci * @tx_irq:	Axidma TX IRQ number
3868c2ecf20Sopenharmony_ci * @rx_irq:	Axidma RX IRQ number
3878c2ecf20Sopenharmony_ci * @phy_mode:	Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X
3888c2ecf20Sopenharmony_ci * @options:	AxiEthernet option word
3898c2ecf20Sopenharmony_ci * @last_link:	Phy link state in which the PHY was negotiated earlier
3908c2ecf20Sopenharmony_ci * @features:	Stores the extended features supported by the axienet hw
3918c2ecf20Sopenharmony_ci * @tx_bd_v:	Virtual address of the TX buffer descriptor ring
3928c2ecf20Sopenharmony_ci * @tx_bd_p:	Physical address(start address) of the TX buffer descr. ring
3938c2ecf20Sopenharmony_ci * @rx_bd_v:	Virtual address of the RX buffer descriptor ring
3948c2ecf20Sopenharmony_ci * @rx_bd_p:	Physical address(start address) of the RX buffer descr. ring
3958c2ecf20Sopenharmony_ci * @tx_bd_ci:	Stores the index of the Tx buffer descriptor in the ring being
3968c2ecf20Sopenharmony_ci *		accessed currently. Used while alloc. BDs before a TX starts
3978c2ecf20Sopenharmony_ci * @tx_bd_tail:	Stores the index of the Tx buffer descriptor in the ring being
3988c2ecf20Sopenharmony_ci *		accessed currently. Used while processing BDs after the TX
3998c2ecf20Sopenharmony_ci *		completed.
4008c2ecf20Sopenharmony_ci * @rx_bd_ci:	Stores the index of the Rx buffer descriptor in the ring being
4018c2ecf20Sopenharmony_ci *		accessed currently.
4028c2ecf20Sopenharmony_ci * @max_frm_size: Stores the maximum size of the frame that can be that
4038c2ecf20Sopenharmony_ci *		  Txed/Rxed in the existing hardware. If jumbo option is
4048c2ecf20Sopenharmony_ci *		  supported, the maximum frame size would be 9k. Else it is
4058c2ecf20Sopenharmony_ci *		  1522 bytes (assuming support for basic VLAN)
4068c2ecf20Sopenharmony_ci * @rxmem:	Stores rx memory size for jumbo frame handling.
4078c2ecf20Sopenharmony_ci * @csum_offload_on_tx_path:	Stores the checksum selection on TX side.
4088c2ecf20Sopenharmony_ci * @csum_offload_on_rx_path:	Stores the checksum selection on RX side.
4098c2ecf20Sopenharmony_ci * @coalesce_count_rx:	Store the irq coalesce on RX side.
4108c2ecf20Sopenharmony_ci * @coalesce_count_tx:	Store the irq coalesce on TX side.
4118c2ecf20Sopenharmony_ci */
4128c2ecf20Sopenharmony_cistruct axienet_local {
4138c2ecf20Sopenharmony_ci	struct net_device *ndev;
4148c2ecf20Sopenharmony_ci	struct device *dev;
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci	/* Connection to PHY device */
4178c2ecf20Sopenharmony_ci	struct device_node *phy_node;
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci	struct phylink *phylink;
4208c2ecf20Sopenharmony_ci	struct phylink_config phylink_config;
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci	/* Reference to PCS/PMA PHY if used */
4238c2ecf20Sopenharmony_ci	struct mdio_device *pcs_phy;
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci	/* Clock for AXI bus */
4268c2ecf20Sopenharmony_ci	struct clk *clk;
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ci	/* MDIO bus data */
4298c2ecf20Sopenharmony_ci	struct mii_bus *mii_bus;	/* MII bus reference */
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	/* IO registers, dma functions and IRQs */
4328c2ecf20Sopenharmony_ci	resource_size_t regs_start;
4338c2ecf20Sopenharmony_ci	void __iomem *regs;
4348c2ecf20Sopenharmony_ci	void __iomem *dma_regs;
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci	struct work_struct dma_err_task;
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci	int tx_irq;
4398c2ecf20Sopenharmony_ci	int rx_irq;
4408c2ecf20Sopenharmony_ci	int eth_irq;
4418c2ecf20Sopenharmony_ci	phy_interface_t phy_mode;
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	u32 options;			/* Current options word */
4448c2ecf20Sopenharmony_ci	u32 features;
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	/* Buffer descriptors */
4478c2ecf20Sopenharmony_ci	struct axidma_bd *tx_bd_v;
4488c2ecf20Sopenharmony_ci	dma_addr_t tx_bd_p;
4498c2ecf20Sopenharmony_ci	u32 tx_bd_num;
4508c2ecf20Sopenharmony_ci	struct axidma_bd *rx_bd_v;
4518c2ecf20Sopenharmony_ci	dma_addr_t rx_bd_p;
4528c2ecf20Sopenharmony_ci	u32 rx_bd_num;
4538c2ecf20Sopenharmony_ci	u32 tx_bd_ci;
4548c2ecf20Sopenharmony_ci	u32 tx_bd_tail;
4558c2ecf20Sopenharmony_ci	u32 rx_bd_ci;
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci	u32 max_frm_size;
4588c2ecf20Sopenharmony_ci	u32 rxmem;
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	int csum_offload_on_tx_path;
4618c2ecf20Sopenharmony_ci	int csum_offload_on_rx_path;
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci	u32 coalesce_count_rx;
4648c2ecf20Sopenharmony_ci	u32 coalesce_count_tx;
4658c2ecf20Sopenharmony_ci};
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci/**
4688c2ecf20Sopenharmony_ci * struct axiethernet_option - Used to set axi ethernet hardware options
4698c2ecf20Sopenharmony_ci * @opt:	Option to be set.
4708c2ecf20Sopenharmony_ci * @reg:	Register offset to be written for setting the option
4718c2ecf20Sopenharmony_ci * @m_or:	Mask to be ORed for setting the option in the register
4728c2ecf20Sopenharmony_ci */
4738c2ecf20Sopenharmony_cistruct axienet_option {
4748c2ecf20Sopenharmony_ci	u32 opt;
4758c2ecf20Sopenharmony_ci	u32 reg;
4768c2ecf20Sopenharmony_ci	u32 m_or;
4778c2ecf20Sopenharmony_ci};
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci/**
4808c2ecf20Sopenharmony_ci * axienet_ior - Memory mapped Axi Ethernet register read
4818c2ecf20Sopenharmony_ci * @lp:         Pointer to axienet local structure
4828c2ecf20Sopenharmony_ci * @offset:     Address offset from the base address of Axi Ethernet core
4838c2ecf20Sopenharmony_ci *
4848c2ecf20Sopenharmony_ci * Return: The contents of the Axi Ethernet register
4858c2ecf20Sopenharmony_ci *
4868c2ecf20Sopenharmony_ci * This function returns the contents of the corresponding register.
4878c2ecf20Sopenharmony_ci */
4888c2ecf20Sopenharmony_cistatic inline u32 axienet_ior(struct axienet_local *lp, off_t offset)
4898c2ecf20Sopenharmony_ci{
4908c2ecf20Sopenharmony_ci	return ioread32(lp->regs + offset);
4918c2ecf20Sopenharmony_ci}
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_cistatic inline u32 axinet_ior_read_mcr(struct axienet_local *lp)
4948c2ecf20Sopenharmony_ci{
4958c2ecf20Sopenharmony_ci	return axienet_ior(lp, XAE_MDIO_MCR_OFFSET);
4968c2ecf20Sopenharmony_ci}
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ci/**
4998c2ecf20Sopenharmony_ci * axienet_iow - Memory mapped Axi Ethernet register write
5008c2ecf20Sopenharmony_ci * @lp:         Pointer to axienet local structure
5018c2ecf20Sopenharmony_ci * @offset:     Address offset from the base address of Axi Ethernet core
5028c2ecf20Sopenharmony_ci * @value:      Value to be written into the Axi Ethernet register
5038c2ecf20Sopenharmony_ci *
5048c2ecf20Sopenharmony_ci * This function writes the desired value into the corresponding Axi Ethernet
5058c2ecf20Sopenharmony_ci * register.
5068c2ecf20Sopenharmony_ci */
5078c2ecf20Sopenharmony_cistatic inline void axienet_iow(struct axienet_local *lp, off_t offset,
5088c2ecf20Sopenharmony_ci			       u32 value)
5098c2ecf20Sopenharmony_ci{
5108c2ecf20Sopenharmony_ci	iowrite32(value, lp->regs + offset);
5118c2ecf20Sopenharmony_ci}
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci/* Function prototypes visible in xilinx_axienet_mdio.c for other files */
5148c2ecf20Sopenharmony_ciint axienet_mdio_enable(struct axienet_local *lp);
5158c2ecf20Sopenharmony_civoid axienet_mdio_disable(struct axienet_local *lp);
5168c2ecf20Sopenharmony_ciint axienet_mdio_setup(struct axienet_local *lp);
5178c2ecf20Sopenharmony_civoid axienet_mdio_teardown(struct axienet_local *lp);
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci#endif /* XILINX_AXI_ENET_H */
520