162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci#ifndef _IMX_SSI_H 462306a36Sopenharmony_ci#define _IMX_SSI_H 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#define SSI_STX0 0x00 762306a36Sopenharmony_ci#define SSI_STX1 0x04 862306a36Sopenharmony_ci#define SSI_SRX0 0x08 962306a36Sopenharmony_ci#define SSI_SRX1 0x0c 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define SSI_SCR 0x10 1262306a36Sopenharmony_ci#define SSI_SCR_CLK_IST (1 << 9) 1362306a36Sopenharmony_ci#define SSI_SCR_CLK_IST_SHIFT 9 1462306a36Sopenharmony_ci#define SSI_SCR_TCH_EN (1 << 8) 1562306a36Sopenharmony_ci#define SSI_SCR_SYS_CLK_EN (1 << 7) 1662306a36Sopenharmony_ci#define SSI_SCR_I2S_MODE_NORM (0 << 5) 1762306a36Sopenharmony_ci#define SSI_SCR_I2S_MODE_MSTR (1 << 5) 1862306a36Sopenharmony_ci#define SSI_SCR_I2S_MODE_SLAVE (2 << 5) 1962306a36Sopenharmony_ci#define SSI_I2S_MODE_MASK (3 << 5) 2062306a36Sopenharmony_ci#define SSI_SCR_SYN (1 << 4) 2162306a36Sopenharmony_ci#define SSI_SCR_NET (1 << 3) 2262306a36Sopenharmony_ci#define SSI_SCR_RE (1 << 2) 2362306a36Sopenharmony_ci#define SSI_SCR_TE (1 << 1) 2462306a36Sopenharmony_ci#define SSI_SCR_SSIEN (1 << 0) 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#define SSI_SISR 0x14 2762306a36Sopenharmony_ci#define SSI_SISR_MASK ((1 << 19) - 1) 2862306a36Sopenharmony_ci#define SSI_SISR_CMDAU (1 << 18) 2962306a36Sopenharmony_ci#define SSI_SISR_CMDDU (1 << 17) 3062306a36Sopenharmony_ci#define SSI_SISR_RXT (1 << 16) 3162306a36Sopenharmony_ci#define SSI_SISR_RDR1 (1 << 15) 3262306a36Sopenharmony_ci#define SSI_SISR_RDR0 (1 << 14) 3362306a36Sopenharmony_ci#define SSI_SISR_TDE1 (1 << 13) 3462306a36Sopenharmony_ci#define SSI_SISR_TDE0 (1 << 12) 3562306a36Sopenharmony_ci#define SSI_SISR_ROE1 (1 << 11) 3662306a36Sopenharmony_ci#define SSI_SISR_ROE0 (1 << 10) 3762306a36Sopenharmony_ci#define SSI_SISR_TUE1 (1 << 9) 3862306a36Sopenharmony_ci#define SSI_SISR_TUE0 (1 << 8) 3962306a36Sopenharmony_ci#define SSI_SISR_TFS (1 << 7) 4062306a36Sopenharmony_ci#define SSI_SISR_RFS (1 << 6) 4162306a36Sopenharmony_ci#define SSI_SISR_TLS (1 << 5) 4262306a36Sopenharmony_ci#define SSI_SISR_RLS (1 << 4) 4362306a36Sopenharmony_ci#define SSI_SISR_RFF1 (1 << 3) 4462306a36Sopenharmony_ci#define SSI_SISR_RFF0 (1 << 2) 4562306a36Sopenharmony_ci#define SSI_SISR_TFE1 (1 << 1) 4662306a36Sopenharmony_ci#define SSI_SISR_TFE0 (1 << 0) 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define SSI_SIER 0x18 4962306a36Sopenharmony_ci#define SSI_SIER_RDMAE (1 << 22) 5062306a36Sopenharmony_ci#define SSI_SIER_RIE (1 << 21) 5162306a36Sopenharmony_ci#define SSI_SIER_TDMAE (1 << 20) 5262306a36Sopenharmony_ci#define SSI_SIER_TIE (1 << 19) 5362306a36Sopenharmony_ci#define SSI_SIER_CMDAU_EN (1 << 18) 5462306a36Sopenharmony_ci#define SSI_SIER_CMDDU_EN (1 << 17) 5562306a36Sopenharmony_ci#define SSI_SIER_RXT_EN (1 << 16) 5662306a36Sopenharmony_ci#define SSI_SIER_RDR1_EN (1 << 15) 5762306a36Sopenharmony_ci#define SSI_SIER_RDR0_EN (1 << 14) 5862306a36Sopenharmony_ci#define SSI_SIER_TDE1_EN (1 << 13) 5962306a36Sopenharmony_ci#define SSI_SIER_TDE0_EN (1 << 12) 6062306a36Sopenharmony_ci#define SSI_SIER_ROE1_EN (1 << 11) 6162306a36Sopenharmony_ci#define SSI_SIER_ROE0_EN (1 << 10) 6262306a36Sopenharmony_ci#define SSI_SIER_TUE1_EN (1 << 9) 6362306a36Sopenharmony_ci#define SSI_SIER_TUE0_EN (1 << 8) 6462306a36Sopenharmony_ci#define SSI_SIER_TFS_EN (1 << 7) 6562306a36Sopenharmony_ci#define SSI_SIER_RFS_EN (1 << 6) 6662306a36Sopenharmony_ci#define SSI_SIER_TLS_EN (1 << 5) 6762306a36Sopenharmony_ci#define SSI_SIER_RLS_EN (1 << 4) 6862306a36Sopenharmony_ci#define SSI_SIER_RFF1_EN (1 << 3) 6962306a36Sopenharmony_ci#define SSI_SIER_RFF0_EN (1 << 2) 7062306a36Sopenharmony_ci#define SSI_SIER_TFE1_EN (1 << 1) 7162306a36Sopenharmony_ci#define SSI_SIER_TFE0_EN (1 << 0) 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define SSI_STCR 0x1c 7462306a36Sopenharmony_ci#define SSI_STCR_TXBIT0 (1 << 9) 7562306a36Sopenharmony_ci#define SSI_STCR_TFEN1 (1 << 8) 7662306a36Sopenharmony_ci#define SSI_STCR_TFEN0 (1 << 7) 7762306a36Sopenharmony_ci#define SSI_FIFO_ENABLE_0_SHIFT 7 7862306a36Sopenharmony_ci#define SSI_STCR_TFDIR (1 << 6) 7962306a36Sopenharmony_ci#define SSI_STCR_TXDIR (1 << 5) 8062306a36Sopenharmony_ci#define SSI_STCR_TSHFD (1 << 4) 8162306a36Sopenharmony_ci#define SSI_STCR_TSCKP (1 << 3) 8262306a36Sopenharmony_ci#define SSI_STCR_TFSI (1 << 2) 8362306a36Sopenharmony_ci#define SSI_STCR_TFSL (1 << 1) 8462306a36Sopenharmony_ci#define SSI_STCR_TEFS (1 << 0) 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci#define SSI_SRCR 0x20 8762306a36Sopenharmony_ci#define SSI_SRCR_RXBIT0 (1 << 9) 8862306a36Sopenharmony_ci#define SSI_SRCR_RFEN1 (1 << 8) 8962306a36Sopenharmony_ci#define SSI_SRCR_RFEN0 (1 << 7) 9062306a36Sopenharmony_ci#define SSI_FIFO_ENABLE_0_SHIFT 7 9162306a36Sopenharmony_ci#define SSI_SRCR_RFDIR (1 << 6) 9262306a36Sopenharmony_ci#define SSI_SRCR_RXDIR (1 << 5) 9362306a36Sopenharmony_ci#define SSI_SRCR_RSHFD (1 << 4) 9462306a36Sopenharmony_ci#define SSI_SRCR_RSCKP (1 << 3) 9562306a36Sopenharmony_ci#define SSI_SRCR_RFSI (1 << 2) 9662306a36Sopenharmony_ci#define SSI_SRCR_RFSL (1 << 1) 9762306a36Sopenharmony_ci#define SSI_SRCR_REFS (1 << 0) 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define SSI_SRCCR 0x28 10062306a36Sopenharmony_ci#define SSI_SRCCR_DIV2 (1 << 18) 10162306a36Sopenharmony_ci#define SSI_SRCCR_PSR (1 << 17) 10262306a36Sopenharmony_ci#define SSI_SRCCR_WL(x) ((((x) - 2) >> 1) << 13) 10362306a36Sopenharmony_ci#define SSI_SRCCR_DC(x) (((x) & 0x1f) << 8) 10462306a36Sopenharmony_ci#define SSI_SRCCR_PM(x) (((x) & 0xff) << 0) 10562306a36Sopenharmony_ci#define SSI_SRCCR_WL_MASK (0xf << 13) 10662306a36Sopenharmony_ci#define SSI_SRCCR_DC_MASK (0x1f << 8) 10762306a36Sopenharmony_ci#define SSI_SRCCR_PM_MASK (0xff << 0) 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define SSI_STCCR 0x24 11062306a36Sopenharmony_ci#define SSI_STCCR_DIV2 (1 << 18) 11162306a36Sopenharmony_ci#define SSI_STCCR_PSR (1 << 17) 11262306a36Sopenharmony_ci#define SSI_STCCR_WL(x) ((((x) - 2) >> 1) << 13) 11362306a36Sopenharmony_ci#define SSI_STCCR_DC(x) (((x) & 0x1f) << 8) 11462306a36Sopenharmony_ci#define SSI_STCCR_PM(x) (((x) & 0xff) << 0) 11562306a36Sopenharmony_ci#define SSI_STCCR_WL_MASK (0xf << 13) 11662306a36Sopenharmony_ci#define SSI_STCCR_DC_MASK (0x1f << 8) 11762306a36Sopenharmony_ci#define SSI_STCCR_PM_MASK (0xff << 0) 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#define SSI_SFCSR 0x2c 12062306a36Sopenharmony_ci#define SSI_SFCSR_RFCNT1(x) (((x) & 0xf) << 28) 12162306a36Sopenharmony_ci#define SSI_RX_FIFO_1_COUNT_SHIFT 28 12262306a36Sopenharmony_ci#define SSI_SFCSR_TFCNT1(x) (((x) & 0xf) << 24) 12362306a36Sopenharmony_ci#define SSI_TX_FIFO_1_COUNT_SHIFT 24 12462306a36Sopenharmony_ci#define SSI_SFCSR_RFWM1(x) (((x) & 0xf) << 20) 12562306a36Sopenharmony_ci#define SSI_SFCSR_TFWM1(x) (((x) & 0xf) << 16) 12662306a36Sopenharmony_ci#define SSI_SFCSR_RFCNT0(x) (((x) & 0xf) << 12) 12762306a36Sopenharmony_ci#define SSI_RX_FIFO_0_COUNT_SHIFT 12 12862306a36Sopenharmony_ci#define SSI_SFCSR_TFCNT0(x) (((x) & 0xf) << 8) 12962306a36Sopenharmony_ci#define SSI_TX_FIFO_0_COUNT_SHIFT 8 13062306a36Sopenharmony_ci#define SSI_SFCSR_RFWM0(x) (((x) & 0xf) << 4) 13162306a36Sopenharmony_ci#define SSI_SFCSR_TFWM0(x) (((x) & 0xf) << 0) 13262306a36Sopenharmony_ci#define SSI_SFCSR_RFWM0_MASK (0xf << 4) 13362306a36Sopenharmony_ci#define SSI_SFCSR_TFWM0_MASK (0xf << 0) 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci#define SSI_STR 0x30 13662306a36Sopenharmony_ci#define SSI_STR_TEST (1 << 15) 13762306a36Sopenharmony_ci#define SSI_STR_RCK2TCK (1 << 14) 13862306a36Sopenharmony_ci#define SSI_STR_RFS2TFS (1 << 13) 13962306a36Sopenharmony_ci#define SSI_STR_RXSTATE(x) (((x) & 0xf) << 8) 14062306a36Sopenharmony_ci#define SSI_STR_TXD2RXD (1 << 7) 14162306a36Sopenharmony_ci#define SSI_STR_TCK2RCK (1 << 6) 14262306a36Sopenharmony_ci#define SSI_STR_TFS2RFS (1 << 5) 14362306a36Sopenharmony_ci#define SSI_STR_TXSTATE(x) (((x) & 0xf) << 0) 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci#define SSI_SOR 0x34 14662306a36Sopenharmony_ci#define SSI_SOR_CLKOFF (1 << 6) 14762306a36Sopenharmony_ci#define SSI_SOR_RX_CLR (1 << 5) 14862306a36Sopenharmony_ci#define SSI_SOR_TX_CLR (1 << 4) 14962306a36Sopenharmony_ci#define SSI_SOR_INIT (1 << 3) 15062306a36Sopenharmony_ci#define SSI_SOR_WAIT(x) (((x) & 0x3) << 1) 15162306a36Sopenharmony_ci#define SSI_SOR_WAIT_MASK (0x3 << 1) 15262306a36Sopenharmony_ci#define SSI_SOR_SYNRST (1 << 0) 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci#define SSI_SACNT 0x38 15562306a36Sopenharmony_ci#define SSI_SACNT_FRDIV(x) (((x) & 0x3f) << 5) 15662306a36Sopenharmony_ci#define SSI_SACNT_WR (1 << 4) 15762306a36Sopenharmony_ci#define SSI_SACNT_RD (1 << 3) 15862306a36Sopenharmony_ci#define SSI_SACNT_TIF (1 << 2) 15962306a36Sopenharmony_ci#define SSI_SACNT_FV (1 << 1) 16062306a36Sopenharmony_ci#define SSI_SACNT_AC97EN (1 << 0) 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci#define SSI_SACADD 0x3c 16362306a36Sopenharmony_ci#define SSI_SACDAT 0x40 16462306a36Sopenharmony_ci#define SSI_SATAG 0x44 16562306a36Sopenharmony_ci#define SSI_STMSK 0x48 16662306a36Sopenharmony_ci#define SSI_SRMSK 0x4c 16762306a36Sopenharmony_ci#define SSI_SACCST 0x50 16862306a36Sopenharmony_ci#define SSI_SACCEN 0x54 16962306a36Sopenharmony_ci#define SSI_SACCDIS 0x58 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci/* SSI clock sources */ 17262306a36Sopenharmony_ci#define IMX_SSP_SYS_CLK 0 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci/* SSI audio dividers */ 17562306a36Sopenharmony_ci#define IMX_SSI_TX_DIV_2 0 17662306a36Sopenharmony_ci#define IMX_SSI_TX_DIV_PSR 1 17762306a36Sopenharmony_ci#define IMX_SSI_TX_DIV_PM 2 17862306a36Sopenharmony_ci#define IMX_SSI_RX_DIV_2 3 17962306a36Sopenharmony_ci#define IMX_SSI_RX_DIV_PSR 4 18062306a36Sopenharmony_ci#define IMX_SSI_RX_DIV_PM 5 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ci#define DRV_NAME "imx-ssi" 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci#include <linux/dmaengine.h> 18562306a36Sopenharmony_ci#include <linux/dma/imx-dma.h> 18662306a36Sopenharmony_ci#include <sound/dmaengine_pcm.h> 18762306a36Sopenharmony_ci#include "imx-pcm.h" 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_cistruct imx_ssi { 19062306a36Sopenharmony_ci struct platform_device *ac97_dev; 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci struct snd_soc_dai *imx_ac97; 19362306a36Sopenharmony_ci struct clk *clk; 19462306a36Sopenharmony_ci void __iomem *base; 19562306a36Sopenharmony_ci int irq; 19662306a36Sopenharmony_ci int fiq_enable; 19762306a36Sopenharmony_ci unsigned int offset; 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci unsigned int flags; 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci void (*ac97_reset) (struct snd_ac97 *ac97); 20262306a36Sopenharmony_ci void (*ac97_warm_reset)(struct snd_ac97 *ac97); 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci struct snd_dmaengine_dai_dma_data dma_params_rx; 20562306a36Sopenharmony_ci struct snd_dmaengine_dai_dma_data dma_params_tx; 20662306a36Sopenharmony_ci struct imx_dma_data filter_data_tx; 20762306a36Sopenharmony_ci struct imx_dma_data filter_data_rx; 20862306a36Sopenharmony_ci struct imx_pcm_fiq_params fiq_params; 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci int fiq_init; 21162306a36Sopenharmony_ci int dma_init; 21262306a36Sopenharmony_ci}; 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci#endif /* _IMX_SSI_H */ 215