162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * HD-audio controller (Azalia) registers and helpers
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * For traditional reasons, we still use azx_ prefix here
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef __SOUND_HDA_REGISTER_H
962306a36Sopenharmony_ci#define __SOUND_HDA_REGISTER_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/io.h>
1262306a36Sopenharmony_ci#include <sound/hdaudio.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define AZX_REG_GCAP			0x00
1562306a36Sopenharmony_ci#define   AZX_GCAP_64OK		(1 << 0)   /* 64bit address support */
1662306a36Sopenharmony_ci#define   AZX_GCAP_NSDO		(3 << 1)   /* # of serial data out signals */
1762306a36Sopenharmony_ci#define   AZX_GCAP_BSS		(31 << 3)  /* # of bidirectional streams */
1862306a36Sopenharmony_ci#define   AZX_GCAP_ISS		(15 << 8)  /* # of input streams */
1962306a36Sopenharmony_ci#define   AZX_GCAP_OSS		(15 << 12) /* # of output streams */
2062306a36Sopenharmony_ci#define AZX_REG_VMIN			0x02
2162306a36Sopenharmony_ci#define AZX_REG_VMAJ			0x03
2262306a36Sopenharmony_ci#define AZX_REG_OUTPAY			0x04
2362306a36Sopenharmony_ci#define AZX_REG_INPAY			0x06
2462306a36Sopenharmony_ci#define AZX_REG_GCTL			0x08
2562306a36Sopenharmony_ci#define   AZX_GCTL_RESET	(1 << 0)   /* controller reset */
2662306a36Sopenharmony_ci#define   AZX_GCTL_FCNTRL	(1 << 1)   /* flush control */
2762306a36Sopenharmony_ci#define   AZX_GCTL_UNSOL	(1 << 8)   /* accept unsol. response enable */
2862306a36Sopenharmony_ci#define AZX_REG_WAKEEN			0x0c
2962306a36Sopenharmony_ci#define AZX_REG_STATESTS		0x0e
3062306a36Sopenharmony_ci#define AZX_REG_GSTS			0x10
3162306a36Sopenharmony_ci#define   AZX_GSTS_FSTS		(1 << 1)   /* flush status */
3262306a36Sopenharmony_ci#define AZX_REG_GCAP2			0x12
3362306a36Sopenharmony_ci#define AZX_REG_LLCH			0x14
3462306a36Sopenharmony_ci#define AZX_REG_OUTSTRMPAY		0x18
3562306a36Sopenharmony_ci#define AZX_REG_INSTRMPAY		0x1A
3662306a36Sopenharmony_ci#define AZX_REG_INTCTL			0x20
3762306a36Sopenharmony_ci#define AZX_REG_INTSTS			0x24
3862306a36Sopenharmony_ci#define AZX_REG_WALLCLK			0x30	/* 24Mhz source */
3962306a36Sopenharmony_ci#define AZX_REG_OLD_SSYNC		0x34	/* SSYNC for old ICH */
4062306a36Sopenharmony_ci#define AZX_REG_SSYNC			0x38
4162306a36Sopenharmony_ci#define AZX_REG_CORBLBASE		0x40
4262306a36Sopenharmony_ci#define AZX_REG_CORBUBASE		0x44
4362306a36Sopenharmony_ci#define AZX_REG_CORBWP			0x48
4462306a36Sopenharmony_ci#define AZX_REG_CORBRP			0x4a
4562306a36Sopenharmony_ci#define   AZX_CORBRP_RST	(1 << 15)  /* read pointer reset */
4662306a36Sopenharmony_ci#define AZX_REG_CORBCTL			0x4c
4762306a36Sopenharmony_ci#define   AZX_CORBCTL_RUN	(1 << 1)   /* enable DMA */
4862306a36Sopenharmony_ci#define   AZX_CORBCTL_CMEIE	(1 << 0)   /* enable memory error irq */
4962306a36Sopenharmony_ci#define AZX_REG_CORBSTS			0x4d
5062306a36Sopenharmony_ci#define   AZX_CORBSTS_CMEI	(1 << 0)   /* memory error indication */
5162306a36Sopenharmony_ci#define AZX_REG_CORBSIZE		0x4e
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define AZX_REG_RIRBLBASE		0x50
5462306a36Sopenharmony_ci#define AZX_REG_RIRBUBASE		0x54
5562306a36Sopenharmony_ci#define AZX_REG_RIRBWP			0x58
5662306a36Sopenharmony_ci#define   AZX_RIRBWP_RST	(1 << 15)  /* write pointer reset */
5762306a36Sopenharmony_ci#define AZX_REG_RINTCNT			0x5a
5862306a36Sopenharmony_ci#define AZX_REG_RIRBCTL			0x5c
5962306a36Sopenharmony_ci#define   AZX_RBCTL_IRQ_EN	(1 << 0)   /* enable IRQ */
6062306a36Sopenharmony_ci#define   AZX_RBCTL_DMA_EN	(1 << 1)   /* enable DMA */
6162306a36Sopenharmony_ci#define   AZX_RBCTL_OVERRUN_EN	(1 << 2)   /* enable overrun irq */
6262306a36Sopenharmony_ci#define AZX_REG_RIRBSTS			0x5d
6362306a36Sopenharmony_ci#define   AZX_RBSTS_IRQ		(1 << 0)   /* response irq */
6462306a36Sopenharmony_ci#define   AZX_RBSTS_OVERRUN	(1 << 2)   /* overrun irq */
6562306a36Sopenharmony_ci#define AZX_REG_RIRBSIZE		0x5e
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define AZX_REG_IC			0x60
6862306a36Sopenharmony_ci#define AZX_REG_IR			0x64
6962306a36Sopenharmony_ci#define AZX_REG_IRS			0x68
7062306a36Sopenharmony_ci#define   AZX_IRS_VALID		(1<<1)
7162306a36Sopenharmony_ci#define   AZX_IRS_BUSY		(1<<0)
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#define AZX_REG_DPLBASE			0x70
7462306a36Sopenharmony_ci#define AZX_REG_DPUBASE			0x74
7562306a36Sopenharmony_ci#define   AZX_DPLBASE_ENABLE	0x1	/* Enable position buffer */
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
7862306a36Sopenharmony_cienum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* stream register offsets from stream base */
8162306a36Sopenharmony_ci#define AZX_REG_SD_CTL			0x00
8262306a36Sopenharmony_ci#define AZX_REG_SD_CTL_3B		0x02 /* 3rd byte of SD_CTL register */
8362306a36Sopenharmony_ci#define AZX_REG_SD_STS			0x03
8462306a36Sopenharmony_ci#define AZX_REG_SD_LPIB			0x04
8562306a36Sopenharmony_ci#define AZX_REG_SD_CBL			0x08
8662306a36Sopenharmony_ci#define AZX_REG_SD_LVI			0x0c
8762306a36Sopenharmony_ci#define AZX_REG_SD_FIFOW		0x0e
8862306a36Sopenharmony_ci#define AZX_REG_SD_FIFOSIZE		0x10
8962306a36Sopenharmony_ci#define AZX_REG_SD_FORMAT		0x12
9062306a36Sopenharmony_ci#define AZX_REG_SD_FIFOL		0x14
9162306a36Sopenharmony_ci#define AZX_REG_SD_BDLPL		0x18
9262306a36Sopenharmony_ci#define AZX_REG_SD_BDLPU		0x1c
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci/* GTS registers */
9562306a36Sopenharmony_ci#define AZX_REG_LLCH			0x14
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci#define AZX_REG_GTS_BASE		0x520
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define AZX_REG_GTSCC	(AZX_REG_GTS_BASE + 0x00)
10062306a36Sopenharmony_ci#define AZX_REG_WALFCC	(AZX_REG_GTS_BASE + 0x04)
10162306a36Sopenharmony_ci#define AZX_REG_TSCCL	(AZX_REG_GTS_BASE + 0x08)
10262306a36Sopenharmony_ci#define AZX_REG_TSCCU	(AZX_REG_GTS_BASE + 0x0C)
10362306a36Sopenharmony_ci#define AZX_REG_LLPFOC	(AZX_REG_GTS_BASE + 0x14)
10462306a36Sopenharmony_ci#define AZX_REG_LLPCL	(AZX_REG_GTS_BASE + 0x18)
10562306a36Sopenharmony_ci#define AZX_REG_LLPCU	(AZX_REG_GTS_BASE + 0x1C)
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci/* Haswell/Broadwell display HD-A controller Extended Mode registers */
10862306a36Sopenharmony_ci#define AZX_REG_HSW_EM4			0x100c
10962306a36Sopenharmony_ci#define AZX_REG_HSW_EM5			0x1010
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci/* Skylake/Broxton vendor-specific registers */
11262306a36Sopenharmony_ci#define AZX_REG_VS_EM1			0x1000
11362306a36Sopenharmony_ci#define AZX_REG_VS_INRC			0x1004
11462306a36Sopenharmony_ci#define AZX_REG_VS_OUTRC		0x1008
11562306a36Sopenharmony_ci#define AZX_REG_VS_FIFOTRK		0x100C
11662306a36Sopenharmony_ci#define AZX_REG_VS_FIFOTRK2		0x1010
11762306a36Sopenharmony_ci#define AZX_REG_VS_EM2			0x1030
11862306a36Sopenharmony_ci#define AZX_REG_VS_EM3L			0x1038
11962306a36Sopenharmony_ci#define AZX_REG_VS_EM3U			0x103C
12062306a36Sopenharmony_ci#define AZX_REG_VS_EM4L			0x1040
12162306a36Sopenharmony_ci#define AZX_REG_VS_EM4U			0x1044
12262306a36Sopenharmony_ci#define AZX_REG_VS_LTRP			0x1048
12362306a36Sopenharmony_ci#define AZX_REG_VS_D0I3C		0x104A
12462306a36Sopenharmony_ci#define AZX_REG_VS_PCE			0x104B
12562306a36Sopenharmony_ci#define AZX_REG_VS_L2MAGC		0x1050
12662306a36Sopenharmony_ci#define AZX_REG_VS_L2LAHPT		0x1054
12762306a36Sopenharmony_ci#define AZX_REG_VS_SDXDPIB_XBASE	0x1084
12862306a36Sopenharmony_ci#define AZX_REG_VS_SDXDPIB_XINTERVAL	0x20
12962306a36Sopenharmony_ci#define AZX_REG_VS_SDXEFIFOS_XBASE	0x1094
13062306a36Sopenharmony_ci#define AZX_REG_VS_SDXEFIFOS_XINTERVAL	0x20
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci/* PCI space */
13362306a36Sopenharmony_ci#define AZX_PCIREG_TCSEL		0x44
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci/*
13662306a36Sopenharmony_ci * other constants
13762306a36Sopenharmony_ci */
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci/* max number of fragments - we may use more if allocating more pages for BDL */
14062306a36Sopenharmony_ci#define BDL_SIZE		4096
14162306a36Sopenharmony_ci#define AZX_MAX_BDL_ENTRIES	(BDL_SIZE / 16)
14262306a36Sopenharmony_ci#define AZX_MAX_FRAG		32
14362306a36Sopenharmony_ci/*
14462306a36Sopenharmony_ci * max buffer size - artificial 4MB limit per stream to avoid big allocations
14562306a36Sopenharmony_ci * In theory it can be really big, but as it is per stream on systems with many streams memory could
14662306a36Sopenharmony_ci * be quickly saturated if userspace requests maximum buffer size for each of them.
14762306a36Sopenharmony_ci */
14862306a36Sopenharmony_ci#define AZX_MAX_BUF_SIZE	(4*1024*1024)
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci/* RIRB int mask: overrun[2], response[0] */
15162306a36Sopenharmony_ci#define RIRB_INT_RESPONSE	0x01
15262306a36Sopenharmony_ci#define RIRB_INT_OVERRUN	0x04
15362306a36Sopenharmony_ci#define RIRB_INT_MASK		0x05
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci/* STATESTS int mask: S3,SD2,SD1,SD0 */
15662306a36Sopenharmony_ci#define STATESTS_INT_MASK	((1 << HDA_MAX_CODECS) - 1)
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci/* SD_CTL bits */
15962306a36Sopenharmony_ci#define SD_CTL_STREAM_RESET	0x01	/* stream reset bit */
16062306a36Sopenharmony_ci#define SD_CTL_DMA_START	0x02	/* stream DMA start bit */
16162306a36Sopenharmony_ci#define SD_CTL_STRIPE		(3 << 16)	/* stripe control */
16262306a36Sopenharmony_ci#define SD_CTL_TRAFFIC_PRIO	(1 << 18)	/* traffic priority */
16362306a36Sopenharmony_ci#define SD_CTL_DIR		(1 << 19)	/* bi-directional stream */
16462306a36Sopenharmony_ci#define SD_CTL_STREAM_TAG_MASK	(0xf << 20)
16562306a36Sopenharmony_ci#define SD_CTL_STREAM_TAG_SHIFT	20
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci/* SD_CTL and SD_STS */
16862306a36Sopenharmony_ci#define SD_INT_DESC_ERR		0x10	/* descriptor error interrupt */
16962306a36Sopenharmony_ci#define SD_INT_FIFO_ERR		0x08	/* FIFO error interrupt */
17062306a36Sopenharmony_ci#define SD_INT_COMPLETE		0x04	/* completion interrupt */
17162306a36Sopenharmony_ci#define SD_INT_MASK		(SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
17262306a36Sopenharmony_ci				 SD_INT_COMPLETE)
17362306a36Sopenharmony_ci#define SD_CTL_STRIPE_MASK	0x3	/* stripe control mask */
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci/* SD_STS */
17662306a36Sopenharmony_ci#define SD_STS_FIFO_READY	0x20	/* FIFO ready */
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci/* INTCTL and INTSTS */
17962306a36Sopenharmony_ci#define AZX_INT_ALL_STREAM	0xff	   /* all stream interrupts */
18062306a36Sopenharmony_ci#define AZX_INT_CTRL_EN	0x40000000 /* controller interrupt enable bit */
18162306a36Sopenharmony_ci#define AZX_INT_GLOBAL_EN	0x80000000 /* global interrupt enable bit */
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci/* below are so far hardcoded - should read registers in future */
18462306a36Sopenharmony_ci#define AZX_MAX_CORB_ENTRIES	256
18562306a36Sopenharmony_ci#define AZX_MAX_RIRB_ENTRIES	256
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci/* Capability header  Structure */
18862306a36Sopenharmony_ci#define AZX_REG_CAP_HDR			0x0
18962306a36Sopenharmony_ci#define AZX_CAP_HDR_VER_OFF		28
19062306a36Sopenharmony_ci#define AZX_CAP_HDR_VER_MASK		(0xF << AZX_CAP_HDR_VER_OFF)
19162306a36Sopenharmony_ci#define AZX_CAP_HDR_ID_OFF		16
19262306a36Sopenharmony_ci#define AZX_CAP_HDR_ID_MASK		(0xFFF << AZX_CAP_HDR_ID_OFF)
19362306a36Sopenharmony_ci#define AZX_CAP_HDR_NXT_PTR_MASK	0xFFFF
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci/* registers of Software Position Based FIFO Capability Structure */
19662306a36Sopenharmony_ci#define AZX_SPB_CAP_ID			0x4
19762306a36Sopenharmony_ci#define AZX_REG_SPB_BASE_ADDR		0x700
19862306a36Sopenharmony_ci#define AZX_REG_SPB_SPBFCH		0x00
19962306a36Sopenharmony_ci#define AZX_REG_SPB_SPBFCCTL		0x04
20062306a36Sopenharmony_ci/* Base used to calculate the iterating register offset */
20162306a36Sopenharmony_ci#define AZX_SPB_BASE			0x08
20262306a36Sopenharmony_ci/* Interval used to calculate the iterating register offset */
20362306a36Sopenharmony_ci#define AZX_SPB_INTERVAL		0x08
20462306a36Sopenharmony_ci/* SPIB base */
20562306a36Sopenharmony_ci#define AZX_SPB_SPIB			0x00
20662306a36Sopenharmony_ci/* SPIB MAXFIFO base*/
20762306a36Sopenharmony_ci#define AZX_SPB_MAXFIFO			0x04
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci/* registers of Global Time Synchronization Capability Structure */
21062306a36Sopenharmony_ci#define AZX_GTS_CAP_ID			0x1
21162306a36Sopenharmony_ci#define AZX_REG_GTS_GTSCH		0x00
21262306a36Sopenharmony_ci#define AZX_REG_GTS_GTSCD		0x04
21362306a36Sopenharmony_ci#define AZX_REG_GTS_GTSCTLAC		0x0C
21462306a36Sopenharmony_ci#define AZX_GTS_BASE			0x20
21562306a36Sopenharmony_ci#define AZX_GTS_INTERVAL		0x20
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ci/* registers for Processing Pipe Capability Structure */
21862306a36Sopenharmony_ci#define AZX_PP_CAP_ID			0x3
21962306a36Sopenharmony_ci#define AZX_REG_PP_PPCH			0x10
22062306a36Sopenharmony_ci#define AZX_REG_PP_PPCTL		0x04
22162306a36Sopenharmony_ci#define AZX_PPCTL_PIE			(1<<31)
22262306a36Sopenharmony_ci#define AZX_PPCTL_GPROCEN		(1<<30)
22362306a36Sopenharmony_ci/* _X_ = dma engine # and cannot * exceed 29 (per spec max 30 dma engines) */
22462306a36Sopenharmony_ci#define AZX_PPCTL_PROCEN(_X_)		(1<<(_X_))
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci#define AZX_REG_PP_PPSTS		0x08
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci#define AZX_PPHC_BASE			0x10
22962306a36Sopenharmony_ci#define AZX_PPHC_INTERVAL		0x10
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci#define AZX_REG_PPHCLLPL		0x0
23262306a36Sopenharmony_ci#define AZX_REG_PPHCLLPU		0x4
23362306a36Sopenharmony_ci#define AZX_REG_PPHCLDPL		0x8
23462306a36Sopenharmony_ci#define AZX_REG_PPHCLDPU		0xC
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci#define AZX_PPLC_BASE			0x10
23762306a36Sopenharmony_ci#define AZX_PPLC_MULTI			0x10
23862306a36Sopenharmony_ci#define AZX_PPLC_INTERVAL		0x10
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci#define AZX_REG_PPLCCTL			0x0
24162306a36Sopenharmony_ci#define AZX_PPLCCTL_STRM_BITS		4
24262306a36Sopenharmony_ci#define AZX_PPLCCTL_STRM_SHIFT		20
24362306a36Sopenharmony_ci#define AZX_REG_MASK(bit_num, offset) \
24462306a36Sopenharmony_ci	(((1 << (bit_num)) - 1) << (offset))
24562306a36Sopenharmony_ci#define AZX_PPLCCTL_STRM_MASK \
24662306a36Sopenharmony_ci	AZX_REG_MASK(AZX_PPLCCTL_STRM_BITS, AZX_PPLCCTL_STRM_SHIFT)
24762306a36Sopenharmony_ci#define AZX_PPLCCTL_RUN			(1<<1)
24862306a36Sopenharmony_ci#define AZX_PPLCCTL_STRST		(1<<0)
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci#define AZX_REG_PPLCFMT			0x4
25162306a36Sopenharmony_ci#define AZX_REG_PPLCLLPL		0x8
25262306a36Sopenharmony_ci#define AZX_REG_PPLCLLPU		0xC
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/* registers for Multiple Links Capability Structure */
25562306a36Sopenharmony_ci#define AZX_ML_CAP_ID			0x2
25662306a36Sopenharmony_ci#define AZX_REG_ML_MLCH			0x00
25762306a36Sopenharmony_ci#define AZX_REG_ML_MLCD			0x04
25862306a36Sopenharmony_ci#define AZX_ML_BASE			0x40
25962306a36Sopenharmony_ci#define AZX_ML_INTERVAL			0x40
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_ci/* HDaudio registers valid for HDaudio and HDaudio extended links */
26262306a36Sopenharmony_ci#define AZX_REG_ML_LCAP			0x00
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ci#define AZX_ML_HDA_LCAP_ALT		BIT(28)
26562306a36Sopenharmony_ci#define AZX_ML_HDA_LCAP_ALT_HDA		0x0
26662306a36Sopenharmony_ci#define AZX_ML_HDA_LCAP_ALT_HDA_EXT	0x1
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci#define AZX_ML_HDA_LCAP_INTC		BIT(27)		/* only used if ALT == 1 */
26962306a36Sopenharmony_ci#define AZX_ML_HDA_LCAP_OFLS		BIT(26)		/* only used if ALT == 1 */
27062306a36Sopenharmony_ci#define AZX_ML_HDA_LCAP_LSS		BIT(23)		/* only used if ALT == 1 */
27162306a36Sopenharmony_ci#define AZX_ML_HDA_LCAP_SLCOUNT		GENMASK(22, 20)	/* only used if ALT == 1 */
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci#define AZX_REG_ML_LCTL			0x04
27462306a36Sopenharmony_ci#define AZX_ML_LCTL_INTSTS		BIT(31)		/* only used if ALT == 1 */
27562306a36Sopenharmony_ci#define AZX_ML_LCTL_CPA			BIT(23)
27662306a36Sopenharmony_ci#define AZX_ML_LCTL_CPA_SHIFT		23
27762306a36Sopenharmony_ci#define AZX_ML_LCTL_SPA			BIT(16)
27862306a36Sopenharmony_ci#define AZX_ML_LCTL_SPA_SHIFT		16
27962306a36Sopenharmony_ci#define AZX_ML_LCTL_INTEN		BIT(5)		/* only used if ALT == 1 */
28062306a36Sopenharmony_ci#define AZX_ML_LCTL_OFLEN		BIT(4)		/* only used if ALT == 1 */
28162306a36Sopenharmony_ci#define AZX_ML_LCTL_SCF			GENMASK(3, 0)	/* only used if ALT == 0 */
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci#define AZX_REG_ML_LOSIDV		0x08
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci/* bit0 is reserved, with BIT(1) mapping to stream1 */
28662306a36Sopenharmony_ci#define AZX_ML_LOSIDV_STREAM_MASK	0xFFFE
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci#define AZX_REG_ML_LSDIID		0x0C
28962306a36Sopenharmony_ci#define AZX_REG_ML_LSDIID_OFFSET(x)	(0x0C + (x) * 0x02)	/* only used if ALT == 1 */
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci/* HDaudio registers only valid if LCAP.ALT == 0 */
29262306a36Sopenharmony_ci#define AZX_REG_ML_LPSOO		0x10
29362306a36Sopenharmony_ci#define AZX_REG_ML_LPSIO		0x12
29462306a36Sopenharmony_ci#define AZX_REG_ML_LWALFC		0x18
29562306a36Sopenharmony_ci#define AZX_REG_ML_LOUTPAY		0x20
29662306a36Sopenharmony_ci#define AZX_REG_ML_LINPAY		0x30
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci/* HDaudio Extended link registers only valid if LCAP.ALT == 1 */
29962306a36Sopenharmony_ci#define AZX_REG_ML_LSYNC		0x1C
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci#define AZX_REG_ML_LSYNC_CMDSYNC	BIT(24)
30262306a36Sopenharmony_ci#define AZX_REG_ML_LSYNC_CMDSYNC_SHIFT	24
30362306a36Sopenharmony_ci#define AZX_REG_ML_LSYNC_SYNCGO		BIT(23)
30462306a36Sopenharmony_ci#define AZX_REG_ML_LSYNC_SYNCPU		BIT(20)
30562306a36Sopenharmony_ci#define AZX_REG_ML_LSYNC_SYNCPRD	GENMASK(19, 0)
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR		0x20
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_ID		GENMASK(31, 24)
31062306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_ID_SHIFT	24
31162306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_ID_SDW		0x00
31262306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_ID_INTEL_SSP	0xC0
31362306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_ID_INTEL_DMIC  0xC1
31462306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_ID_INTEL_UAOL  0xC2
31562306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_VER		GENMASK(23, 20)
31662306a36Sopenharmony_ci#define AZX_REG_ML_LEPTR_PTR		GENMASK(19, 0)
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci/* registers for DMA Resume Capability Structure */
31962306a36Sopenharmony_ci#define AZX_DRSM_CAP_ID			0x5
32062306a36Sopenharmony_ci#define AZX_REG_DRSM_CTL		0x4
32162306a36Sopenharmony_ci/* Base used to calculate the iterating register offset */
32262306a36Sopenharmony_ci#define AZX_DRSM_BASE			0x08
32362306a36Sopenharmony_ci/* Interval used to calculate the iterating register offset */
32462306a36Sopenharmony_ci#define AZX_DRSM_INTERVAL		0x08
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci/* Global time synchronization registers */
32762306a36Sopenharmony_ci#define GTSCC_TSCCD_MASK		0x80000000
32862306a36Sopenharmony_ci#define GTSCC_TSCCD_SHIFT		BIT(31)
32962306a36Sopenharmony_ci#define GTSCC_TSCCI_MASK		0x20
33062306a36Sopenharmony_ci#define GTSCC_CDMAS_DMA_DIR_SHIFT	4
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci#define WALFCC_CIF_MASK			0x1FF
33362306a36Sopenharmony_ci#define WALFCC_FN_SHIFT			9
33462306a36Sopenharmony_ci#define HDA_CLK_CYCLES_PER_FRAME	512
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ci/*
33762306a36Sopenharmony_ci * An error occurs near frame "rollover". The clocks in frame value indicates
33862306a36Sopenharmony_ci * whether this error may have occurred. Here we use the value of 10. Please
33962306a36Sopenharmony_ci * see the errata for the right number [<10]
34062306a36Sopenharmony_ci */
34162306a36Sopenharmony_ci#define HDA_MAX_CYCLE_VALUE		499
34262306a36Sopenharmony_ci#define HDA_MAX_CYCLE_OFFSET		10
34362306a36Sopenharmony_ci#define HDA_MAX_CYCLE_READ_RETRY	10
34462306a36Sopenharmony_ci
34562306a36Sopenharmony_ci#define TSCCU_CCU_SHIFT			32
34662306a36Sopenharmony_ci#define LLPC_CCU_SHIFT			32
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci/*
35062306a36Sopenharmony_ci * helpers to read the stream position
35162306a36Sopenharmony_ci */
35262306a36Sopenharmony_cistatic inline unsigned int
35362306a36Sopenharmony_cisnd_hdac_stream_get_pos_lpib(struct hdac_stream *stream)
35462306a36Sopenharmony_ci{
35562306a36Sopenharmony_ci	return snd_hdac_stream_readl(stream, SD_LPIB);
35662306a36Sopenharmony_ci}
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_cistatic inline unsigned int
35962306a36Sopenharmony_cisnd_hdac_stream_get_pos_posbuf(struct hdac_stream *stream)
36062306a36Sopenharmony_ci{
36162306a36Sopenharmony_ci	return le32_to_cpu(*stream->posbuf);
36262306a36Sopenharmony_ci}
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci#endif /* __SOUND_HDA_REGISTER_H */
365