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