xref: /openbmc/qemu/include/hw/net/npcm_gmac.h (revision 8fcc477d)
108f787a3SHao Wu /*
208f787a3SHao Wu  * Nuvoton NPCM7xx/8xx GMAC Module
308f787a3SHao Wu  *
408f787a3SHao Wu  * Copyright 2024 Google LLC
508f787a3SHao Wu  * Authors:
608f787a3SHao Wu  * Hao Wu <wuhaotsh@google.com>
708f787a3SHao Wu  * Nabih Estefan <nabihestefan@google.com>
808f787a3SHao Wu  *
908f787a3SHao Wu  * This program is free software; you can redistribute it and/or modify it
1008f787a3SHao Wu  * under the terms of the GNU General Public License as published by the
1108f787a3SHao Wu  * Free Software Foundation; either version 2 of the License, or
1208f787a3SHao Wu  * (at your option) any later version.
1308f787a3SHao Wu  *
1408f787a3SHao Wu  * This program is distributed in the hope that it will be useful, but WITHOUT
1508f787a3SHao Wu  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1608f787a3SHao Wu  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1708f787a3SHao Wu  * for more details.
1808f787a3SHao Wu  */
1908f787a3SHao Wu 
2008f787a3SHao Wu #ifndef NPCM_GMAC_H
2108f787a3SHao Wu #define NPCM_GMAC_H
2208f787a3SHao Wu 
2308f787a3SHao Wu #include "hw/irq.h"
2408f787a3SHao Wu #include "hw/sysbus.h"
2508f787a3SHao Wu #include "net/net.h"
2608f787a3SHao Wu 
2708f787a3SHao Wu #define NPCM_GMAC_NR_REGS (0x1060 / sizeof(uint32_t))
2808f787a3SHao Wu 
2908f787a3SHao Wu #define NPCM_GMAC_MAX_PHYS 32
3008f787a3SHao Wu #define NPCM_GMAC_MAX_PHY_REGS 32
3108f787a3SHao Wu 
3208f787a3SHao Wu struct NPCMGMACRxDesc {
3308f787a3SHao Wu     uint32_t rdes0;
3408f787a3SHao Wu     uint32_t rdes1;
3508f787a3SHao Wu     uint32_t rdes2;
3608f787a3SHao Wu     uint32_t rdes3;
3708f787a3SHao Wu };
3808f787a3SHao Wu 
3908f787a3SHao Wu /* NPCMGMACRxDesc.flags values */
4008f787a3SHao Wu /* RDES2 and RDES3 are buffer addresses */
4108f787a3SHao Wu /* Owner: 0 = software, 1 = dma */
4208f787a3SHao Wu #define RX_DESC_RDES0_OWN BIT(31)
4308f787a3SHao Wu /* Destination Address Filter Fail */
4408f787a3SHao Wu #define RX_DESC_RDES0_DEST_ADDR_FILT_FAIL BIT(30)
4508f787a3SHao Wu /* Frame length */
4608f787a3SHao Wu #define RX_DESC_RDES0_FRAME_LEN_MASK(word) extract32(word, 16, 14)
4708f787a3SHao Wu /* Frame length Shift*/
4808f787a3SHao Wu #define RX_DESC_RDES0_FRAME_LEN_SHIFT 16
4908f787a3SHao Wu /* Error Summary */
5008f787a3SHao Wu #define RX_DESC_RDES0_ERR_SUMM_MASK BIT(15)
5108f787a3SHao Wu /* Descriptor Error */
5208f787a3SHao Wu #define RX_DESC_RDES0_DESC_ERR_MASK BIT(14)
5308f787a3SHao Wu /* Source Address Filter Fail */
5408f787a3SHao Wu #define RX_DESC_RDES0_SRC_ADDR_FILT_FAIL_MASK BIT(13)
5508f787a3SHao Wu /* Length Error */
5608f787a3SHao Wu #define RX_DESC_RDES0_LEN_ERR_MASK BIT(12)
5708f787a3SHao Wu /* Overflow Error */
5808f787a3SHao Wu #define RX_DESC_RDES0_OVRFLW_ERR_MASK BIT(11)
5908f787a3SHao Wu /* VLAN Tag */
6008f787a3SHao Wu #define RX_DESC_RDES0_VLAN_TAG_MASK BIT(10)
6108f787a3SHao Wu /* First Descriptor */
6208f787a3SHao Wu #define RX_DESC_RDES0_FIRST_DESC_MASK BIT(9)
6308f787a3SHao Wu /* Last Descriptor */
6408f787a3SHao Wu #define RX_DESC_RDES0_LAST_DESC_MASK BIT(8)
6508f787a3SHao Wu /* IPC Checksum Error/Giant Frame */
6608f787a3SHao Wu #define RX_DESC_RDES0_IPC_CHKSM_ERR_GNT_FRM_MASK BIT(7)
6708f787a3SHao Wu /* Late Collision */
6808f787a3SHao Wu #define RX_DESC_RDES0_LT_COLL_MASK BIT(6)
6908f787a3SHao Wu /* Frame Type */
7008f787a3SHao Wu #define RX_DESC_RDES0_FRM_TYPE_MASK BIT(5)
7108f787a3SHao Wu /* Receive Watchdog Timeout */
7208f787a3SHao Wu #define RX_DESC_RDES0_REC_WTCHDG_TMT_MASK BIT(4)
7308f787a3SHao Wu /* Receive Error */
7408f787a3SHao Wu #define RX_DESC_RDES0_RCV_ERR_MASK BIT(3)
7508f787a3SHao Wu /* Dribble Bit Error */
7608f787a3SHao Wu #define RX_DESC_RDES0_DRBL_BIT_ERR_MASK BIT(2)
7708f787a3SHao Wu /* Cyclcic Redundancy Check Error */
7808f787a3SHao Wu #define RX_DESC_RDES0_CRC_ERR_MASK BIT(1)
7908f787a3SHao Wu /* Rx MAC Address/Payload Checksum Error */
8008f787a3SHao Wu #define RC_DESC_RDES0_RCE_MASK BIT(0)
8108f787a3SHao Wu 
8208f787a3SHao Wu /* Disable Interrupt on Completion */
8308f787a3SHao Wu #define RX_DESC_RDES1_DIS_INTR_COMP_MASK BIT(31)
84*8fcc477dSManos Pitsidianakis /* Receive end of ring */
8508f787a3SHao Wu #define RX_DESC_RDES1_RC_END_RING_MASK BIT(25)
8608f787a3SHao Wu /* Second Address Chained */
8708f787a3SHao Wu #define RX_DESC_RDES1_SEC_ADDR_CHND_MASK BIT(24)
8808f787a3SHao Wu /* Receive Buffer 2 Size */
8908f787a3SHao Wu #define RX_DESC_RDES1_BFFR2_SZ_SHIFT 11
9008f787a3SHao Wu #define RX_DESC_RDES1_BFFR2_SZ_MASK(word) extract32(word, \
9108f787a3SHao Wu     RX_DESC_RDES1_BFFR2_SZ_SHIFT, 11)
9208f787a3SHao Wu /* Receive Buffer 1 Size */
9308f787a3SHao Wu #define RX_DESC_RDES1_BFFR1_SZ_MASK(word) extract32(word, 0, 11)
9408f787a3SHao Wu 
9508f787a3SHao Wu 
9608f787a3SHao Wu struct NPCMGMACTxDesc {
9708f787a3SHao Wu     uint32_t tdes0;
9808f787a3SHao Wu     uint32_t tdes1;
9908f787a3SHao Wu     uint32_t tdes2;
10008f787a3SHao Wu     uint32_t tdes3;
10108f787a3SHao Wu };
10208f787a3SHao Wu 
10308f787a3SHao Wu /* NPCMGMACTxDesc.flags values */
10408f787a3SHao Wu /* TDES2 and TDES3 are buffer addresses */
10508f787a3SHao Wu /* Owner: 0 = software, 1 = gmac */
10608f787a3SHao Wu #define TX_DESC_TDES0_OWN BIT(31)
10708f787a3SHao Wu /* Tx Time Stamp Status */
10808f787a3SHao Wu #define TX_DESC_TDES0_TTSS_MASK BIT(17)
10908f787a3SHao Wu /* IP Header Error */
11008f787a3SHao Wu #define TX_DESC_TDES0_IP_HEAD_ERR_MASK BIT(16)
11108f787a3SHao Wu /* Error Summary */
11208f787a3SHao Wu #define TX_DESC_TDES0_ERR_SUMM_MASK BIT(15)
11308f787a3SHao Wu /* Jabber Timeout */
11408f787a3SHao Wu #define TX_DESC_TDES0_JBBR_TMT_MASK BIT(14)
11508f787a3SHao Wu /* Frame Flushed */
11608f787a3SHao Wu #define TX_DESC_TDES0_FRM_FLSHD_MASK BIT(13)
11708f787a3SHao Wu /* Payload Checksum Error */
11808f787a3SHao Wu #define TX_DESC_TDES0_PYLD_CHKSM_ERR_MASK BIT(12)
11908f787a3SHao Wu /* Loss of Carrier */
12008f787a3SHao Wu #define TX_DESC_TDES0_LSS_CARR_MASK BIT(11)
12108f787a3SHao Wu /* No Carrier */
12208f787a3SHao Wu #define TX_DESC_TDES0_NO_CARR_MASK BIT(10)
12308f787a3SHao Wu /* Late Collision */
12408f787a3SHao Wu #define TX_DESC_TDES0_LATE_COLL_MASK BIT(9)
12508f787a3SHao Wu /* Excessive Collision */
12608f787a3SHao Wu #define TX_DESC_TDES0_EXCS_COLL_MASK BIT(8)
12708f787a3SHao Wu /* VLAN Frame */
12808f787a3SHao Wu #define TX_DESC_TDES0_VLAN_FRM_MASK BIT(7)
12908f787a3SHao Wu /* Collision Count */
13008f787a3SHao Wu #define TX_DESC_TDES0_COLL_CNT_MASK(word) extract32(word, 3, 4)
13108f787a3SHao Wu /* Excessive Deferral */
13208f787a3SHao Wu #define TX_DESC_TDES0_EXCS_DEF_MASK BIT(2)
13308f787a3SHao Wu /* Underflow Error */
13408f787a3SHao Wu #define TX_DESC_TDES0_UNDRFLW_ERR_MASK BIT(1)
13508f787a3SHao Wu /* Deferred Bit */
13608f787a3SHao Wu #define TX_DESC_TDES0_DFRD_BIT_MASK BIT(0)
13708f787a3SHao Wu 
13808f787a3SHao Wu /* Interrupt of Completion */
13908f787a3SHao Wu #define TX_DESC_TDES1_INTERR_COMP_MASK BIT(31)
14008f787a3SHao Wu /* Last Segment */
14108f787a3SHao Wu #define TX_DESC_TDES1_LAST_SEG_MASK BIT(30)
14208f787a3SHao Wu /* First Segment */
14308f787a3SHao Wu #define TX_DESC_TDES1_FIRST_SEG_MASK BIT(29)
14408f787a3SHao Wu /* Checksum Insertion Control */
14508f787a3SHao Wu #define TX_DESC_TDES1_CHKSM_INS_CTRL_MASK(word) extract32(word, 27, 2)
14608f787a3SHao Wu /* Disable Cyclic Redundancy Check */
14708f787a3SHao Wu #define TX_DESC_TDES1_DIS_CDC_MASK BIT(26)
14808f787a3SHao Wu /* Transmit End of Ring */
14908f787a3SHao Wu #define TX_DESC_TDES1_TX_END_RING_MASK BIT(25)
15008f787a3SHao Wu /* Secondary Address Chained */
15108f787a3SHao Wu #define TX_DESC_TDES1_SEC_ADDR_CHND_MASK BIT(24)
15208f787a3SHao Wu /* Transmit Buffer 2 Size */
15308f787a3SHao Wu #define TX_DESC_TDES1_BFFR2_SZ_MASK(word) extract32(word, 11, 11)
15408f787a3SHao Wu /* Transmit Buffer 1 Size */
15508f787a3SHao Wu #define TX_DESC_TDES1_BFFR1_SZ_MASK(word) extract32(word, 0, 11)
15608f787a3SHao Wu 
15708f787a3SHao Wu typedef struct NPCMGMACState {
15808f787a3SHao Wu     SysBusDevice parent;
15908f787a3SHao Wu 
16008f787a3SHao Wu     MemoryRegion iomem;
16108f787a3SHao Wu     qemu_irq irq;
16208f787a3SHao Wu 
16308f787a3SHao Wu     NICState *nic;
16408f787a3SHao Wu     NICConf conf;
16508f787a3SHao Wu 
16608f787a3SHao Wu     uint32_t regs[NPCM_GMAC_NR_REGS];
16708f787a3SHao Wu     uint16_t phy_regs[NPCM_GMAC_MAX_PHYS][NPCM_GMAC_MAX_PHY_REGS];
16808f787a3SHao Wu } NPCMGMACState;
16908f787a3SHao Wu 
17008f787a3SHao Wu #define TYPE_NPCM_GMAC "npcm-gmac"
17108f787a3SHao Wu OBJECT_DECLARE_SIMPLE_TYPE(NPCMGMACState, NPCM_GMAC)
17208f787a3SHao Wu 
17308f787a3SHao Wu /* Mask for RO bits in Status */
17408f787a3SHao Wu #define NPCM_DMA_STATUS_RO_MASK(word) (word & 0xfffe0000)
17508f787a3SHao Wu /* Mask for RO bits in Status */
17608f787a3SHao Wu #define NPCM_DMA_STATUS_W1C_MASK(word) (word & 0x1e7ff)
17708f787a3SHao Wu 
17808f787a3SHao Wu /* Transmit Process State */
17908f787a3SHao Wu #define NPCM_DMA_STATUS_TX_PROCESS_STATE_SHIFT 20
18008f787a3SHao Wu /* Transmit States */
18108f787a3SHao Wu #define NPCM_DMA_STATUS_TX_STOPPED_STATE \
18208f787a3SHao Wu     (0b000)
18308f787a3SHao Wu #define NPCM_DMA_STATUS_TX_RUNNING_FETCHING_STATE \
18408f787a3SHao Wu     (0b001)
18508f787a3SHao Wu #define NPCM_DMA_STATUS_TX_RUNNING_WAITING_STATE \
18608f787a3SHao Wu     (0b010)
18708f787a3SHao Wu #define NPCM_DMA_STATUS_TX_RUNNING_READ_STATE \
18808f787a3SHao Wu     (0b011)
18908f787a3SHao Wu #define NPCM_DMA_STATUS_TX_SUSPENDED_STATE \
19008f787a3SHao Wu     (0b110)
19108f787a3SHao Wu #define NPCM_DMA_STATUS_TX_RUNNING_CLOSING_STATE \
19208f787a3SHao Wu     (0b111)
19308f787a3SHao Wu /* Transmit Process State */
19408f787a3SHao Wu #define NPCM_DMA_STATUS_RX_PROCESS_STATE_SHIFT 17
19508f787a3SHao Wu /* Receive States */
19608f787a3SHao Wu #define NPCM_DMA_STATUS_RX_STOPPED_STATE \
19708f787a3SHao Wu     (0b000)
19808f787a3SHao Wu #define NPCM_DMA_STATUS_RX_RUNNING_FETCHING_STATE \
19908f787a3SHao Wu     (0b001)
20008f787a3SHao Wu #define NPCM_DMA_STATUS_RX_RUNNING_WAITING_STATE \
20108f787a3SHao Wu     (0b011)
20208f787a3SHao Wu #define NPCM_DMA_STATUS_RX_SUSPENDED_STATE \
20308f787a3SHao Wu     (0b100)
20408f787a3SHao Wu #define NPCM_DMA_STATUS_RX_RUNNING_CLOSING_STATE \
20508f787a3SHao Wu     (0b101)
20608f787a3SHao Wu #define NPCM_DMA_STATUS_RX_RUNNING_TRANSFERRING_STATE \
20708f787a3SHao Wu     (0b111)
20808f787a3SHao Wu 
20908f787a3SHao Wu 
21008f787a3SHao Wu /* Early Receive Interrupt */
21108f787a3SHao Wu #define NPCM_DMA_STATUS_ERI BIT(14)
21208f787a3SHao Wu /* Fatal Bus Error Interrupt */
21308f787a3SHao Wu #define NPCM_DMA_STATUS_FBI BIT(13)
21408f787a3SHao Wu /* Early transmit Interrupt */
21508f787a3SHao Wu #define NPCM_DMA_STATUS_ETI BIT(10)
216*8fcc477dSManos Pitsidianakis /* Receive Watchdog Timeout */
21708f787a3SHao Wu #define NPCM_DMA_STATUS_RWT BIT(9)
21808f787a3SHao Wu /* Receive Process Stopped */
21908f787a3SHao Wu #define NPCM_DMA_STATUS_RPS BIT(8)
22008f787a3SHao Wu /* Receive Buffer Unavailable */
22108f787a3SHao Wu #define NPCM_DMA_STATUS_RU BIT(7)
22208f787a3SHao Wu /* Receive Interrupt */
22308f787a3SHao Wu #define NPCM_DMA_STATUS_RI BIT(6)
22408f787a3SHao Wu /* Transmit Underflow */
22508f787a3SHao Wu #define NPCM_DMA_STATUS_UNF BIT(5)
22608f787a3SHao Wu /* Receive Overflow */
22708f787a3SHao Wu #define NPCM_DMA_STATUS_OVF BIT(4)
22808f787a3SHao Wu /* Transmit Jabber Timeout */
22908f787a3SHao Wu #define NPCM_DMA_STATUS_TJT BIT(3)
23008f787a3SHao Wu /* Transmit Buffer Unavailable */
23108f787a3SHao Wu #define NPCM_DMA_STATUS_TU BIT(2)
23208f787a3SHao Wu /* Transmit Process Stopped */
23308f787a3SHao Wu #define NPCM_DMA_STATUS_TPS BIT(1)
23408f787a3SHao Wu /* Transmit Interrupt */
23508f787a3SHao Wu #define NPCM_DMA_STATUS_TI BIT(0)
23608f787a3SHao Wu 
23708f787a3SHao Wu /* Normal Interrupt Summary */
23808f787a3SHao Wu #define NPCM_DMA_STATUS_NIS BIT(16)
23908f787a3SHao Wu /* Interrupts enabled by NIE */
24008f787a3SHao Wu #define NPCM_DMA_STATUS_NIS_BITS (NPCM_DMA_STATUS_TI | \
24108f787a3SHao Wu                                   NPCM_DMA_STATUS_TU | \
24208f787a3SHao Wu                                   NPCM_DMA_STATUS_RI | \
24308f787a3SHao Wu                                   NPCM_DMA_STATUS_ERI)
24408f787a3SHao Wu /* Abnormal Interrupt Summary */
24508f787a3SHao Wu #define NPCM_DMA_STATUS_AIS BIT(15)
24608f787a3SHao Wu /* Interrupts enabled by AIE */
24708f787a3SHao Wu #define NPCM_DMA_STATUS_AIS_BITS (NPCM_DMA_STATUS_TPS | \
24808f787a3SHao Wu                                   NPCM_DMA_STATUS_TJT | \
24908f787a3SHao Wu                                   NPCM_DMA_STATUS_OVF | \
25008f787a3SHao Wu                                   NPCM_DMA_STATUS_UNF | \
25108f787a3SHao Wu                                   NPCM_DMA_STATUS_RU  | \
25208f787a3SHao Wu                                   NPCM_DMA_STATUS_RPS | \
25308f787a3SHao Wu                                   NPCM_DMA_STATUS_RWT | \
25408f787a3SHao Wu                                   NPCM_DMA_STATUS_ETI | \
25508f787a3SHao Wu                                   NPCM_DMA_STATUS_FBI)
25608f787a3SHao Wu 
25708f787a3SHao Wu /* Early Receive Interrupt Enable */
25808f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_ERE BIT(14)
25908f787a3SHao Wu /* Fatal Bus Error Interrupt Enable */
26008f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_FBE BIT(13)
26108f787a3SHao Wu /* Early transmit Interrupt Enable */
26208f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_ETE BIT(10)
26308f787a3SHao Wu /* Receive Watchdog Timout Enable */
26408f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_RWE BIT(9)
26508f787a3SHao Wu /* Receive Process Stopped Enable */
26608f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_RSE BIT(8)
26708f787a3SHao Wu /* Receive Buffer Unavailable Enable */
26808f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_RUE BIT(7)
26908f787a3SHao Wu /* Receive Interrupt Enable */
27008f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_RIE BIT(6)
27108f787a3SHao Wu /* Transmit Underflow Enable */
27208f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_UNE BIT(5)
27308f787a3SHao Wu /* Receive Overflow Enable */
27408f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_OVE BIT(4)
27508f787a3SHao Wu /* Transmit Jabber Timeout Enable */
27608f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_TJE BIT(3)
27708f787a3SHao Wu /* Transmit Buffer Unavailable Enable */
27808f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_TUE BIT(2)
27908f787a3SHao Wu /* Transmit Process Stopped Enable */
28008f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_TSE BIT(1)
28108f787a3SHao Wu /* Transmit Interrupt Enable */
28208f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_TIE BIT(0)
28308f787a3SHao Wu 
28408f787a3SHao Wu /* Normal Interrupt Summary Enable */
28508f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_NIE BIT(16)
28608f787a3SHao Wu /* Interrupts enabled by NIE Enable */
28708f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_NIE_BITS (NPCM_DMA_INTR_ENAB_TIE | \
28808f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_TUE | \
28908f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_RIE | \
29008f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_ERE)
29108f787a3SHao Wu /* Abnormal Interrupt Summary Enable */
29208f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_AIE BIT(15)
29308f787a3SHao Wu /* Interrupts enabled by AIE Enable */
29408f787a3SHao Wu #define NPCM_DMA_INTR_ENAB_AIE_BITS (NPCM_DMA_INTR_ENAB_TSE | \
29508f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_TJE | \
29608f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_OVE | \
29708f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_UNE | \
29808f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_RUE | \
29908f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_RSE | \
30008f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_RWE | \
30108f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_ETE | \
30208f787a3SHao Wu                                      NPCM_DMA_INTR_ENAB_FBE)
30308f787a3SHao Wu 
30408f787a3SHao Wu /* Flushing Disabled */
30508f787a3SHao Wu #define NPCM_DMA_CONTROL_FLUSH_MASK BIT(24)
30608f787a3SHao Wu /* Start/stop Transmit */
30708f787a3SHao Wu #define NPCM_DMA_CONTROL_START_STOP_TX BIT(13)
30808f787a3SHao Wu /* Start/stop Receive */
30908f787a3SHao Wu #define NPCM_DMA_CONTROL_START_STOP_RX BIT(1)
31008f787a3SHao Wu /* Next receive descriptor start address */
31108f787a3SHao Wu #define NPCM_DMA_HOST_RX_DESC_MASK(word) ((uint32_t) (word) & ~3u)
31208f787a3SHao Wu /* Next transmit descriptor start address */
31308f787a3SHao Wu #define NPCM_DMA_HOST_TX_DESC_MASK(word) ((uint32_t) (word) & ~3u)
31408f787a3SHao Wu 
31508f787a3SHao Wu /* Receive enable */
31608f787a3SHao Wu #define NPCM_GMAC_MAC_CONFIG_RX_EN BIT(2)
31708f787a3SHao Wu /* Transmit enable */
31808f787a3SHao Wu #define NPCM_GMAC_MAC_CONFIG_TX_EN BIT(3)
31908f787a3SHao Wu 
32008f787a3SHao Wu /* Frame Receive All */
32108f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_REC_ALL_MASK BIT(31)
32208f787a3SHao Wu /* Frame HPF Filter*/
32308f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_HPF_MASK BIT(10)
32408f787a3SHao Wu /* Frame SAF Filter*/
32508f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_SAF_MASK BIT(9)
32608f787a3SHao Wu /* Frame SAIF Filter*/
32708f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_SAIF_MASK BIT(8)
32808f787a3SHao Wu /* Frame PCF Filter*/
32908f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_PCF_MASK BIT(word) extract32((word), 6, 2)
33008f787a3SHao Wu /* Frame DBF Filter*/
33108f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_DBF_MASK BIT(5)
33208f787a3SHao Wu /* Frame PM Filter*/
33308f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_PM_MASK BIT(4)
33408f787a3SHao Wu /* Frame DAIF Filter*/
33508f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_DAIF_MASK BIT(3)
33608f787a3SHao Wu /* Frame HMC Filter*/
33708f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_HMC_MASK BIT(2)
33808f787a3SHao Wu /* Frame HUC Filter*/
33908f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_HUC_MASK BIT(1)
34008f787a3SHao Wu /* Frame PR Filter*/
34108f787a3SHao Wu #define NPCM_GMAC_FRAME_FILTER_PR_MASK BIT(0)
34208f787a3SHao Wu 
34308f787a3SHao Wu #endif /* NPCM_GMAC_H */
344