162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * ALSA SoC McASP Audio Layer for TI DAVINCI processor
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * MCASP related definitions
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Author: Nirmal Pandey <n-pandey@ti.com>,
862306a36Sopenharmony_ci *         Suresh Rajashekara <suresh.r@ti.com>
962306a36Sopenharmony_ci *         Steve Chen <schen@.mvista.com>
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * Copyright:   (C) 2009 MontaVista Software, Inc., <source@mvista.com>
1262306a36Sopenharmony_ci * Copyright:   (C) 2009  Texas Instruments, India
1362306a36Sopenharmony_ci */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#ifndef DAVINCI_MCASP_H
1662306a36Sopenharmony_ci#define DAVINCI_MCASP_H
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/*
1962306a36Sopenharmony_ci * McASP register definitions
2062306a36Sopenharmony_ci */
2162306a36Sopenharmony_ci#define DAVINCI_MCASP_PID_REG		0x00
2262306a36Sopenharmony_ci#define DAVINCI_MCASP_PWREMUMGT_REG	0x04
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define DAVINCI_MCASP_PFUNC_REG		0x10
2562306a36Sopenharmony_ci#define DAVINCI_MCASP_PDIR_REG		0x14
2662306a36Sopenharmony_ci#define DAVINCI_MCASP_PDOUT_REG		0x18
2762306a36Sopenharmony_ci#define DAVINCI_MCASP_PDSET_REG		0x1c
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#define DAVINCI_MCASP_PDCLR_REG		0x20
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define DAVINCI_MCASP_TLGC_REG		0x30
3262306a36Sopenharmony_ci#define DAVINCI_MCASP_TLMR_REG		0x34
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#define DAVINCI_MCASP_GBLCTL_REG	0x44
3562306a36Sopenharmony_ci#define DAVINCI_MCASP_AMUTE_REG		0x48
3662306a36Sopenharmony_ci#define DAVINCI_MCASP_LBCTL_REG		0x4c
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#define DAVINCI_MCASP_TXDITCTL_REG	0x50
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define DAVINCI_MCASP_GBLCTLR_REG	0x60
4162306a36Sopenharmony_ci#define DAVINCI_MCASP_RXMASK_REG	0x64
4262306a36Sopenharmony_ci#define DAVINCI_MCASP_RXFMT_REG		0x68
4362306a36Sopenharmony_ci#define DAVINCI_MCASP_RXFMCTL_REG	0x6c
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define DAVINCI_MCASP_ACLKRCTL_REG	0x70
4662306a36Sopenharmony_ci#define DAVINCI_MCASP_AHCLKRCTL_REG	0x74
4762306a36Sopenharmony_ci#define DAVINCI_MCASP_RXTDM_REG		0x78
4862306a36Sopenharmony_ci#define DAVINCI_MCASP_EVTCTLR_REG	0x7c
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define DAVINCI_MCASP_RXSTAT_REG	0x80
5162306a36Sopenharmony_ci#define DAVINCI_MCASP_RXTDMSLOT_REG	0x84
5262306a36Sopenharmony_ci#define DAVINCI_MCASP_RXCLKCHK_REG	0x88
5362306a36Sopenharmony_ci#define DAVINCI_MCASP_REVTCTL_REG	0x8c
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#define DAVINCI_MCASP_GBLCTLX_REG	0xa0
5662306a36Sopenharmony_ci#define DAVINCI_MCASP_TXMASK_REG	0xa4
5762306a36Sopenharmony_ci#define DAVINCI_MCASP_TXFMT_REG		0xa8
5862306a36Sopenharmony_ci#define DAVINCI_MCASP_TXFMCTL_REG	0xac
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define DAVINCI_MCASP_ACLKXCTL_REG	0xb0
6162306a36Sopenharmony_ci#define DAVINCI_MCASP_AHCLKXCTL_REG	0xb4
6262306a36Sopenharmony_ci#define DAVINCI_MCASP_TXTDM_REG		0xb8
6362306a36Sopenharmony_ci#define DAVINCI_MCASP_EVTCTLX_REG	0xbc
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define DAVINCI_MCASP_TXSTAT_REG	0xc0
6662306a36Sopenharmony_ci#define DAVINCI_MCASP_TXTDMSLOT_REG	0xc4
6762306a36Sopenharmony_ci#define DAVINCI_MCASP_TXCLKCHK_REG	0xc8
6862306a36Sopenharmony_ci#define DAVINCI_MCASP_XEVTCTL_REG	0xcc
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/* Left(even TDM Slot) Channel Status Register File */
7162306a36Sopenharmony_ci#define DAVINCI_MCASP_DITCSRA_REG	0x100
7262306a36Sopenharmony_ci/* Right(odd TDM slot) Channel Status Register File */
7362306a36Sopenharmony_ci#define DAVINCI_MCASP_DITCSRB_REG	0x118
7462306a36Sopenharmony_ci/* Left(even TDM slot) User Data Register File */
7562306a36Sopenharmony_ci#define DAVINCI_MCASP_DITUDRA_REG	0x130
7662306a36Sopenharmony_ci/* Right(odd TDM Slot) User Data Register File */
7762306a36Sopenharmony_ci#define DAVINCI_MCASP_DITUDRB_REG	0x148
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci/* Serializer n Control Register */
8062306a36Sopenharmony_ci#define DAVINCI_MCASP_XRSRCTL_BASE_REG	0x180
8162306a36Sopenharmony_ci#define DAVINCI_MCASP_XRSRCTL_REG(n)	(DAVINCI_MCASP_XRSRCTL_BASE_REG + \
8262306a36Sopenharmony_ci						(n << 2))
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/* Transmit Buffer for Serializer n */
8562306a36Sopenharmony_ci#define DAVINCI_MCASP_TXBUF_REG(n)	(0x200 + (n << 2))
8662306a36Sopenharmony_ci/* Receive Buffer for Serializer n */
8762306a36Sopenharmony_ci#define DAVINCI_MCASP_RXBUF_REG(n)	(0x280 + (n << 2))
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci/* McASP FIFO Registers */
9062306a36Sopenharmony_ci#define DAVINCI_MCASP_V2_AFIFO_BASE	(0x1010)
9162306a36Sopenharmony_ci#define DAVINCI_MCASP_V3_AFIFO_BASE	(0x1000)
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* FIFO register offsets from AFIFO base */
9462306a36Sopenharmony_ci#define MCASP_WFIFOCTL_OFFSET		(0x0)
9562306a36Sopenharmony_ci#define MCASP_WFIFOSTS_OFFSET		(0x4)
9662306a36Sopenharmony_ci#define MCASP_RFIFOCTL_OFFSET		(0x8)
9762306a36Sopenharmony_ci#define MCASP_RFIFOSTS_OFFSET		(0xc)
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci/*
10062306a36Sopenharmony_ci * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management
10162306a36Sopenharmony_ci *     Register Bits
10262306a36Sopenharmony_ci */
10362306a36Sopenharmony_ci#define MCASP_FREE	BIT(0)
10462306a36Sopenharmony_ci#define MCASP_SOFT	BIT(1)
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/*
10762306a36Sopenharmony_ci * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits
10862306a36Sopenharmony_ci * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits
10962306a36Sopenharmony_ci * DAVINCI_MCASP_PDOUT_REG - Pin output in GPIO mode
11062306a36Sopenharmony_ci * DAVINCI_MCASP_PDSET_REG - Pin input in GPIO mode
11162306a36Sopenharmony_ci */
11262306a36Sopenharmony_ci#define PIN_BIT_AXR(n)	(n)
11362306a36Sopenharmony_ci#define PIN_BIT_AMUTE	25
11462306a36Sopenharmony_ci#define PIN_BIT_ACLKX	26
11562306a36Sopenharmony_ci#define PIN_BIT_AHCLKX	27
11662306a36Sopenharmony_ci#define PIN_BIT_AFSX	28
11762306a36Sopenharmony_ci#define PIN_BIT_ACLKR	29
11862306a36Sopenharmony_ci#define PIN_BIT_AHCLKR	30
11962306a36Sopenharmony_ci#define PIN_BIT_AFSR	31
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci/*
12262306a36Sopenharmony_ci * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits
12362306a36Sopenharmony_ci */
12462306a36Sopenharmony_ci#define DITEN	BIT(0)	/* Transmit DIT mode enable/disable */
12562306a36Sopenharmony_ci#define VA	BIT(2)
12662306a36Sopenharmony_ci#define VB	BIT(3)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci/*
12962306a36Sopenharmony_ci * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits
13062306a36Sopenharmony_ci */
13162306a36Sopenharmony_ci#define TXROT(val)	(val)
13262306a36Sopenharmony_ci#define TXSEL		BIT(3)
13362306a36Sopenharmony_ci#define TXSSZ(val)	(val<<4)
13462306a36Sopenharmony_ci#define TXPBIT(val)	(val<<8)
13562306a36Sopenharmony_ci#define TXPAD(val)	(val<<13)
13662306a36Sopenharmony_ci#define TXORD		BIT(15)
13762306a36Sopenharmony_ci#define FSXDLY(val)	(val<<16)
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci/*
14062306a36Sopenharmony_ci * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits
14162306a36Sopenharmony_ci */
14262306a36Sopenharmony_ci#define RXROT(val)	(val)
14362306a36Sopenharmony_ci#define RXSEL		BIT(3)
14462306a36Sopenharmony_ci#define RXSSZ(val)	(val<<4)
14562306a36Sopenharmony_ci#define RXPBIT(val)	(val<<8)
14662306a36Sopenharmony_ci#define RXPAD(val)	(val<<13)
14762306a36Sopenharmony_ci#define RXORD		BIT(15)
14862306a36Sopenharmony_ci#define FSRDLY(val)	(val<<16)
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci/*
15162306a36Sopenharmony_ci * DAVINCI_MCASP_TXFMCTL_REG -  Transmit Frame Control Register Bits
15262306a36Sopenharmony_ci */
15362306a36Sopenharmony_ci#define FSXPOL		BIT(0)
15462306a36Sopenharmony_ci#define AFSXE		BIT(1)
15562306a36Sopenharmony_ci#define FSXDUR		BIT(4)
15662306a36Sopenharmony_ci#define FSXMOD(val)	(val<<7)
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci/*
15962306a36Sopenharmony_ci * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits
16062306a36Sopenharmony_ci */
16162306a36Sopenharmony_ci#define FSRPOL		BIT(0)
16262306a36Sopenharmony_ci#define AFSRE		BIT(1)
16362306a36Sopenharmony_ci#define FSRDUR		BIT(4)
16462306a36Sopenharmony_ci#define FSRMOD(val)	(val<<7)
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci/*
16762306a36Sopenharmony_ci * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits
16862306a36Sopenharmony_ci */
16962306a36Sopenharmony_ci#define ACLKXDIV(val)	(val)
17062306a36Sopenharmony_ci#define ACLKXE		BIT(5)
17162306a36Sopenharmony_ci#define TX_ASYNC	BIT(6)
17262306a36Sopenharmony_ci#define ACLKXPOL	BIT(7)
17362306a36Sopenharmony_ci#define ACLKXDIV_MASK	0x1f
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci/*
17662306a36Sopenharmony_ci * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits
17762306a36Sopenharmony_ci */
17862306a36Sopenharmony_ci#define ACLKRDIV(val)	(val)
17962306a36Sopenharmony_ci#define ACLKRE		BIT(5)
18062306a36Sopenharmony_ci#define RX_ASYNC	BIT(6)
18162306a36Sopenharmony_ci#define ACLKRPOL	BIT(7)
18262306a36Sopenharmony_ci#define ACLKRDIV_MASK	0x1f
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci/*
18562306a36Sopenharmony_ci * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control
18662306a36Sopenharmony_ci *     Register Bits
18762306a36Sopenharmony_ci */
18862306a36Sopenharmony_ci#define AHCLKXDIV(val)	(val)
18962306a36Sopenharmony_ci#define AHCLKXPOL	BIT(14)
19062306a36Sopenharmony_ci#define AHCLKXE		BIT(15)
19162306a36Sopenharmony_ci#define AHCLKXDIV_MASK	0xfff
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci/*
19462306a36Sopenharmony_ci * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control
19562306a36Sopenharmony_ci *     Register Bits
19662306a36Sopenharmony_ci */
19762306a36Sopenharmony_ci#define AHCLKRDIV(val)	(val)
19862306a36Sopenharmony_ci#define AHCLKRPOL	BIT(14)
19962306a36Sopenharmony_ci#define AHCLKRE		BIT(15)
20062306a36Sopenharmony_ci#define AHCLKRDIV_MASK	0xfff
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci/*
20362306a36Sopenharmony_ci * DAVINCI_MCASP_XRSRCTL_BASE_REG -  Serializer Control Register Bits
20462306a36Sopenharmony_ci */
20562306a36Sopenharmony_ci#define MODE(val)	(val)
20662306a36Sopenharmony_ci#define DISMOD_3STATE	(0x0)
20762306a36Sopenharmony_ci#define DISMOD_LOW	(0x2 << 2)
20862306a36Sopenharmony_ci#define DISMOD_HIGH	(0x3 << 2)
20962306a36Sopenharmony_ci#define DISMOD_VAL(x)	((x) << 2)
21062306a36Sopenharmony_ci#define DISMOD_MASK	DISMOD_HIGH
21162306a36Sopenharmony_ci#define TXSTATE		BIT(4)
21262306a36Sopenharmony_ci#define RXSTATE		BIT(5)
21362306a36Sopenharmony_ci#define SRMOD_MASK	3
21462306a36Sopenharmony_ci#define SRMOD_INACTIVE	0
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci/*
21762306a36Sopenharmony_ci * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits
21862306a36Sopenharmony_ci */
21962306a36Sopenharmony_ci#define LBEN		BIT(0)
22062306a36Sopenharmony_ci#define LBORD		BIT(1)
22162306a36Sopenharmony_ci#define LBGENMODE(val)	(val<<2)
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci/*
22462306a36Sopenharmony_ci * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration
22562306a36Sopenharmony_ci */
22662306a36Sopenharmony_ci#define TXTDMS(n)	(1<<n)
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci/*
22962306a36Sopenharmony_ci * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration
23062306a36Sopenharmony_ci */
23162306a36Sopenharmony_ci#define RXTDMS(n)	(1<<n)
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_ci/*
23462306a36Sopenharmony_ci * DAVINCI_MCASP_GBLCTL_REG -  Global Control Register Bits
23562306a36Sopenharmony_ci */
23662306a36Sopenharmony_ci#define RXCLKRST	BIT(0)	/* Receiver Clock Divider Reset */
23762306a36Sopenharmony_ci#define RXHCLKRST	BIT(1)	/* Receiver High Frequency Clock Divider */
23862306a36Sopenharmony_ci#define RXSERCLR	BIT(2)	/* Receiver Serializer Clear */
23962306a36Sopenharmony_ci#define RXSMRST		BIT(3)	/* Receiver State Machine Reset */
24062306a36Sopenharmony_ci#define RXFSRST		BIT(4)	/* Frame Sync Generator Reset */
24162306a36Sopenharmony_ci#define TXCLKRST	BIT(8)	/* Transmitter Clock Divider Reset */
24262306a36Sopenharmony_ci#define TXHCLKRST	BIT(9)	/* Transmitter High Frequency Clock Divider*/
24362306a36Sopenharmony_ci#define TXSERCLR	BIT(10)	/* Transmit Serializer Clear */
24462306a36Sopenharmony_ci#define TXSMRST		BIT(11)	/* Transmitter State Machine Reset */
24562306a36Sopenharmony_ci#define TXFSRST		BIT(12)	/* Frame Sync Generator Reset */
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci/*
24862306a36Sopenharmony_ci * DAVINCI_MCASP_TXSTAT_REG - Transmitter Status Register Bits
24962306a36Sopenharmony_ci * DAVINCI_MCASP_RXSTAT_REG - Receiver Status Register Bits
25062306a36Sopenharmony_ci */
25162306a36Sopenharmony_ci#define XRERR		BIT(8) /* Transmit/Receive error */
25262306a36Sopenharmony_ci#define XRDATA		BIT(5) /* Transmit/Receive data ready */
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/*
25562306a36Sopenharmony_ci * DAVINCI_MCASP_AMUTE_REG -  Mute Control Register Bits
25662306a36Sopenharmony_ci */
25762306a36Sopenharmony_ci#define MUTENA(val)	(val)
25862306a36Sopenharmony_ci#define MUTEINPOL	BIT(2)
25962306a36Sopenharmony_ci#define MUTEINENA	BIT(3)
26062306a36Sopenharmony_ci#define MUTEIN		BIT(4)
26162306a36Sopenharmony_ci#define MUTER		BIT(5)
26262306a36Sopenharmony_ci#define MUTEX		BIT(6)
26362306a36Sopenharmony_ci#define MUTEFSR		BIT(7)
26462306a36Sopenharmony_ci#define MUTEFSX		BIT(8)
26562306a36Sopenharmony_ci#define MUTEBADCLKR	BIT(9)
26662306a36Sopenharmony_ci#define MUTEBADCLKX	BIT(10)
26762306a36Sopenharmony_ci#define MUTERXDMAERR	BIT(11)
26862306a36Sopenharmony_ci#define MUTETXDMAERR	BIT(12)
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci/*
27162306a36Sopenharmony_ci * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits
27262306a36Sopenharmony_ci */
27362306a36Sopenharmony_ci#define RXDATADMADIS	BIT(0)
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci/*
27662306a36Sopenharmony_ci * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits
27762306a36Sopenharmony_ci */
27862306a36Sopenharmony_ci#define TXDATADMADIS	BIT(0)
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci/*
28162306a36Sopenharmony_ci * DAVINCI_MCASP_EVTCTLR_REG - Receiver Interrupt Control Register Bits
28262306a36Sopenharmony_ci */
28362306a36Sopenharmony_ci#define ROVRN		BIT(0)
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci/*
28662306a36Sopenharmony_ci * DAVINCI_MCASP_EVTCTLX_REG - Transmitter Interrupt Control Register Bits
28762306a36Sopenharmony_ci */
28862306a36Sopenharmony_ci#define XUNDRN		BIT(0)
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci/*
29162306a36Sopenharmony_ci * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits
29262306a36Sopenharmony_ci */
29362306a36Sopenharmony_ci#define FIFO_ENABLE	BIT(16)
29462306a36Sopenharmony_ci#define NUMEVT_MASK	(0xFF << 8)
29562306a36Sopenharmony_ci#define NUMEVT(x)	(((x) & 0xFF) << 8)
29662306a36Sopenharmony_ci#define NUMDMA_MASK	(0xFF)
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci/* Source of High-frequency transmit/receive clock */
29962306a36Sopenharmony_ci#define MCASP_CLK_HCLK_AHCLK		0 /* AHCLKX/R */
30062306a36Sopenharmony_ci#define MCASP_CLK_HCLK_AUXCLK		1 /* Internal functional clock */
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ci/* clock divider IDs */
30362306a36Sopenharmony_ci#define MCASP_CLKDIV_AUXCLK		0 /* HCLK divider from AUXCLK */
30462306a36Sopenharmony_ci#define MCASP_CLKDIV_BCLK		1 /* BCLK divider from HCLK */
30562306a36Sopenharmony_ci#define MCASP_CLKDIV_BCLK_FS_RATIO	2 /* to set BCLK FS ration */
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci#endif	/* DAVINCI_MCASP_H */
308