162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Texas Instruments PCM186x Universal Audio ADC 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2015-2017 Texas Instruments Incorporated - https://www.ti.com 662306a36Sopenharmony_ci * Andreas Dannenberg <dannenberg@ti.com> 762306a36Sopenharmony_ci * Andrew F. Davis <afd@ti.com> 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef _PCM186X_H_ 1162306a36Sopenharmony_ci#define _PCM186X_H_ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <linux/pm.h> 1462306a36Sopenharmony_ci#include <linux/regmap.h> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_cienum pcm186x_type { 1762306a36Sopenharmony_ci PCM1862, 1862306a36Sopenharmony_ci PCM1863, 1962306a36Sopenharmony_ci PCM1864, 2062306a36Sopenharmony_ci PCM1865, 2162306a36Sopenharmony_ci}; 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define PCM186X_RATES SNDRV_PCM_RATE_8000_192000 2462306a36Sopenharmony_ci#define PCM186X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ 2562306a36Sopenharmony_ci SNDRV_PCM_FMTBIT_S20_3LE |\ 2662306a36Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | \ 2762306a36Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE) 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define PCM186X_PAGE_LEN 0x0100 3062306a36Sopenharmony_ci#define PCM186X_PAGE_BASE(n) (PCM186X_PAGE_LEN * n) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci/* The page selection register address is the same on all pages */ 3362306a36Sopenharmony_ci#define PCM186X_PAGE 0 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* Register Definitions - Page 0 */ 3662306a36Sopenharmony_ci#define PCM186X_PGA_VAL_CH1_L (PCM186X_PAGE_BASE(0) + 1) 3762306a36Sopenharmony_ci#define PCM186X_PGA_VAL_CH1_R (PCM186X_PAGE_BASE(0) + 2) 3862306a36Sopenharmony_ci#define PCM186X_PGA_VAL_CH2_L (PCM186X_PAGE_BASE(0) + 3) 3962306a36Sopenharmony_ci#define PCM186X_PGA_VAL_CH2_R (PCM186X_PAGE_BASE(0) + 4) 4062306a36Sopenharmony_ci#define PCM186X_PGA_CTRL (PCM186X_PAGE_BASE(0) + 5) 4162306a36Sopenharmony_ci#define PCM186X_ADC1_INPUT_SEL_L (PCM186X_PAGE_BASE(0) + 6) 4262306a36Sopenharmony_ci#define PCM186X_ADC1_INPUT_SEL_R (PCM186X_PAGE_BASE(0) + 7) 4362306a36Sopenharmony_ci#define PCM186X_ADC2_INPUT_SEL_L (PCM186X_PAGE_BASE(0) + 8) 4462306a36Sopenharmony_ci#define PCM186X_ADC2_INPUT_SEL_R (PCM186X_PAGE_BASE(0) + 9) 4562306a36Sopenharmony_ci#define PCM186X_AUXADC_INPUT_SEL (PCM186X_PAGE_BASE(0) + 10) 4662306a36Sopenharmony_ci#define PCM186X_PCM_CFG (PCM186X_PAGE_BASE(0) + 11) 4762306a36Sopenharmony_ci#define PCM186X_TDM_TX_SEL (PCM186X_PAGE_BASE(0) + 12) 4862306a36Sopenharmony_ci#define PCM186X_TDM_TX_OFFSET (PCM186X_PAGE_BASE(0) + 13) 4962306a36Sopenharmony_ci#define PCM186X_TDM_RX_OFFSET (PCM186X_PAGE_BASE(0) + 14) 5062306a36Sopenharmony_ci#define PCM186X_DPGA_VAL_CH1_L (PCM186X_PAGE_BASE(0) + 15) 5162306a36Sopenharmony_ci#define PCM186X_GPIO1_0_CTRL (PCM186X_PAGE_BASE(0) + 16) 5262306a36Sopenharmony_ci#define PCM186X_GPIO3_2_CTRL (PCM186X_PAGE_BASE(0) + 17) 5362306a36Sopenharmony_ci#define PCM186X_GPIO1_0_DIR_CTRL (PCM186X_PAGE_BASE(0) + 18) 5462306a36Sopenharmony_ci#define PCM186X_GPIO3_2_DIR_CTRL (PCM186X_PAGE_BASE(0) + 19) 5562306a36Sopenharmony_ci#define PCM186X_GPIO_IN_OUT (PCM186X_PAGE_BASE(0) + 20) 5662306a36Sopenharmony_ci#define PCM186X_GPIO_PULL_CTRL (PCM186X_PAGE_BASE(0) + 21) 5762306a36Sopenharmony_ci#define PCM186X_DPGA_VAL_CH1_R (PCM186X_PAGE_BASE(0) + 22) 5862306a36Sopenharmony_ci#define PCM186X_DPGA_VAL_CH2_L (PCM186X_PAGE_BASE(0) + 23) 5962306a36Sopenharmony_ci#define PCM186X_DPGA_VAL_CH2_R (PCM186X_PAGE_BASE(0) + 24) 6062306a36Sopenharmony_ci#define PCM186X_DPGA_GAIN_CTRL (PCM186X_PAGE_BASE(0) + 25) 6162306a36Sopenharmony_ci#define PCM186X_DPGA_MIC_CTRL (PCM186X_PAGE_BASE(0) + 26) 6262306a36Sopenharmony_ci#define PCM186X_DIN_RESAMP_CTRL (PCM186X_PAGE_BASE(0) + 27) 6362306a36Sopenharmony_ci#define PCM186X_CLK_CTRL (PCM186X_PAGE_BASE(0) + 32) 6462306a36Sopenharmony_ci#define PCM186X_DSP1_CLK_DIV (PCM186X_PAGE_BASE(0) + 33) 6562306a36Sopenharmony_ci#define PCM186X_DSP2_CLK_DIV (PCM186X_PAGE_BASE(0) + 34) 6662306a36Sopenharmony_ci#define PCM186X_ADC_CLK_DIV (PCM186X_PAGE_BASE(0) + 35) 6762306a36Sopenharmony_ci#define PCM186X_PLL_SCK_DIV (PCM186X_PAGE_BASE(0) + 37) 6862306a36Sopenharmony_ci#define PCM186X_BCK_DIV (PCM186X_PAGE_BASE(0) + 38) 6962306a36Sopenharmony_ci#define PCM186X_LRK_DIV (PCM186X_PAGE_BASE(0) + 39) 7062306a36Sopenharmony_ci#define PCM186X_PLL_CTRL (PCM186X_PAGE_BASE(0) + 40) 7162306a36Sopenharmony_ci#define PCM186X_PLL_P_DIV (PCM186X_PAGE_BASE(0) + 41) 7262306a36Sopenharmony_ci#define PCM186X_PLL_R_DIV (PCM186X_PAGE_BASE(0) + 42) 7362306a36Sopenharmony_ci#define PCM186X_PLL_J_DIV (PCM186X_PAGE_BASE(0) + 43) 7462306a36Sopenharmony_ci#define PCM186X_PLL_D_DIV_LSB (PCM186X_PAGE_BASE(0) + 44) 7562306a36Sopenharmony_ci#define PCM186X_PLL_D_DIV_MSB (PCM186X_PAGE_BASE(0) + 45) 7662306a36Sopenharmony_ci#define PCM186X_SIGDET_MODE (PCM186X_PAGE_BASE(0) + 48) 7762306a36Sopenharmony_ci#define PCM186X_SIGDET_MASK (PCM186X_PAGE_BASE(0) + 49) 7862306a36Sopenharmony_ci#define PCM186X_SIGDET_STAT (PCM186X_PAGE_BASE(0) + 50) 7962306a36Sopenharmony_ci#define PCM186X_SIGDET_LOSS_TIME (PCM186X_PAGE_BASE(0) + 52) 8062306a36Sopenharmony_ci#define PCM186X_SIGDET_SCAN_TIME (PCM186X_PAGE_BASE(0) + 53) 8162306a36Sopenharmony_ci#define PCM186X_SIGDET_INT_INTVL (PCM186X_PAGE_BASE(0) + 54) 8262306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH1_L (PCM186X_PAGE_BASE(0) + 64) 8362306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH1_L (PCM186X_PAGE_BASE(0) + 65) 8462306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH1_L (PCM186X_PAGE_BASE(0) + 66) 8562306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH1_R (PCM186X_PAGE_BASE(0) + 67) 8662306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH1_R (PCM186X_PAGE_BASE(0) + 68) 8762306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH1_R (PCM186X_PAGE_BASE(0) + 69) 8862306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH2_L (PCM186X_PAGE_BASE(0) + 70) 8962306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH2_L (PCM186X_PAGE_BASE(0) + 71) 9062306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH2_L (PCM186X_PAGE_BASE(0) + 72) 9162306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH2_R (PCM186X_PAGE_BASE(0) + 73) 9262306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH2_R (PCM186X_PAGE_BASE(0) + 74) 9362306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH2_R (PCM186X_PAGE_BASE(0) + 75) 9462306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH3_L (PCM186X_PAGE_BASE(0) + 76) 9562306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH3_L (PCM186X_PAGE_BASE(0) + 77) 9662306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH3_L (PCM186X_PAGE_BASE(0) + 78) 9762306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH3_R (PCM186X_PAGE_BASE(0) + 79) 9862306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH3_R (PCM186X_PAGE_BASE(0) + 80) 9962306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH3_R (PCM186X_PAGE_BASE(0) + 81) 10062306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH4_L (PCM186X_PAGE_BASE(0) + 82) 10162306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH4_L (PCM186X_PAGE_BASE(0) + 83) 10262306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH4_L (PCM186X_PAGE_BASE(0) + 84) 10362306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_REF_CH4_R (PCM186X_PAGE_BASE(0) + 85) 10462306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_DIFF_CH4_R (PCM186X_PAGE_BASE(0) + 86) 10562306a36Sopenharmony_ci#define PCM186X_SIGDET_DC_LEV_CH4_R (PCM186X_PAGE_BASE(0) + 87) 10662306a36Sopenharmony_ci#define PCM186X_AUXADC_DATA_CTRL (PCM186X_PAGE_BASE(0) + 88) 10762306a36Sopenharmony_ci#define PCM186X_AUXADC_DATA_LSB (PCM186X_PAGE_BASE(0) + 89) 10862306a36Sopenharmony_ci#define PCM186X_AUXADC_DATA_MSB (PCM186X_PAGE_BASE(0) + 90) 10962306a36Sopenharmony_ci#define PCM186X_INT_ENABLE (PCM186X_PAGE_BASE(0) + 96) 11062306a36Sopenharmony_ci#define PCM186X_INT_FLAG (PCM186X_PAGE_BASE(0) + 97) 11162306a36Sopenharmony_ci#define PCM186X_INT_POL_WIDTH (PCM186X_PAGE_BASE(0) + 98) 11262306a36Sopenharmony_ci#define PCM186X_POWER_CTRL (PCM186X_PAGE_BASE(0) + 112) 11362306a36Sopenharmony_ci#define PCM186X_FILTER_MUTE_CTRL (PCM186X_PAGE_BASE(0) + 113) 11462306a36Sopenharmony_ci#define PCM186X_DEVICE_STATUS (PCM186X_PAGE_BASE(0) + 114) 11562306a36Sopenharmony_ci#define PCM186X_FSAMPLE_STATUS (PCM186X_PAGE_BASE(0) + 115) 11662306a36Sopenharmony_ci#define PCM186X_DIV_STATUS (PCM186X_PAGE_BASE(0) + 116) 11762306a36Sopenharmony_ci#define PCM186X_CLK_STATUS (PCM186X_PAGE_BASE(0) + 117) 11862306a36Sopenharmony_ci#define PCM186X_SUPPLY_STATUS (PCM186X_PAGE_BASE(0) + 120) 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci/* Register Definitions - Page 1 */ 12162306a36Sopenharmony_ci#define PCM186X_MMAP_STAT_CTRL (PCM186X_PAGE_BASE(1) + 1) 12262306a36Sopenharmony_ci#define PCM186X_MMAP_ADDRESS (PCM186X_PAGE_BASE(1) + 2) 12362306a36Sopenharmony_ci#define PCM186X_MEM_WDATA0 (PCM186X_PAGE_BASE(1) + 4) 12462306a36Sopenharmony_ci#define PCM186X_MEM_WDATA1 (PCM186X_PAGE_BASE(1) + 5) 12562306a36Sopenharmony_ci#define PCM186X_MEM_WDATA2 (PCM186X_PAGE_BASE(1) + 6) 12662306a36Sopenharmony_ci#define PCM186X_MEM_WDATA3 (PCM186X_PAGE_BASE(1) + 7) 12762306a36Sopenharmony_ci#define PCM186X_MEM_RDATA0 (PCM186X_PAGE_BASE(1) + 8) 12862306a36Sopenharmony_ci#define PCM186X_MEM_RDATA1 (PCM186X_PAGE_BASE(1) + 9) 12962306a36Sopenharmony_ci#define PCM186X_MEM_RDATA2 (PCM186X_PAGE_BASE(1) + 10) 13062306a36Sopenharmony_ci#define PCM186X_MEM_RDATA3 (PCM186X_PAGE_BASE(1) + 11) 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/* Register Definitions - Page 3 */ 13362306a36Sopenharmony_ci#define PCM186X_OSC_PWR_DOWN_CTRL (PCM186X_PAGE_BASE(3) + 18) 13462306a36Sopenharmony_ci#define PCM186X_MIC_BIAS_CTRL (PCM186X_PAGE_BASE(3) + 21) 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci/* Register Definitions - Page 253 */ 13762306a36Sopenharmony_ci#define PCM186X_CURR_TRIM_CTRL (PCM186X_PAGE_BASE(253) + 20) 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci#define PCM186X_MAX_REGISTER PCM186X_CURR_TRIM_CTRL 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci/* PCM186X_PAGE */ 14262306a36Sopenharmony_ci#define PCM186X_RESET 0xfe 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci/* PCM186X_ADCX_INPUT_SEL_X */ 14562306a36Sopenharmony_ci#define PCM186X_ADC_INPUT_SEL_POL BIT(7) 14662306a36Sopenharmony_ci#define PCM186X_ADC_INPUT_SEL_MASK GENMASK(5, 0) 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci/* PCM186X_PCM_CFG */ 14962306a36Sopenharmony_ci#define PCM186X_PCM_CFG_RX_WLEN_MASK GENMASK(7, 6) 15062306a36Sopenharmony_ci#define PCM186X_PCM_CFG_RX_WLEN_SHIFT 6 15162306a36Sopenharmony_ci#define PCM186X_PCM_CFG_RX_WLEN_32 0x00 15262306a36Sopenharmony_ci#define PCM186X_PCM_CFG_RX_WLEN_24 0x01 15362306a36Sopenharmony_ci#define PCM186X_PCM_CFG_RX_WLEN_20 0x02 15462306a36Sopenharmony_ci#define PCM186X_PCM_CFG_RX_WLEN_16 0x03 15562306a36Sopenharmony_ci#define PCM186X_PCM_CFG_TDM_LRCK_MODE BIT(4) 15662306a36Sopenharmony_ci#define PCM186X_PCM_CFG_TX_WLEN_MASK GENMASK(3, 2) 15762306a36Sopenharmony_ci#define PCM186X_PCM_CFG_TX_WLEN_SHIFT 2 15862306a36Sopenharmony_ci#define PCM186X_PCM_CFG_TX_WLEN_32 0x00 15962306a36Sopenharmony_ci#define PCM186X_PCM_CFG_TX_WLEN_24 0x01 16062306a36Sopenharmony_ci#define PCM186X_PCM_CFG_TX_WLEN_20 0x02 16162306a36Sopenharmony_ci#define PCM186X_PCM_CFG_TX_WLEN_16 0x03 16262306a36Sopenharmony_ci#define PCM186X_PCM_CFG_FMT_MASK GENMASK(1, 0) 16362306a36Sopenharmony_ci#define PCM186X_PCM_CFG_FMT_SHIFT 0 16462306a36Sopenharmony_ci#define PCM186X_PCM_CFG_FMT_I2S 0x00 16562306a36Sopenharmony_ci#define PCM186X_PCM_CFG_FMT_LEFTJ 0x01 16662306a36Sopenharmony_ci#define PCM186X_PCM_CFG_FMT_RIGHTJ 0x02 16762306a36Sopenharmony_ci#define PCM186X_PCM_CFG_FMT_TDM 0x03 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci/* PCM186X_TDM_TX_SEL */ 17062306a36Sopenharmony_ci#define PCM186X_TDM_TX_SEL_2CH 0x00 17162306a36Sopenharmony_ci#define PCM186X_TDM_TX_SEL_4CH 0x01 17262306a36Sopenharmony_ci#define PCM186X_TDM_TX_SEL_6CH 0x02 17362306a36Sopenharmony_ci#define PCM186X_TDM_TX_SEL_MASK 0x03 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci/* PCM186X_CLK_CTRL */ 17662306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_SCK_XI_SEL1 BIT(7) 17762306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_SCK_XI_SEL0 BIT(6) 17862306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_SCK_SRC_PLL BIT(5) 17962306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_MST_MODE BIT(4) 18062306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_ADC_SRC_PLL BIT(3) 18162306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_DSP2_SRC_PLL BIT(2) 18262306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_DSP1_SRC_PLL BIT(1) 18362306a36Sopenharmony_ci#define PCM186X_CLK_CTRL_CLKDET_EN BIT(0) 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci/* PCM186X_PLL_CTRL */ 18662306a36Sopenharmony_ci#define PCM186X_PLL_CTRL_LOCK BIT(4) 18762306a36Sopenharmony_ci#define PCM186X_PLL_CTRL_REF_SEL BIT(1) 18862306a36Sopenharmony_ci#define PCM186X_PLL_CTRL_EN BIT(0) 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci/* PCM186X_POWER_CTRL */ 19162306a36Sopenharmony_ci#define PCM186X_PWR_CTRL_PWRDN BIT(2) 19262306a36Sopenharmony_ci#define PCM186X_PWR_CTRL_SLEEP BIT(1) 19362306a36Sopenharmony_ci#define PCM186X_PWR_CTRL_STBY BIT(0) 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci/* PCM186X_CLK_STATUS */ 19662306a36Sopenharmony_ci#define PCM186X_CLK_STATUS_LRCKHLT BIT(6) 19762306a36Sopenharmony_ci#define PCM186X_CLK_STATUS_BCKHLT BIT(5) 19862306a36Sopenharmony_ci#define PCM186X_CLK_STATUS_SCKHLT BIT(4) 19962306a36Sopenharmony_ci#define PCM186X_CLK_STATUS_LRCKERR BIT(2) 20062306a36Sopenharmony_ci#define PCM186X_CLK_STATUS_BCKERR BIT(1) 20162306a36Sopenharmony_ci#define PCM186X_CLK_STATUS_SCKERR BIT(0) 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci/* PCM186X_SUPPLY_STATUS */ 20462306a36Sopenharmony_ci#define PCM186X_SUPPLY_STATUS_DVDD BIT(2) 20562306a36Sopenharmony_ci#define PCM186X_SUPPLY_STATUS_AVDD BIT(1) 20662306a36Sopenharmony_ci#define PCM186X_SUPPLY_STATUS_LDO BIT(0) 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci/* PCM186X_MMAP_STAT_CTRL */ 20962306a36Sopenharmony_ci#define PCM186X_MMAP_STAT_DONE BIT(4) 21062306a36Sopenharmony_ci#define PCM186X_MMAP_STAT_BUSY BIT(2) 21162306a36Sopenharmony_ci#define PCM186X_MMAP_STAT_R_REQ BIT(1) 21262306a36Sopenharmony_ci#define PCM186X_MMAP_STAT_W_REQ BIT(0) 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ciextern const struct regmap_config pcm186x_regmap; 21562306a36Sopenharmony_ci 21662306a36Sopenharmony_ciint pcm186x_probe(struct device *dev, enum pcm186x_type type, int irq, 21762306a36Sopenharmony_ci struct regmap *regmap); 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci#endif /* _PCM186X_H_ */ 220