Home | History | Annotate | Line # | Download | only in ee
dmacreg.h revision 1.3.10.1
      1  1.3.10.1  yamt /*	$NetBSD: dmacreg.h,v 1.3.10.1 2014/05/22 11:40:02 yamt Exp $	*/
      2       1.1   uch 
      3       1.1   uch /*-
      4       1.1   uch  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5       1.1   uch  * All rights reserved.
      6       1.1   uch  *
      7       1.1   uch  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1   uch  * by UCHIYAMA Yasushi.
      9       1.1   uch  *
     10       1.1   uch  * Redistribution and use in source and binary forms, with or without
     11       1.1   uch  * modification, are permitted provided that the following conditions
     12       1.1   uch  * are met:
     13       1.1   uch  * 1. Redistributions of source code must retain the above copyright
     14       1.1   uch  *    notice, this list of conditions and the following disclaimer.
     15       1.1   uch  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1   uch  *    notice, this list of conditions and the following disclaimer in the
     17       1.1   uch  *    documentation and/or other materials provided with the distribution.
     18       1.1   uch  *
     19       1.1   uch  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.1   uch  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.1   uch  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.1   uch  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.1   uch  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.1   uch  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.1   uch  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.1   uch  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.1   uch  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.1   uch  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.1   uch  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1   uch  */
     31       1.1   uch 
     32       1.1   uch typedef u_int64_t dmatag_t;
     33       1.1   uch 
     34       1.1   uch #define DMAC_BLOCK_SIZE		16
     35       1.1   uch #define DMAC_SLICE_SIZE		128
     36       1.1   uch #define DMAC_TRANSFER_QWCMAX	0xffff
     37       1.1   uch 
     38       1.1   uch /* all register length are 32bit */
     39       1.1   uch #define DMAC_REGBASE		MIPS_PHYS_TO_KSEG1(0x10008000)
     40       1.1   uch #define DMAC_REGSIZE		0x00010000
     41       1.1   uch 
     42       1.1   uch /*
     43       1.1   uch  * DMAC common registers.
     44       1.1   uch  */
     45       1.1   uch #define D_CTRL_REG	MIPS_PHYS_TO_KSEG1(0x1000e000) /* DMA control */
     46       1.1   uch #define D_STAT_REG	MIPS_PHYS_TO_KSEG1(0x1000e010) /* interrupt status */
     47       1.1   uch #define D_PCR_REG	MIPS_PHYS_TO_KSEG1(0x1000e020) /* priority control */
     48       1.1   uch #define D_SQWC_REG	MIPS_PHYS_TO_KSEG1(0x1000e030) /* interleave size */
     49       1.1   uch #define D_RBOR_REG	MIPS_PHYS_TO_KSEG1(0x1000e040) /* ring buffer addr */
     50       1.1   uch #define D_RBSR_REG	MIPS_PHYS_TO_KSEG1(0x1000e050) /* ring buffer size */
     51       1.1   uch #define D_STADR_REG	MIPS_PHYS_TO_KSEG1(0x1000e060) /* stall address */
     52       1.1   uch #define D_ENABLER_REG	MIPS_PHYS_TO_KSEG1(0x1000f520) /* DMA enable (r) */
     53       1.1   uch #define D_ENABLEW_REG	MIPS_PHYS_TO_KSEG1(0x1000f590) /* DMA enable (w) */
     54       1.1   uch 
     55       1.1   uch /*
     56       1.1   uch  * Channel registers. (10ch)
     57       1.1   uch  */
     58       1.1   uch #define	DMA_CH_VIF0			0 /* to (priority 0) */
     59       1.1   uch #define	DMA_CH_VIF1			1 /* both */
     60       1.1   uch #define	DMA_CH_GIF			2 /* to */
     61       1.1   uch #define	DMA_CH_FROMIPU			3
     62       1.1   uch #define	DMA_CH_TOIPU			4
     63       1.1   uch #define	DMA_CH_SIF0			5 /* from */
     64       1.1   uch #define	DMA_CH_SIF1			6 /* to */
     65       1.1   uch #define	DMA_CH_SIF2			7 /* both (priority 1) */
     66       1.1   uch #define	DMA_CH_FROMSPR			8 /* burst channel */
     67       1.1   uch #define	DMA_CH_TOSPR			9 /* burst channel */
     68       1.1   uch #define DMA_CH_VALID(x)	(((x) >= 0) && ((x) <= 9))
     69       1.1   uch 
     70       1.1   uch #define D_CHCR_OFS		0x00
     71       1.1   uch #define D_MADR_OFS		0x10
     72       1.1   uch #define D_QWC_OFS		0x20
     73       1.1   uch #define D_TADR_OFS		0x30
     74       1.1   uch #define D_ASR0_OFS		0x40
     75       1.1   uch #define D_ASR1_OFS		0x50
     76       1.1   uch #define D_SADR_OFS		0x80
     77       1.1   uch 
     78       1.1   uch #define D0_REGBASE		MIPS_PHYS_TO_KSEG1(0x10008000)
     79       1.1   uch #define D1_REGBASE		MIPS_PHYS_TO_KSEG1(0x10009000)
     80       1.1   uch #define D2_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000a000)
     81       1.1   uch #define D3_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000b000)
     82       1.1   uch #define D4_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000b400)
     83       1.1   uch #define D5_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000c000)
     84       1.1   uch #define D6_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000c400)
     85       1.1   uch #define D7_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000c800)
     86       1.1   uch #define D8_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000d000)
     87       1.1   uch #define D9_REGBASE		MIPS_PHYS_TO_KSEG1(0x1000d400)
     88       1.1   uch 
     89       1.1   uch #define D_CHCR_REG(base)	(base)
     90       1.1   uch #define D_MADR_REG(base)	(base + D_MADR_OFS)
     91       1.1   uch #define D_QWC_REG(base)		(base + D_QWC_OFS)
     92       1.1   uch #define D_TADR_REG(base)	(base + D_TADR_OFS)
     93       1.1   uch #define D_ASR0_REG(base)	(base + D_ASR0_OFS)
     94       1.1   uch #define D_ASR1_REG(base)	(base + D_ASR1_OFS)
     95       1.1   uch #define D_SADR_REG(base)	(base + D_SADR_OFS)
     96       1.1   uch 
     97       1.1   uch #define D0_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x10008000)
     98       1.1   uch #define D0_MADR_REG		MIPS_PHYS_TO_KSEG1(0x10008010)
     99       1.1   uch #define D0_QWC_REG		MIPS_PHYS_TO_KSEG1(0x10008020)
    100       1.1   uch #define D0_TADR_REG		MIPS_PHYS_TO_KSEG1(0x10008030)
    101       1.1   uch #define D0_ASR0_REG		MIPS_PHYS_TO_KSEG1(0x10008040)
    102       1.1   uch #define D0_ASR1_REG		MIPS_PHYS_TO_KSEG1(0x10008050)
    103       1.1   uch 
    104       1.1   uch #define D1_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x10009000)
    105       1.1   uch #define D1_MADR_REG		MIPS_PHYS_TO_KSEG1(0x10009010)
    106       1.1   uch #define D1_QWC_REG		MIPS_PHYS_TO_KSEG1(0x10009020)
    107       1.1   uch #define D1_TADR_REG		MIPS_PHYS_TO_KSEG1(0x10009030)
    108       1.1   uch #define D1_ASR0_REG		MIPS_PHYS_TO_KSEG1(0x10009040)
    109       1.1   uch #define D1_ASR1_REG		MIPS_PHYS_TO_KSEG1(0x10009050)
    110       1.1   uch 
    111       1.1   uch #define D2_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000a000)
    112       1.1   uch #define D2_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000a010)
    113       1.1   uch #define D2_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000a020)
    114       1.1   uch #define D2_TADR_REG		MIPS_PHYS_TO_KSEG1(0x1000a030)
    115       1.1   uch #define D2_ASR0_REG		MIPS_PHYS_TO_KSEG1(0x1000a040)
    116       1.1   uch #define D2_ASR1_REG		MIPS_PHYS_TO_KSEG1(0x1000a050)
    117       1.1   uch 
    118       1.1   uch #define D3_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000b000)
    119       1.1   uch #define D3_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000b010)
    120       1.1   uch #define D3_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000b020)
    121       1.1   uch 
    122       1.1   uch #define D4_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000b400)
    123       1.1   uch #define D4_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000b410)
    124       1.1   uch #define D4_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000b420)
    125       1.1   uch #define D4_TADR_REG		MIPS_PHYS_TO_KSEG1(0x1000b430)
    126       1.1   uch 
    127       1.1   uch #define D5_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000c000)
    128       1.1   uch #define D5_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000c010)
    129       1.1   uch #define D5_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000c020)
    130       1.1   uch 
    131       1.1   uch #define D6_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000c400)
    132       1.1   uch #define D6_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000c410)
    133       1.1   uch #define D6_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000c420)
    134       1.1   uch #define D6_TADR_REG		MIPS_PHYS_TO_KSEG1(0x1000c430)
    135       1.1   uch 
    136       1.1   uch #define D7_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000c800)
    137       1.1   uch #define D7_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000c810)
    138       1.1   uch #define D7_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000c820)
    139       1.1   uch 
    140       1.1   uch #define D8_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000d000)
    141       1.1   uch #define D8_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000d010)
    142       1.1   uch #define D8_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000d020)
    143       1.1   uch #define D8_SADR_REG		MIPS_PHYS_TO_KSEG1(0x1000d080)
    144       1.1   uch 
    145       1.1   uch #define D9_CHCR_REG		MIPS_PHYS_TO_KSEG1(0x1000d400)
    146       1.1   uch #define D9_MADR_REG		MIPS_PHYS_TO_KSEG1(0x1000d410)
    147       1.1   uch #define D9_QWC_REG		MIPS_PHYS_TO_KSEG1(0x1000d420)
    148       1.1   uch #define D9_TADR_REG		MIPS_PHYS_TO_KSEG1(0x1000d430)
    149       1.1   uch #define D9_SADR_REG		MIPS_PHYS_TO_KSEG1(0x1000d480)
    150       1.1   uch 
    151       1.1   uch /*
    152       1.1   uch  * DMA control
    153       1.1   uch  */
    154       1.1   uch #define D_CTRL_DMAE		0x00000001 /* all DMA enable/disable */
    155       1.1   uch #define D_CTRL_RELE		0x00000002 /* Cycle stealing on/off */
    156       1.1   uch /* Memory FIFO drain control */
    157       1.1   uch #define D_CTRL_MFD_MASK		0x3
    158       1.1   uch #define D_CTRL_MFD_SHIFT	2
    159       1.1   uch #define D_CTRL_MFD(x)							\
    160       1.1   uch 	(((x) >> D_CTRL_MFD_SHIFT) & D_CTRL_MFD_MASK)
    161       1.1   uch #define D_CTRL_MFD_CLR(x)						\
    162       1.1   uch 	((x) & ~(D_CTRL_MFD_MASK << D_CTRL_MFD_SHIFT))
    163       1.1   uch #define D_CTRL_MFD_SET(x, val)						\
    164       1.1   uch 	((x) | (((val) << D_CTRL_MFD_SHIFT) &				\
    165       1.1   uch 	(D_CTRL_MFD_MASK << D_CTRL_MFD_SHIFT)))
    166       1.1   uch #define D_CTRL_MFD_DISABLE	0
    167       1.1   uch #define D_CTRL_MFD_VIF1		2
    168       1.1   uch #define D_CTRL_MFD_GIF		3
    169       1.1   uch 
    170       1.1   uch /* Stall control source channel */
    171       1.1   uch #define D_CTRL_STS_MASK		0x3
    172       1.1   uch #define D_CTRL_STS_SHIFT	4
    173       1.1   uch #define D_CTRL_STS(x)							\
    174       1.1   uch 	(((x) >> D_CTRL_STS_SHIFT) & D_CTRL_STS_MASK)
    175       1.1   uch #define D_CTRL_STS_CLR(x)						\
    176       1.1   uch 	((x) & ~(D_CTRL_STS_MASK << D_CTRL_STS_SHIFT))
    177       1.1   uch #define D_CTRL_STS_SET(x, val)						\
    178       1.1   uch 	((x) | (((val) << D_CTRL_STS_SHIFT) &				\
    179       1.1   uch 	(D_CTRL_STS_MASK << D_CTRL_STS_SHIFT)))
    180       1.1   uch #define D_CTRL_STS_NONE		0
    181       1.1   uch #define D_CTRL_STS_SIF0		1
    182       1.1   uch #define D_CTRL_STS_FROMSPR	2
    183       1.1   uch #define D_CTRL_STS_FROMIPU	3
    184       1.1   uch 
    185       1.1   uch /* Stall control drain channel */
    186       1.1   uch #define D_CTRL_STD_MASK		0x3
    187       1.1   uch #define D_CTRL_STD_SHIFT	6
    188       1.1   uch #define D_CTRL_STD(x)							\
    189       1.1   uch 	(((x) >> D_CTRL_STD_SHIFT) & D_CTRL_STD_MASK)
    190       1.1   uch #define D_CTRL_STD_CLR(x)						\
    191       1.1   uch 	((x) & ~(D_CTRL_STD_MASK << D_CTRL_STD_SHIFT))
    192       1.1   uch #define D_CTRL_STD_SET(x, val)						\
    193       1.1   uch 	((x) | (((val) << D_CTRL_STD_SHIFT) &				\
    194       1.1   uch 	(D_CTRL_STD_MASK << D_CTRL_STD_SHIFT)))
    195       1.1   uch #define D_CTRL_STD_NONE		0
    196       1.1   uch #define D_CTRL_STD_VIF1		1
    197       1.1   uch #define D_CTRL_STD_GIF		2
    198       1.1   uch #define D_CTRL_STD_SIF1		3
    199       1.1   uch 
    200       1.1   uch /*
    201       1.1   uch  * Release cycle
    202       1.1   uch  *   for burst channel Cycle steanling on mode only.
    203       1.1   uch  */
    204       1.1   uch #define D_CTRL_RCYC_MASK		0x7
    205       1.1   uch #define D_CTRL_RCYC_SHIFT		8
    206       1.1   uch #define D_CTRL_RCYC(x)							\
    207       1.1   uch 	(((x) >> D_CTRL_RCYC_SHIFT) & D_CTRL_RCYC_MASK)
    208       1.1   uch #define D_CTRL_RCYC_CLR(x)						\
    209       1.1   uch 	((x) & ~(D_CTRL_RCYC_MASK << D_CTRL_RCYC_SHIFT))
    210       1.1   uch #define D_CTRL_RCYC_SET(x, val)						\
    211       1.1   uch 	((x) | (((val) << D_CTRL_RCYC_SHIFT) &				\
    212       1.1   uch 	(D_CTRL_RCYC_MASK << D_CTRL_RCYC_SHIFT)))
    213       1.1   uch #define D_CTRL_RCYC_CYCLE(x)		(8 << (x))
    214       1.1   uch 
    215       1.1   uch /*
    216       1.1   uch  * Interrupt status register (write clear/invert)
    217       1.1   uch  *   DMAC interrupt line connected to MIPS HwINT1
    218       1.1   uch  */
    219       1.1   uch /* MFIFO empty interrupt enable */
    220       1.1   uch #define D_STAT_MEIM		0x40000000
    221       1.1   uch /* DMA stall interrupt enable */
    222       1.1   uch #define D_STAT_SIM		0x20000000
    223       1.1   uch /* Channel interrupt enable */
    224       1.1   uch #define D_STAT_CIM_MASK		0x3ff
    225       1.1   uch #define D_STAT_CIM_SHIFT	16
    226       1.1   uch #define D_STAT_CIM(x)		(((x) >> D_STAT_CIM_SHIFT) & D_STAT_CIM_MASK)
    227       1.1   uch #define D_STAT_CIM_BIT(x)	((1 << (x)) << D_STAT_CIM_SHIFT)
    228       1.1   uch #define D_STAT_CIM9		0x02000000
    229       1.1   uch #define D_STAT_CIM8		0x01000000
    230       1.1   uch #define D_STAT_CIM7		0x00800000
    231       1.1   uch #define D_STAT_CIM6		0x00400000
    232       1.1   uch #define D_STAT_CIM5		0x00200000
    233       1.1   uch #define D_STAT_CIM4		0x00100000
    234       1.1   uch #define D_STAT_CIM3		0x00080000
    235       1.1   uch #define D_STAT_CIM2		0x00040000
    236       1.1   uch #define D_STAT_CIM1		0x00020000
    237       1.1   uch #define D_STAT_CIM0		0x00010000
    238       1.1   uch /* BUSERR interrupt status */
    239       1.1   uch #define D_STAT_BEIS		0x00008000
    240       1.1   uch /* MFIFO empty interrupt status */
    241       1.1   uch #define D_STAT_MEIS		0x00004000
    242       1.1   uch /* DMA stall interrupt status */
    243       1.1   uch #define D_STAT_SIS		0x00002000
    244       1.1   uch /* Channel interrupt status */
    245       1.1   uch #define D_STAT_CIS_MASK		0x3ff
    246       1.1   uch #define D_STAT_CIS_SHIFT	0
    247       1.1   uch #define D_STAT_CIS_BIT(x)	(1 << (x))
    248       1.1   uch #define D_STAT_CIS9		0x00000200
    249       1.1   uch #define D_STAT_CIS8		0x00000100
    250       1.1   uch #define D_STAT_CIS7		0x00000080
    251       1.1   uch #define D_STAT_CIS6		0x00000040
    252       1.1   uch #define D_STAT_CIS5		0x00000020
    253       1.1   uch #define D_STAT_CIS4		0x00000010
    254       1.1   uch #define D_STAT_CIS3		0x00000008
    255       1.1   uch #define D_STAT_CIS2		0x00000004
    256       1.1   uch #define D_STAT_CIS1		0x00000002
    257       1.1   uch #define D_STAT_CIS0		0x00000001
    258       1.1   uch 
    259       1.1   uch /*
    260       1.1   uch  * Priority control register.
    261       1.1   uch  */
    262       1.1   uch /* Priority control enable */
    263       1.1   uch #define D_PCR_PCE		0x80000000
    264       1.1   uch /* Channel DMA enable (packet priority control enable) */
    265       1.1   uch #define D_PCR_CDE_MASK		0x3ff
    266       1.1   uch #define D_PCR_CDE_SHIFT		16
    267       1.1   uch #define D_PCR_CDE(x)							\
    268       1.1   uch 	(((x) >> D_PCR_CDE_SHIFT) & D_PCR_CDE_MASK)
    269       1.1   uch #define D_PCR_CDE_CLR(x)						\
    270       1.1   uch 	((x) & ~(D_PCR_CDE_MASK << D_PCR_CDE_SHIFT))
    271       1.1   uch #define D_PCR_CDE_SET(x, val)						\
    272       1.1   uch 	((x) | (((val) << D_PCR_CDE_SHIFT) &				\
    273       1.1   uch 	(D_PCR_CDE_MASK << D_PCR_CDE_SHIFT)))
    274       1.1   uch #define D_PCR_CDE9		0x02000000
    275       1.1   uch #define D_PCR_CDE8		0x01000000
    276       1.1   uch #define D_PCR_CDE7		0x00800000
    277       1.1   uch #define D_PCR_CDE6		0x00400000
    278       1.1   uch #define D_PCR_CDE5		0x00200000
    279       1.1   uch #define D_PCR_CDE4		0x00100000
    280       1.1   uch #define D_PCR_CDE3		0x00080000
    281       1.1   uch #define D_PCR_CDE2		0x00040000
    282       1.1   uch #define D_PCR_CDE1		0x00020000
    283       1.1   uch #define D_PCR_CDE0		0x00010000
    284       1.1   uch /* COP control (interrupt status connect to CPCOND[0] or not) */
    285       1.1   uch #define D_PCR_CPC_MASK		0x3ff
    286       1.1   uch #define D_PCR_CPC_SHIFT		0
    287       1.1   uch #define D_PCR_CPC(x)		((x) & D_PCR_CPC_MASK)
    288       1.1   uch #define D_PCR_CPC_CLR(x)	((x) & ~D_PCR_CPC_MASK)
    289       1.1   uch #define D_PCR_CPC_SET(x, val)	((x) | ((val) & D_PCR_CPC_MASK))
    290       1.1   uch #define D_PCR_CPC_BIT(x)	(1 << (x))
    291       1.1   uch #define D_PCR_CPC9		0x00000200
    292       1.1   uch #define D_PCR_CPC8		0x00000100
    293       1.1   uch #define D_PCR_CPC7		0x00000080
    294       1.1   uch #define D_PCR_CPC6		0x00000040
    295       1.1   uch #define D_PCR_CPC5		0x00000020
    296       1.1   uch #define D_PCR_CPC4		0x00000010
    297       1.1   uch #define D_PCR_CPC3		0x00000008
    298       1.1   uch #define D_PCR_CPC2		0x00000004
    299       1.1   uch #define D_PCR_CPC1		0x00000002
    300       1.1   uch #define D_PCR_CPC0		0x00000001
    301       1.1   uch 
    302       1.1   uch /*
    303       1.1   uch  * Interleave size register
    304       1.1   uch  */
    305       1.1   uch /* Transfer quadword counter */
    306       1.1   uch #define D_SQWC_TQWC_MASK		0xff
    307       1.1   uch #define D_SQWC_TQWC_SHIFT		16
    308       1.1   uch #define D_SQWC_TQWC(x)							\
    309       1.1   uch 	(((x) >> D_SQWC_TQWC_SHIFT) & D_SQWC_TQWC_MASK)
    310       1.1   uch #define D_SQWC_TQWC_CLR(x)						\
    311       1.1   uch 	((x) & ~(D_SQWC_TQWC_MASK << D_SQWC_TQWC_SHIFT))
    312       1.1   uch #define D_SQWC_TQWC_SET(x, val)						\
    313       1.1   uch 	((x) | (((val) << D_SQWC_TQWC_SHIFT) &				\
    314       1.1   uch 	(D_SQWC_TQWC_MASK << D_SQWC_TQWC_SHIFT)))
    315       1.1   uch /* Skip quadword counter */
    316       1.1   uch #define D_SQWC_SQWC_MASK		0xff
    317       1.1   uch #define D_SQWC_SQWC_SHIFT		0
    318       1.1   uch #define D_SQWC_SQWC(x)							\
    319       1.1   uch 	(((x) >> D_SQWC_SQWC_SHIFT) & D_SQWC_SQWC_MASK)
    320       1.1   uch #define D_SQWC_SQWC_CLR(x)						\
    321       1.1   uch 	((x) & ~(D_SQWC_SQWC_MASK << D_SQWC_SQWC_SHIFT))
    322       1.1   uch #define D_SQWC_SQWC_SET(x, val)						\
    323       1.1   uch 	((x) | (((val) << D_SQWC_SQWC_SHIFT) &				\
    324       1.1   uch 	(D_SQWC_SQWC_MASK << D_SQWC_SQWC_SHIFT)))
    325       1.1   uch 
    326       1.1   uch /*
    327       1.1   uch  * Ring buffer address register
    328       1.1   uch  *   16byte alignment address [30:4]
    329       1.1   uch  */
    330       1.1   uch 
    331       1.1   uch /*
    332       1.1   uch  * Ring buffer size register
    333       1.1   uch  *   must be 2 ** n qword. [30:4]
    334       1.1   uch  */
    335       1.1   uch 
    336       1.1   uch /*
    337       1.1   uch  * Stall address register
    338       1.1   uch  *   [30:0] (qword alignment)
    339       1.1   uch  */
    340       1.1   uch 
    341       1.1   uch /*
    342       1.1   uch  * DMA suspend register
    343       1.1   uch  */
    344       1.1   uch #define	D_ENABLE_SUSPEND		0x00010000
    345       1.1   uch 
    346       1.1   uch 
    347       1.1   uch /*
    348       1.1   uch  *	Channel specific register.
    349       1.1   uch  */
    350       1.1   uch 
    351       1.1   uch /* CHANNEL CONTROL REGISTER */
    352       1.1   uch /* upper 16bit of DMA tag last read. */
    353       1.1   uch #define D_CHCR_TAG_MASK		0xff
    354       1.1   uch #define D_CHCR_TAG_SHIFT	16
    355       1.1   uch #define D_CHCR_TAG(x)							\
    356       1.1   uch 	(((x) >> D_CHCR_TAG_SHIFT) & D_CHCR_TAG_MASK)
    357       1.1   uch #define D_CHCR_TAG_CLR(x)						\
    358       1.1   uch 	((x) & ~(D_CHCR_TAG_MASK << D_CHCR_TAG_SHIFT))
    359       1.1   uch #define D_CHCR_TAG_SET(x, val)						\
    360       1.1   uch 	((x) | (((val) << D_CHCR_TAG_SHIFT) &				\
    361       1.1   uch 	(D_CHCR_TAG_MASK << D_CHCR_TAG_SHIFT)))
    362       1.1   uch /* DMA start */
    363       1.1   uch #define D_CHCR_STR			0x00000100
    364       1.1   uch /* Tag interrupt enable (IRQ bit of DMAtag) */
    365       1.1   uch #define D_CHCR_TIE			0x00000080
    366       1.1   uch /* Tag transfer enable (Source chain mode only) */
    367       1.1   uch #define D_CHCR_TTE			0x00000040
    368       1.1   uch /* Address stack pointer */
    369       1.1   uch #define D_CHCR_ASP_MASK		0x3
    370       1.1   uch #define D_CHCR_ASP_SHIFT	4
    371       1.1   uch #define D_CHCR_ASP(x)							\
    372       1.1   uch 	(((x) >> D_CHCR_ASP_SHIFT) & D_CHCR_ASP_MASK)
    373       1.1   uch #define D_CHCR_ASP_CLR(x)						\
    374       1.1   uch 	((x) & ~(D_CHCR_ASP_MASK << D_CHCR_ASP_SHIFT))
    375       1.1   uch #define D_CHCR_ASP_SET(x, val)						\
    376       1.1   uch 	((x) | (((val) << D_CHCR_ASP_SHIFT) &				\
    377       1.1   uch 	(D_CHCR_ASP_MASK << D_CHCR_ASP_SHIFT)))
    378       1.1   uch #define D_CHCR_ASP_PUSHED_NONE	0
    379       1.1   uch #define D_CHCR_ASP_PUSHED_1	1
    380       1.1   uch #define D_CHCR_ASP_PUSHED_2	2
    381       1.1   uch /* Logical transfer mode */
    382       1.1   uch #define D_CHCR_MOD_MASK		0x3
    383       1.1   uch #define D_CHCR_MOD_SHIFT	2
    384       1.1   uch #define D_CHCR_MOD(x)							\
    385       1.1   uch 	(((x) >> D_CHCR_MOD_SHIFT) & D_CHCR_MOD_MASK)
    386       1.1   uch #define D_CHCR_MOD_CLR(x)						\
    387       1.1   uch 	((x) & ~(D_CHCR_MOD_MASK << D_CHCR_MOD_SHIFT))
    388       1.1   uch #define D_CHCR_MOD_SET(x, val)						\
    389       1.1   uch 	((x) | (((val) << D_CHCR_MOD_SHIFT) &				\
    390       1.1   uch 	(D_CHCR_MOD_MASK << D_CHCR_MOD_SHIFT)))
    391       1.1   uch #define D_CHCR_MOD_NORMAL	0
    392       1.1   uch #define D_CHCR_MOD_CHAIN	1
    393       1.1   uch #define D_CHCR_MOD_INTERLEAVE	2
    394       1.1   uch /*
    395       1.1   uch  * DMA transfer direction (1 ... from Memory, 0 ... to Memory)
    396       1.1   uch  *   (VIF1, SIF2 only. i.e. `both'-direction channel requires this)
    397       1.1   uch  */
    398       1.1   uch #define D_CHCR_DIR			0x00000001
    399       1.1   uch 
    400       1.1   uch /*
    401       1.1   uch  * TRANSFER ADDRESS REGISTER (D-RAM address)
    402       1.1   uch  *   16 byte alignment. In FROMSPR, TOSPR channel, D_MADR_SPR always 0
    403       1.1   uch  */
    404       1.1   uch #define D_MADR_SPR			0x80000000
    405       1.1   uch 
    406       1.1   uch /*
    407       1.1   uch  * TAG ADDRESS REGISTER (next tag address)
    408       1.1   uch  *   16 byte alignment.
    409       1.1   uch  */
    410       1.1   uch #define D_TADR_SPR			0x80000000
    411       1.1   uch 
    412       1.1   uch /*
    413       1.1   uch  * TAG ADDRESS STACK REGISTER (2 stage)
    414       1.1   uch  *   16 byte alignment.
    415       1.1   uch  */
    416       1.1   uch #define D_ASR_SPR			0x80000000
    417       1.1   uch 
    418       1.1   uch /*
    419       1.1   uch  * SPR TRANSFER ADDRESS REGISTER (SPR address)
    420       1.1   uch  *   16 byte alignment. FROMSPR, TOSPR only.
    421       1.1   uch  */
    422       1.1   uch #define D_SADR_MASK		0x3fff
    423       1.1   uch #define D_SADR_SHIFT		0
    424       1.1   uch #define D_SADR(x)							\
    425       1.1   uch 	((u_int32_t)(x) & D_SADR_MASK)
    426       1.1   uch /*
    427       1.1   uch  * TRANSFER SIZE REGISTER
    428       1.1   uch  *   min 16 byte to max 1 Mbyte.
    429       1.1   uch  */
    430       1.1   uch #define D_QWC_MASK		0xffff
    431       1.1   uch #define D_QWC_SHIFT		0
    432       1.1   uch #define D_QWC(x)	(((x) >> D_QWC_SHIFT) & D_QWC_MASK)
    433       1.1   uch #define D_QWC_CLR(x)	((x) & ~(D_QWC_MASK << D_QWC_SHIFT))
    434       1.1   uch #define D_QWC_SET(x, val)						\
    435       1.1   uch 	((x) | (((val) << D_QWC_SHIFT) & D_QWC_MASK << D_QWC_SHIFT))
    436       1.1   uch 
    437       1.1   uch /*
    438       1.1   uch  * Source/Destination Chain Tag definition.
    439       1.1   uch  *  SC ... VIF0, VIF1, GIF, toIPU, SIF1, toSPR
    440       1.1   uch  *  DC ... SIF0, fromSPR
    441       1.1   uch  */
    442       1.1   uch /*
    443       1.1   uch  * DMA address
    444       1.1   uch  *  At least, 16byte align.
    445       1.1   uch  *  but 64byte align is recommended. because EE D-cash line size is 64byte.
    446       1.1   uch  *  To gain maximum DMA speed, use 128 byte align.
    447       1.1   uch  */
    448       1.1   uch #define DMATAG_ADDR_MASK		0xffffffff
    449       1.1   uch #define DMATAG_ADDR_SHIFT		32
    450       1.1   uch #define DMATAG_ADDR(x)							\
    451       1.1   uch 	((u_int32_t)(((x) >> DMATAG_ADDR_SHIFT) & DMATAG_ADDR_MASK))
    452       1.1   uch #define DMATAG_ADDR_SET(x, val)						\
    453       1.1   uch 	((dmatag_t)(x) | (((dmatag_t)(val)) << DMATAG_ADDR_SHIFT))
    454       1.1   uch 
    455       1.1   uch #define DMATAG_ADDR32_INVALID(x)	((x) & 0xf) /* 16byte alignment */
    456       1.1   uch 
    457       1.1   uch /*
    458       1.1   uch  * DMA controller command
    459       1.1   uch  */
    460       1.1   uch #define DMATAG_CMD_MASK			0xffffffff
    461       1.1   uch #define DMATAG_CMD_SHIFT		0
    462       1.1   uch #define DMATAG_CMD(x)							\
    463       1.1   uch 	((u_int32_t)((x) & DMATAG_CMD_MASK))
    464       1.1   uch 
    465       1.1   uch #define DMATAG_CMD_IRQ			0x80000000
    466       1.1   uch 
    467       1.1   uch #define DMATAG_CMD_ID_MASK		0x7
    468       1.1   uch #define DMATAG_CMD_ID_SHIFT		28
    469       1.1   uch #define DMATAG_CMD_ID(x)						\
    470       1.1   uch 	(((x) >> DMATAG_CMD_ID_SHIFT) & DMATAG_CMD_ID_MASK)
    471       1.1   uch #define DMATAG_CMD_ID_CLR(x)						\
    472       1.1   uch 	((x) & ~(DMATAG_CMD_ID_MASK <<	DMATAG_CMD_ID_SHIFT))
    473       1.1   uch #define DMATAG_CMD_ID_SET(x, val)					\
    474       1.1   uch 	((x) | (((val) << DMATAG_CMD_ID_SHIFT) &			\
    475       1.1   uch 	(DMATAG_CMD_ID_MASK << DMATAG_CMD_ID_SHIFT)))
    476       1.1   uch #define DMATAG_CMD_SCID_REFE		0
    477       1.1   uch #define DMATAG_CMD_SCID_CNT		1
    478       1.1   uch #define DMATAG_CMD_SCID_NEXT		2
    479       1.1   uch #define DMATAG_CMD_SCID_REF		3
    480       1.1   uch #define DMATAG_CMD_SCID_REFS		4 /* VIF1, GIF, SIF1 only */
    481       1.1   uch #define DMATAG_CMD_SCID_CALL		5 /* VIF0, VIF1, GIF only */
    482       1.1   uch #define DMATAG_CMD_SCID_RET		6 /* VIF0, VIF1, GIF only */
    483       1.1   uch #define DMATAG_CMD_SCID_END		7
    484       1.1   uch 
    485       1.1   uch #define DMATAG_CMD_DCID_CNTS		0 /* SIF0, fromSPR only */
    486       1.1   uch #define DMATAG_CMD_DCID_CNT		1
    487       1.1   uch #define DMATAG_CMD_DCID_END		7
    488       1.1   uch 
    489       1.1   uch #define DMATAG_CMD_PCE_MASK		0x3
    490       1.1   uch #define DMATAG_CMD_PCE_SHIFT		26
    491       1.1   uch #define DMATAG_CMD_PCE(x)						\
    492       1.1   uch 	(((x) >> DMATAG_CMD_PCE_SHIFT) & DMATAG_CMD_PCE_MASK)
    493       1.1   uch #define DMATAG_CMD_PCE_CLR(x)						\
    494       1.1   uch 	((x) & ~(DMATAG_CMD_PCE_MASK <<	DMATAG_CMD_PCE_SHIFT))
    495       1.1   uch #define DMATAG_CMD_PCE_SET(x, val)					\
    496       1.1   uch 	((x) | (((val) << DMATAG_CMD_PCE_SHIFT) &			\
    497       1.1   uch 	(DMATAG_CMD_PCE_MASK << DMATAG_CMD_PCE_SHIFT)))
    498       1.1   uch #define DMATAG_CMD_PCE_NONE		0
    499       1.1   uch #define DMATAG_CMD_PCE_DISABLE		2
    500       1.1   uch #define DMATAG_CMD_PCE_ENABLE		3
    501       1.1   uch 
    502       1.1   uch #define DMATAG_CMD_QWC_MASK		0xffff
    503       1.1   uch #define DMATAG_CMD_QWC_SHIFT		0
    504       1.1   uch #define DMATAG_CMD_QWC(x)						\
    505       1.1   uch 	(((x) >> DMATAG_CMD_QWC_SHIFT) & DMATAG_CMD_QWC_MASK)
    506       1.1   uch #define DMATAG_CMD_QWC_CLR(x)						\
    507       1.1   uch 	((x) & ~(DMATAG_CMD_QWC_MASK <<	DMATAG_CMD_QWC_SHIFT))
    508       1.1   uch #define DMATAG_CMD_QWC_SET(x, val)					\
    509       1.1   uch 	((x) | (((val) << DMATAG_CMD_QWC_SHIFT) &			\
    510       1.1   uch 	(DMATAG_CMD_QWC_MASK << DMATAG_CMD_QWC_SHIFT)))
    511