xref: /kernel/linux/linux-6.6/sound/soc/fsl/fsl_dma.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * mpc8610-pcm.h - ALSA PCM interface for the Freescale MPC8610 SoC
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef _MPC8610_PCM_H
762306a36Sopenharmony_ci#define _MPC8610_PCM_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_cistruct ccsr_dma {
1062306a36Sopenharmony_ci	u8 res0[0x100];
1162306a36Sopenharmony_ci	struct ccsr_dma_channel {
1262306a36Sopenharmony_ci		__be32 mr;      /* Mode register */
1362306a36Sopenharmony_ci		__be32 sr;      /* Status register */
1462306a36Sopenharmony_ci		__be32 eclndar; /* Current link descriptor extended addr reg */
1562306a36Sopenharmony_ci		__be32 clndar;  /* Current link descriptor address register */
1662306a36Sopenharmony_ci		__be32 satr;    /* Source attributes register */
1762306a36Sopenharmony_ci		__be32 sar;     /* Source address register */
1862306a36Sopenharmony_ci		__be32 datr;    /* Destination attributes register */
1962306a36Sopenharmony_ci		__be32 dar;     /* Destination address register */
2062306a36Sopenharmony_ci		__be32 bcr;     /* Byte count register */
2162306a36Sopenharmony_ci		__be32 enlndar; /* Next link descriptor extended address reg */
2262306a36Sopenharmony_ci		__be32 nlndar;  /* Next link descriptor address register */
2362306a36Sopenharmony_ci		u8 res1[4];
2462306a36Sopenharmony_ci		__be32 eclsdar; /* Current list descriptor extended addr reg */
2562306a36Sopenharmony_ci		__be32 clsdar;  /* Current list descriptor address register */
2662306a36Sopenharmony_ci		__be32 enlsdar; /* Next list descriptor extended address reg */
2762306a36Sopenharmony_ci		__be32 nlsdar;  /* Next list descriptor address register */
2862306a36Sopenharmony_ci		__be32 ssr;     /* Source stride register */
2962306a36Sopenharmony_ci		__be32 dsr;     /* Destination stride register */
3062306a36Sopenharmony_ci		u8 res2[0x38];
3162306a36Sopenharmony_ci	} channel[4];
3262306a36Sopenharmony_ci	__be32 dgsr;
3362306a36Sopenharmony_ci};
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define CCSR_DMA_MR_BWC_DISABLED	0x0F000000
3662306a36Sopenharmony_ci#define CCSR_DMA_MR_BWC_SHIFT   	24
3762306a36Sopenharmony_ci#define CCSR_DMA_MR_BWC_MASK    	0x0F000000
3862306a36Sopenharmony_ci#define CCSR_DMA_MR_BWC(x) \
3962306a36Sopenharmony_ci	((ilog2(x) << CCSR_DMA_MR_BWC_SHIFT) & CCSR_DMA_MR_BWC_MASK)
4062306a36Sopenharmony_ci#define CCSR_DMA_MR_EMP_EN      	0x00200000
4162306a36Sopenharmony_ci#define CCSR_DMA_MR_EMS_EN      	0x00040000
4262306a36Sopenharmony_ci#define CCSR_DMA_MR_DAHTS_MASK  	0x00030000
4362306a36Sopenharmony_ci#define CCSR_DMA_MR_DAHTS_1     	0x00000000
4462306a36Sopenharmony_ci#define CCSR_DMA_MR_DAHTS_2     	0x00010000
4562306a36Sopenharmony_ci#define CCSR_DMA_MR_DAHTS_4     	0x00020000
4662306a36Sopenharmony_ci#define CCSR_DMA_MR_DAHTS_8     	0x00030000
4762306a36Sopenharmony_ci#define CCSR_DMA_MR_SAHTS_MASK  	0x0000C000
4862306a36Sopenharmony_ci#define CCSR_DMA_MR_SAHTS_1     	0x00000000
4962306a36Sopenharmony_ci#define CCSR_DMA_MR_SAHTS_2     	0x00004000
5062306a36Sopenharmony_ci#define CCSR_DMA_MR_SAHTS_4     	0x00008000
5162306a36Sopenharmony_ci#define CCSR_DMA_MR_SAHTS_8     	0x0000C000
5262306a36Sopenharmony_ci#define CCSR_DMA_MR_DAHE		0x00002000
5362306a36Sopenharmony_ci#define CCSR_DMA_MR_SAHE		0x00001000
5462306a36Sopenharmony_ci#define CCSR_DMA_MR_SRW 		0x00000400
5562306a36Sopenharmony_ci#define CCSR_DMA_MR_EOSIE       	0x00000200
5662306a36Sopenharmony_ci#define CCSR_DMA_MR_EOLNIE      	0x00000100
5762306a36Sopenharmony_ci#define CCSR_DMA_MR_EOLSIE      	0x00000080
5862306a36Sopenharmony_ci#define CCSR_DMA_MR_EIE 		0x00000040
5962306a36Sopenharmony_ci#define CCSR_DMA_MR_XFE 		0x00000020
6062306a36Sopenharmony_ci#define CCSR_DMA_MR_CDSM_SWSM   	0x00000010
6162306a36Sopenharmony_ci#define CCSR_DMA_MR_CA  		0x00000008
6262306a36Sopenharmony_ci#define CCSR_DMA_MR_CTM 		0x00000004
6362306a36Sopenharmony_ci#define CCSR_DMA_MR_CC  		0x00000002
6462306a36Sopenharmony_ci#define CCSR_DMA_MR_CS  		0x00000001
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#define CCSR_DMA_SR_TE  		0x00000080
6762306a36Sopenharmony_ci#define CCSR_DMA_SR_CH  		0x00000020
6862306a36Sopenharmony_ci#define CCSR_DMA_SR_PE  		0x00000010
6962306a36Sopenharmony_ci#define CCSR_DMA_SR_EOLNI       	0x00000008
7062306a36Sopenharmony_ci#define CCSR_DMA_SR_CB  		0x00000004
7162306a36Sopenharmony_ci#define CCSR_DMA_SR_EOSI		0x00000002
7262306a36Sopenharmony_ci#define CCSR_DMA_SR_EOLSI       	0x00000001
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/* ECLNDAR takes bits 32-36 of the CLNDAR register */
7562306a36Sopenharmony_cistatic inline u32 CCSR_DMA_ECLNDAR_ADDR(u64 x)
7662306a36Sopenharmony_ci{
7762306a36Sopenharmony_ci	return (x >> 32) & 0xf;
7862306a36Sopenharmony_ci}
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci#define CCSR_DMA_CLNDAR_ADDR(x) ((x) & 0xFFFFFFFE)
8162306a36Sopenharmony_ci#define CCSR_DMA_CLNDAR_EOSIE   	0x00000008
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/* SATR and DATR, combined */
8462306a36Sopenharmony_ci#define CCSR_DMA_ATR_PBATMU     	0x20000000
8562306a36Sopenharmony_ci#define CCSR_DMA_ATR_TFLOWLVL_0 	0x00000000
8662306a36Sopenharmony_ci#define CCSR_DMA_ATR_TFLOWLVL_1 	0x06000000
8762306a36Sopenharmony_ci#define CCSR_DMA_ATR_TFLOWLVL_2 	0x08000000
8862306a36Sopenharmony_ci#define CCSR_DMA_ATR_TFLOWLVL_3 	0x0C000000
8962306a36Sopenharmony_ci#define CCSR_DMA_ATR_PCIORDER   	0x02000000
9062306a36Sopenharmony_ci#define CCSR_DMA_ATR_SME		0x01000000
9162306a36Sopenharmony_ci#define CCSR_DMA_ATR_NOSNOOP    	0x00040000
9262306a36Sopenharmony_ci#define CCSR_DMA_ATR_SNOOP      	0x00050000
9362306a36Sopenharmony_ci#define CCSR_DMA_ATR_ESAD_MASK  	0x0000000F
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci/**
9662306a36Sopenharmony_ci *  List Descriptor for extended chaining mode DMA operations.
9762306a36Sopenharmony_ci *
9862306a36Sopenharmony_ci *  The CLSDAR register points to the first (in a linked-list) List
9962306a36Sopenharmony_ci *  Descriptor.  Each object must be aligned on a 32-byte boundary. Each
10062306a36Sopenharmony_ci *  list descriptor points to a linked-list of link Descriptors.
10162306a36Sopenharmony_ci */
10262306a36Sopenharmony_cistruct fsl_dma_list_descriptor {
10362306a36Sopenharmony_ci	__be64 next;    	/* Address of next list descriptor */
10462306a36Sopenharmony_ci	__be64 first_link;      /* Address of first link descriptor */
10562306a36Sopenharmony_ci	__be32 source;  	/* Source stride */
10662306a36Sopenharmony_ci	__be32 dest;    	/* Destination stride */
10762306a36Sopenharmony_ci	u8 res[8];      	/* Reserved */
10862306a36Sopenharmony_ci} __attribute__ ((aligned(32), packed));
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci/**
11162306a36Sopenharmony_ci *  Link Descriptor for basic and extended chaining mode DMA operations.
11262306a36Sopenharmony_ci *
11362306a36Sopenharmony_ci *  A Link Descriptor points to a single DMA buffer.  Each link descriptor
11462306a36Sopenharmony_ci *  must be aligned on a 32-byte boundary.
11562306a36Sopenharmony_ci */
11662306a36Sopenharmony_cistruct fsl_dma_link_descriptor {
11762306a36Sopenharmony_ci	__be32 source_attr;     /* Programmed into SATR register */
11862306a36Sopenharmony_ci	__be32 source_addr;     /* Programmed into SAR register */
11962306a36Sopenharmony_ci	__be32 dest_attr;       /* Programmed into DATR register */
12062306a36Sopenharmony_ci	__be32 dest_addr;       /* Programmed into DAR register */
12162306a36Sopenharmony_ci	__be64 next;    /* Address of next link descriptor */
12262306a36Sopenharmony_ci	__be32 count;   /* Byte count */
12362306a36Sopenharmony_ci	u8 res[4];      /* Reserved */
12462306a36Sopenharmony_ci} __attribute__ ((aligned(32), packed));
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#endif
127