18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci#ifndef _IMX_SSI_H
48c2ecf20Sopenharmony_ci#define _IMX_SSI_H
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#define SSI_STX0	0x00
78c2ecf20Sopenharmony_ci#define SSI_STX1	0x04
88c2ecf20Sopenharmony_ci#define SSI_SRX0	0x08
98c2ecf20Sopenharmony_ci#define SSI_SRX1	0x0c
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define SSI_SCR		0x10
128c2ecf20Sopenharmony_ci#define SSI_SCR_CLK_IST		(1 << 9)
138c2ecf20Sopenharmony_ci#define SSI_SCR_CLK_IST_SHIFT	9
148c2ecf20Sopenharmony_ci#define SSI_SCR_TCH_EN		(1 << 8)
158c2ecf20Sopenharmony_ci#define SSI_SCR_SYS_CLK_EN	(1 << 7)
168c2ecf20Sopenharmony_ci#define SSI_SCR_I2S_MODE_NORM	(0 << 5)
178c2ecf20Sopenharmony_ci#define SSI_SCR_I2S_MODE_MSTR	(1 << 5)
188c2ecf20Sopenharmony_ci#define SSI_SCR_I2S_MODE_SLAVE	(2 << 5)
198c2ecf20Sopenharmony_ci#define SSI_I2S_MODE_MASK	(3 << 5)
208c2ecf20Sopenharmony_ci#define SSI_SCR_SYN		(1 << 4)
218c2ecf20Sopenharmony_ci#define SSI_SCR_NET		(1 << 3)
228c2ecf20Sopenharmony_ci#define SSI_SCR_RE		(1 << 2)
238c2ecf20Sopenharmony_ci#define SSI_SCR_TE		(1 << 1)
248c2ecf20Sopenharmony_ci#define SSI_SCR_SSIEN		(1 << 0)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define SSI_SISR	0x14
278c2ecf20Sopenharmony_ci#define SSI_SISR_MASK		((1 << 19) - 1)
288c2ecf20Sopenharmony_ci#define SSI_SISR_CMDAU		(1 << 18)
298c2ecf20Sopenharmony_ci#define SSI_SISR_CMDDU		(1 << 17)
308c2ecf20Sopenharmony_ci#define SSI_SISR_RXT		(1 << 16)
318c2ecf20Sopenharmony_ci#define SSI_SISR_RDR1		(1 << 15)
328c2ecf20Sopenharmony_ci#define SSI_SISR_RDR0		(1 << 14)
338c2ecf20Sopenharmony_ci#define SSI_SISR_TDE1		(1 << 13)
348c2ecf20Sopenharmony_ci#define SSI_SISR_TDE0		(1 << 12)
358c2ecf20Sopenharmony_ci#define SSI_SISR_ROE1		(1 << 11)
368c2ecf20Sopenharmony_ci#define SSI_SISR_ROE0		(1 << 10)
378c2ecf20Sopenharmony_ci#define SSI_SISR_TUE1		(1 << 9)
388c2ecf20Sopenharmony_ci#define SSI_SISR_TUE0		(1 << 8)
398c2ecf20Sopenharmony_ci#define SSI_SISR_TFS		(1 << 7)
408c2ecf20Sopenharmony_ci#define SSI_SISR_RFS		(1 << 6)
418c2ecf20Sopenharmony_ci#define SSI_SISR_TLS		(1 << 5)
428c2ecf20Sopenharmony_ci#define SSI_SISR_RLS		(1 << 4)
438c2ecf20Sopenharmony_ci#define SSI_SISR_RFF1		(1 << 3)
448c2ecf20Sopenharmony_ci#define SSI_SISR_RFF0		(1 << 2)
458c2ecf20Sopenharmony_ci#define SSI_SISR_TFE1		(1 << 1)
468c2ecf20Sopenharmony_ci#define SSI_SISR_TFE0		(1 << 0)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define SSI_SIER	0x18
498c2ecf20Sopenharmony_ci#define SSI_SIER_RDMAE		(1 << 22)
508c2ecf20Sopenharmony_ci#define SSI_SIER_RIE		(1 << 21)
518c2ecf20Sopenharmony_ci#define SSI_SIER_TDMAE		(1 << 20)
528c2ecf20Sopenharmony_ci#define SSI_SIER_TIE		(1 << 19)
538c2ecf20Sopenharmony_ci#define SSI_SIER_CMDAU_EN	(1 << 18)
548c2ecf20Sopenharmony_ci#define SSI_SIER_CMDDU_EN	(1 << 17)
558c2ecf20Sopenharmony_ci#define SSI_SIER_RXT_EN		(1 << 16)
568c2ecf20Sopenharmony_ci#define SSI_SIER_RDR1_EN	(1 << 15)
578c2ecf20Sopenharmony_ci#define SSI_SIER_RDR0_EN	(1 << 14)
588c2ecf20Sopenharmony_ci#define SSI_SIER_TDE1_EN	(1 << 13)
598c2ecf20Sopenharmony_ci#define SSI_SIER_TDE0_EN	(1 << 12)
608c2ecf20Sopenharmony_ci#define SSI_SIER_ROE1_EN	(1 << 11)
618c2ecf20Sopenharmony_ci#define SSI_SIER_ROE0_EN	(1 << 10)
628c2ecf20Sopenharmony_ci#define SSI_SIER_TUE1_EN	(1 << 9)
638c2ecf20Sopenharmony_ci#define SSI_SIER_TUE0_EN	(1 << 8)
648c2ecf20Sopenharmony_ci#define SSI_SIER_TFS_EN		(1 << 7)
658c2ecf20Sopenharmony_ci#define SSI_SIER_RFS_EN		(1 << 6)
668c2ecf20Sopenharmony_ci#define SSI_SIER_TLS_EN		(1 << 5)
678c2ecf20Sopenharmony_ci#define SSI_SIER_RLS_EN		(1 << 4)
688c2ecf20Sopenharmony_ci#define SSI_SIER_RFF1_EN	(1 << 3)
698c2ecf20Sopenharmony_ci#define SSI_SIER_RFF0_EN	(1 << 2)
708c2ecf20Sopenharmony_ci#define SSI_SIER_TFE1_EN	(1 << 1)
718c2ecf20Sopenharmony_ci#define SSI_SIER_TFE0_EN	(1 << 0)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define SSI_STCR	0x1c
748c2ecf20Sopenharmony_ci#define SSI_STCR_TXBIT0		(1 << 9)
758c2ecf20Sopenharmony_ci#define SSI_STCR_TFEN1		(1 << 8)
768c2ecf20Sopenharmony_ci#define SSI_STCR_TFEN0		(1 << 7)
778c2ecf20Sopenharmony_ci#define SSI_FIFO_ENABLE_0_SHIFT 7
788c2ecf20Sopenharmony_ci#define SSI_STCR_TFDIR		(1 << 6)
798c2ecf20Sopenharmony_ci#define SSI_STCR_TXDIR		(1 << 5)
808c2ecf20Sopenharmony_ci#define SSI_STCR_TSHFD		(1 << 4)
818c2ecf20Sopenharmony_ci#define SSI_STCR_TSCKP		(1 << 3)
828c2ecf20Sopenharmony_ci#define SSI_STCR_TFSI		(1 << 2)
838c2ecf20Sopenharmony_ci#define SSI_STCR_TFSL		(1 << 1)
848c2ecf20Sopenharmony_ci#define SSI_STCR_TEFS		(1 << 0)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define SSI_SRCR	0x20
878c2ecf20Sopenharmony_ci#define SSI_SRCR_RXBIT0		(1 << 9)
888c2ecf20Sopenharmony_ci#define SSI_SRCR_RFEN1		(1 << 8)
898c2ecf20Sopenharmony_ci#define SSI_SRCR_RFEN0		(1 << 7)
908c2ecf20Sopenharmony_ci#define SSI_FIFO_ENABLE_0_SHIFT 7
918c2ecf20Sopenharmony_ci#define SSI_SRCR_RFDIR		(1 << 6)
928c2ecf20Sopenharmony_ci#define SSI_SRCR_RXDIR		(1 << 5)
938c2ecf20Sopenharmony_ci#define SSI_SRCR_RSHFD		(1 << 4)
948c2ecf20Sopenharmony_ci#define SSI_SRCR_RSCKP		(1 << 3)
958c2ecf20Sopenharmony_ci#define SSI_SRCR_RFSI		(1 << 2)
968c2ecf20Sopenharmony_ci#define SSI_SRCR_RFSL		(1 << 1)
978c2ecf20Sopenharmony_ci#define SSI_SRCR_REFS		(1 << 0)
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define SSI_SRCCR		0x28
1008c2ecf20Sopenharmony_ci#define SSI_SRCCR_DIV2		(1 << 18)
1018c2ecf20Sopenharmony_ci#define SSI_SRCCR_PSR		(1 << 17)
1028c2ecf20Sopenharmony_ci#define SSI_SRCCR_WL(x)		((((x) - 2) >> 1) << 13)
1038c2ecf20Sopenharmony_ci#define SSI_SRCCR_DC(x)		(((x) & 0x1f) << 8)
1048c2ecf20Sopenharmony_ci#define SSI_SRCCR_PM(x)		(((x) & 0xff) << 0)
1058c2ecf20Sopenharmony_ci#define SSI_SRCCR_WL_MASK	(0xf << 13)
1068c2ecf20Sopenharmony_ci#define SSI_SRCCR_DC_MASK	(0x1f << 8)
1078c2ecf20Sopenharmony_ci#define SSI_SRCCR_PM_MASK	(0xff << 0)
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define SSI_STCCR		0x24
1108c2ecf20Sopenharmony_ci#define SSI_STCCR_DIV2		(1 << 18)
1118c2ecf20Sopenharmony_ci#define SSI_STCCR_PSR		(1 << 17)
1128c2ecf20Sopenharmony_ci#define SSI_STCCR_WL(x)		((((x) - 2) >> 1) << 13)
1138c2ecf20Sopenharmony_ci#define SSI_STCCR_DC(x)		(((x) & 0x1f) << 8)
1148c2ecf20Sopenharmony_ci#define SSI_STCCR_PM(x)		(((x) & 0xff) << 0)
1158c2ecf20Sopenharmony_ci#define SSI_STCCR_WL_MASK	(0xf << 13)
1168c2ecf20Sopenharmony_ci#define SSI_STCCR_DC_MASK	(0x1f << 8)
1178c2ecf20Sopenharmony_ci#define SSI_STCCR_PM_MASK	(0xff << 0)
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define SSI_SFCSR	0x2c
1208c2ecf20Sopenharmony_ci#define SSI_SFCSR_RFCNT1(x)	(((x) & 0xf) << 28)
1218c2ecf20Sopenharmony_ci#define SSI_RX_FIFO_1_COUNT_SHIFT 28
1228c2ecf20Sopenharmony_ci#define SSI_SFCSR_TFCNT1(x)	(((x) & 0xf) << 24)
1238c2ecf20Sopenharmony_ci#define SSI_TX_FIFO_1_COUNT_SHIFT 24
1248c2ecf20Sopenharmony_ci#define SSI_SFCSR_RFWM1(x)	(((x) & 0xf) << 20)
1258c2ecf20Sopenharmony_ci#define SSI_SFCSR_TFWM1(x)	(((x) & 0xf) << 16)
1268c2ecf20Sopenharmony_ci#define SSI_SFCSR_RFCNT0(x)	(((x) & 0xf) << 12)
1278c2ecf20Sopenharmony_ci#define SSI_RX_FIFO_0_COUNT_SHIFT 12
1288c2ecf20Sopenharmony_ci#define SSI_SFCSR_TFCNT0(x)	(((x) & 0xf) <<  8)
1298c2ecf20Sopenharmony_ci#define SSI_TX_FIFO_0_COUNT_SHIFT 8
1308c2ecf20Sopenharmony_ci#define SSI_SFCSR_RFWM0(x)	(((x) & 0xf) <<  4)
1318c2ecf20Sopenharmony_ci#define SSI_SFCSR_TFWM0(x)	(((x) & 0xf) <<  0)
1328c2ecf20Sopenharmony_ci#define SSI_SFCSR_RFWM0_MASK	(0xf <<  4)
1338c2ecf20Sopenharmony_ci#define SSI_SFCSR_TFWM0_MASK	(0xf <<  0)
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define SSI_STR		0x30
1368c2ecf20Sopenharmony_ci#define SSI_STR_TEST		(1 << 15)
1378c2ecf20Sopenharmony_ci#define SSI_STR_RCK2TCK		(1 << 14)
1388c2ecf20Sopenharmony_ci#define SSI_STR_RFS2TFS		(1 << 13)
1398c2ecf20Sopenharmony_ci#define SSI_STR_RXSTATE(x)	(((x) & 0xf) << 8)
1408c2ecf20Sopenharmony_ci#define SSI_STR_TXD2RXD		(1 <<  7)
1418c2ecf20Sopenharmony_ci#define SSI_STR_TCK2RCK		(1 <<  6)
1428c2ecf20Sopenharmony_ci#define SSI_STR_TFS2RFS		(1 <<  5)
1438c2ecf20Sopenharmony_ci#define SSI_STR_TXSTATE(x)	(((x) & 0xf) << 0)
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci#define SSI_SOR		0x34
1468c2ecf20Sopenharmony_ci#define SSI_SOR_CLKOFF		(1 << 6)
1478c2ecf20Sopenharmony_ci#define SSI_SOR_RX_CLR		(1 << 5)
1488c2ecf20Sopenharmony_ci#define SSI_SOR_TX_CLR		(1 << 4)
1498c2ecf20Sopenharmony_ci#define SSI_SOR_INIT		(1 << 3)
1508c2ecf20Sopenharmony_ci#define SSI_SOR_WAIT(x)		(((x) & 0x3) << 1)
1518c2ecf20Sopenharmony_ci#define SSI_SOR_WAIT_MASK	(0x3 << 1)
1528c2ecf20Sopenharmony_ci#define SSI_SOR_SYNRST		(1 << 0)
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci#define SSI_SACNT	0x38
1558c2ecf20Sopenharmony_ci#define SSI_SACNT_FRDIV(x)	(((x) & 0x3f) << 5)
1568c2ecf20Sopenharmony_ci#define SSI_SACNT_WR		(1 << 4)
1578c2ecf20Sopenharmony_ci#define SSI_SACNT_RD		(1 << 3)
1588c2ecf20Sopenharmony_ci#define SSI_SACNT_TIF		(1 << 2)
1598c2ecf20Sopenharmony_ci#define SSI_SACNT_FV		(1 << 1)
1608c2ecf20Sopenharmony_ci#define SSI_SACNT_AC97EN	(1 << 0)
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define SSI_SACADD	0x3c
1638c2ecf20Sopenharmony_ci#define SSI_SACDAT	0x40
1648c2ecf20Sopenharmony_ci#define SSI_SATAG	0x44
1658c2ecf20Sopenharmony_ci#define SSI_STMSK	0x48
1668c2ecf20Sopenharmony_ci#define SSI_SRMSK	0x4c
1678c2ecf20Sopenharmony_ci#define SSI_SACCST	0x50
1688c2ecf20Sopenharmony_ci#define SSI_SACCEN	0x54
1698c2ecf20Sopenharmony_ci#define SSI_SACCDIS	0x58
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/* SSI clock sources */
1728c2ecf20Sopenharmony_ci#define IMX_SSP_SYS_CLK		0
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci/* SSI audio dividers */
1758c2ecf20Sopenharmony_ci#define IMX_SSI_TX_DIV_2	0
1768c2ecf20Sopenharmony_ci#define IMX_SSI_TX_DIV_PSR	1
1778c2ecf20Sopenharmony_ci#define IMX_SSI_TX_DIV_PM	2
1788c2ecf20Sopenharmony_ci#define IMX_SSI_RX_DIV_2	3
1798c2ecf20Sopenharmony_ci#define IMX_SSI_RX_DIV_PSR	4
1808c2ecf20Sopenharmony_ci#define IMX_SSI_RX_DIV_PM	5
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#define DRV_NAME "imx-ssi"
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci#include <linux/dmaengine.h>
1858c2ecf20Sopenharmony_ci#include <linux/platform_data/dma-imx.h>
1868c2ecf20Sopenharmony_ci#include <sound/dmaengine_pcm.h>
1878c2ecf20Sopenharmony_ci#include "imx-pcm.h"
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistruct imx_ssi {
1908c2ecf20Sopenharmony_ci	struct platform_device *ac97_dev;
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	struct snd_soc_dai *imx_ac97;
1938c2ecf20Sopenharmony_ci	struct clk *clk;
1948c2ecf20Sopenharmony_ci	void __iomem *base;
1958c2ecf20Sopenharmony_ci	int irq;
1968c2ecf20Sopenharmony_ci	int fiq_enable;
1978c2ecf20Sopenharmony_ci	unsigned int offset;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	unsigned int flags;
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	void (*ac97_reset) (struct snd_ac97 *ac97);
2028c2ecf20Sopenharmony_ci	void (*ac97_warm_reset)(struct snd_ac97 *ac97);
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data dma_params_rx;
2058c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data dma_params_tx;
2068c2ecf20Sopenharmony_ci	struct imx_dma_data filter_data_tx;
2078c2ecf20Sopenharmony_ci	struct imx_dma_data filter_data_rx;
2088c2ecf20Sopenharmony_ci	struct imx_pcm_fiq_params fiq_params;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	int fiq_init;
2118c2ecf20Sopenharmony_ci	int dma_init;
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#endif /* _IMX_SSI_H */
215