18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * NXP AUDMIX ALSA SoC Digital Audio Interface (DAI) driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2017 NXP 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __FSL_AUDMIX_H 98c2ecf20Sopenharmony_ci#define __FSL_AUDMIX_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define FSL_AUDMIX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 128c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE |\ 138c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE) 148c2ecf20Sopenharmony_ci/* AUDMIX Registers */ 158c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR 0x200 /* Control */ 168c2ecf20Sopenharmony_ci#define FSL_AUDMIX_STR 0x204 /* Status */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATCR0 0x208 /* Attenuation Control */ 198c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATIVAL0 0x20c /* Attenuation Initial Value */ 208c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPUP0 0x210 /* Attenuation step up factor */ 218c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPDN0 0x214 /* Attenuation step down factor */ 228c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPTGT0 0x218 /* Attenuation step target */ 238c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATTNVAL0 0x21c /* Attenuation Value */ 248c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTP0 0x220 /* Attenuation step number */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATCR1 0x228 /* Attenuation Control */ 278c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATIVAL1 0x22c /* Attenuation Initial Value */ 288c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPUP1 0x230 /* Attenuation step up factor */ 298c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPDN1 0x234 /* Attenuation step down factor */ 308c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPTGT1 0x238 /* Attenuation step target */ 318c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATTNVAL1 0x23c /* Attenuation Value */ 328c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTP1 0x240 /* Attenuation step number */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* AUDMIX Control Register */ 358c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MIXCLK_SHIFT 0 368c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MIXCLK_MASK BIT(FSL_AUDMIX_CTR_MIXCLK_SHIFT) 378c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MIXCLK(i) ((i) << FSL_AUDMIX_CTR_MIXCLK_SHIFT) 388c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTSRC_SHIFT 1 398c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTSRC_MASK (0x3 << FSL_AUDMIX_CTR_OUTSRC_SHIFT) 408c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTSRC(i) (((i) << FSL_AUDMIX_CTR_OUTSRC_SHIFT)\ 418c2ecf20Sopenharmony_ci & FSL_AUDMIX_CTR_OUTSRC_MASK) 428c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTWIDTH_SHIFT 3 438c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTWIDTH_MASK (0x7 << FSL_AUDMIX_CTR_OUTWIDTH_SHIFT) 448c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTWIDTH(i) (((i) << FSL_AUDMIX_CTR_OUTWIDTH_SHIFT)\ 458c2ecf20Sopenharmony_ci & FSL_AUDMIX_CTR_OUTWIDTH_MASK) 468c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTCKPOL_SHIFT 6 478c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTCKPOL_MASK BIT(FSL_AUDMIX_CTR_OUTCKPOL_SHIFT) 488c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_OUTCKPOL(i) ((i) << FSL_AUDMIX_CTR_OUTCKPOL_SHIFT) 498c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MASKRTDF_SHIFT 7 508c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MASKRTDF_MASK BIT(FSL_AUDMIX_CTR_MASKRTDF_SHIFT) 518c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MASKRTDF(i) ((i) << FSL_AUDMIX_CTR_MASKRTDF_SHIFT) 528c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MASKCKDF_SHIFT 8 538c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MASKCKDF_MASK BIT(FSL_AUDMIX_CTR_MASKCKDF_SHIFT) 548c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_MASKCKDF(i) ((i) << FSL_AUDMIX_CTR_MASKCKDF_SHIFT) 558c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_SYNCMODE_SHIFT 9 568c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_SYNCMODE_MASK BIT(FSL_AUDMIX_CTR_SYNCMODE_SHIFT) 578c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_SYNCMODE(i) ((i) << FSL_AUDMIX_CTR_SYNCMODE_SHIFT) 588c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_SYNCSRC_SHIFT 10 598c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_SYNCSRC_MASK BIT(FSL_AUDMIX_CTR_SYNCSRC_SHIFT) 608c2ecf20Sopenharmony_ci#define FSL_AUDMIX_CTR_SYNCSRC(i) ((i) << FSL_AUDMIX_CTR_SYNCSRC_SHIFT) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* AUDMIX Status Register */ 638c2ecf20Sopenharmony_ci#define FSL_AUDMIX_STR_RATEDIFF BIT(0) 648c2ecf20Sopenharmony_ci#define FSL_AUDMIX_STR_CLKDIFF BIT(1) 658c2ecf20Sopenharmony_ci#define FSL_AUDMIX_STR_MIXSTAT_SHIFT 2 668c2ecf20Sopenharmony_ci#define FSL_AUDMIX_STR_MIXSTAT_MASK (0x3 << FSL_AUDMIX_STR_MIXSTAT_SHIFT) 678c2ecf20Sopenharmony_ci#define FSL_AUDMIX_STR_MIXSTAT(i) (((i) & FSL_AUDMIX_STR_MIXSTAT_MASK) \ 688c2ecf20Sopenharmony_ci >> FSL_AUDMIX_STR_MIXSTAT_SHIFT) 698c2ecf20Sopenharmony_ci/* AUDMIX Attenuation Control Register */ 708c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATCR_AT_EN BIT(0) 718c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATCR_AT_UPDN BIT(1) 728c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATCR_ATSTPDIF_SHIFT 2 738c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATCR_ATSTPDFI_MASK \ 748c2ecf20Sopenharmony_ci (0xfff << FSL_AUDMIX_ATCR_ATSTPDIF_SHIFT) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* AUDMIX Attenuation Initial Value Register */ 778c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATIVAL_ATINVAL_MASK 0x3FFFF 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* AUDMIX Attenuation Step Up Factor Register */ 808c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPUP_ATSTEPUP_MASK 0x3FFFF 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* AUDMIX Attenuation Step Down Factor Register */ 838c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPDN_ATSTEPDN_MASK 0x3FFFF 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* AUDMIX Attenuation Step Target Register */ 868c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTPTGT_ATSTPTG_MASK 0x3FFFF 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* AUDMIX Attenuation Value Register */ 898c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATTNVAL_ATCURVAL_MASK 0x3FFFF 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* AUDMIX Attenuation Step Number Register */ 928c2ecf20Sopenharmony_ci#define FSL_AUDMIX_ATSTP_STPCTR_MASK 0x3FFFF 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define FSL_AUDMIX_MAX_DAIS 2 958c2ecf20Sopenharmony_cistruct fsl_audmix { 968c2ecf20Sopenharmony_ci struct platform_device *pdev; 978c2ecf20Sopenharmony_ci struct regmap *regmap; 988c2ecf20Sopenharmony_ci struct clk *ipg_clk; 998c2ecf20Sopenharmony_ci spinlock_t lock; /* Protect tdms */ 1008c2ecf20Sopenharmony_ci u8 tdms; 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#endif /* __FSL_AUDMIX_H */ 104