162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2006-2008 PA Semi, Inc
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Hardware register layout and descriptor formats for the on-board
662306a36Sopenharmony_ci * DMA engine on PA Semi PWRficient. Used by ethernet, function and security
762306a36Sopenharmony_ci * drivers.
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef ASM_PASEMI_DMA_H
1162306a36Sopenharmony_ci#define ASM_PASEMI_DMA_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* status register layout in IOB region, at 0xfb800000 */
1462306a36Sopenharmony_cistruct pasdma_status {
1562306a36Sopenharmony_ci	u64 rx_sta[64];		/* RX channel status */
1662306a36Sopenharmony_ci	u64 tx_sta[20];		/* TX channel status */
1762306a36Sopenharmony_ci};
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* All these registers live in the PCI configuration space for the DMA PCI
2162306a36Sopenharmony_ci * device. Use the normal PCI config access functions for them.
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_cienum {
2462306a36Sopenharmony_ci	PAS_DMA_CAP_TXCH  = 0x44,	/* Transmit Channel Info      */
2562306a36Sopenharmony_ci	PAS_DMA_CAP_RXCH  = 0x48,	/* Transmit Channel Info      */
2662306a36Sopenharmony_ci	PAS_DMA_CAP_IFI	  = 0x4c,	/* Interface Info	      */
2762306a36Sopenharmony_ci	PAS_DMA_COM_TXCMD = 0x100,	/* Transmit Command Register  */
2862306a36Sopenharmony_ci	PAS_DMA_COM_TXSTA = 0x104,	/* Transmit Status Register   */
2962306a36Sopenharmony_ci	PAS_DMA_COM_RXCMD = 0x108,	/* Receive Command Register   */
3062306a36Sopenharmony_ci	PAS_DMA_COM_RXSTA = 0x10c,	/* Receive Status Register    */
3162306a36Sopenharmony_ci	PAS_DMA_COM_CFG   = 0x114,	/* Common config reg	      */
3262306a36Sopenharmony_ci	PAS_DMA_TXF_SFLG0 = 0x140,	/* Set flags                  */
3362306a36Sopenharmony_ci	PAS_DMA_TXF_SFLG1 = 0x144,	/* Set flags                  */
3462306a36Sopenharmony_ci	PAS_DMA_TXF_CFLG0 = 0x148,	/* Set flags                  */
3562306a36Sopenharmony_ci	PAS_DMA_TXF_CFLG1 = 0x14c,	/* Set flags                  */
3662306a36Sopenharmony_ci};
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define PAS_DMA_CAP_TXCH_TCHN_M	0x00ff0000 /* # of TX channels */
4062306a36Sopenharmony_ci#define PAS_DMA_CAP_TXCH_TCHN_S	16
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define PAS_DMA_CAP_RXCH_RCHN_M	0x00ff0000 /* # of RX channels */
4362306a36Sopenharmony_ci#define PAS_DMA_CAP_RXCH_RCHN_S	16
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define PAS_DMA_CAP_IFI_IOFF_M	0xff000000 /* Cfg reg for intf pointers */
4662306a36Sopenharmony_ci#define PAS_DMA_CAP_IFI_IOFF_S	24
4762306a36Sopenharmony_ci#define PAS_DMA_CAP_IFI_NIN_M	0x00ff0000 /* # of interfaces */
4862306a36Sopenharmony_ci#define PAS_DMA_CAP_IFI_NIN_S	16
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define PAS_DMA_COM_TXCMD_EN	0x00000001 /* enable */
5162306a36Sopenharmony_ci#define PAS_DMA_COM_TXSTA_ACT	0x00000001 /* active */
5262306a36Sopenharmony_ci#define PAS_DMA_COM_RXCMD_EN	0x00000001 /* enable */
5362306a36Sopenharmony_ci#define PAS_DMA_COM_RXSTA_ACT	0x00000001 /* active */
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* Per-interface and per-channel registers */
5762306a36Sopenharmony_ci#define _PAS_DMA_RXINT_STRIDE		0x20
5862306a36Sopenharmony_ci#define PAS_DMA_RXINT_RCMDSTA(i)	(0x200+(i)*_PAS_DMA_RXINT_STRIDE)
5962306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_EN	0x00000001
6062306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_ST	0x00000002
6162306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_MBT	0x00000008
6262306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_MDR	0x00000010
6362306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_MOO	0x00000020
6462306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_MBP	0x00000040
6562306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_BT	0x00000800
6662306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_DR	0x00001000
6762306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_OO	0x00002000
6862306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_BP	0x00004000
6962306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_TB	0x00008000
7062306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_ACT	0x00010000
7162306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_DROPS_M	0xfffe0000
7262306a36Sopenharmony_ci#define    PAS_DMA_RXINT_RCMDSTA_DROPS_S	17
7362306a36Sopenharmony_ci#define PAS_DMA_RXINT_CFG(i)		(0x204+(i)*_PAS_DMA_RXINT_STRIDE)
7462306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_RBP	0x80000000
7562306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_ITRR	0x40000000
7662306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_DHL_M	0x07000000
7762306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_DHL_S	24
7862306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_DHL(x)	(((x) << PAS_DMA_RXINT_CFG_DHL_S) & \
7962306a36Sopenharmony_ci					 PAS_DMA_RXINT_CFG_DHL_M)
8062306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_ITR	0x00400000
8162306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_LW		0x00200000
8262306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_L2		0x00100000
8362306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_HEN	0x00080000
8462306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_WIF	0x00000002
8562306a36Sopenharmony_ci#define    PAS_DMA_RXINT_CFG_WIL	0x00000001
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define PAS_DMA_RXINT_INCR(i)		(0x210+(i)*_PAS_DMA_RXINT_STRIDE)
8862306a36Sopenharmony_ci#define    PAS_DMA_RXINT_INCR_INCR_M	0x0000ffff
8962306a36Sopenharmony_ci#define    PAS_DMA_RXINT_INCR_INCR_S	0
9062306a36Sopenharmony_ci#define    PAS_DMA_RXINT_INCR_INCR(x)	((x) & 0x0000ffff)
9162306a36Sopenharmony_ci#define PAS_DMA_RXINT_BASEL(i)		(0x218+(i)*_PAS_DMA_RXINT_STRIDE)
9262306a36Sopenharmony_ci#define    PAS_DMA_RXINT_BASEL_BRBL(x)	((x) & ~0x3f)
9362306a36Sopenharmony_ci#define PAS_DMA_RXINT_BASEU(i)		(0x21c+(i)*_PAS_DMA_RXINT_STRIDE)
9462306a36Sopenharmony_ci#define    PAS_DMA_RXINT_BASEU_BRBH(x)	((x) & 0xfff)
9562306a36Sopenharmony_ci#define    PAS_DMA_RXINT_BASEU_SIZ_M	0x3fff0000	/* # of cache lines worth of buffer ring */
9662306a36Sopenharmony_ci#define    PAS_DMA_RXINT_BASEU_SIZ_S	16		/* 0 = 16K */
9762306a36Sopenharmony_ci#define    PAS_DMA_RXINT_BASEU_SIZ(x)	(((x) << PAS_DMA_RXINT_BASEU_SIZ_S) & \
9862306a36Sopenharmony_ci					 PAS_DMA_RXINT_BASEU_SIZ_M)
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_STRIDE	0x20    /* Size per channel		*/
10262306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_TCMDSTA	0x300	/* Command / Status		*/
10362306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_CFG	0x304	/* Configuration		*/
10462306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_DSCRBU	0x308	/* Descriptor BU Allocation	*/
10562306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_INCR	0x310	/* Descriptor increment		*/
10662306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_CNT	0x314	/* Descriptor count/offset	*/
10762306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_BASEL	0x318	/* Descriptor ring base (low)	*/
10862306a36Sopenharmony_ci#define _PAS_DMA_TXCHAN_BASEU	0x31c	/*			(high)	*/
10962306a36Sopenharmony_ci#define PAS_DMA_TXCHAN_TCMDSTA(c) (0x300+(c)*_PAS_DMA_TXCHAN_STRIDE)
11062306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_TCMDSTA_EN	0x00000001	/* Enabled */
11162306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_TCMDSTA_ST	0x00000002	/* Stop interface */
11262306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_TCMDSTA_ACT	0x00010000	/* Active */
11362306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_TCMDSTA_SZ	0x00000800
11462306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_TCMDSTA_DB	0x00000400
11562306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_TCMDSTA_DE	0x00000200
11662306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_TCMDSTA_DA	0x00000100
11762306a36Sopenharmony_ci#define PAS_DMA_TXCHAN_CFG(c)     (0x304+(c)*_PAS_DMA_TXCHAN_STRIDE)
11862306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TY_IFACE	0x00000000	/* Type = interface */
11962306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TY_COPY	0x00000001	/* Type = copy only */
12062306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TY_FUNC	0x00000002	/* Type = function */
12162306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TY_XOR	0x00000003	/* Type = xor only */
12262306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TATTR_M	0x0000003c
12362306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TATTR_S	2
12462306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TATTR(x)	(((x) << PAS_DMA_TXCHAN_CFG_TATTR_S) & \
12562306a36Sopenharmony_ci					 PAS_DMA_TXCHAN_CFG_TATTR_M)
12662306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_LPDQ	0x00000800
12762306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_LPSQ	0x00000400
12862306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_WT_M	0x000003c0
12962306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_WT_S	6
13062306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_WT(x)	(((x) << PAS_DMA_TXCHAN_CFG_WT_S) & \
13162306a36Sopenharmony_ci					 PAS_DMA_TXCHAN_CFG_WT_M)
13262306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TRD	0x00010000	/* translate data */
13362306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_TRR	0x00008000	/* translate rings */
13462306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_UP	0x00004000	/* update tx descr when sent */
13562306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_CL	0x00002000	/* Clean last line */
13662306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_CFG_CF	0x00001000	/* Clean first line */
13762306a36Sopenharmony_ci#define PAS_DMA_TXCHAN_INCR(c)    (0x310+(c)*_PAS_DMA_TXCHAN_STRIDE)
13862306a36Sopenharmony_ci#define PAS_DMA_TXCHAN_BASEL(c)   (0x318+(c)*_PAS_DMA_TXCHAN_STRIDE)
13962306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEL_BRBL_M	0xffffffc0
14062306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEL_BRBL_S	0
14162306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEL_BRBL(x)	(((x) << PAS_DMA_TXCHAN_BASEL_BRBL_S) & \
14262306a36Sopenharmony_ci					 PAS_DMA_TXCHAN_BASEL_BRBL_M)
14362306a36Sopenharmony_ci#define PAS_DMA_TXCHAN_BASEU(c)   (0x31c+(c)*_PAS_DMA_TXCHAN_STRIDE)
14462306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEU_BRBH_M	0x00000fff
14562306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEU_BRBH_S	0
14662306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEU_BRBH(x)	(((x) << PAS_DMA_TXCHAN_BASEU_BRBH_S) & \
14762306a36Sopenharmony_ci					 PAS_DMA_TXCHAN_BASEU_BRBH_M)
14862306a36Sopenharmony_ci/* # of cache lines worth of buffer ring */
14962306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEU_SIZ_M	0x3fff0000
15062306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEU_SIZ_S	16		/* 0 = 16K */
15162306a36Sopenharmony_ci#define    PAS_DMA_TXCHAN_BASEU_SIZ(x)	(((x) << PAS_DMA_TXCHAN_BASEU_SIZ_S) & \
15262306a36Sopenharmony_ci					 PAS_DMA_TXCHAN_BASEU_SIZ_M)
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci#define _PAS_DMA_RXCHAN_STRIDE	0x20    /* Size per channel		*/
15562306a36Sopenharmony_ci#define _PAS_DMA_RXCHAN_CCMDSTA	0x800	/* Command / Status		*/
15662306a36Sopenharmony_ci#define _PAS_DMA_RXCHAN_CFG	0x804	/* Configuration		*/
15762306a36Sopenharmony_ci#define _PAS_DMA_RXCHAN_INCR	0x810	/* Descriptor increment		*/
15862306a36Sopenharmony_ci#define _PAS_DMA_RXCHAN_CNT	0x814	/* Descriptor count/offset	*/
15962306a36Sopenharmony_ci#define _PAS_DMA_RXCHAN_BASEL	0x818	/* Descriptor ring base (low)	*/
16062306a36Sopenharmony_ci#define _PAS_DMA_RXCHAN_BASEU	0x81c	/*			(high)	*/
16162306a36Sopenharmony_ci#define PAS_DMA_RXCHAN_CCMDSTA(c) (0x800+(c)*_PAS_DMA_RXCHAN_STRIDE)
16262306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CCMDSTA_EN	0x00000001	/* Enabled */
16362306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CCMDSTA_ST	0x00000002	/* Stop interface */
16462306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CCMDSTA_ACT	0x00010000	/* Active */
16562306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CCMDSTA_DU	0x00020000
16662306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CCMDSTA_OD	0x00002000
16762306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CCMDSTA_FD	0x00001000
16862306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CCMDSTA_DT	0x00000800
16962306a36Sopenharmony_ci#define PAS_DMA_RXCHAN_CFG(c)     (0x804+(c)*_PAS_DMA_RXCHAN_STRIDE)
17062306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CFG_CTR	0x00000400
17162306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CFG_HBU_M	0x00000380
17262306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CFG_HBU_S	7
17362306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_CFG_HBU(x)	(((x) << PAS_DMA_RXCHAN_CFG_HBU_S) & \
17462306a36Sopenharmony_ci					 PAS_DMA_RXCHAN_CFG_HBU_M)
17562306a36Sopenharmony_ci#define PAS_DMA_RXCHAN_INCR(c)    (0x810+(c)*_PAS_DMA_RXCHAN_STRIDE)
17662306a36Sopenharmony_ci#define PAS_DMA_RXCHAN_BASEL(c)   (0x818+(c)*_PAS_DMA_RXCHAN_STRIDE)
17762306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEL_BRBL_M	0xffffffc0
17862306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEL_BRBL_S	0
17962306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEL_BRBL(x)	(((x) << PAS_DMA_RXCHAN_BASEL_BRBL_S) & \
18062306a36Sopenharmony_ci					 PAS_DMA_RXCHAN_BASEL_BRBL_M)
18162306a36Sopenharmony_ci#define PAS_DMA_RXCHAN_BASEU(c)   (0x81c+(c)*_PAS_DMA_RXCHAN_STRIDE)
18262306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEU_BRBH_M	0x00000fff
18362306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEU_BRBH_S	0
18462306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEU_BRBH(x)	(((x) << PAS_DMA_RXCHAN_BASEU_BRBH_S) & \
18562306a36Sopenharmony_ci					 PAS_DMA_RXCHAN_BASEU_BRBH_M)
18662306a36Sopenharmony_ci/* # of cache lines worth of buffer ring */
18762306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEU_SIZ_M	0x3fff0000
18862306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEU_SIZ_S	16		/* 0 = 16K */
18962306a36Sopenharmony_ci#define    PAS_DMA_RXCHAN_BASEU_SIZ(x)	(((x) << PAS_DMA_RXCHAN_BASEU_SIZ_S) & \
19062306a36Sopenharmony_ci					 PAS_DMA_RXCHAN_BASEU_SIZ_M)
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci#define    PAS_STATUS_PCNT_M		0x000000000000ffffull
19362306a36Sopenharmony_ci#define    PAS_STATUS_PCNT_S		0
19462306a36Sopenharmony_ci#define    PAS_STATUS_DCNT_M		0x00000000ffff0000ull
19562306a36Sopenharmony_ci#define    PAS_STATUS_DCNT_S		16
19662306a36Sopenharmony_ci#define    PAS_STATUS_BPCNT_M		0x0000ffff00000000ull
19762306a36Sopenharmony_ci#define    PAS_STATUS_BPCNT_S		32
19862306a36Sopenharmony_ci#define    PAS_STATUS_CAUSE_M		0xf000000000000000ull
19962306a36Sopenharmony_ci#define    PAS_STATUS_TIMER		0x1000000000000000ull
20062306a36Sopenharmony_ci#define    PAS_STATUS_ERROR		0x2000000000000000ull
20162306a36Sopenharmony_ci#define    PAS_STATUS_SOFT		0x4000000000000000ull
20262306a36Sopenharmony_ci#define    PAS_STATUS_INT		0x8000000000000000ull
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci#define PAS_IOB_COM_PKTHDRCNT		0x120
20562306a36Sopenharmony_ci#define    PAS_IOB_COM_PKTHDRCNT_PKTHDR1_M	0x0fff0000
20662306a36Sopenharmony_ci#define    PAS_IOB_COM_PKTHDRCNT_PKTHDR1_S	16
20762306a36Sopenharmony_ci#define    PAS_IOB_COM_PKTHDRCNT_PKTHDR0_M	0x00000fff
20862306a36Sopenharmony_ci#define    PAS_IOB_COM_PKTHDRCNT_PKTHDR0_S	0
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define PAS_IOB_DMA_RXCH_CFG(i)		(0x1100 + (i)*4)
21162306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_CFG_CNTTH_M		0x00000fff
21262306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_CFG_CNTTH_S		0
21362306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_CFG_CNTTH(x)	(((x) << PAS_IOB_DMA_RXCH_CFG_CNTTH_S) & \
21462306a36Sopenharmony_ci						 PAS_IOB_DMA_RXCH_CFG_CNTTH_M)
21562306a36Sopenharmony_ci#define PAS_IOB_DMA_TXCH_CFG(i)		(0x1200 + (i)*4)
21662306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_CFG_CNTTH_M		0x00000fff
21762306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_CFG_CNTTH_S		0
21862306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_CFG_CNTTH(x)	(((x) << PAS_IOB_DMA_TXCH_CFG_CNTTH_S) & \
21962306a36Sopenharmony_ci						 PAS_IOB_DMA_TXCH_CFG_CNTTH_M)
22062306a36Sopenharmony_ci#define PAS_IOB_DMA_RXCH_STAT(i)	(0x1300 + (i)*4)
22162306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_STAT_INTGEN	0x00001000
22262306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_STAT_CNTDEL_M	0x00000fff
22362306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_STAT_CNTDEL_S	0
22462306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_STAT_CNTDEL(x)	(((x) << PAS_IOB_DMA_RXCH_STAT_CNTDEL_S) &\
22562306a36Sopenharmony_ci						 PAS_IOB_DMA_RXCH_STAT_CNTDEL_M)
22662306a36Sopenharmony_ci#define PAS_IOB_DMA_TXCH_STAT(i)	(0x1400 + (i)*4)
22762306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_STAT_INTGEN	0x00001000
22862306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_STAT_CNTDEL_M	0x00000fff
22962306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_STAT_CNTDEL_S	0
23062306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_STAT_CNTDEL(x)	(((x) << PAS_IOB_DMA_TXCH_STAT_CNTDEL_S) &\
23162306a36Sopenharmony_ci						 PAS_IOB_DMA_TXCH_STAT_CNTDEL_M)
23262306a36Sopenharmony_ci#define PAS_IOB_DMA_RXCH_RESET(i)	(0x1500 + (i)*4)
23362306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_PCNT_M	0xffff0000
23462306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_PCNT_S	16
23562306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_PCNT(x)	(((x) << PAS_IOB_DMA_RXCH_RESET_PCNT_S) & \
23662306a36Sopenharmony_ci						 PAS_IOB_DMA_RXCH_RESET_PCNT_M)
23762306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_PCNTRST	0x00000020
23862306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_DCNTRST	0x00000010
23962306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_TINTC		0x00000008
24062306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_DINTC		0x00000004
24162306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_SINTC		0x00000002
24262306a36Sopenharmony_ci#define    PAS_IOB_DMA_RXCH_RESET_PINTC		0x00000001
24362306a36Sopenharmony_ci#define PAS_IOB_DMA_TXCH_RESET(i)	(0x1600 + (i)*4)
24462306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_PCNT_M	0xffff0000
24562306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_PCNT_S	16
24662306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_PCNT(x)	(((x) << PAS_IOB_DMA_TXCH_RESET_PCNT_S) & \
24762306a36Sopenharmony_ci						 PAS_IOB_DMA_TXCH_RESET_PCNT_M)
24862306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_PCNTRST	0x00000020
24962306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_DCNTRST	0x00000010
25062306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_TINTC		0x00000008
25162306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_DINTC		0x00000004
25262306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_SINTC		0x00000002
25362306a36Sopenharmony_ci#define    PAS_IOB_DMA_TXCH_RESET_PINTC		0x00000001
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci#define PAS_IOB_DMA_COM_TIMEOUTCFG		0x1700
25662306a36Sopenharmony_ci#define    PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M	0x00ffffff
25762306a36Sopenharmony_ci#define    PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S	0
25862306a36Sopenharmony_ci#define    PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(x)	(((x) << PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S) & \
25962306a36Sopenharmony_ci						 PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M)
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_ci/* Transmit descriptor fields */
26262306a36Sopenharmony_ci#define	XCT_MACTX_T		0x8000000000000000ull
26362306a36Sopenharmony_ci#define	XCT_MACTX_ST		0x4000000000000000ull
26462306a36Sopenharmony_ci#define XCT_MACTX_NORES		0x0000000000000000ull
26562306a36Sopenharmony_ci#define XCT_MACTX_8BRES		0x1000000000000000ull
26662306a36Sopenharmony_ci#define XCT_MACTX_24BRES	0x2000000000000000ull
26762306a36Sopenharmony_ci#define XCT_MACTX_40BRES	0x3000000000000000ull
26862306a36Sopenharmony_ci#define XCT_MACTX_I		0x0800000000000000ull
26962306a36Sopenharmony_ci#define XCT_MACTX_O		0x0400000000000000ull
27062306a36Sopenharmony_ci#define XCT_MACTX_E		0x0200000000000000ull
27162306a36Sopenharmony_ci#define XCT_MACTX_VLAN_M	0x0180000000000000ull
27262306a36Sopenharmony_ci#define XCT_MACTX_VLAN_NOP	0x0000000000000000ull
27362306a36Sopenharmony_ci#define XCT_MACTX_VLAN_REMOVE	0x0080000000000000ull
27462306a36Sopenharmony_ci#define XCT_MACTX_VLAN_INSERT   0x0100000000000000ull
27562306a36Sopenharmony_ci#define XCT_MACTX_VLAN_REPLACE  0x0180000000000000ull
27662306a36Sopenharmony_ci#define XCT_MACTX_CRC_M		0x0060000000000000ull
27762306a36Sopenharmony_ci#define XCT_MACTX_CRC_NOP	0x0000000000000000ull
27862306a36Sopenharmony_ci#define XCT_MACTX_CRC_INSERT	0x0020000000000000ull
27962306a36Sopenharmony_ci#define XCT_MACTX_CRC_PAD	0x0040000000000000ull
28062306a36Sopenharmony_ci#define XCT_MACTX_CRC_REPLACE	0x0060000000000000ull
28162306a36Sopenharmony_ci#define XCT_MACTX_SS		0x0010000000000000ull
28262306a36Sopenharmony_ci#define XCT_MACTX_LLEN_M	0x00007fff00000000ull
28362306a36Sopenharmony_ci#define XCT_MACTX_LLEN_S	32ull
28462306a36Sopenharmony_ci#define XCT_MACTX_LLEN(x)	((((long)(x)) << XCT_MACTX_LLEN_S) & \
28562306a36Sopenharmony_ci				 XCT_MACTX_LLEN_M)
28662306a36Sopenharmony_ci#define XCT_MACTX_IPH_M		0x00000000f8000000ull
28762306a36Sopenharmony_ci#define XCT_MACTX_IPH_S		27ull
28862306a36Sopenharmony_ci#define XCT_MACTX_IPH(x)	((((long)(x)) << XCT_MACTX_IPH_S) & \
28962306a36Sopenharmony_ci				 XCT_MACTX_IPH_M)
29062306a36Sopenharmony_ci#define XCT_MACTX_IPO_M		0x0000000007c00000ull
29162306a36Sopenharmony_ci#define XCT_MACTX_IPO_S		22ull
29262306a36Sopenharmony_ci#define XCT_MACTX_IPO(x)	((((long)(x)) << XCT_MACTX_IPO_S) & \
29362306a36Sopenharmony_ci				 XCT_MACTX_IPO_M)
29462306a36Sopenharmony_ci#define XCT_MACTX_CSUM_M	0x0000000000000060ull
29562306a36Sopenharmony_ci#define XCT_MACTX_CSUM_NOP	0x0000000000000000ull
29662306a36Sopenharmony_ci#define XCT_MACTX_CSUM_TCP	0x0000000000000040ull
29762306a36Sopenharmony_ci#define XCT_MACTX_CSUM_UDP	0x0000000000000060ull
29862306a36Sopenharmony_ci#define XCT_MACTX_V6		0x0000000000000010ull
29962306a36Sopenharmony_ci#define XCT_MACTX_C		0x0000000000000004ull
30062306a36Sopenharmony_ci#define XCT_MACTX_AL2		0x0000000000000002ull
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ci/* Receive descriptor fields */
30362306a36Sopenharmony_ci#define	XCT_MACRX_T		0x8000000000000000ull
30462306a36Sopenharmony_ci#define	XCT_MACRX_ST		0x4000000000000000ull
30562306a36Sopenharmony_ci#define XCT_MACRX_RR_M		0x3000000000000000ull
30662306a36Sopenharmony_ci#define XCT_MACRX_RR_NORES	0x0000000000000000ull
30762306a36Sopenharmony_ci#define XCT_MACRX_RR_8BRES	0x1000000000000000ull
30862306a36Sopenharmony_ci#define XCT_MACRX_O		0x0400000000000000ull
30962306a36Sopenharmony_ci#define XCT_MACRX_E		0x0200000000000000ull
31062306a36Sopenharmony_ci#define XCT_MACRX_FF		0x0100000000000000ull
31162306a36Sopenharmony_ci#define XCT_MACRX_PF		0x0080000000000000ull
31262306a36Sopenharmony_ci#define XCT_MACRX_OB		0x0040000000000000ull
31362306a36Sopenharmony_ci#define XCT_MACRX_OD		0x0020000000000000ull
31462306a36Sopenharmony_ci#define XCT_MACRX_FS		0x0010000000000000ull
31562306a36Sopenharmony_ci#define XCT_MACRX_NB_M		0x000fc00000000000ull
31662306a36Sopenharmony_ci#define XCT_MACRX_NB_S		46ULL
31762306a36Sopenharmony_ci#define XCT_MACRX_NB(x)		((((long)(x)) << XCT_MACRX_NB_S) & \
31862306a36Sopenharmony_ci				 XCT_MACRX_NB_M)
31962306a36Sopenharmony_ci#define XCT_MACRX_LLEN_M	0x00003fff00000000ull
32062306a36Sopenharmony_ci#define XCT_MACRX_LLEN_S	32ULL
32162306a36Sopenharmony_ci#define XCT_MACRX_LLEN(x)	((((long)(x)) << XCT_MACRX_LLEN_S) & \
32262306a36Sopenharmony_ci				 XCT_MACRX_LLEN_M)
32362306a36Sopenharmony_ci#define XCT_MACRX_CRC		0x0000000080000000ull
32462306a36Sopenharmony_ci#define XCT_MACRX_LEN_M		0x0000000060000000ull
32562306a36Sopenharmony_ci#define XCT_MACRX_LEN_TOOSHORT	0x0000000020000000ull
32662306a36Sopenharmony_ci#define XCT_MACRX_LEN_BELOWMIN	0x0000000040000000ull
32762306a36Sopenharmony_ci#define XCT_MACRX_LEN_TRUNC	0x0000000060000000ull
32862306a36Sopenharmony_ci#define XCT_MACRX_CAST_M	0x0000000018000000ull
32962306a36Sopenharmony_ci#define XCT_MACRX_CAST_UNI	0x0000000000000000ull
33062306a36Sopenharmony_ci#define XCT_MACRX_CAST_MULTI	0x0000000008000000ull
33162306a36Sopenharmony_ci#define XCT_MACRX_CAST_BROAD	0x0000000010000000ull
33262306a36Sopenharmony_ci#define XCT_MACRX_CAST_PAUSE	0x0000000018000000ull
33362306a36Sopenharmony_ci#define XCT_MACRX_VLC_M		0x0000000006000000ull
33462306a36Sopenharmony_ci#define XCT_MACRX_FM		0x0000000001000000ull
33562306a36Sopenharmony_ci#define XCT_MACRX_HTY_M		0x0000000000c00000ull
33662306a36Sopenharmony_ci#define XCT_MACRX_HTY_IPV4_OK	0x0000000000000000ull
33762306a36Sopenharmony_ci#define XCT_MACRX_HTY_IPV6 	0x0000000000400000ull
33862306a36Sopenharmony_ci#define XCT_MACRX_HTY_IPV4_BAD	0x0000000000800000ull
33962306a36Sopenharmony_ci#define XCT_MACRX_HTY_NONIP	0x0000000000c00000ull
34062306a36Sopenharmony_ci#define XCT_MACRX_IPP_M		0x00000000003f0000ull
34162306a36Sopenharmony_ci#define XCT_MACRX_IPP_S		16
34262306a36Sopenharmony_ci#define XCT_MACRX_CSUM_M	0x000000000000ffffull
34362306a36Sopenharmony_ci#define XCT_MACRX_CSUM_S	0
34462306a36Sopenharmony_ci
34562306a36Sopenharmony_ci#define XCT_PTR_T		0x8000000000000000ull
34662306a36Sopenharmony_ci#define XCT_PTR_LEN_M		0x7ffff00000000000ull
34762306a36Sopenharmony_ci#define XCT_PTR_LEN_S		44
34862306a36Sopenharmony_ci#define XCT_PTR_LEN(x)		((((long)(x)) << XCT_PTR_LEN_S) & \
34962306a36Sopenharmony_ci				 XCT_PTR_LEN_M)
35062306a36Sopenharmony_ci#define XCT_PTR_ADDR_M		0x00000fffffffffffull
35162306a36Sopenharmony_ci#define XCT_PTR_ADDR_S		0
35262306a36Sopenharmony_ci#define XCT_PTR_ADDR(x)		((((long)(x)) << XCT_PTR_ADDR_S) & \
35362306a36Sopenharmony_ci				 XCT_PTR_ADDR_M)
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci/* Receive interface 8byte result fields */
35662306a36Sopenharmony_ci#define XCT_RXRES_8B_L4O_M	0xff00000000000000ull
35762306a36Sopenharmony_ci#define XCT_RXRES_8B_L4O_S	56
35862306a36Sopenharmony_ci#define XCT_RXRES_8B_RULE_M	0x00ffff0000000000ull
35962306a36Sopenharmony_ci#define XCT_RXRES_8B_RULE_S	40
36062306a36Sopenharmony_ci#define XCT_RXRES_8B_EVAL_M	0x000000ffff000000ull
36162306a36Sopenharmony_ci#define XCT_RXRES_8B_EVAL_S	24
36262306a36Sopenharmony_ci#define XCT_RXRES_8B_HTYPE_M	0x0000000000f00000ull
36362306a36Sopenharmony_ci#define XCT_RXRES_8B_HASH_M	0x00000000000fffffull
36462306a36Sopenharmony_ci#define XCT_RXRES_8B_HASH_S	0
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci/* Receive interface buffer fields */
36762306a36Sopenharmony_ci#define XCT_RXB_LEN_M		0x0ffff00000000000ull
36862306a36Sopenharmony_ci#define XCT_RXB_LEN_S		44
36962306a36Sopenharmony_ci#define XCT_RXB_LEN(x)		((((long)(x)) << XCT_RXB_LEN_S) & \
37062306a36Sopenharmony_ci				 XCT_RXB_LEN_M)
37162306a36Sopenharmony_ci#define XCT_RXB_ADDR_M		0x00000fffffffffffull
37262306a36Sopenharmony_ci#define XCT_RXB_ADDR_S		0
37362306a36Sopenharmony_ci#define XCT_RXB_ADDR(x)		((((long)(x)) << XCT_RXB_ADDR_S) & \
37462306a36Sopenharmony_ci				 XCT_RXB_ADDR_M)
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci/* Copy descriptor fields */
37762306a36Sopenharmony_ci#define XCT_COPY_T		0x8000000000000000ull
37862306a36Sopenharmony_ci#define XCT_COPY_ST		0x4000000000000000ull
37962306a36Sopenharmony_ci#define XCT_COPY_RR_M		0x3000000000000000ull
38062306a36Sopenharmony_ci#define XCT_COPY_RR_NORES	0x0000000000000000ull
38162306a36Sopenharmony_ci#define XCT_COPY_RR_8BRES	0x1000000000000000ull
38262306a36Sopenharmony_ci#define XCT_COPY_RR_24BRES	0x2000000000000000ull
38362306a36Sopenharmony_ci#define XCT_COPY_RR_40BRES	0x3000000000000000ull
38462306a36Sopenharmony_ci#define XCT_COPY_I		0x0800000000000000ull
38562306a36Sopenharmony_ci#define XCT_COPY_O		0x0400000000000000ull
38662306a36Sopenharmony_ci#define XCT_COPY_E		0x0200000000000000ull
38762306a36Sopenharmony_ci#define XCT_COPY_STY_ZERO	0x01c0000000000000ull
38862306a36Sopenharmony_ci#define XCT_COPY_DTY_PREF	0x0038000000000000ull
38962306a36Sopenharmony_ci#define XCT_COPY_LLEN_M		0x0007ffff00000000ull
39062306a36Sopenharmony_ci#define XCT_COPY_LLEN_S		32
39162306a36Sopenharmony_ci#define XCT_COPY_LLEN(x)	((((long)(x)) << XCT_COPY_LLEN_S) & \
39262306a36Sopenharmony_ci				 XCT_COPY_LLEN_M)
39362306a36Sopenharmony_ci#define XCT_COPY_SE		0x0000000000000001ull
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci/* Function descriptor fields */
39662306a36Sopenharmony_ci#define XCT_FUN_T		0x8000000000000000ull
39762306a36Sopenharmony_ci#define XCT_FUN_ST		0x4000000000000000ull
39862306a36Sopenharmony_ci#define XCT_FUN_RR_M		0x3000000000000000ull
39962306a36Sopenharmony_ci#define XCT_FUN_RR_NORES	0x0000000000000000ull
40062306a36Sopenharmony_ci#define XCT_FUN_RR_8BRES	0x1000000000000000ull
40162306a36Sopenharmony_ci#define XCT_FUN_RR_24BRES	0x2000000000000000ull
40262306a36Sopenharmony_ci#define XCT_FUN_RR_40BRES	0x3000000000000000ull
40362306a36Sopenharmony_ci#define XCT_FUN_I		0x0800000000000000ull
40462306a36Sopenharmony_ci#define XCT_FUN_O		0x0400000000000000ull
40562306a36Sopenharmony_ci#define XCT_FUN_E		0x0200000000000000ull
40662306a36Sopenharmony_ci#define XCT_FUN_FUN_M		0x01c0000000000000ull
40762306a36Sopenharmony_ci#define XCT_FUN_FUN_S		54
40862306a36Sopenharmony_ci#define XCT_FUN_FUN(x)		((((long)(x)) << XCT_FUN_FUN_S) & XCT_FUN_FUN_M)
40962306a36Sopenharmony_ci#define XCT_FUN_CRM_M		0x0038000000000000ull
41062306a36Sopenharmony_ci#define XCT_FUN_CRM_NOP		0x0000000000000000ull
41162306a36Sopenharmony_ci#define XCT_FUN_CRM_SIG		0x0008000000000000ull
41262306a36Sopenharmony_ci#define XCT_FUN_LLEN_M		0x0007ffff00000000ull
41362306a36Sopenharmony_ci#define XCT_FUN_LLEN_S		32
41462306a36Sopenharmony_ci#define XCT_FUN_LLEN(x)		((((long)(x)) << XCT_FUN_LLEN_S) & XCT_FUN_LLEN_M)
41562306a36Sopenharmony_ci#define XCT_FUN_SHL_M		0x00000000f8000000ull
41662306a36Sopenharmony_ci#define XCT_FUN_SHL_S		27
41762306a36Sopenharmony_ci#define XCT_FUN_SHL(x)		((((long)(x)) << XCT_FUN_SHL_S) & XCT_FUN_SHL_M)
41862306a36Sopenharmony_ci#define XCT_FUN_CHL_M		0x0000000007c00000ull
41962306a36Sopenharmony_ci#define XCT_FUN_HSZ_M		0x00000000003c0000ull
42062306a36Sopenharmony_ci#define XCT_FUN_ALG_M		0x0000000000038000ull
42162306a36Sopenharmony_ci#define XCT_FUN_HP		0x0000000000004000ull
42262306a36Sopenharmony_ci#define XCT_FUN_BCM_M		0x0000000000003800ull
42362306a36Sopenharmony_ci#define XCT_FUN_BCP_M		0x0000000000000600ull
42462306a36Sopenharmony_ci#define XCT_FUN_SIG_M		0x00000000000001f0ull
42562306a36Sopenharmony_ci#define XCT_FUN_SIG_TCP4	0x0000000000000140ull
42662306a36Sopenharmony_ci#define XCT_FUN_SIG_TCP6	0x0000000000000150ull
42762306a36Sopenharmony_ci#define XCT_FUN_SIG_UDP4	0x0000000000000160ull
42862306a36Sopenharmony_ci#define XCT_FUN_SIG_UDP6	0x0000000000000170ull
42962306a36Sopenharmony_ci#define XCT_FUN_A		0x0000000000000008ull
43062306a36Sopenharmony_ci#define XCT_FUN_C		0x0000000000000004ull
43162306a36Sopenharmony_ci#define XCT_FUN_AL2		0x0000000000000002ull
43262306a36Sopenharmony_ci#define XCT_FUN_SE		0x0000000000000001ull
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci/* Function descriptor 8byte result fields */
43562306a36Sopenharmony_ci#define XCT_FUNRES_8B_CS_M	0x0000ffff00000000ull
43662306a36Sopenharmony_ci#define XCT_FUNRES_8B_CS_S	32
43762306a36Sopenharmony_ci#define XCT_FUNRES_8B_CRC_M	0x00000000ffffffffull
43862306a36Sopenharmony_ci#define XCT_FUNRES_8B_CRC_S	0
43962306a36Sopenharmony_ci
44062306a36Sopenharmony_ci/* Control descriptor fields */
44162306a36Sopenharmony_ci#define CTRL_CMD_T		0x8000000000000000ull
44262306a36Sopenharmony_ci#define CTRL_CMD_META_EVT	0x2000000000000000ull
44362306a36Sopenharmony_ci#define CTRL_CMD_O		0x0400000000000000ull
44462306a36Sopenharmony_ci#define CTRL_CMD_ETYPE_M	0x0038000000000000ull
44562306a36Sopenharmony_ci#define CTRL_CMD_ETYPE_EXT	0x0000000000000000ull
44662306a36Sopenharmony_ci#define CTRL_CMD_ETYPE_WSET	0x0020000000000000ull
44762306a36Sopenharmony_ci#define CTRL_CMD_ETYPE_WCLR	0x0028000000000000ull
44862306a36Sopenharmony_ci#define CTRL_CMD_ETYPE_SET	0x0030000000000000ull
44962306a36Sopenharmony_ci#define CTRL_CMD_ETYPE_CLR	0x0038000000000000ull
45062306a36Sopenharmony_ci#define CTRL_CMD_REG_M		0x000000000000007full
45162306a36Sopenharmony_ci#define CTRL_CMD_REG_S		0
45262306a36Sopenharmony_ci#define CTRL_CMD_REG(x)		((((long)(x)) << CTRL_CMD_REG_S) & \
45362306a36Sopenharmony_ci				 CTRL_CMD_REG_M)
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ci
45762306a36Sopenharmony_ci/* Prototypes for the shared DMA functions in the platform code. */
45862306a36Sopenharmony_ci
45962306a36Sopenharmony_ci/* DMA TX Channel type. Right now only limitations used are event types 0/1,
46062306a36Sopenharmony_ci * for event-triggered DMA transactions.
46162306a36Sopenharmony_ci */
46262306a36Sopenharmony_ci
46362306a36Sopenharmony_cienum pasemi_dmachan_type {
46462306a36Sopenharmony_ci	RXCHAN = 0,		/* Any RX chan */
46562306a36Sopenharmony_ci	TXCHAN = 1,		/* Any TX chan */
46662306a36Sopenharmony_ci	TXCHAN_EVT0 = 0x1001,	/* TX chan in event class 0 (chan 0-9) */
46762306a36Sopenharmony_ci	TXCHAN_EVT1 = 0x2001,	/* TX chan in event class 1 (chan 10-19) */
46862306a36Sopenharmony_ci};
46962306a36Sopenharmony_ci
47062306a36Sopenharmony_cistruct pasemi_dmachan {
47162306a36Sopenharmony_ci	int		 chno;		/* Channel number */
47262306a36Sopenharmony_ci	enum pasemi_dmachan_type chan_type;	/* TX / RX */
47362306a36Sopenharmony_ci	u64		*status;	/* Ptr to cacheable status */
47462306a36Sopenharmony_ci	int		 irq;		/* IRQ used by channel */
47562306a36Sopenharmony_ci	unsigned int	 ring_size;	/* size of allocated ring */
47662306a36Sopenharmony_ci	dma_addr_t	 ring_dma;	/* DMA address for ring */
47762306a36Sopenharmony_ci	u64		*ring_virt;	/* Virt address for ring */
47862306a36Sopenharmony_ci	void		*priv;		/* Ptr to start of client struct */
47962306a36Sopenharmony_ci};
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_ci/* Read/write the different registers in the I/O Bridge, Ethernet
48262306a36Sopenharmony_ci * and DMA Controller
48362306a36Sopenharmony_ci */
48462306a36Sopenharmony_ciextern unsigned int pasemi_read_iob_reg(unsigned int reg);
48562306a36Sopenharmony_ciextern void pasemi_write_iob_reg(unsigned int reg, unsigned int val);
48662306a36Sopenharmony_ci
48762306a36Sopenharmony_ciextern unsigned int pasemi_read_mac_reg(int intf, unsigned int reg);
48862306a36Sopenharmony_ciextern void pasemi_write_mac_reg(int intf, unsigned int reg, unsigned int val);
48962306a36Sopenharmony_ci
49062306a36Sopenharmony_ciextern unsigned int pasemi_read_dma_reg(unsigned int reg);
49162306a36Sopenharmony_ciextern void pasemi_write_dma_reg(unsigned int reg, unsigned int val);
49262306a36Sopenharmony_ci
49362306a36Sopenharmony_ci/* Channel management routines */
49462306a36Sopenharmony_ci
49562306a36Sopenharmony_ciextern void *pasemi_dma_alloc_chan(enum pasemi_dmachan_type type,
49662306a36Sopenharmony_ci				   int total_size, int offset);
49762306a36Sopenharmony_ciextern void pasemi_dma_free_chan(struct pasemi_dmachan *chan);
49862306a36Sopenharmony_ci
49962306a36Sopenharmony_ciextern void pasemi_dma_start_chan(const struct pasemi_dmachan *chan,
50062306a36Sopenharmony_ci				  const u32 cmdsta);
50162306a36Sopenharmony_ciextern int pasemi_dma_stop_chan(const struct pasemi_dmachan *chan);
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ci/* Common routines to allocate rings and buffers */
50462306a36Sopenharmony_ci
50562306a36Sopenharmony_ciextern int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size);
50662306a36Sopenharmony_ciextern void pasemi_dma_free_ring(struct pasemi_dmachan *chan);
50762306a36Sopenharmony_ci
50862306a36Sopenharmony_ciextern void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
50962306a36Sopenharmony_ci				  dma_addr_t *handle);
51062306a36Sopenharmony_ciextern void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
51162306a36Sopenharmony_ci				dma_addr_t *handle);
51262306a36Sopenharmony_ci
51362306a36Sopenharmony_ci/* Routines to allocate flags (events) for channel synchronization */
51462306a36Sopenharmony_ciextern int  pasemi_dma_alloc_flag(void);
51562306a36Sopenharmony_ciextern void pasemi_dma_free_flag(int flag);
51662306a36Sopenharmony_ciextern void pasemi_dma_set_flag(int flag);
51762306a36Sopenharmony_ciextern void pasemi_dma_clear_flag(int flag);
51862306a36Sopenharmony_ci
51962306a36Sopenharmony_ci/* Routines to allocate function engines */
52062306a36Sopenharmony_ciextern int  pasemi_dma_alloc_fun(void);
52162306a36Sopenharmony_ciextern void pasemi_dma_free_fun(int fun);
52262306a36Sopenharmony_ci
52362306a36Sopenharmony_ci/* Initialize the library, must be called before any other functions */
52462306a36Sopenharmony_ciextern int pasemi_dma_init(void);
52562306a36Sopenharmony_ci
52662306a36Sopenharmony_ci#endif /* ASM_PASEMI_DMA_H */
527