162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/bitops.h> 762306a36Sopenharmony_ci#include <linux/device.h> 862306a36Sopenharmony_ci#include <linux/gpio/consumer.h> 962306a36Sopenharmony_ci#include <linux/init.h> 1062306a36Sopenharmony_ci#include <linux/kernel.h> 1162306a36Sopenharmony_ci#include <linux/module.h> 1262306a36Sopenharmony_ci#include <linux/of_gpio.h> 1362306a36Sopenharmony_ci#include <linux/pm_runtime.h> 1462306a36Sopenharmony_ci#include <linux/printk.h> 1562306a36Sopenharmony_ci#include <linux/regmap.h> 1662306a36Sopenharmony_ci#include <linux/regulator/consumer.h> 1762306a36Sopenharmony_ci#include <linux/slab.h> 1862306a36Sopenharmony_ci#include <linux/soundwire/sdw.h> 1962306a36Sopenharmony_ci#include <linux/soundwire/sdw_registers.h> 2062306a36Sopenharmony_ci#include <linux/soundwire/sdw_type.h> 2162306a36Sopenharmony_ci#include <sound/pcm.h> 2262306a36Sopenharmony_ci#include <sound/pcm_params.h> 2362306a36Sopenharmony_ci#include <sound/soc-dapm.h> 2462306a36Sopenharmony_ci#include <sound/soc.h> 2562306a36Sopenharmony_ci#include <sound/tlv.h> 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define WSA883X_BASE 0x3000 2862306a36Sopenharmony_ci#define WSA883X_ANA_BG_TSADC_BASE (WSA883X_BASE + 0x00000001) 2962306a36Sopenharmony_ci#define WSA883X_REF_CTRL (WSA883X_ANA_BG_TSADC_BASE + 0x0000) 3062306a36Sopenharmony_ci#define WSA883X_TEST_CTL_0 (WSA883X_ANA_BG_TSADC_BASE + 0x0001) 3162306a36Sopenharmony_ci#define WSA883X_BIAS_0 (WSA883X_ANA_BG_TSADC_BASE + 0x0002) 3262306a36Sopenharmony_ci#define WSA883X_OP_CTL (WSA883X_ANA_BG_TSADC_BASE + 0x0003) 3362306a36Sopenharmony_ci#define WSA883X_IREF_CTL (WSA883X_ANA_BG_TSADC_BASE + 0x0004) 3462306a36Sopenharmony_ci#define WSA883X_ISENS_CTL (WSA883X_ANA_BG_TSADC_BASE + 0x0005) 3562306a36Sopenharmony_ci#define WSA883X_CLK_CTL (WSA883X_ANA_BG_TSADC_BASE + 0x0006) 3662306a36Sopenharmony_ci#define WSA883X_TEST_CTL_1 (WSA883X_ANA_BG_TSADC_BASE + 0x0007) 3762306a36Sopenharmony_ci#define WSA883X_BIAS_1 (WSA883X_ANA_BG_TSADC_BASE + 0x0008) 3862306a36Sopenharmony_ci#define WSA883X_ADC_CTL (WSA883X_ANA_BG_TSADC_BASE + 0x0009) 3962306a36Sopenharmony_ci#define WSA883X_DOUT_MSB (WSA883X_ANA_BG_TSADC_BASE + 0x000A) 4062306a36Sopenharmony_ci#define WSA883X_DOUT_LSB (WSA883X_ANA_BG_TSADC_BASE + 0x000B) 4162306a36Sopenharmony_ci#define WSA883X_VBAT_SNS (WSA883X_ANA_BG_TSADC_BASE + 0x000C) 4262306a36Sopenharmony_ci#define WSA883X_ITRIM_CODE (WSA883X_ANA_BG_TSADC_BASE + 0x000D) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define WSA883X_ANA_IVSENSE_BASE (WSA883X_BASE + 0x0000000F) 4562306a36Sopenharmony_ci#define WSA883X_EN (WSA883X_ANA_IVSENSE_BASE + 0x0000) 4662306a36Sopenharmony_ci#define WSA883X_OVERRIDE1 (WSA883X_ANA_IVSENSE_BASE + 0x0001) 4762306a36Sopenharmony_ci#define WSA883X_OVERRIDE2 (WSA883X_ANA_IVSENSE_BASE + 0x0002) 4862306a36Sopenharmony_ci#define WSA883X_VSENSE1 (WSA883X_ANA_IVSENSE_BASE + 0x0003) 4962306a36Sopenharmony_ci#define WSA883X_ISENSE1 (WSA883X_ANA_IVSENSE_BASE + 0x0004) 5062306a36Sopenharmony_ci#define WSA883X_ISENSE2 (WSA883X_ANA_IVSENSE_BASE + 0x0005) 5162306a36Sopenharmony_ci#define WSA883X_ISENSE_CAL (WSA883X_ANA_IVSENSE_BASE + 0x0006) 5262306a36Sopenharmony_ci#define WSA883X_MISC (WSA883X_ANA_IVSENSE_BASE + 0x0007) 5362306a36Sopenharmony_ci#define WSA883X_ADC_0 (WSA883X_ANA_IVSENSE_BASE + 0x0008) 5462306a36Sopenharmony_ci#define WSA883X_ADC_1 (WSA883X_ANA_IVSENSE_BASE + 0x0009) 5562306a36Sopenharmony_ci#define WSA883X_ADC_2 (WSA883X_ANA_IVSENSE_BASE + 0x000A) 5662306a36Sopenharmony_ci#define WSA883X_ADC_3 (WSA883X_ANA_IVSENSE_BASE + 0x000B) 5762306a36Sopenharmony_ci#define WSA883X_ADC_4 (WSA883X_ANA_IVSENSE_BASE + 0x000C) 5862306a36Sopenharmony_ci#define WSA883X_ADC_5 (WSA883X_ANA_IVSENSE_BASE + 0x000D) 5962306a36Sopenharmony_ci#define WSA883X_ADC_6 (WSA883X_ANA_IVSENSE_BASE + 0x000E) 6062306a36Sopenharmony_ci#define WSA883X_ADC_7 (WSA883X_ANA_IVSENSE_BASE + 0x000F) 6162306a36Sopenharmony_ci#define WSA883X_STATUS (WSA883X_ANA_IVSENSE_BASE + 0x0010) 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci#define WSA883X_ANA_SPK_TOP_BASE (WSA883X_BASE + 0x00000025) 6462306a36Sopenharmony_ci#define WSA883X_DAC_CTRL_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0000) 6562306a36Sopenharmony_ci#define WSA883X_DAC_EN_DEBUG_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0001) 6662306a36Sopenharmony_ci#define WSA883X_DAC_OPAMP_BIAS1_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0002) 6762306a36Sopenharmony_ci#define WSA883X_DAC_OPAMP_BIAS2_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0003) 6862306a36Sopenharmony_ci#define WSA883X_DAC_VCM_CTRL_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0004) 6962306a36Sopenharmony_ci#define WSA883X_DAC_VOLTAGE_CTRL_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0005) 7062306a36Sopenharmony_ci#define WSA883X_ATEST1_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0006) 7162306a36Sopenharmony_ci#define WSA883X_ATEST2_REG (WSA883X_ANA_SPK_TOP_BASE + 0x0007) 7262306a36Sopenharmony_ci#define WSA883X_SPKR_TOP_BIAS_REG1 (WSA883X_ANA_SPK_TOP_BASE + 0x0008) 7362306a36Sopenharmony_ci#define WSA883X_SPKR_TOP_BIAS_REG2 (WSA883X_ANA_SPK_TOP_BASE + 0x0009) 7462306a36Sopenharmony_ci#define WSA883X_SPKR_TOP_BIAS_REG3 (WSA883X_ANA_SPK_TOP_BASE + 0x000A) 7562306a36Sopenharmony_ci#define WSA883X_SPKR_TOP_BIAS_REG4 (WSA883X_ANA_SPK_TOP_BASE + 0x000B) 7662306a36Sopenharmony_ci#define WSA883X_SPKR_CLIP_DET_REG (WSA883X_ANA_SPK_TOP_BASE + 0x000C) 7762306a36Sopenharmony_ci#define WSA883X_SPKR_DRV_LF_BLK_EN (WSA883X_ANA_SPK_TOP_BASE + 0x000D) 7862306a36Sopenharmony_ci#define WSA883X_SPKR_DRV_LF_EN (WSA883X_ANA_SPK_TOP_BASE + 0x000E) 7962306a36Sopenharmony_ci#define WSA883X_SPKR_DRV_LF_MASK_DCC_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x000F) 8062306a36Sopenharmony_ci#define WSA883X_SPKR_DRV_LF_MISC_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x0010) 8162306a36Sopenharmony_ci#define WSA883X_SPKR_DRV_LF_REG_GAIN (WSA883X_ANA_SPK_TOP_BASE + 0x0011) 8262306a36Sopenharmony_ci#define WSA883X_SPKR_DRV_OS_CAL_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x0012) 8362306a36Sopenharmony_ci#define WSA883X_SPKR_DRV_OS_CAL_CTL1 (WSA883X_ANA_SPK_TOP_BASE + 0x0013) 8462306a36Sopenharmony_ci#define WSA883X_SPKR_PWM_CLK_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x0014) 8562306a36Sopenharmony_ci#define WSA883X_SPKR_PWM_FREQ_SEL_MASK BIT(3) 8662306a36Sopenharmony_ci#define WSA883X_SPKR_PWM_FREQ_F300KHZ 0 8762306a36Sopenharmony_ci#define WSA883X_SPKR_PWM_FREQ_F600KHZ 1 8862306a36Sopenharmony_ci#define WSA883X_SPKR_PDRV_HS_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x0015) 8962306a36Sopenharmony_ci#define WSA883X_SPKR_PDRV_LS_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x0016) 9062306a36Sopenharmony_ci#define WSA883X_SPKR_PWRSTG_DBG (WSA883X_ANA_SPK_TOP_BASE + 0x0017) 9162306a36Sopenharmony_ci#define WSA883X_SPKR_OCP_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x0018) 9262306a36Sopenharmony_ci#define WSA883X_SPKR_BBM_CTL (WSA883X_ANA_SPK_TOP_BASE + 0x0019) 9362306a36Sopenharmony_ci#define WSA883X_PA_STATUS0 (WSA883X_ANA_SPK_TOP_BASE + 0x001A) 9462306a36Sopenharmony_ci#define WSA883X_PA_STATUS1 (WSA883X_ANA_SPK_TOP_BASE + 0x001B) 9562306a36Sopenharmony_ci#define WSA883X_PA_STATUS2 (WSA883X_ANA_SPK_TOP_BASE + 0x001C) 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#define WSA883X_ANA_BOOST_BASE (WSA883X_BASE + 0x00000043) 9862306a36Sopenharmony_ci#define WSA883X_EN_CTRL (WSA883X_ANA_BOOST_BASE + 0x0000) 9962306a36Sopenharmony_ci#define WSA883X_CURRENT_LIMIT (WSA883X_ANA_BOOST_BASE + 0x0001) 10062306a36Sopenharmony_ci#define WSA883X_IBIAS1 (WSA883X_ANA_BOOST_BASE + 0x0002) 10162306a36Sopenharmony_ci#define WSA883X_IBIAS2 (WSA883X_ANA_BOOST_BASE + 0x0003) 10262306a36Sopenharmony_ci#define WSA883X_IBIAS3 (WSA883X_ANA_BOOST_BASE + 0x0004) 10362306a36Sopenharmony_ci#define WSA883X_LDO_PROG (WSA883X_ANA_BOOST_BASE + 0x0005) 10462306a36Sopenharmony_ci#define WSA883X_STABILITY_CTRL1 (WSA883X_ANA_BOOST_BASE + 0x0006) 10562306a36Sopenharmony_ci#define WSA883X_STABILITY_CTRL2 (WSA883X_ANA_BOOST_BASE + 0x0007) 10662306a36Sopenharmony_ci#define WSA883X_PWRSTAGE_CTRL1 (WSA883X_ANA_BOOST_BASE + 0x0008) 10762306a36Sopenharmony_ci#define WSA883X_PWRSTAGE_CTRL2 (WSA883X_ANA_BOOST_BASE + 0x0009) 10862306a36Sopenharmony_ci#define WSA883X_BYPASS_1 (WSA883X_ANA_BOOST_BASE + 0x000A) 10962306a36Sopenharmony_ci#define WSA883X_BYPASS_2 (WSA883X_ANA_BOOST_BASE + 0x000B) 11062306a36Sopenharmony_ci#define WSA883X_ZX_CTRL_1 (WSA883X_ANA_BOOST_BASE + 0x000C) 11162306a36Sopenharmony_ci#define WSA883X_ZX_CTRL_2 (WSA883X_ANA_BOOST_BASE + 0x000D) 11262306a36Sopenharmony_ci#define WSA883X_MISC1 (WSA883X_ANA_BOOST_BASE + 0x000E) 11362306a36Sopenharmony_ci#define WSA883X_MISC2 (WSA883X_ANA_BOOST_BASE + 0x000F) 11462306a36Sopenharmony_ci#define WSA883X_GMAMP_SUP1 (WSA883X_ANA_BOOST_BASE + 0x0010) 11562306a36Sopenharmony_ci#define WSA883X_PWRSTAGE_CTRL3 (WSA883X_ANA_BOOST_BASE + 0x0011) 11662306a36Sopenharmony_ci#define WSA883X_PWRSTAGE_CTRL4 (WSA883X_ANA_BOOST_BASE + 0x0012) 11762306a36Sopenharmony_ci#define WSA883X_TEST1 (WSA883X_ANA_BOOST_BASE + 0x0013) 11862306a36Sopenharmony_ci#define WSA883X_SPARE1 (WSA883X_ANA_BOOST_BASE + 0x0014) 11962306a36Sopenharmony_ci#define WSA883X_SPARE2 (WSA883X_ANA_BOOST_BASE + 0x0015) 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci#define WSA883X_ANA_PON_LDOL_BASE (WSA883X_BASE + 0x00000059) 12262306a36Sopenharmony_ci#define WSA883X_PON_CTL_0 (WSA883X_ANA_PON_LDOL_BASE + 0x0000) 12362306a36Sopenharmony_ci#define WSA883X_PON_CLT_1 (WSA883X_ANA_PON_LDOL_BASE + 0x0001) 12462306a36Sopenharmony_ci#define WSA883X_PON_CTL_2 (WSA883X_ANA_PON_LDOL_BASE + 0x0002) 12562306a36Sopenharmony_ci#define WSA883X_PON_CTL_3 (WSA883X_ANA_PON_LDOL_BASE + 0x0003) 12662306a36Sopenharmony_ci#define WSA883X_CKWD_CTL_0 (WSA883X_ANA_PON_LDOL_BASE + 0x0004) 12762306a36Sopenharmony_ci#define WSA883X_CKWD_CTL_1 (WSA883X_ANA_PON_LDOL_BASE + 0x0005) 12862306a36Sopenharmony_ci#define WSA883X_CKWD_CTL_2 (WSA883X_ANA_PON_LDOL_BASE + 0x0006) 12962306a36Sopenharmony_ci#define WSA883X_CKSK_CTL_0 (WSA883X_ANA_PON_LDOL_BASE + 0x0007) 13062306a36Sopenharmony_ci#define WSA883X_PADSW_CTL_0 (WSA883X_ANA_PON_LDOL_BASE + 0x0008) 13162306a36Sopenharmony_ci#define WSA883X_TEST_0 (WSA883X_ANA_PON_LDOL_BASE + 0x0009) 13262306a36Sopenharmony_ci#define WSA883X_TEST_1 (WSA883X_ANA_PON_LDOL_BASE + 0x000A) 13362306a36Sopenharmony_ci#define WSA883X_STATUS_0 (WSA883X_ANA_PON_LDOL_BASE + 0x000B) 13462306a36Sopenharmony_ci#define WSA883X_STATUS_1 (WSA883X_ANA_PON_LDOL_BASE + 0x000C) 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci#define WSA883X_DIG_CTRL_BASE (WSA883X_BASE + 0x00000400) 13762306a36Sopenharmony_ci#define WSA883X_CHIP_ID0 (WSA883X_DIG_CTRL_BASE + 0x0001) 13862306a36Sopenharmony_ci#define WSA883X_CHIP_ID1 (WSA883X_DIG_CTRL_BASE + 0x0002) 13962306a36Sopenharmony_ci#define WSA883X_CHIP_ID2 (WSA883X_DIG_CTRL_BASE + 0x0003) 14062306a36Sopenharmony_ci#define WSA883X_CHIP_ID3 (WSA883X_DIG_CTRL_BASE + 0x0004) 14162306a36Sopenharmony_ci#define WSA883X_BUS_ID (WSA883X_DIG_CTRL_BASE + 0x0005) 14262306a36Sopenharmony_ci#define WSA883X_CDC_RST_CTL (WSA883X_DIG_CTRL_BASE + 0x0006) 14362306a36Sopenharmony_ci#define WSA883X_TOP_CLK_CFG (WSA883X_DIG_CTRL_BASE + 0x0007) 14462306a36Sopenharmony_ci#define WSA883X_CDC_PATH_MODE (WSA883X_DIG_CTRL_BASE + 0x0008) 14562306a36Sopenharmony_ci#define WSA883X_RXD_MODE_MASK BIT(1) 14662306a36Sopenharmony_ci#define WSA883X_RXD_MODE_NORMAL 0 14762306a36Sopenharmony_ci#define WSA883X_RXD_MODE_HIFI 1 14862306a36Sopenharmony_ci#define WSA883X_CDC_CLK_CTL (WSA883X_DIG_CTRL_BASE + 0x0009) 14962306a36Sopenharmony_ci#define WSA883X_SWR_RESET_EN (WSA883X_DIG_CTRL_BASE + 0x000A) 15062306a36Sopenharmony_ci#define WSA883X_RESET_CTL (WSA883X_DIG_CTRL_BASE + 0x000B) 15162306a36Sopenharmony_ci#define WSA883X_PA_FSM_CTL (WSA883X_DIG_CTRL_BASE + 0x0010) 15262306a36Sopenharmony_ci#define WSA883X_GLOBAL_PA_EN_MASK BIT(0) 15362306a36Sopenharmony_ci#define WSA883X_GLOBAL_PA_ENABLE 1 15462306a36Sopenharmony_ci#define WSA883X_PA_FSM_TIMER0 (WSA883X_DIG_CTRL_BASE + 0x0011) 15562306a36Sopenharmony_ci#define WSA883X_PA_FSM_TIMER1 (WSA883X_DIG_CTRL_BASE + 0x0012) 15662306a36Sopenharmony_ci#define WSA883X_PA_FSM_STA (WSA883X_DIG_CTRL_BASE + 0x0013) 15762306a36Sopenharmony_ci#define WSA883X_PA_FSM_ERR_COND (WSA883X_DIG_CTRL_BASE + 0x0014) 15862306a36Sopenharmony_ci#define WSA883X_PA_FSM_MSK (WSA883X_DIG_CTRL_BASE + 0x0015) 15962306a36Sopenharmony_ci#define WSA883X_PA_FSM_BYP (WSA883X_DIG_CTRL_BASE + 0x0016) 16062306a36Sopenharmony_ci#define WSA883X_PA_FSM_DBG (WSA883X_DIG_CTRL_BASE + 0x0017) 16162306a36Sopenharmony_ci#define WSA883X_TADC_VALUE_CTL (WSA883X_DIG_CTRL_BASE + 0x0020) 16262306a36Sopenharmony_ci#define WSA883X_TEMP_DETECT_CTL (WSA883X_DIG_CTRL_BASE + 0x0021) 16362306a36Sopenharmony_ci#define WSA883X_TEMP_MSB (WSA883X_DIG_CTRL_BASE + 0x0022) 16462306a36Sopenharmony_ci#define WSA883X_TEMP_LSB (WSA883X_DIG_CTRL_BASE + 0x0023) 16562306a36Sopenharmony_ci#define WSA883X_TEMP_CONFIG0 (WSA883X_DIG_CTRL_BASE + 0x0024) 16662306a36Sopenharmony_ci#define WSA883X_TEMP_CONFIG1 (WSA883X_DIG_CTRL_BASE + 0x0025) 16762306a36Sopenharmony_ci#define WSA883X_VBAT_ADC_FLT_CTL (WSA883X_DIG_CTRL_BASE + 0x0026) 16862306a36Sopenharmony_ci#define WSA883X_VBAT_ADC_FLT_EN_MASK BIT(0) 16962306a36Sopenharmony_ci#define WSA883X_VBAT_ADC_COEF_SEL_MASK GENMASK(3, 1) 17062306a36Sopenharmony_ci#define WSA883X_VBAT_ADC_COEF_F_1DIV2 0x0 17162306a36Sopenharmony_ci#define WSA883X_VBAT_ADC_COEF_F_1DIV16 0x3 17262306a36Sopenharmony_ci#define WSA883X_VBAT_DIN_MSB (WSA883X_DIG_CTRL_BASE + 0x0027) 17362306a36Sopenharmony_ci#define WSA883X_VBAT_DIN_LSB (WSA883X_DIG_CTRL_BASE + 0x0028) 17462306a36Sopenharmony_ci#define WSA883X_VBAT_DOUT (WSA883X_DIG_CTRL_BASE + 0x0029) 17562306a36Sopenharmony_ci#define WSA883X_SDM_PDM9_LSB (WSA883X_DIG_CTRL_BASE + 0x002A) 17662306a36Sopenharmony_ci#define WSA883X_SDM_PDM9_MSB (WSA883X_DIG_CTRL_BASE + 0x002B) 17762306a36Sopenharmony_ci#define WSA883X_CDC_RX_CTL (WSA883X_DIG_CTRL_BASE + 0x0030) 17862306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A1_0 (WSA883X_DIG_CTRL_BASE + 0x0031) 17962306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A1_1 (WSA883X_DIG_CTRL_BASE + 0x0032) 18062306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A2_0 (WSA883X_DIG_CTRL_BASE + 0x0033) 18162306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A2_1 (WSA883X_DIG_CTRL_BASE + 0x0034) 18262306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A3_0 (WSA883X_DIG_CTRL_BASE + 0x0035) 18362306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A3_1 (WSA883X_DIG_CTRL_BASE + 0x0036) 18462306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A4_0 (WSA883X_DIG_CTRL_BASE + 0x0037) 18562306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A4_1 (WSA883X_DIG_CTRL_BASE + 0x0038) 18662306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A5_0 (WSA883X_DIG_CTRL_BASE + 0x0039) 18762306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A5_1 (WSA883X_DIG_CTRL_BASE + 0x003A) 18862306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A6_0 (WSA883X_DIG_CTRL_BASE + 0x003B) 18962306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_A7_0 (WSA883X_DIG_CTRL_BASE + 0x003C) 19062306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_C_0 (WSA883X_DIG_CTRL_BASE + 0x003D) 19162306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_C_1 (WSA883X_DIG_CTRL_BASE + 0x003E) 19262306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_C_2 (WSA883X_DIG_CTRL_BASE + 0x003F) 19362306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_C_3 (WSA883X_DIG_CTRL_BASE + 0x0040) 19462306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_R1 (WSA883X_DIG_CTRL_BASE + 0x0041) 19562306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_R2 (WSA883X_DIG_CTRL_BASE + 0x0042) 19662306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_R3 (WSA883X_DIG_CTRL_BASE + 0x0043) 19762306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_R4 (WSA883X_DIG_CTRL_BASE + 0x0044) 19862306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_R5 (WSA883X_DIG_CTRL_BASE + 0x0045) 19962306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_R6 (WSA883X_DIG_CTRL_BASE + 0x0046) 20062306a36Sopenharmony_ci#define WSA883X_CDC_SPK_DSM_R7 (WSA883X_DIG_CTRL_BASE + 0x0047) 20162306a36Sopenharmony_ci#define WSA883X_CDC_SPK_GAIN_PDM_0 (WSA883X_DIG_CTRL_BASE + 0x0048) 20262306a36Sopenharmony_ci#define WSA883X_CDC_SPK_GAIN_PDM_1 (WSA883X_DIG_CTRL_BASE + 0x0049) 20362306a36Sopenharmony_ci#define WSA883X_CDC_SPK_GAIN_PDM_2 (WSA883X_DIG_CTRL_BASE + 0x004A) 20462306a36Sopenharmony_ci#define WSA883X_PDM_WD_CTL (WSA883X_DIG_CTRL_BASE + 0x004B) 20562306a36Sopenharmony_ci#define WSA883X_PDM_EN_MASK BIT(0) 20662306a36Sopenharmony_ci#define WSA883X_PDM_ENABLE BIT(0) 20762306a36Sopenharmony_ci#define WSA883X_DEM_BYPASS_DATA0 (WSA883X_DIG_CTRL_BASE + 0x004C) 20862306a36Sopenharmony_ci#define WSA883X_DEM_BYPASS_DATA1 (WSA883X_DIG_CTRL_BASE + 0x004D) 20962306a36Sopenharmony_ci#define WSA883X_DEM_BYPASS_DATA2 (WSA883X_DIG_CTRL_BASE + 0x004E) 21062306a36Sopenharmony_ci#define WSA883X_DEM_BYPASS_DATA3 (WSA883X_DIG_CTRL_BASE + 0x004F) 21162306a36Sopenharmony_ci#define WSA883X_WAVG_CTL (WSA883X_DIG_CTRL_BASE + 0x0050) 21262306a36Sopenharmony_ci#define WSA883X_WAVG_LRA_PER_0 (WSA883X_DIG_CTRL_BASE + 0x0051) 21362306a36Sopenharmony_ci#define WSA883X_WAVG_LRA_PER_1 (WSA883X_DIG_CTRL_BASE + 0x0052) 21462306a36Sopenharmony_ci#define WSA883X_WAVG_DELTA_THETA_0 (WSA883X_DIG_CTRL_BASE + 0x0053) 21562306a36Sopenharmony_ci#define WSA883X_WAVG_DELTA_THETA_1 (WSA883X_DIG_CTRL_BASE + 0x0054) 21662306a36Sopenharmony_ci#define WSA883X_WAVG_DIRECT_AMP_0 (WSA883X_DIG_CTRL_BASE + 0x0055) 21762306a36Sopenharmony_ci#define WSA883X_WAVG_DIRECT_AMP_1 (WSA883X_DIG_CTRL_BASE + 0x0056) 21862306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP0_0 (WSA883X_DIG_CTRL_BASE + 0x0057) 21962306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP0_1 (WSA883X_DIG_CTRL_BASE + 0x0058) 22062306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP1_0 (WSA883X_DIG_CTRL_BASE + 0x0059) 22162306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP1_1 (WSA883X_DIG_CTRL_BASE + 0x005A) 22262306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP2_0 (WSA883X_DIG_CTRL_BASE + 0x005B) 22362306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP2_1 (WSA883X_DIG_CTRL_BASE + 0x005C) 22462306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP3_0 (WSA883X_DIG_CTRL_BASE + 0x005D) 22562306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP3_1 (WSA883X_DIG_CTRL_BASE + 0x005E) 22662306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP4_0 (WSA883X_DIG_CTRL_BASE + 0x005F) 22762306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP4_1 (WSA883X_DIG_CTRL_BASE + 0x0060) 22862306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP5_0 (WSA883X_DIG_CTRL_BASE + 0x0061) 22962306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP5_1 (WSA883X_DIG_CTRL_BASE + 0x0062) 23062306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP6_0 (WSA883X_DIG_CTRL_BASE + 0x0063) 23162306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP6_1 (WSA883X_DIG_CTRL_BASE + 0x0064) 23262306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP7_0 (WSA883X_DIG_CTRL_BASE + 0x0065) 23362306a36Sopenharmony_ci#define WSA883X_WAVG_PTRN_AMP7_1 (WSA883X_DIG_CTRL_BASE + 0x0066) 23462306a36Sopenharmony_ci#define WSA883X_WAVG_PER_0_1 (WSA883X_DIG_CTRL_BASE + 0x0067) 23562306a36Sopenharmony_ci#define WSA883X_WAVG_PER_2_3 (WSA883X_DIG_CTRL_BASE + 0x0068) 23662306a36Sopenharmony_ci#define WSA883X_WAVG_PER_4_5 (WSA883X_DIG_CTRL_BASE + 0x0069) 23762306a36Sopenharmony_ci#define WSA883X_WAVG_PER_6_7 (WSA883X_DIG_CTRL_BASE + 0x006A) 23862306a36Sopenharmony_ci#define WSA883X_WAVG_STA (WSA883X_DIG_CTRL_BASE + 0x006B) 23962306a36Sopenharmony_ci#define WSA883X_DRE_CTL_0 (WSA883X_DIG_CTRL_BASE + 0x006C) 24062306a36Sopenharmony_ci#define WSA883X_DRE_OFFSET_MASK GENMASK(2, 0) 24162306a36Sopenharmony_ci#define WSA883X_DRE_PROG_DELAY_MASK GENMASK(7, 4) 24262306a36Sopenharmony_ci#define WSA883X_DRE_CTL_1 (WSA883X_DIG_CTRL_BASE + 0x006D) 24362306a36Sopenharmony_ci#define WSA883X_DRE_GAIN_EN_MASK BIT(0) 24462306a36Sopenharmony_ci#define WSA883X_DRE_GAIN_FROM_CSR 1 24562306a36Sopenharmony_ci#define WSA883X_DRE_IDLE_DET_CTL (WSA883X_DIG_CTRL_BASE + 0x006E) 24662306a36Sopenharmony_ci#define WSA883X_CLSH_CTL_0 (WSA883X_DIG_CTRL_BASE + 0x0070) 24762306a36Sopenharmony_ci#define WSA883X_CLSH_CTL_1 (WSA883X_DIG_CTRL_BASE + 0x0071) 24862306a36Sopenharmony_ci#define WSA883X_CLSH_V_HD_PA (WSA883X_DIG_CTRL_BASE + 0x0072) 24962306a36Sopenharmony_ci#define WSA883X_CLSH_V_PA_MIN (WSA883X_DIG_CTRL_BASE + 0x0073) 25062306a36Sopenharmony_ci#define WSA883X_CLSH_OVRD_VAL (WSA883X_DIG_CTRL_BASE + 0x0074) 25162306a36Sopenharmony_ci#define WSA883X_CLSH_HARD_MAX (WSA883X_DIG_CTRL_BASE + 0x0075) 25262306a36Sopenharmony_ci#define WSA883X_CLSH_SOFT_MAX (WSA883X_DIG_CTRL_BASE + 0x0076) 25362306a36Sopenharmony_ci#define WSA883X_CLSH_SIG_DP (WSA883X_DIG_CTRL_BASE + 0x0077) 25462306a36Sopenharmony_ci#define WSA883X_TAGC_CTL (WSA883X_DIG_CTRL_BASE + 0x0078) 25562306a36Sopenharmony_ci#define WSA883X_TAGC_TIME (WSA883X_DIG_CTRL_BASE + 0x0079) 25662306a36Sopenharmony_ci#define WSA883X_TAGC_E2E_GAIN (WSA883X_DIG_CTRL_BASE + 0x007A) 25762306a36Sopenharmony_ci#define WSA883X_TAGC_FORCE_VAL (WSA883X_DIG_CTRL_BASE + 0x007B) 25862306a36Sopenharmony_ci#define WSA883X_VAGC_CTL (WSA883X_DIG_CTRL_BASE + 0x007C) 25962306a36Sopenharmony_ci#define WSA883X_VAGC_TIME (WSA883X_DIG_CTRL_BASE + 0x007D) 26062306a36Sopenharmony_ci#define WSA883X_VAGC_ATTN_LVL_1_2 (WSA883X_DIG_CTRL_BASE + 0x007E) 26162306a36Sopenharmony_ci#define WSA883X_VAGC_ATTN_LVL_3 (WSA883X_DIG_CTRL_BASE + 0x007F) 26262306a36Sopenharmony_ci#define WSA883X_INTR_MODE (WSA883X_DIG_CTRL_BASE + 0x0080) 26362306a36Sopenharmony_ci#define WSA883X_INTR_MASK0 (WSA883X_DIG_CTRL_BASE + 0x0081) 26462306a36Sopenharmony_ci#define WSA883X_INTR_MASK1 (WSA883X_DIG_CTRL_BASE + 0x0082) 26562306a36Sopenharmony_ci#define WSA883X_INTR_STATUS0 (WSA883X_DIG_CTRL_BASE + 0x0083) 26662306a36Sopenharmony_ci#define WSA883X_INTR_STATUS1 (WSA883X_DIG_CTRL_BASE + 0x0084) 26762306a36Sopenharmony_ci#define WSA883X_INTR_CLEAR0 (WSA883X_DIG_CTRL_BASE + 0x0085) 26862306a36Sopenharmony_ci#define WSA883X_INTR_CLEAR1 (WSA883X_DIG_CTRL_BASE + 0x0086) 26962306a36Sopenharmony_ci#define WSA883X_INTR_LEVEL0 (WSA883X_DIG_CTRL_BASE + 0x0087) 27062306a36Sopenharmony_ci#define WSA883X_INTR_LEVEL1 (WSA883X_DIG_CTRL_BASE + 0x0088) 27162306a36Sopenharmony_ci#define WSA883X_INTR_SET0 (WSA883X_DIG_CTRL_BASE + 0x0089) 27262306a36Sopenharmony_ci#define WSA883X_INTR_SET1 (WSA883X_DIG_CTRL_BASE + 0x008A) 27362306a36Sopenharmony_ci#define WSA883X_INTR_TEST0 (WSA883X_DIG_CTRL_BASE + 0x008B) 27462306a36Sopenharmony_ci#define WSA883X_INTR_TEST1 (WSA883X_DIG_CTRL_BASE + 0x008C) 27562306a36Sopenharmony_ci#define WSA883X_OTP_CTRL0 (WSA883X_DIG_CTRL_BASE + 0x0090) 27662306a36Sopenharmony_ci#define WSA883X_OTP_CTRL1 (WSA883X_DIG_CTRL_BASE + 0x0091) 27762306a36Sopenharmony_ci#define WSA883X_HDRIVE_CTL_GROUP1 (WSA883X_DIG_CTRL_BASE + 0x0092) 27862306a36Sopenharmony_ci#define WSA883X_PIN_CTL (WSA883X_DIG_CTRL_BASE + 0x0093) 27962306a36Sopenharmony_ci#define WSA883X_PIN_CTL_OE (WSA883X_DIG_CTRL_BASE + 0x0094) 28062306a36Sopenharmony_ci#define WSA883X_PIN_WDATA_IOPAD (WSA883X_DIG_CTRL_BASE + 0x0095) 28162306a36Sopenharmony_ci#define WSA883X_PIN_STATUS (WSA883X_DIG_CTRL_BASE + 0x0096) 28262306a36Sopenharmony_ci#define WSA883X_I2C_SLAVE_CTL (WSA883X_DIG_CTRL_BASE + 0x0097) 28362306a36Sopenharmony_ci#define WSA883X_PDM_TEST_MODE (WSA883X_DIG_CTRL_BASE + 0x00A0) 28462306a36Sopenharmony_ci#define WSA883X_ATE_TEST_MODE (WSA883X_DIG_CTRL_BASE + 0x00A1) 28562306a36Sopenharmony_ci#define WSA883X_DIG_DEBUG_MODE (WSA883X_DIG_CTRL_BASE + 0x00A3) 28662306a36Sopenharmony_ci#define WSA883X_DIG_DEBUG_SEL (WSA883X_DIG_CTRL_BASE + 0x00A4) 28762306a36Sopenharmony_ci#define WSA883X_DIG_DEBUG_EN (WSA883X_DIG_CTRL_BASE + 0x00A5) 28862306a36Sopenharmony_ci#define WSA883X_SWR_HM_TEST0 (WSA883X_DIG_CTRL_BASE + 0x00A6) 28962306a36Sopenharmony_ci#define WSA883X_SWR_HM_TEST1 (WSA883X_DIG_CTRL_BASE + 0x00A7) 29062306a36Sopenharmony_ci#define WSA883X_SWR_PAD_CTL (WSA883X_DIG_CTRL_BASE + 0x00A8) 29162306a36Sopenharmony_ci#define WSA883X_TADC_DETECT_DBG_CTL (WSA883X_DIG_CTRL_BASE + 0x00A9) 29262306a36Sopenharmony_ci#define WSA883X_TADC_DEBUG_MSB (WSA883X_DIG_CTRL_BASE + 0x00AA) 29362306a36Sopenharmony_ci#define WSA883X_TADC_DEBUG_LSB (WSA883X_DIG_CTRL_BASE + 0x00AB) 29462306a36Sopenharmony_ci#define WSA883X_SAMPLE_EDGE_SEL (WSA883X_DIG_CTRL_BASE + 0x00AC) 29562306a36Sopenharmony_ci#define WSA883X_SWR_EDGE_SEL (WSA883X_DIG_CTRL_BASE + 0x00AD) 29662306a36Sopenharmony_ci#define WSA883X_TEST_MODE_CTL (WSA883X_DIG_CTRL_BASE + 0x00AE) 29762306a36Sopenharmony_ci#define WSA883X_IOPAD_CTL (WSA883X_DIG_CTRL_BASE + 0x00AF) 29862306a36Sopenharmony_ci#define WSA883X_ANA_CSR_DBG_ADD (WSA883X_DIG_CTRL_BASE + 0x00B0) 29962306a36Sopenharmony_ci#define WSA883X_ANA_CSR_DBG_CTL (WSA883X_DIG_CTRL_BASE + 0x00B1) 30062306a36Sopenharmony_ci#define WSA883X_SPARE_R (WSA883X_DIG_CTRL_BASE + 0x00BC) 30162306a36Sopenharmony_ci#define WSA883X_SPARE_0 (WSA883X_DIG_CTRL_BASE + 0x00BD) 30262306a36Sopenharmony_ci#define WSA883X_SPARE_1 (WSA883X_DIG_CTRL_BASE + 0x00BE) 30362306a36Sopenharmony_ci#define WSA883X_SPARE_2 (WSA883X_DIG_CTRL_BASE + 0x00BF) 30462306a36Sopenharmony_ci#define WSA883X_SCODE (WSA883X_DIG_CTRL_BASE + 0x00C0) 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci#define WSA883X_DIG_TRIM_BASE (WSA883X_BASE + 0x00000500) 30762306a36Sopenharmony_ci#define WSA883X_OTP_REG_0 (WSA883X_DIG_TRIM_BASE + 0x0080) 30862306a36Sopenharmony_ci#define WSA883X_ID_MASK GENMASK(3, 0) 30962306a36Sopenharmony_ci#define WSA883X_OTP_REG_1 (WSA883X_DIG_TRIM_BASE + 0x0081) 31062306a36Sopenharmony_ci#define WSA883X_OTP_REG_2 (WSA883X_DIG_TRIM_BASE + 0x0082) 31162306a36Sopenharmony_ci#define WSA883X_OTP_REG_3 (WSA883X_DIG_TRIM_BASE + 0x0083) 31262306a36Sopenharmony_ci#define WSA883X_OTP_REG_4 (WSA883X_DIG_TRIM_BASE + 0x0084) 31362306a36Sopenharmony_ci#define WSA883X_OTP_REG_5 (WSA883X_DIG_TRIM_BASE + 0x0085) 31462306a36Sopenharmony_ci#define WSA883X_OTP_REG_6 (WSA883X_DIG_TRIM_BASE + 0x0086) 31562306a36Sopenharmony_ci#define WSA883X_OTP_REG_7 (WSA883X_DIG_TRIM_BASE + 0x0087) 31662306a36Sopenharmony_ci#define WSA883X_OTP_REG_8 (WSA883X_DIG_TRIM_BASE + 0x0088) 31762306a36Sopenharmony_ci#define WSA883X_OTP_REG_9 (WSA883X_DIG_TRIM_BASE + 0x0089) 31862306a36Sopenharmony_ci#define WSA883X_OTP_REG_10 (WSA883X_DIG_TRIM_BASE + 0x008A) 31962306a36Sopenharmony_ci#define WSA883X_OTP_REG_11 (WSA883X_DIG_TRIM_BASE + 0x008B) 32062306a36Sopenharmony_ci#define WSA883X_OTP_REG_12 (WSA883X_DIG_TRIM_BASE + 0x008C) 32162306a36Sopenharmony_ci#define WSA883X_OTP_REG_13 (WSA883X_DIG_TRIM_BASE + 0x008D) 32262306a36Sopenharmony_ci#define WSA883X_OTP_REG_14 (WSA883X_DIG_TRIM_BASE + 0x008E) 32362306a36Sopenharmony_ci#define WSA883X_OTP_REG_15 (WSA883X_DIG_TRIM_BASE + 0x008F) 32462306a36Sopenharmony_ci#define WSA883X_OTP_REG_16 (WSA883X_DIG_TRIM_BASE + 0x0090) 32562306a36Sopenharmony_ci#define WSA883X_OTP_REG_17 (WSA883X_DIG_TRIM_BASE + 0x0091) 32662306a36Sopenharmony_ci#define WSA883X_OTP_REG_18 (WSA883X_DIG_TRIM_BASE + 0x0092) 32762306a36Sopenharmony_ci#define WSA883X_OTP_REG_19 (WSA883X_DIG_TRIM_BASE + 0x0093) 32862306a36Sopenharmony_ci#define WSA883X_OTP_REG_20 (WSA883X_DIG_TRIM_BASE + 0x0094) 32962306a36Sopenharmony_ci#define WSA883X_OTP_REG_21 (WSA883X_DIG_TRIM_BASE + 0x0095) 33062306a36Sopenharmony_ci#define WSA883X_OTP_REG_22 (WSA883X_DIG_TRIM_BASE + 0x0096) 33162306a36Sopenharmony_ci#define WSA883X_OTP_REG_23 (WSA883X_DIG_TRIM_BASE + 0x0097) 33262306a36Sopenharmony_ci#define WSA883X_OTP_REG_24 (WSA883X_DIG_TRIM_BASE + 0x0098) 33362306a36Sopenharmony_ci#define WSA883X_OTP_REG_25 (WSA883X_DIG_TRIM_BASE + 0x0099) 33462306a36Sopenharmony_ci#define WSA883X_OTP_REG_26 (WSA883X_DIG_TRIM_BASE + 0x009A) 33562306a36Sopenharmony_ci#define WSA883X_OTP_REG_27 (WSA883X_DIG_TRIM_BASE + 0x009B) 33662306a36Sopenharmony_ci#define WSA883X_OTP_REG_28 (WSA883X_DIG_TRIM_BASE + 0x009C) 33762306a36Sopenharmony_ci#define WSA883X_OTP_REG_29 (WSA883X_DIG_TRIM_BASE + 0x009D) 33862306a36Sopenharmony_ci#define WSA883X_OTP_REG_30 (WSA883X_DIG_TRIM_BASE + 0x009E) 33962306a36Sopenharmony_ci#define WSA883X_OTP_REG_31 (WSA883X_DIG_TRIM_BASE + 0x009F) 34062306a36Sopenharmony_ci#define WSA883X_OTP_REG_32 (WSA883X_DIG_TRIM_BASE + 0x00A0) 34162306a36Sopenharmony_ci#define WSA883X_OTP_REG_33 (WSA883X_DIG_TRIM_BASE + 0x00A1) 34262306a36Sopenharmony_ci#define WSA883X_OTP_REG_34 (WSA883X_DIG_TRIM_BASE + 0x00A2) 34362306a36Sopenharmony_ci#define WSA883X_OTP_REG_35 (WSA883X_DIG_TRIM_BASE + 0x00A3) 34462306a36Sopenharmony_ci#define WSA883X_OTP_REG_63 (WSA883X_DIG_TRIM_BASE + 0x00BF) 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci#define WSA883X_DIG_EMEM_BASE (WSA883X_BASE + 0x000005C0) 34762306a36Sopenharmony_ci#define WSA883X_EMEM_0 (WSA883X_DIG_EMEM_BASE + 0x0000) 34862306a36Sopenharmony_ci#define WSA883X_EMEM_1 (WSA883X_DIG_EMEM_BASE + 0x0001) 34962306a36Sopenharmony_ci#define WSA883X_EMEM_2 (WSA883X_DIG_EMEM_BASE + 0x0002) 35062306a36Sopenharmony_ci#define WSA883X_EMEM_3 (WSA883X_DIG_EMEM_BASE + 0x0003) 35162306a36Sopenharmony_ci#define WSA883X_EMEM_4 (WSA883X_DIG_EMEM_BASE + 0x0004) 35262306a36Sopenharmony_ci#define WSA883X_EMEM_5 (WSA883X_DIG_EMEM_BASE + 0x0005) 35362306a36Sopenharmony_ci#define WSA883X_EMEM_6 (WSA883X_DIG_EMEM_BASE + 0x0006) 35462306a36Sopenharmony_ci#define WSA883X_EMEM_7 (WSA883X_DIG_EMEM_BASE + 0x0007) 35562306a36Sopenharmony_ci#define WSA883X_EMEM_8 (WSA883X_DIG_EMEM_BASE + 0x0008) 35662306a36Sopenharmony_ci#define WSA883X_EMEM_9 (WSA883X_DIG_EMEM_BASE + 0x0009) 35762306a36Sopenharmony_ci#define WSA883X_EMEM_10 (WSA883X_DIG_EMEM_BASE + 0x000A) 35862306a36Sopenharmony_ci#define WSA883X_EMEM_11 (WSA883X_DIG_EMEM_BASE + 0x000B) 35962306a36Sopenharmony_ci#define WSA883X_EMEM_12 (WSA883X_DIG_EMEM_BASE + 0x000C) 36062306a36Sopenharmony_ci#define WSA883X_EMEM_13 (WSA883X_DIG_EMEM_BASE + 0x000D) 36162306a36Sopenharmony_ci#define WSA883X_EMEM_14 (WSA883X_DIG_EMEM_BASE + 0x000E) 36262306a36Sopenharmony_ci#define WSA883X_EMEM_15 (WSA883X_DIG_EMEM_BASE + 0x000F) 36362306a36Sopenharmony_ci#define WSA883X_EMEM_16 (WSA883X_DIG_EMEM_BASE + 0x0010) 36462306a36Sopenharmony_ci#define WSA883X_EMEM_17 (WSA883X_DIG_EMEM_BASE + 0x0011) 36562306a36Sopenharmony_ci#define WSA883X_EMEM_18 (WSA883X_DIG_EMEM_BASE + 0x0012) 36662306a36Sopenharmony_ci#define WSA883X_EMEM_19 (WSA883X_DIG_EMEM_BASE + 0x0013) 36762306a36Sopenharmony_ci#define WSA883X_EMEM_20 (WSA883X_DIG_EMEM_BASE + 0x0014) 36862306a36Sopenharmony_ci#define WSA883X_EMEM_21 (WSA883X_DIG_EMEM_BASE + 0x0015) 36962306a36Sopenharmony_ci#define WSA883X_EMEM_22 (WSA883X_DIG_EMEM_BASE + 0x0016) 37062306a36Sopenharmony_ci#define WSA883X_EMEM_23 (WSA883X_DIG_EMEM_BASE + 0x0017) 37162306a36Sopenharmony_ci#define WSA883X_EMEM_24 (WSA883X_DIG_EMEM_BASE + 0x0018) 37262306a36Sopenharmony_ci#define WSA883X_EMEM_25 (WSA883X_DIG_EMEM_BASE + 0x0019) 37362306a36Sopenharmony_ci#define WSA883X_EMEM_26 (WSA883X_DIG_EMEM_BASE + 0x001A) 37462306a36Sopenharmony_ci#define WSA883X_EMEM_27 (WSA883X_DIG_EMEM_BASE + 0x001B) 37562306a36Sopenharmony_ci#define WSA883X_EMEM_28 (WSA883X_DIG_EMEM_BASE + 0x001C) 37662306a36Sopenharmony_ci#define WSA883X_EMEM_29 (WSA883X_DIG_EMEM_BASE + 0x001D) 37762306a36Sopenharmony_ci#define WSA883X_EMEM_30 (WSA883X_DIG_EMEM_BASE + 0x001E) 37862306a36Sopenharmony_ci#define WSA883X_EMEM_31 (WSA883X_DIG_EMEM_BASE + 0x001F) 37962306a36Sopenharmony_ci#define WSA883X_EMEM_32 (WSA883X_DIG_EMEM_BASE + 0x0020) 38062306a36Sopenharmony_ci#define WSA883X_EMEM_33 (WSA883X_DIG_EMEM_BASE + 0x0021) 38162306a36Sopenharmony_ci#define WSA883X_EMEM_34 (WSA883X_DIG_EMEM_BASE + 0x0022) 38262306a36Sopenharmony_ci#define WSA883X_EMEM_35 (WSA883X_DIG_EMEM_BASE + 0x0023) 38362306a36Sopenharmony_ci#define WSA883X_EMEM_36 (WSA883X_DIG_EMEM_BASE + 0x0024) 38462306a36Sopenharmony_ci#define WSA883X_EMEM_37 (WSA883X_DIG_EMEM_BASE + 0x0025) 38562306a36Sopenharmony_ci#define WSA883X_EMEM_38 (WSA883X_DIG_EMEM_BASE + 0x0026) 38662306a36Sopenharmony_ci#define WSA883X_EMEM_39 (WSA883X_DIG_EMEM_BASE + 0x0027) 38762306a36Sopenharmony_ci#define WSA883X_EMEM_40 (WSA883X_DIG_EMEM_BASE + 0x0028) 38862306a36Sopenharmony_ci#define WSA883X_EMEM_41 (WSA883X_DIG_EMEM_BASE + 0x0029) 38962306a36Sopenharmony_ci#define WSA883X_EMEM_42 (WSA883X_DIG_EMEM_BASE + 0x002A) 39062306a36Sopenharmony_ci#define WSA883X_EMEM_43 (WSA883X_DIG_EMEM_BASE + 0x002B) 39162306a36Sopenharmony_ci#define WSA883X_EMEM_44 (WSA883X_DIG_EMEM_BASE + 0x002C) 39262306a36Sopenharmony_ci#define WSA883X_EMEM_45 (WSA883X_DIG_EMEM_BASE + 0x002D) 39362306a36Sopenharmony_ci#define WSA883X_EMEM_46 (WSA883X_DIG_EMEM_BASE + 0x002E) 39462306a36Sopenharmony_ci#define WSA883X_EMEM_47 (WSA883X_DIG_EMEM_BASE + 0x002F) 39562306a36Sopenharmony_ci#define WSA883X_EMEM_48 (WSA883X_DIG_EMEM_BASE + 0x0030) 39662306a36Sopenharmony_ci#define WSA883X_EMEM_49 (WSA883X_DIG_EMEM_BASE + 0x0031) 39762306a36Sopenharmony_ci#define WSA883X_EMEM_50 (WSA883X_DIG_EMEM_BASE + 0x0032) 39862306a36Sopenharmony_ci#define WSA883X_EMEM_51 (WSA883X_DIG_EMEM_BASE + 0x0033) 39962306a36Sopenharmony_ci#define WSA883X_EMEM_52 (WSA883X_DIG_EMEM_BASE + 0x0034) 40062306a36Sopenharmony_ci#define WSA883X_EMEM_53 (WSA883X_DIG_EMEM_BASE + 0x0035) 40162306a36Sopenharmony_ci#define WSA883X_EMEM_54 (WSA883X_DIG_EMEM_BASE + 0x0036) 40262306a36Sopenharmony_ci#define WSA883X_EMEM_55 (WSA883X_DIG_EMEM_BASE + 0x0037) 40362306a36Sopenharmony_ci#define WSA883X_EMEM_56 (WSA883X_DIG_EMEM_BASE + 0x0038) 40462306a36Sopenharmony_ci#define WSA883X_EMEM_57 (WSA883X_DIG_EMEM_BASE + 0x0039) 40562306a36Sopenharmony_ci#define WSA883X_EMEM_58 (WSA883X_DIG_EMEM_BASE + 0x003A) 40662306a36Sopenharmony_ci#define WSA883X_EMEM_59 (WSA883X_DIG_EMEM_BASE + 0x003B) 40762306a36Sopenharmony_ci#define WSA883X_EMEM_60 (WSA883X_DIG_EMEM_BASE + 0x003C) 40862306a36Sopenharmony_ci#define WSA883X_EMEM_61 (WSA883X_DIG_EMEM_BASE + 0x003D) 40962306a36Sopenharmony_ci#define WSA883X_EMEM_62 (WSA883X_DIG_EMEM_BASE + 0x003E) 41062306a36Sopenharmony_ci#define WSA883X_EMEM_63 (WSA883X_DIG_EMEM_BASE + 0x003F) 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci#define WSA883X_NUM_REGISTERS (WSA883X_EMEM_63 + 1) 41362306a36Sopenharmony_ci#define WSA883X_MAX_REGISTER (WSA883X_NUM_REGISTERS - 1) 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_ci#define WSA883X_VERSION_1_0 0 41662306a36Sopenharmony_ci#define WSA883X_VERSION_1_1 1 41762306a36Sopenharmony_ci 41862306a36Sopenharmony_ci#define WSA883X_MAX_SWR_PORTS 4 41962306a36Sopenharmony_ci#define WSA883X_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ 42062306a36Sopenharmony_ci SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ 42162306a36Sopenharmony_ci SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\ 42262306a36Sopenharmony_ci SNDRV_PCM_RATE_384000) 42362306a36Sopenharmony_ci/* Fractional Rates */ 42462306a36Sopenharmony_ci#define WSA883X_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\ 42562306a36Sopenharmony_ci SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800) 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci#define WSA883X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 42862306a36Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE |\ 42962306a36Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_cistruct wsa883x_priv { 43262306a36Sopenharmony_ci struct regmap *regmap; 43362306a36Sopenharmony_ci struct device *dev; 43462306a36Sopenharmony_ci struct regulator *vdd; 43562306a36Sopenharmony_ci struct sdw_slave *slave; 43662306a36Sopenharmony_ci struct sdw_stream_config sconfig; 43762306a36Sopenharmony_ci struct sdw_stream_runtime *sruntime; 43862306a36Sopenharmony_ci struct sdw_port_config port_config[WSA883X_MAX_SWR_PORTS]; 43962306a36Sopenharmony_ci struct gpio_desc *sd_n; 44062306a36Sopenharmony_ci bool port_prepared[WSA883X_MAX_SWR_PORTS]; 44162306a36Sopenharmony_ci bool port_enable[WSA883X_MAX_SWR_PORTS]; 44262306a36Sopenharmony_ci int version; 44362306a36Sopenharmony_ci int variant; 44462306a36Sopenharmony_ci int active_ports; 44562306a36Sopenharmony_ci int dev_mode; 44662306a36Sopenharmony_ci int comp_offset; 44762306a36Sopenharmony_ci}; 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_cienum { 45062306a36Sopenharmony_ci WSA8830 = 0, 45162306a36Sopenharmony_ci WSA8835, 45262306a36Sopenharmony_ci WSA8832, 45362306a36Sopenharmony_ci WSA8835_V2 = 5, 45462306a36Sopenharmony_ci}; 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_cienum { 45762306a36Sopenharmony_ci COMP_OFFSET0, 45862306a36Sopenharmony_ci COMP_OFFSET1, 45962306a36Sopenharmony_ci COMP_OFFSET2, 46062306a36Sopenharmony_ci COMP_OFFSET3, 46162306a36Sopenharmony_ci COMP_OFFSET4, 46262306a36Sopenharmony_ci}; 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_cienum wsa_port_ids { 46562306a36Sopenharmony_ci WSA883X_PORT_DAC, 46662306a36Sopenharmony_ci WSA883X_PORT_COMP, 46762306a36Sopenharmony_ci WSA883X_PORT_BOOST, 46862306a36Sopenharmony_ci WSA883X_PORT_VISENSE, 46962306a36Sopenharmony_ci}; 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_cistatic const char * const wsa_dev_mode_text[] = { 47262306a36Sopenharmony_ci "Speaker", "Receiver", "Ultrasound" 47362306a36Sopenharmony_ci}; 47462306a36Sopenharmony_ci 47562306a36Sopenharmony_cienum { 47662306a36Sopenharmony_ci SPEAKER, 47762306a36Sopenharmony_ci RECEIVER, 47862306a36Sopenharmony_ci ULTRASOUND, 47962306a36Sopenharmony_ci}; 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_cistatic const struct soc_enum wsa_dev_mode_enum = 48262306a36Sopenharmony_ci SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(wsa_dev_mode_text), wsa_dev_mode_text); 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci/* 4 ports */ 48562306a36Sopenharmony_cistatic struct sdw_dpn_prop wsa_sink_dpn_prop[WSA883X_MAX_SWR_PORTS] = { 48662306a36Sopenharmony_ci { 48762306a36Sopenharmony_ci /* DAC */ 48862306a36Sopenharmony_ci .num = 1, 48962306a36Sopenharmony_ci .type = SDW_DPN_SIMPLE, 49062306a36Sopenharmony_ci .min_ch = 1, 49162306a36Sopenharmony_ci .max_ch = 1, 49262306a36Sopenharmony_ci .simple_ch_prep_sm = true, 49362306a36Sopenharmony_ci .read_only_wordlength = true, 49462306a36Sopenharmony_ci }, { 49562306a36Sopenharmony_ci /* COMP */ 49662306a36Sopenharmony_ci .num = 2, 49762306a36Sopenharmony_ci .type = SDW_DPN_SIMPLE, 49862306a36Sopenharmony_ci .min_ch = 1, 49962306a36Sopenharmony_ci .max_ch = 1, 50062306a36Sopenharmony_ci .simple_ch_prep_sm = true, 50162306a36Sopenharmony_ci .read_only_wordlength = true, 50262306a36Sopenharmony_ci }, { 50362306a36Sopenharmony_ci /* BOOST */ 50462306a36Sopenharmony_ci .num = 3, 50562306a36Sopenharmony_ci .type = SDW_DPN_SIMPLE, 50662306a36Sopenharmony_ci .min_ch = 1, 50762306a36Sopenharmony_ci .max_ch = 1, 50862306a36Sopenharmony_ci .simple_ch_prep_sm = true, 50962306a36Sopenharmony_ci .read_only_wordlength = true, 51062306a36Sopenharmony_ci }, { 51162306a36Sopenharmony_ci /* VISENSE */ 51262306a36Sopenharmony_ci .num = 4, 51362306a36Sopenharmony_ci .type = SDW_DPN_SIMPLE, 51462306a36Sopenharmony_ci .min_ch = 1, 51562306a36Sopenharmony_ci .max_ch = 1, 51662306a36Sopenharmony_ci .simple_ch_prep_sm = true, 51762306a36Sopenharmony_ci .read_only_wordlength = true, 51862306a36Sopenharmony_ci } 51962306a36Sopenharmony_ci}; 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_cistatic const struct sdw_port_config wsa883x_pconfig[WSA883X_MAX_SWR_PORTS] = { 52262306a36Sopenharmony_ci { 52362306a36Sopenharmony_ci .num = 1, 52462306a36Sopenharmony_ci .ch_mask = 0x1, 52562306a36Sopenharmony_ci }, { 52662306a36Sopenharmony_ci .num = 2, 52762306a36Sopenharmony_ci .ch_mask = 0xf, 52862306a36Sopenharmony_ci }, { 52962306a36Sopenharmony_ci .num = 3, 53062306a36Sopenharmony_ci .ch_mask = 0x3, 53162306a36Sopenharmony_ci }, { /* IV feedback */ 53262306a36Sopenharmony_ci .num = 4, 53362306a36Sopenharmony_ci .ch_mask = 0x3, 53462306a36Sopenharmony_ci }, 53562306a36Sopenharmony_ci}; 53662306a36Sopenharmony_ci 53762306a36Sopenharmony_cistatic struct reg_default wsa883x_defaults[] = { 53862306a36Sopenharmony_ci { WSA883X_REF_CTRL, 0xD5 }, 53962306a36Sopenharmony_ci { WSA883X_TEST_CTL_0, 0x06 }, 54062306a36Sopenharmony_ci { WSA883X_BIAS_0, 0xD2 }, 54162306a36Sopenharmony_ci { WSA883X_OP_CTL, 0xE0 }, 54262306a36Sopenharmony_ci { WSA883X_IREF_CTL, 0x57 }, 54362306a36Sopenharmony_ci { WSA883X_ISENS_CTL, 0x47 }, 54462306a36Sopenharmony_ci { WSA883X_CLK_CTL, 0x87 }, 54562306a36Sopenharmony_ci { WSA883X_TEST_CTL_1, 0x00 }, 54662306a36Sopenharmony_ci { WSA883X_BIAS_1, 0x51 }, 54762306a36Sopenharmony_ci { WSA883X_ADC_CTL, 0x01 }, 54862306a36Sopenharmony_ci { WSA883X_DOUT_MSB, 0x00 }, 54962306a36Sopenharmony_ci { WSA883X_DOUT_LSB, 0x00 }, 55062306a36Sopenharmony_ci { WSA883X_VBAT_SNS, 0x40 }, 55162306a36Sopenharmony_ci { WSA883X_ITRIM_CODE, 0x9F }, 55262306a36Sopenharmony_ci { WSA883X_EN, 0x20 }, 55362306a36Sopenharmony_ci { WSA883X_OVERRIDE1, 0x00 }, 55462306a36Sopenharmony_ci { WSA883X_OVERRIDE2, 0x08 }, 55562306a36Sopenharmony_ci { WSA883X_VSENSE1, 0xD3 }, 55662306a36Sopenharmony_ci { WSA883X_ISENSE1, 0xD4 }, 55762306a36Sopenharmony_ci { WSA883X_ISENSE2, 0x20 }, 55862306a36Sopenharmony_ci { WSA883X_ISENSE_CAL, 0x00 }, 55962306a36Sopenharmony_ci { WSA883X_MISC, 0x08 }, 56062306a36Sopenharmony_ci { WSA883X_ADC_0, 0x00 }, 56162306a36Sopenharmony_ci { WSA883X_ADC_1, 0x00 }, 56262306a36Sopenharmony_ci { WSA883X_ADC_2, 0x40 }, 56362306a36Sopenharmony_ci { WSA883X_ADC_3, 0x80 }, 56462306a36Sopenharmony_ci { WSA883X_ADC_4, 0x25 }, 56562306a36Sopenharmony_ci { WSA883X_ADC_5, 0x25 }, 56662306a36Sopenharmony_ci { WSA883X_ADC_6, 0x08 }, 56762306a36Sopenharmony_ci { WSA883X_ADC_7, 0x81 }, 56862306a36Sopenharmony_ci { WSA883X_STATUS, 0x00 }, 56962306a36Sopenharmony_ci { WSA883X_DAC_CTRL_REG, 0x53 }, 57062306a36Sopenharmony_ci { WSA883X_DAC_EN_DEBUG_REG, 0x00 }, 57162306a36Sopenharmony_ci { WSA883X_DAC_OPAMP_BIAS1_REG, 0x48 }, 57262306a36Sopenharmony_ci { WSA883X_DAC_OPAMP_BIAS2_REG, 0x48 }, 57362306a36Sopenharmony_ci { WSA883X_DAC_VCM_CTRL_REG, 0x88 }, 57462306a36Sopenharmony_ci { WSA883X_DAC_VOLTAGE_CTRL_REG, 0xA5 }, 57562306a36Sopenharmony_ci { WSA883X_ATEST1_REG, 0x00 }, 57662306a36Sopenharmony_ci { WSA883X_ATEST2_REG, 0x00 }, 57762306a36Sopenharmony_ci { WSA883X_SPKR_TOP_BIAS_REG1, 0x6A }, 57862306a36Sopenharmony_ci { WSA883X_SPKR_TOP_BIAS_REG2, 0x65 }, 57962306a36Sopenharmony_ci { WSA883X_SPKR_TOP_BIAS_REG3, 0x55 }, 58062306a36Sopenharmony_ci { WSA883X_SPKR_TOP_BIAS_REG4, 0xA9 }, 58162306a36Sopenharmony_ci { WSA883X_SPKR_CLIP_DET_REG, 0x9C }, 58262306a36Sopenharmony_ci { WSA883X_SPKR_DRV_LF_BLK_EN, 0x0F }, 58362306a36Sopenharmony_ci { WSA883X_SPKR_DRV_LF_EN, 0x0A }, 58462306a36Sopenharmony_ci { WSA883X_SPKR_DRV_LF_MASK_DCC_CTL, 0x00 }, 58562306a36Sopenharmony_ci { WSA883X_SPKR_DRV_LF_MISC_CTL, 0x3A }, 58662306a36Sopenharmony_ci { WSA883X_SPKR_DRV_LF_REG_GAIN, 0x00 }, 58762306a36Sopenharmony_ci { WSA883X_SPKR_DRV_OS_CAL_CTL, 0x00 }, 58862306a36Sopenharmony_ci { WSA883X_SPKR_DRV_OS_CAL_CTL1, 0x90 }, 58962306a36Sopenharmony_ci { WSA883X_SPKR_PWM_CLK_CTL, 0x00 }, 59062306a36Sopenharmony_ci { WSA883X_SPKR_PDRV_HS_CTL, 0x52 }, 59162306a36Sopenharmony_ci { WSA883X_SPKR_PDRV_LS_CTL, 0x48 }, 59262306a36Sopenharmony_ci { WSA883X_SPKR_PWRSTG_DBG, 0x08 }, 59362306a36Sopenharmony_ci { WSA883X_SPKR_OCP_CTL, 0xE2 }, 59462306a36Sopenharmony_ci { WSA883X_SPKR_BBM_CTL, 0x92 }, 59562306a36Sopenharmony_ci { WSA883X_PA_STATUS0, 0x00 }, 59662306a36Sopenharmony_ci { WSA883X_PA_STATUS1, 0x00 }, 59762306a36Sopenharmony_ci { WSA883X_PA_STATUS2, 0x80 }, 59862306a36Sopenharmony_ci { WSA883X_EN_CTRL, 0x44 }, 59962306a36Sopenharmony_ci { WSA883X_CURRENT_LIMIT, 0xCC }, 60062306a36Sopenharmony_ci { WSA883X_IBIAS1, 0x00 }, 60162306a36Sopenharmony_ci { WSA883X_IBIAS2, 0x00 }, 60262306a36Sopenharmony_ci { WSA883X_IBIAS3, 0x00 }, 60362306a36Sopenharmony_ci { WSA883X_LDO_PROG, 0x02 }, 60462306a36Sopenharmony_ci { WSA883X_STABILITY_CTRL1, 0x8E }, 60562306a36Sopenharmony_ci { WSA883X_STABILITY_CTRL2, 0x10 }, 60662306a36Sopenharmony_ci { WSA883X_PWRSTAGE_CTRL1, 0x06 }, 60762306a36Sopenharmony_ci { WSA883X_PWRSTAGE_CTRL2, 0x00 }, 60862306a36Sopenharmony_ci { WSA883X_BYPASS_1, 0x19 }, 60962306a36Sopenharmony_ci { WSA883X_BYPASS_2, 0x13 }, 61062306a36Sopenharmony_ci { WSA883X_ZX_CTRL_1, 0xF0 }, 61162306a36Sopenharmony_ci { WSA883X_ZX_CTRL_2, 0x04 }, 61262306a36Sopenharmony_ci { WSA883X_MISC1, 0x06 }, 61362306a36Sopenharmony_ci { WSA883X_MISC2, 0xA0 }, 61462306a36Sopenharmony_ci { WSA883X_GMAMP_SUP1, 0x82 }, 61562306a36Sopenharmony_ci { WSA883X_PWRSTAGE_CTRL3, 0x39 }, 61662306a36Sopenharmony_ci { WSA883X_PWRSTAGE_CTRL4, 0x5F }, 61762306a36Sopenharmony_ci { WSA883X_TEST1, 0x00 }, 61862306a36Sopenharmony_ci { WSA883X_SPARE1, 0x00 }, 61962306a36Sopenharmony_ci { WSA883X_SPARE2, 0x00 }, 62062306a36Sopenharmony_ci { WSA883X_PON_CTL_0, 0x10 }, 62162306a36Sopenharmony_ci { WSA883X_PON_CLT_1, 0xE0 }, 62262306a36Sopenharmony_ci { WSA883X_PON_CTL_2, 0x90 }, 62362306a36Sopenharmony_ci { WSA883X_PON_CTL_3, 0x70 }, 62462306a36Sopenharmony_ci { WSA883X_CKWD_CTL_0, 0x34 }, 62562306a36Sopenharmony_ci { WSA883X_CKWD_CTL_1, 0x0F }, 62662306a36Sopenharmony_ci { WSA883X_CKWD_CTL_2, 0x00 }, 62762306a36Sopenharmony_ci { WSA883X_CKSK_CTL_0, 0x00 }, 62862306a36Sopenharmony_ci { WSA883X_PADSW_CTL_0, 0x00 }, 62962306a36Sopenharmony_ci { WSA883X_TEST_0, 0x00 }, 63062306a36Sopenharmony_ci { WSA883X_TEST_1, 0x00 }, 63162306a36Sopenharmony_ci { WSA883X_STATUS_0, 0x00 }, 63262306a36Sopenharmony_ci { WSA883X_STATUS_1, 0x00 }, 63362306a36Sopenharmony_ci { WSA883X_CHIP_ID0, 0x00 }, 63462306a36Sopenharmony_ci { WSA883X_CHIP_ID1, 0x00 }, 63562306a36Sopenharmony_ci { WSA883X_CHIP_ID2, 0x02 }, 63662306a36Sopenharmony_ci { WSA883X_CHIP_ID3, 0x02 }, 63762306a36Sopenharmony_ci { WSA883X_BUS_ID, 0x00 }, 63862306a36Sopenharmony_ci { WSA883X_CDC_RST_CTL, 0x01 }, 63962306a36Sopenharmony_ci { WSA883X_TOP_CLK_CFG, 0x00 }, 64062306a36Sopenharmony_ci { WSA883X_CDC_PATH_MODE, 0x00 }, 64162306a36Sopenharmony_ci { WSA883X_CDC_CLK_CTL, 0xFF }, 64262306a36Sopenharmony_ci { WSA883X_SWR_RESET_EN, 0x00 }, 64362306a36Sopenharmony_ci { WSA883X_RESET_CTL, 0x00 }, 64462306a36Sopenharmony_ci { WSA883X_PA_FSM_CTL, 0x00 }, 64562306a36Sopenharmony_ci { WSA883X_PA_FSM_TIMER0, 0x80 }, 64662306a36Sopenharmony_ci { WSA883X_PA_FSM_TIMER1, 0x80 }, 64762306a36Sopenharmony_ci { WSA883X_PA_FSM_STA, 0x00 }, 64862306a36Sopenharmony_ci { WSA883X_PA_FSM_ERR_COND, 0x00 }, 64962306a36Sopenharmony_ci { WSA883X_PA_FSM_MSK, 0x00 }, 65062306a36Sopenharmony_ci { WSA883X_PA_FSM_BYP, 0x01 }, 65162306a36Sopenharmony_ci { WSA883X_PA_FSM_DBG, 0x00 }, 65262306a36Sopenharmony_ci { WSA883X_TADC_VALUE_CTL, 0x03 }, 65362306a36Sopenharmony_ci { WSA883X_TEMP_DETECT_CTL, 0x01 }, 65462306a36Sopenharmony_ci { WSA883X_TEMP_MSB, 0x00 }, 65562306a36Sopenharmony_ci { WSA883X_TEMP_LSB, 0x00 }, 65662306a36Sopenharmony_ci { WSA883X_TEMP_CONFIG0, 0x00 }, 65762306a36Sopenharmony_ci { WSA883X_TEMP_CONFIG1, 0x00 }, 65862306a36Sopenharmony_ci { WSA883X_VBAT_ADC_FLT_CTL, 0x00 }, 65962306a36Sopenharmony_ci { WSA883X_VBAT_DIN_MSB, 0x00 }, 66062306a36Sopenharmony_ci { WSA883X_VBAT_DIN_LSB, 0x00 }, 66162306a36Sopenharmony_ci { WSA883X_VBAT_DOUT, 0x00 }, 66262306a36Sopenharmony_ci { WSA883X_SDM_PDM9_LSB, 0x00 }, 66362306a36Sopenharmony_ci { WSA883X_SDM_PDM9_MSB, 0x00 }, 66462306a36Sopenharmony_ci { WSA883X_CDC_RX_CTL, 0xFE }, 66562306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A1_0, 0x00 }, 66662306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A1_1, 0x01 }, 66762306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A2_0, 0x96 }, 66862306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A2_1, 0x09 }, 66962306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A3_0, 0xAB }, 67062306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A3_1, 0x05 }, 67162306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A4_0, 0x1C }, 67262306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A4_1, 0x02 }, 67362306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A5_0, 0x17 }, 67462306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A5_1, 0x02 }, 67562306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A6_0, 0xAA }, 67662306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_A7_0, 0xE3 }, 67762306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_C_0, 0x69 }, 67862306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_C_1, 0x54 }, 67962306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_C_2, 0x02 }, 68062306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_C_3, 0x15 }, 68162306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_R1, 0xA4 }, 68262306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_R2, 0xB5 }, 68362306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_R3, 0x86 }, 68462306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_R4, 0x85 }, 68562306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_R5, 0xAA }, 68662306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_R6, 0xE2 }, 68762306a36Sopenharmony_ci { WSA883X_CDC_SPK_DSM_R7, 0x62 }, 68862306a36Sopenharmony_ci { WSA883X_CDC_SPK_GAIN_PDM_0, 0x00 }, 68962306a36Sopenharmony_ci { WSA883X_CDC_SPK_GAIN_PDM_1, 0xFC }, 69062306a36Sopenharmony_ci { WSA883X_CDC_SPK_GAIN_PDM_2, 0x05 }, 69162306a36Sopenharmony_ci { WSA883X_PDM_WD_CTL, 0x00 }, 69262306a36Sopenharmony_ci { WSA883X_DEM_BYPASS_DATA0, 0x00 }, 69362306a36Sopenharmony_ci { WSA883X_DEM_BYPASS_DATA1, 0x00 }, 69462306a36Sopenharmony_ci { WSA883X_DEM_BYPASS_DATA2, 0x00 }, 69562306a36Sopenharmony_ci { WSA883X_DEM_BYPASS_DATA3, 0x00 }, 69662306a36Sopenharmony_ci { WSA883X_WAVG_CTL, 0x06 }, 69762306a36Sopenharmony_ci { WSA883X_WAVG_LRA_PER_0, 0xD1 }, 69862306a36Sopenharmony_ci { WSA883X_WAVG_LRA_PER_1, 0x00 }, 69962306a36Sopenharmony_ci { WSA883X_WAVG_DELTA_THETA_0, 0xE6 }, 70062306a36Sopenharmony_ci { WSA883X_WAVG_DELTA_THETA_1, 0x04 }, 70162306a36Sopenharmony_ci { WSA883X_WAVG_DIRECT_AMP_0, 0x50 }, 70262306a36Sopenharmony_ci { WSA883X_WAVG_DIRECT_AMP_1, 0x00 }, 70362306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP0_0, 0x50 }, 70462306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP0_1, 0x00 }, 70562306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP1_0, 0x50 }, 70662306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP1_1, 0x00 }, 70762306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP2_0, 0x50 }, 70862306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP2_1, 0x00 }, 70962306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP3_0, 0x50 }, 71062306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP3_1, 0x00 }, 71162306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP4_0, 0x50 }, 71262306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP4_1, 0x00 }, 71362306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP5_0, 0x50 }, 71462306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP5_1, 0x00 }, 71562306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP6_0, 0x50 }, 71662306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP6_1, 0x00 }, 71762306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP7_0, 0x50 }, 71862306a36Sopenharmony_ci { WSA883X_WAVG_PTRN_AMP7_1, 0x00 }, 71962306a36Sopenharmony_ci { WSA883X_WAVG_PER_0_1, 0x88 }, 72062306a36Sopenharmony_ci { WSA883X_WAVG_PER_2_3, 0x88 }, 72162306a36Sopenharmony_ci { WSA883X_WAVG_PER_4_5, 0x88 }, 72262306a36Sopenharmony_ci { WSA883X_WAVG_PER_6_7, 0x88 }, 72362306a36Sopenharmony_ci { WSA883X_WAVG_STA, 0x00 }, 72462306a36Sopenharmony_ci { WSA883X_DRE_CTL_0, 0x70 }, 72562306a36Sopenharmony_ci { WSA883X_DRE_CTL_1, 0x08 }, 72662306a36Sopenharmony_ci { WSA883X_DRE_IDLE_DET_CTL, 0x1F }, 72762306a36Sopenharmony_ci { WSA883X_CLSH_CTL_0, 0x37 }, 72862306a36Sopenharmony_ci { WSA883X_CLSH_CTL_1, 0x81 }, 72962306a36Sopenharmony_ci { WSA883X_CLSH_V_HD_PA, 0x0F }, 73062306a36Sopenharmony_ci { WSA883X_CLSH_V_PA_MIN, 0x00 }, 73162306a36Sopenharmony_ci { WSA883X_CLSH_OVRD_VAL, 0x00 }, 73262306a36Sopenharmony_ci { WSA883X_CLSH_HARD_MAX, 0xFF }, 73362306a36Sopenharmony_ci { WSA883X_CLSH_SOFT_MAX, 0xF5 }, 73462306a36Sopenharmony_ci { WSA883X_CLSH_SIG_DP, 0x00 }, 73562306a36Sopenharmony_ci { WSA883X_TAGC_CTL, 0x10 }, 73662306a36Sopenharmony_ci { WSA883X_TAGC_TIME, 0x20 }, 73762306a36Sopenharmony_ci { WSA883X_TAGC_E2E_GAIN, 0x02 }, 73862306a36Sopenharmony_ci { WSA883X_TAGC_FORCE_VAL, 0x00 }, 73962306a36Sopenharmony_ci { WSA883X_VAGC_CTL, 0x00 }, 74062306a36Sopenharmony_ci { WSA883X_VAGC_TIME, 0x08 }, 74162306a36Sopenharmony_ci { WSA883X_VAGC_ATTN_LVL_1_2, 0x21 }, 74262306a36Sopenharmony_ci { WSA883X_VAGC_ATTN_LVL_3, 0x03 }, 74362306a36Sopenharmony_ci { WSA883X_INTR_MODE, 0x00 }, 74462306a36Sopenharmony_ci { WSA883X_INTR_MASK0, 0x90 }, 74562306a36Sopenharmony_ci { WSA883X_INTR_MASK1, 0x00 }, 74662306a36Sopenharmony_ci { WSA883X_INTR_STATUS0, 0x00 }, 74762306a36Sopenharmony_ci { WSA883X_INTR_STATUS1, 0x00 }, 74862306a36Sopenharmony_ci { WSA883X_INTR_CLEAR0, 0x00 }, 74962306a36Sopenharmony_ci { WSA883X_INTR_CLEAR1, 0x00 }, 75062306a36Sopenharmony_ci { WSA883X_INTR_LEVEL0, 0x00 }, 75162306a36Sopenharmony_ci { WSA883X_INTR_LEVEL1, 0x00 }, 75262306a36Sopenharmony_ci { WSA883X_INTR_SET0, 0x00 }, 75362306a36Sopenharmony_ci { WSA883X_INTR_SET1, 0x00 }, 75462306a36Sopenharmony_ci { WSA883X_INTR_TEST0, 0x00 }, 75562306a36Sopenharmony_ci { WSA883X_INTR_TEST1, 0x00 }, 75662306a36Sopenharmony_ci { WSA883X_OTP_CTRL0, 0x00 }, 75762306a36Sopenharmony_ci { WSA883X_OTP_CTRL1, 0x00 }, 75862306a36Sopenharmony_ci { WSA883X_HDRIVE_CTL_GROUP1, 0x00 }, 75962306a36Sopenharmony_ci { WSA883X_PIN_CTL, 0x04 }, 76062306a36Sopenharmony_ci { WSA883X_PIN_CTL_OE, 0x00 }, 76162306a36Sopenharmony_ci { WSA883X_PIN_WDATA_IOPAD, 0x00 }, 76262306a36Sopenharmony_ci { WSA883X_PIN_STATUS, 0x00 }, 76362306a36Sopenharmony_ci { WSA883X_I2C_SLAVE_CTL, 0x00 }, 76462306a36Sopenharmony_ci { WSA883X_PDM_TEST_MODE, 0x00 }, 76562306a36Sopenharmony_ci { WSA883X_ATE_TEST_MODE, 0x00 }, 76662306a36Sopenharmony_ci { WSA883X_DIG_DEBUG_MODE, 0x00 }, 76762306a36Sopenharmony_ci { WSA883X_DIG_DEBUG_SEL, 0x00 }, 76862306a36Sopenharmony_ci { WSA883X_DIG_DEBUG_EN, 0x00 }, 76962306a36Sopenharmony_ci { WSA883X_SWR_HM_TEST0, 0x08 }, 77062306a36Sopenharmony_ci { WSA883X_SWR_HM_TEST1, 0x00 }, 77162306a36Sopenharmony_ci { WSA883X_SWR_PAD_CTL, 0x37 }, 77262306a36Sopenharmony_ci { WSA883X_TADC_DETECT_DBG_CTL, 0x00 }, 77362306a36Sopenharmony_ci { WSA883X_TADC_DEBUG_MSB, 0x00 }, 77462306a36Sopenharmony_ci { WSA883X_TADC_DEBUG_LSB, 0x00 }, 77562306a36Sopenharmony_ci { WSA883X_SAMPLE_EDGE_SEL, 0x7F }, 77662306a36Sopenharmony_ci { WSA883X_SWR_EDGE_SEL, 0x00 }, 77762306a36Sopenharmony_ci { WSA883X_TEST_MODE_CTL, 0x04 }, 77862306a36Sopenharmony_ci { WSA883X_IOPAD_CTL, 0x00 }, 77962306a36Sopenharmony_ci { WSA883X_ANA_CSR_DBG_ADD, 0x00 }, 78062306a36Sopenharmony_ci { WSA883X_ANA_CSR_DBG_CTL, 0x12 }, 78162306a36Sopenharmony_ci { WSA883X_SPARE_R, 0x00 }, 78262306a36Sopenharmony_ci { WSA883X_SPARE_0, 0x00 }, 78362306a36Sopenharmony_ci { WSA883X_SPARE_1, 0x00 }, 78462306a36Sopenharmony_ci { WSA883X_SPARE_2, 0x00 }, 78562306a36Sopenharmony_ci { WSA883X_SCODE, 0x00 }, 78662306a36Sopenharmony_ci { WSA883X_OTP_REG_0, 0x05 }, 78762306a36Sopenharmony_ci { WSA883X_OTP_REG_1, 0xFF }, 78862306a36Sopenharmony_ci { WSA883X_OTP_REG_2, 0xC0 }, 78962306a36Sopenharmony_ci { WSA883X_OTP_REG_3, 0xFF }, 79062306a36Sopenharmony_ci { WSA883X_OTP_REG_4, 0xC0 }, 79162306a36Sopenharmony_ci { WSA883X_OTP_REG_5, 0xFF }, 79262306a36Sopenharmony_ci { WSA883X_OTP_REG_6, 0xFF }, 79362306a36Sopenharmony_ci { WSA883X_OTP_REG_7, 0xFF }, 79462306a36Sopenharmony_ci { WSA883X_OTP_REG_8, 0xFF }, 79562306a36Sopenharmony_ci { WSA883X_OTP_REG_9, 0xFF }, 79662306a36Sopenharmony_ci { WSA883X_OTP_REG_10, 0xFF }, 79762306a36Sopenharmony_ci { WSA883X_OTP_REG_11, 0xFF }, 79862306a36Sopenharmony_ci { WSA883X_OTP_REG_12, 0xFF }, 79962306a36Sopenharmony_ci { WSA883X_OTP_REG_13, 0xFF }, 80062306a36Sopenharmony_ci { WSA883X_OTP_REG_14, 0xFF }, 80162306a36Sopenharmony_ci { WSA883X_OTP_REG_15, 0xFF }, 80262306a36Sopenharmony_ci { WSA883X_OTP_REG_16, 0xFF }, 80362306a36Sopenharmony_ci { WSA883X_OTP_REG_17, 0xFF }, 80462306a36Sopenharmony_ci { WSA883X_OTP_REG_18, 0xFF }, 80562306a36Sopenharmony_ci { WSA883X_OTP_REG_19, 0xFF }, 80662306a36Sopenharmony_ci { WSA883X_OTP_REG_20, 0xFF }, 80762306a36Sopenharmony_ci { WSA883X_OTP_REG_21, 0xFF }, 80862306a36Sopenharmony_ci { WSA883X_OTP_REG_22, 0xFF }, 80962306a36Sopenharmony_ci { WSA883X_OTP_REG_23, 0xFF }, 81062306a36Sopenharmony_ci { WSA883X_OTP_REG_24, 0x37 }, 81162306a36Sopenharmony_ci { WSA883X_OTP_REG_25, 0x3F }, 81262306a36Sopenharmony_ci { WSA883X_OTP_REG_26, 0x03 }, 81362306a36Sopenharmony_ci { WSA883X_OTP_REG_27, 0x00 }, 81462306a36Sopenharmony_ci { WSA883X_OTP_REG_28, 0x00 }, 81562306a36Sopenharmony_ci { WSA883X_OTP_REG_29, 0x00 }, 81662306a36Sopenharmony_ci { WSA883X_OTP_REG_30, 0x00 }, 81762306a36Sopenharmony_ci { WSA883X_OTP_REG_31, 0x03 }, 81862306a36Sopenharmony_ci { WSA883X_OTP_REG_32, 0x00 }, 81962306a36Sopenharmony_ci { WSA883X_OTP_REG_33, 0xFF }, 82062306a36Sopenharmony_ci { WSA883X_OTP_REG_34, 0x00 }, 82162306a36Sopenharmony_ci { WSA883X_OTP_REG_35, 0x00 }, 82262306a36Sopenharmony_ci { WSA883X_OTP_REG_63, 0x40 }, 82362306a36Sopenharmony_ci { WSA883X_EMEM_0, 0x00 }, 82462306a36Sopenharmony_ci { WSA883X_EMEM_1, 0x00 }, 82562306a36Sopenharmony_ci { WSA883X_EMEM_2, 0x00 }, 82662306a36Sopenharmony_ci { WSA883X_EMEM_3, 0x00 }, 82762306a36Sopenharmony_ci { WSA883X_EMEM_4, 0x00 }, 82862306a36Sopenharmony_ci { WSA883X_EMEM_5, 0x00 }, 82962306a36Sopenharmony_ci { WSA883X_EMEM_6, 0x00 }, 83062306a36Sopenharmony_ci { WSA883X_EMEM_7, 0x00 }, 83162306a36Sopenharmony_ci { WSA883X_EMEM_8, 0x00 }, 83262306a36Sopenharmony_ci { WSA883X_EMEM_9, 0x00 }, 83362306a36Sopenharmony_ci { WSA883X_EMEM_10, 0x00 }, 83462306a36Sopenharmony_ci { WSA883X_EMEM_11, 0x00 }, 83562306a36Sopenharmony_ci { WSA883X_EMEM_12, 0x00 }, 83662306a36Sopenharmony_ci { WSA883X_EMEM_13, 0x00 }, 83762306a36Sopenharmony_ci { WSA883X_EMEM_14, 0x00 }, 83862306a36Sopenharmony_ci { WSA883X_EMEM_15, 0x00 }, 83962306a36Sopenharmony_ci { WSA883X_EMEM_16, 0x00 }, 84062306a36Sopenharmony_ci { WSA883X_EMEM_17, 0x00 }, 84162306a36Sopenharmony_ci { WSA883X_EMEM_18, 0x00 }, 84262306a36Sopenharmony_ci { WSA883X_EMEM_19, 0x00 }, 84362306a36Sopenharmony_ci { WSA883X_EMEM_20, 0x00 }, 84462306a36Sopenharmony_ci { WSA883X_EMEM_21, 0x00 }, 84562306a36Sopenharmony_ci { WSA883X_EMEM_22, 0x00 }, 84662306a36Sopenharmony_ci { WSA883X_EMEM_23, 0x00 }, 84762306a36Sopenharmony_ci { WSA883X_EMEM_24, 0x00 }, 84862306a36Sopenharmony_ci { WSA883X_EMEM_25, 0x00 }, 84962306a36Sopenharmony_ci { WSA883X_EMEM_26, 0x00 }, 85062306a36Sopenharmony_ci { WSA883X_EMEM_27, 0x00 }, 85162306a36Sopenharmony_ci { WSA883X_EMEM_28, 0x00 }, 85262306a36Sopenharmony_ci { WSA883X_EMEM_29, 0x00 }, 85362306a36Sopenharmony_ci { WSA883X_EMEM_30, 0x00 }, 85462306a36Sopenharmony_ci { WSA883X_EMEM_31, 0x00 }, 85562306a36Sopenharmony_ci { WSA883X_EMEM_32, 0x00 }, 85662306a36Sopenharmony_ci { WSA883X_EMEM_33, 0x00 }, 85762306a36Sopenharmony_ci { WSA883X_EMEM_34, 0x00 }, 85862306a36Sopenharmony_ci { WSA883X_EMEM_35, 0x00 }, 85962306a36Sopenharmony_ci { WSA883X_EMEM_36, 0x00 }, 86062306a36Sopenharmony_ci { WSA883X_EMEM_37, 0x00 }, 86162306a36Sopenharmony_ci { WSA883X_EMEM_38, 0x00 }, 86262306a36Sopenharmony_ci { WSA883X_EMEM_39, 0x00 }, 86362306a36Sopenharmony_ci { WSA883X_EMEM_40, 0x00 }, 86462306a36Sopenharmony_ci { WSA883X_EMEM_41, 0x00 }, 86562306a36Sopenharmony_ci { WSA883X_EMEM_42, 0x00 }, 86662306a36Sopenharmony_ci { WSA883X_EMEM_43, 0x00 }, 86762306a36Sopenharmony_ci { WSA883X_EMEM_44, 0x00 }, 86862306a36Sopenharmony_ci { WSA883X_EMEM_45, 0x00 }, 86962306a36Sopenharmony_ci { WSA883X_EMEM_46, 0x00 }, 87062306a36Sopenharmony_ci { WSA883X_EMEM_47, 0x00 }, 87162306a36Sopenharmony_ci { WSA883X_EMEM_48, 0x00 }, 87262306a36Sopenharmony_ci { WSA883X_EMEM_49, 0x00 }, 87362306a36Sopenharmony_ci { WSA883X_EMEM_50, 0x00 }, 87462306a36Sopenharmony_ci { WSA883X_EMEM_51, 0x00 }, 87562306a36Sopenharmony_ci { WSA883X_EMEM_52, 0x00 }, 87662306a36Sopenharmony_ci { WSA883X_EMEM_53, 0x00 }, 87762306a36Sopenharmony_ci { WSA883X_EMEM_54, 0x00 }, 87862306a36Sopenharmony_ci { WSA883X_EMEM_55, 0x00 }, 87962306a36Sopenharmony_ci { WSA883X_EMEM_56, 0x00 }, 88062306a36Sopenharmony_ci { WSA883X_EMEM_57, 0x00 }, 88162306a36Sopenharmony_ci { WSA883X_EMEM_58, 0x00 }, 88262306a36Sopenharmony_ci { WSA883X_EMEM_59, 0x00 }, 88362306a36Sopenharmony_ci { WSA883X_EMEM_60, 0x00 }, 88462306a36Sopenharmony_ci { WSA883X_EMEM_61, 0x00 }, 88562306a36Sopenharmony_ci { WSA883X_EMEM_62, 0x00 }, 88662306a36Sopenharmony_ci { WSA883X_EMEM_63, 0x00 }, 88762306a36Sopenharmony_ci}; 88862306a36Sopenharmony_ci 88962306a36Sopenharmony_cistatic bool wsa883x_readonly_register(struct device *dev, unsigned int reg) 89062306a36Sopenharmony_ci{ 89162306a36Sopenharmony_ci switch (reg) { 89262306a36Sopenharmony_ci case WSA883X_DOUT_MSB: 89362306a36Sopenharmony_ci case WSA883X_DOUT_LSB: 89462306a36Sopenharmony_ci case WSA883X_STATUS: 89562306a36Sopenharmony_ci case WSA883X_PA_STATUS0: 89662306a36Sopenharmony_ci case WSA883X_PA_STATUS1: 89762306a36Sopenharmony_ci case WSA883X_PA_STATUS2: 89862306a36Sopenharmony_ci case WSA883X_STATUS_0: 89962306a36Sopenharmony_ci case WSA883X_STATUS_1: 90062306a36Sopenharmony_ci case WSA883X_CHIP_ID0: 90162306a36Sopenharmony_ci case WSA883X_CHIP_ID1: 90262306a36Sopenharmony_ci case WSA883X_CHIP_ID2: 90362306a36Sopenharmony_ci case WSA883X_CHIP_ID3: 90462306a36Sopenharmony_ci case WSA883X_BUS_ID: 90562306a36Sopenharmony_ci case WSA883X_PA_FSM_STA: 90662306a36Sopenharmony_ci case WSA883X_PA_FSM_ERR_COND: 90762306a36Sopenharmony_ci case WSA883X_TEMP_MSB: 90862306a36Sopenharmony_ci case WSA883X_TEMP_LSB: 90962306a36Sopenharmony_ci case WSA883X_VBAT_DIN_MSB: 91062306a36Sopenharmony_ci case WSA883X_VBAT_DIN_LSB: 91162306a36Sopenharmony_ci case WSA883X_VBAT_DOUT: 91262306a36Sopenharmony_ci case WSA883X_SDM_PDM9_LSB: 91362306a36Sopenharmony_ci case WSA883X_SDM_PDM9_MSB: 91462306a36Sopenharmony_ci case WSA883X_WAVG_STA: 91562306a36Sopenharmony_ci case WSA883X_INTR_STATUS0: 91662306a36Sopenharmony_ci case WSA883X_INTR_STATUS1: 91762306a36Sopenharmony_ci case WSA883X_OTP_CTRL1: 91862306a36Sopenharmony_ci case WSA883X_PIN_STATUS: 91962306a36Sopenharmony_ci case WSA883X_ATE_TEST_MODE: 92062306a36Sopenharmony_ci case WSA883X_SWR_HM_TEST1: 92162306a36Sopenharmony_ci case WSA883X_SPARE_R: 92262306a36Sopenharmony_ci case WSA883X_OTP_REG_0: 92362306a36Sopenharmony_ci return true; 92462306a36Sopenharmony_ci } 92562306a36Sopenharmony_ci return false; 92662306a36Sopenharmony_ci} 92762306a36Sopenharmony_ci 92862306a36Sopenharmony_cistatic bool wsa883x_writeable_register(struct device *dev, unsigned int reg) 92962306a36Sopenharmony_ci{ 93062306a36Sopenharmony_ci return !wsa883x_readonly_register(dev, reg); 93162306a36Sopenharmony_ci} 93262306a36Sopenharmony_ci 93362306a36Sopenharmony_cistatic bool wsa883x_volatile_register(struct device *dev, unsigned int reg) 93462306a36Sopenharmony_ci{ 93562306a36Sopenharmony_ci return wsa883x_readonly_register(dev, reg); 93662306a36Sopenharmony_ci} 93762306a36Sopenharmony_ci 93862306a36Sopenharmony_cistatic struct regmap_config wsa883x_regmap_config = { 93962306a36Sopenharmony_ci .reg_bits = 32, 94062306a36Sopenharmony_ci .val_bits = 8, 94162306a36Sopenharmony_ci .cache_type = REGCACHE_MAPLE, 94262306a36Sopenharmony_ci .reg_defaults = wsa883x_defaults, 94362306a36Sopenharmony_ci .max_register = WSA883X_MAX_REGISTER, 94462306a36Sopenharmony_ci .num_reg_defaults = ARRAY_SIZE(wsa883x_defaults), 94562306a36Sopenharmony_ci .volatile_reg = wsa883x_volatile_register, 94662306a36Sopenharmony_ci .writeable_reg = wsa883x_writeable_register, 94762306a36Sopenharmony_ci .reg_format_endian = REGMAP_ENDIAN_NATIVE, 94862306a36Sopenharmony_ci .val_format_endian = REGMAP_ENDIAN_NATIVE, 94962306a36Sopenharmony_ci .use_single_read = true, 95062306a36Sopenharmony_ci}; 95162306a36Sopenharmony_ci 95262306a36Sopenharmony_cistatic const struct reg_sequence reg_init[] = { 95362306a36Sopenharmony_ci {WSA883X_PA_FSM_BYP, 0x00}, 95462306a36Sopenharmony_ci {WSA883X_ADC_6, 0x02}, 95562306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A2_0, 0x0A}, 95662306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A2_1, 0x08}, 95762306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A3_0, 0xF3}, 95862306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A3_1, 0x07}, 95962306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A4_0, 0x79}, 96062306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A4_1, 0x02}, 96162306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A5_0, 0x0B}, 96262306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A5_1, 0x02}, 96362306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A6_0, 0x8A}, 96462306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_A7_0, 0x9B}, 96562306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_C_0, 0x68}, 96662306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_C_1, 0x54}, 96762306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_C_2, 0xF2}, 96862306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_C_3, 0x20}, 96962306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_R1, 0x83}, 97062306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_R2, 0x7F}, 97162306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_R3, 0x9D}, 97262306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_R4, 0x82}, 97362306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_R5, 0x8B}, 97462306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_R6, 0x9B}, 97562306a36Sopenharmony_ci {WSA883X_CDC_SPK_DSM_R7, 0x3F}, 97662306a36Sopenharmony_ci {WSA883X_VBAT_SNS, 0x20}, 97762306a36Sopenharmony_ci {WSA883X_DRE_CTL_0, 0x92}, 97862306a36Sopenharmony_ci {WSA883X_DRE_IDLE_DET_CTL, 0x0F}, 97962306a36Sopenharmony_ci {WSA883X_CURRENT_LIMIT, 0xC4}, 98062306a36Sopenharmony_ci {WSA883X_VAGC_TIME, 0x0F}, 98162306a36Sopenharmony_ci {WSA883X_VAGC_ATTN_LVL_1_2, 0x00}, 98262306a36Sopenharmony_ci {WSA883X_VAGC_ATTN_LVL_3, 0x01}, 98362306a36Sopenharmony_ci {WSA883X_VAGC_CTL, 0x01}, 98462306a36Sopenharmony_ci {WSA883X_TAGC_CTL, 0x1A}, 98562306a36Sopenharmony_ci {WSA883X_TAGC_TIME, 0x2C}, 98662306a36Sopenharmony_ci {WSA883X_TEMP_CONFIG0, 0x02}, 98762306a36Sopenharmony_ci {WSA883X_TEMP_CONFIG1, 0x02}, 98862306a36Sopenharmony_ci {WSA883X_OTP_REG_1, 0x49}, 98962306a36Sopenharmony_ci {WSA883X_OTP_REG_2, 0x80}, 99062306a36Sopenharmony_ci {WSA883X_OTP_REG_3, 0xC9}, 99162306a36Sopenharmony_ci {WSA883X_OTP_REG_4, 0x40}, 99262306a36Sopenharmony_ci {WSA883X_TAGC_CTL, 0x1B}, 99362306a36Sopenharmony_ci {WSA883X_ADC_2, 0x00}, 99462306a36Sopenharmony_ci {WSA883X_ADC_7, 0x85}, 99562306a36Sopenharmony_ci {WSA883X_ADC_7, 0x87}, 99662306a36Sopenharmony_ci {WSA883X_CKWD_CTL_0, 0x14}, 99762306a36Sopenharmony_ci {WSA883X_CKWD_CTL_1, 0x1B}, 99862306a36Sopenharmony_ci {WSA883X_GMAMP_SUP1, 0xE2}, 99962306a36Sopenharmony_ci}; 100062306a36Sopenharmony_ci 100162306a36Sopenharmony_cistatic void wsa883x_init(struct wsa883x_priv *wsa883x) 100262306a36Sopenharmony_ci{ 100362306a36Sopenharmony_ci struct regmap *regmap = wsa883x->regmap; 100462306a36Sopenharmony_ci int variant, version; 100562306a36Sopenharmony_ci 100662306a36Sopenharmony_ci regmap_read(regmap, WSA883X_OTP_REG_0, &variant); 100762306a36Sopenharmony_ci wsa883x->variant = variant & WSA883X_ID_MASK; 100862306a36Sopenharmony_ci 100962306a36Sopenharmony_ci regmap_read(regmap, WSA883X_CHIP_ID0, &version); 101062306a36Sopenharmony_ci wsa883x->version = version; 101162306a36Sopenharmony_ci 101262306a36Sopenharmony_ci switch (wsa883x->variant) { 101362306a36Sopenharmony_ci case WSA8830: 101462306a36Sopenharmony_ci dev_info(wsa883x->dev, "WSA883X Version 1_%d, Variant: WSA8830\n", 101562306a36Sopenharmony_ci wsa883x->version); 101662306a36Sopenharmony_ci break; 101762306a36Sopenharmony_ci case WSA8835: 101862306a36Sopenharmony_ci dev_info(wsa883x->dev, "WSA883X Version 1_%d, Variant: WSA8835\n", 101962306a36Sopenharmony_ci wsa883x->version); 102062306a36Sopenharmony_ci break; 102162306a36Sopenharmony_ci case WSA8832: 102262306a36Sopenharmony_ci dev_info(wsa883x->dev, "WSA883X Version 1_%d, Variant: WSA8832\n", 102362306a36Sopenharmony_ci wsa883x->version); 102462306a36Sopenharmony_ci break; 102562306a36Sopenharmony_ci case WSA8835_V2: 102662306a36Sopenharmony_ci dev_info(wsa883x->dev, "WSA883X Version 1_%d, Variant: WSA8835_V2\n", 102762306a36Sopenharmony_ci wsa883x->version); 102862306a36Sopenharmony_ci break; 102962306a36Sopenharmony_ci default: 103062306a36Sopenharmony_ci break; 103162306a36Sopenharmony_ci } 103262306a36Sopenharmony_ci 103362306a36Sopenharmony_ci wsa883x->comp_offset = COMP_OFFSET2; 103462306a36Sopenharmony_ci 103562306a36Sopenharmony_ci /* Initial settings */ 103662306a36Sopenharmony_ci regmap_multi_reg_write(regmap, reg_init, ARRAY_SIZE(reg_init)); 103762306a36Sopenharmony_ci 103862306a36Sopenharmony_ci if (wsa883x->variant == WSA8830 || wsa883x->variant == WSA8832) { 103962306a36Sopenharmony_ci wsa883x->comp_offset = COMP_OFFSET3; 104062306a36Sopenharmony_ci regmap_update_bits(regmap, WSA883X_DRE_CTL_0, 104162306a36Sopenharmony_ci WSA883X_DRE_OFFSET_MASK, 104262306a36Sopenharmony_ci wsa883x->comp_offset); 104362306a36Sopenharmony_ci } 104462306a36Sopenharmony_ci} 104562306a36Sopenharmony_ci 104662306a36Sopenharmony_cistatic int wsa883x_update_status(struct sdw_slave *slave, 104762306a36Sopenharmony_ci enum sdw_slave_status status) 104862306a36Sopenharmony_ci{ 104962306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = dev_get_drvdata(&slave->dev); 105062306a36Sopenharmony_ci 105162306a36Sopenharmony_ci if (status == SDW_SLAVE_ATTACHED && slave->dev_num > 0) 105262306a36Sopenharmony_ci wsa883x_init(wsa883x); 105362306a36Sopenharmony_ci 105462306a36Sopenharmony_ci return 0; 105562306a36Sopenharmony_ci} 105662306a36Sopenharmony_ci 105762306a36Sopenharmony_cistatic int wsa883x_port_prep(struct sdw_slave *slave, 105862306a36Sopenharmony_ci struct sdw_prepare_ch *prepare_ch, 105962306a36Sopenharmony_ci enum sdw_port_prep_ops state) 106062306a36Sopenharmony_ci{ 106162306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = dev_get_drvdata(&slave->dev); 106262306a36Sopenharmony_ci 106362306a36Sopenharmony_ci if (state == SDW_OPS_PORT_POST_PREP) 106462306a36Sopenharmony_ci wsa883x->port_prepared[prepare_ch->num - 1] = true; 106562306a36Sopenharmony_ci else 106662306a36Sopenharmony_ci wsa883x->port_prepared[prepare_ch->num - 1] = false; 106762306a36Sopenharmony_ci 106862306a36Sopenharmony_ci return 0; 106962306a36Sopenharmony_ci} 107062306a36Sopenharmony_ci 107162306a36Sopenharmony_cistatic const struct sdw_slave_ops wsa883x_slave_ops = { 107262306a36Sopenharmony_ci .update_status = wsa883x_update_status, 107362306a36Sopenharmony_ci .port_prep = wsa883x_port_prep, 107462306a36Sopenharmony_ci}; 107562306a36Sopenharmony_ci 107662306a36Sopenharmony_cistatic int wsa_dev_mode_get(struct snd_kcontrol *kcontrol, 107762306a36Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 107862306a36Sopenharmony_ci{ 107962306a36Sopenharmony_ci struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 108062306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); 108162306a36Sopenharmony_ci 108262306a36Sopenharmony_ci ucontrol->value.enumerated.item[0] = wsa883x->dev_mode; 108362306a36Sopenharmony_ci 108462306a36Sopenharmony_ci return 0; 108562306a36Sopenharmony_ci} 108662306a36Sopenharmony_ci 108762306a36Sopenharmony_cistatic int wsa_dev_mode_put(struct snd_kcontrol *kcontrol, 108862306a36Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 108962306a36Sopenharmony_ci{ 109062306a36Sopenharmony_ci struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 109162306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); 109262306a36Sopenharmony_ci 109362306a36Sopenharmony_ci if (wsa883x->dev_mode == ucontrol->value.enumerated.item[0]) 109462306a36Sopenharmony_ci return 0; 109562306a36Sopenharmony_ci 109662306a36Sopenharmony_ci wsa883x->dev_mode = ucontrol->value.enumerated.item[0]; 109762306a36Sopenharmony_ci 109862306a36Sopenharmony_ci return 1; 109962306a36Sopenharmony_ci} 110062306a36Sopenharmony_ci 110162306a36Sopenharmony_cistatic const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(pa_gain, 110262306a36Sopenharmony_ci 0, 14, TLV_DB_SCALE_ITEM(-300, 0, 0), 110362306a36Sopenharmony_ci 15, 29, TLV_DB_SCALE_ITEM(-300, 150, 0), 110462306a36Sopenharmony_ci 30, 31, TLV_DB_SCALE_ITEM(1800, 0, 0), 110562306a36Sopenharmony_ci); 110662306a36Sopenharmony_ci 110762306a36Sopenharmony_cistatic int wsa883x_get_swr_port(struct snd_kcontrol *kcontrol, 110862306a36Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 110962306a36Sopenharmony_ci{ 111062306a36Sopenharmony_ci struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); 111162306a36Sopenharmony_ci struct wsa883x_priv *data = snd_soc_component_get_drvdata(comp); 111262306a36Sopenharmony_ci struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; 111362306a36Sopenharmony_ci int portidx = mixer->reg; 111462306a36Sopenharmony_ci 111562306a36Sopenharmony_ci ucontrol->value.integer.value[0] = data->port_enable[portidx]; 111662306a36Sopenharmony_ci 111762306a36Sopenharmony_ci return 0; 111862306a36Sopenharmony_ci} 111962306a36Sopenharmony_ci 112062306a36Sopenharmony_cistatic int wsa883x_set_swr_port(struct snd_kcontrol *kcontrol, 112162306a36Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 112262306a36Sopenharmony_ci{ 112362306a36Sopenharmony_ci struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); 112462306a36Sopenharmony_ci struct wsa883x_priv *data = snd_soc_component_get_drvdata(comp); 112562306a36Sopenharmony_ci struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; 112662306a36Sopenharmony_ci int portidx = mixer->reg; 112762306a36Sopenharmony_ci 112862306a36Sopenharmony_ci if (ucontrol->value.integer.value[0]) { 112962306a36Sopenharmony_ci if (data->port_enable[portidx]) 113062306a36Sopenharmony_ci return 0; 113162306a36Sopenharmony_ci 113262306a36Sopenharmony_ci data->port_enable[portidx] = true; 113362306a36Sopenharmony_ci } else { 113462306a36Sopenharmony_ci if (!data->port_enable[portidx]) 113562306a36Sopenharmony_ci return 0; 113662306a36Sopenharmony_ci 113762306a36Sopenharmony_ci data->port_enable[portidx] = false; 113862306a36Sopenharmony_ci } 113962306a36Sopenharmony_ci 114062306a36Sopenharmony_ci return 1; 114162306a36Sopenharmony_ci} 114262306a36Sopenharmony_ci 114362306a36Sopenharmony_cistatic int wsa883x_get_comp_offset(struct snd_kcontrol *kcontrol, 114462306a36Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 114562306a36Sopenharmony_ci{ 114662306a36Sopenharmony_ci struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 114762306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); 114862306a36Sopenharmony_ci 114962306a36Sopenharmony_ci ucontrol->value.integer.value[0] = wsa883x->comp_offset; 115062306a36Sopenharmony_ci 115162306a36Sopenharmony_ci return 0; 115262306a36Sopenharmony_ci} 115362306a36Sopenharmony_ci 115462306a36Sopenharmony_cistatic int wsa883x_set_comp_offset(struct snd_kcontrol *kcontrol, 115562306a36Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 115662306a36Sopenharmony_ci{ 115762306a36Sopenharmony_ci struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 115862306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); 115962306a36Sopenharmony_ci 116062306a36Sopenharmony_ci if (wsa883x->comp_offset == ucontrol->value.integer.value[0]) 116162306a36Sopenharmony_ci return 0; 116262306a36Sopenharmony_ci 116362306a36Sopenharmony_ci wsa883x->comp_offset = ucontrol->value.integer.value[0]; 116462306a36Sopenharmony_ci 116562306a36Sopenharmony_ci return 1; 116662306a36Sopenharmony_ci} 116762306a36Sopenharmony_ci 116862306a36Sopenharmony_cistatic int wsa883x_codec_probe(struct snd_soc_component *comp) 116962306a36Sopenharmony_ci{ 117062306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(comp); 117162306a36Sopenharmony_ci 117262306a36Sopenharmony_ci snd_soc_component_init_regmap(comp, wsa883x->regmap); 117362306a36Sopenharmony_ci 117462306a36Sopenharmony_ci return 0; 117562306a36Sopenharmony_ci} 117662306a36Sopenharmony_ci 117762306a36Sopenharmony_cistatic int wsa883x_spkr_event(struct snd_soc_dapm_widget *w, 117862306a36Sopenharmony_ci struct snd_kcontrol *kcontrol, int event) 117962306a36Sopenharmony_ci{ 118062306a36Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 118162306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); 118262306a36Sopenharmony_ci 118362306a36Sopenharmony_ci switch (event) { 118462306a36Sopenharmony_ci case SND_SOC_DAPM_POST_PMU: 118562306a36Sopenharmony_ci switch (wsa883x->dev_mode) { 118662306a36Sopenharmony_ci case RECEIVER: 118762306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_CDC_PATH_MODE, 118862306a36Sopenharmony_ci WSA883X_RXD_MODE_MASK, 118962306a36Sopenharmony_ci WSA883X_RXD_MODE_HIFI); 119062306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_SPKR_PWM_CLK_CTL, 119162306a36Sopenharmony_ci WSA883X_SPKR_PWM_FREQ_SEL_MASK, 119262306a36Sopenharmony_ci WSA883X_SPKR_PWM_FREQ_F600KHZ); 119362306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_DRE_CTL_0, 119462306a36Sopenharmony_ci WSA883X_DRE_PROG_DELAY_MASK, 0x0); 119562306a36Sopenharmony_ci break; 119662306a36Sopenharmony_ci case SPEAKER: 119762306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_CDC_PATH_MODE, 119862306a36Sopenharmony_ci WSA883X_RXD_MODE_MASK, 119962306a36Sopenharmony_ci WSA883X_RXD_MODE_NORMAL); 120062306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_SPKR_PWM_CLK_CTL, 120162306a36Sopenharmony_ci WSA883X_SPKR_PWM_FREQ_SEL_MASK, 120262306a36Sopenharmony_ci WSA883X_SPKR_PWM_FREQ_F300KHZ); 120362306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_DRE_CTL_0, 120462306a36Sopenharmony_ci WSA883X_DRE_PROG_DELAY_MASK, 0x9); 120562306a36Sopenharmony_ci break; 120662306a36Sopenharmony_ci default: 120762306a36Sopenharmony_ci break; 120862306a36Sopenharmony_ci } 120962306a36Sopenharmony_ci 121062306a36Sopenharmony_ci if (wsa883x->port_enable[WSA883X_PORT_COMP]) 121162306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_DRE_CTL_0, 121262306a36Sopenharmony_ci WSA883X_DRE_OFFSET_MASK, 121362306a36Sopenharmony_ci wsa883x->comp_offset); 121462306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_VBAT_ADC_FLT_CTL, 121562306a36Sopenharmony_ci WSA883X_VBAT_ADC_COEF_SEL_MASK, 121662306a36Sopenharmony_ci WSA883X_VBAT_ADC_COEF_F_1DIV16); 121762306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_VBAT_ADC_FLT_CTL, 121862306a36Sopenharmony_ci WSA883X_VBAT_ADC_FLT_EN_MASK, 0x1); 121962306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_PDM_WD_CTL, 122062306a36Sopenharmony_ci WSA883X_PDM_EN_MASK, 122162306a36Sopenharmony_ci WSA883X_PDM_ENABLE); 122262306a36Sopenharmony_ci 122362306a36Sopenharmony_ci break; 122462306a36Sopenharmony_ci case SND_SOC_DAPM_PRE_PMD: 122562306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_VBAT_ADC_FLT_CTL, 122662306a36Sopenharmony_ci WSA883X_VBAT_ADC_FLT_EN_MASK, 0x0); 122762306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_VBAT_ADC_FLT_CTL, 122862306a36Sopenharmony_ci WSA883X_VBAT_ADC_COEF_SEL_MASK, 122962306a36Sopenharmony_ci WSA883X_VBAT_ADC_COEF_F_1DIV2); 123062306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_PA_FSM_CTL, 123162306a36Sopenharmony_ci WSA883X_GLOBAL_PA_EN_MASK, 0); 123262306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_PDM_WD_CTL, 123362306a36Sopenharmony_ci WSA883X_PDM_EN_MASK, 0); 123462306a36Sopenharmony_ci break; 123562306a36Sopenharmony_ci } 123662306a36Sopenharmony_ci return 0; 123762306a36Sopenharmony_ci} 123862306a36Sopenharmony_ci 123962306a36Sopenharmony_cistatic const struct snd_soc_dapm_widget wsa883x_dapm_widgets[] = { 124062306a36Sopenharmony_ci SND_SOC_DAPM_INPUT("IN"), 124162306a36Sopenharmony_ci SND_SOC_DAPM_SPK("SPKR", wsa883x_spkr_event), 124262306a36Sopenharmony_ci}; 124362306a36Sopenharmony_ci 124462306a36Sopenharmony_cistatic const struct snd_kcontrol_new wsa883x_snd_controls[] = { 124562306a36Sopenharmony_ci SOC_SINGLE_RANGE_TLV("PA Volume", WSA883X_DRE_CTL_1, 1, 124662306a36Sopenharmony_ci 0x0, 0x1f, 1, pa_gain), 124762306a36Sopenharmony_ci SOC_ENUM_EXT("WSA MODE", wsa_dev_mode_enum, 124862306a36Sopenharmony_ci wsa_dev_mode_get, wsa_dev_mode_put), 124962306a36Sopenharmony_ci SOC_SINGLE_EXT("COMP Offset", SND_SOC_NOPM, 0, 4, 0, 125062306a36Sopenharmony_ci wsa883x_get_comp_offset, wsa883x_set_comp_offset), 125162306a36Sopenharmony_ci SOC_SINGLE_EXT("DAC Switch", WSA883X_PORT_DAC, 0, 1, 0, 125262306a36Sopenharmony_ci wsa883x_get_swr_port, wsa883x_set_swr_port), 125362306a36Sopenharmony_ci SOC_SINGLE_EXT("COMP Switch", WSA883X_PORT_COMP, 0, 1, 0, 125462306a36Sopenharmony_ci wsa883x_get_swr_port, wsa883x_set_swr_port), 125562306a36Sopenharmony_ci SOC_SINGLE_EXT("BOOST Switch", WSA883X_PORT_BOOST, 0, 1, 0, 125662306a36Sopenharmony_ci wsa883x_get_swr_port, wsa883x_set_swr_port), 125762306a36Sopenharmony_ci SOC_SINGLE_EXT("VISENSE Switch", WSA883X_PORT_VISENSE, 0, 1, 0, 125862306a36Sopenharmony_ci wsa883x_get_swr_port, wsa883x_set_swr_port), 125962306a36Sopenharmony_ci}; 126062306a36Sopenharmony_ci 126162306a36Sopenharmony_cistatic const struct snd_soc_dapm_route wsa883x_audio_map[] = { 126262306a36Sopenharmony_ci {"SPKR", NULL, "IN"}, 126362306a36Sopenharmony_ci}; 126462306a36Sopenharmony_ci 126562306a36Sopenharmony_cistatic const struct snd_soc_component_driver wsa883x_component_drv = { 126662306a36Sopenharmony_ci .name = "WSA883x", 126762306a36Sopenharmony_ci .probe = wsa883x_codec_probe, 126862306a36Sopenharmony_ci .controls = wsa883x_snd_controls, 126962306a36Sopenharmony_ci .num_controls = ARRAY_SIZE(wsa883x_snd_controls), 127062306a36Sopenharmony_ci .dapm_widgets = wsa883x_dapm_widgets, 127162306a36Sopenharmony_ci .num_dapm_widgets = ARRAY_SIZE(wsa883x_dapm_widgets), 127262306a36Sopenharmony_ci .dapm_routes = wsa883x_audio_map, 127362306a36Sopenharmony_ci .num_dapm_routes = ARRAY_SIZE(wsa883x_audio_map), 127462306a36Sopenharmony_ci}; 127562306a36Sopenharmony_ci 127662306a36Sopenharmony_cistatic int wsa883x_hw_params(struct snd_pcm_substream *substream, 127762306a36Sopenharmony_ci struct snd_pcm_hw_params *params, 127862306a36Sopenharmony_ci struct snd_soc_dai *dai) 127962306a36Sopenharmony_ci{ 128062306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = dev_get_drvdata(dai->dev); 128162306a36Sopenharmony_ci int i; 128262306a36Sopenharmony_ci 128362306a36Sopenharmony_ci wsa883x->active_ports = 0; 128462306a36Sopenharmony_ci for (i = 0; i < WSA883X_MAX_SWR_PORTS; i++) { 128562306a36Sopenharmony_ci if (!wsa883x->port_enable[i]) 128662306a36Sopenharmony_ci continue; 128762306a36Sopenharmony_ci 128862306a36Sopenharmony_ci wsa883x->port_config[wsa883x->active_ports] = wsa883x_pconfig[i]; 128962306a36Sopenharmony_ci wsa883x->active_ports++; 129062306a36Sopenharmony_ci } 129162306a36Sopenharmony_ci 129262306a36Sopenharmony_ci wsa883x->sconfig.frame_rate = params_rate(params); 129362306a36Sopenharmony_ci 129462306a36Sopenharmony_ci return sdw_stream_add_slave(wsa883x->slave, &wsa883x->sconfig, 129562306a36Sopenharmony_ci wsa883x->port_config, wsa883x->active_ports, 129662306a36Sopenharmony_ci wsa883x->sruntime); 129762306a36Sopenharmony_ci} 129862306a36Sopenharmony_ci 129962306a36Sopenharmony_cistatic int wsa883x_hw_free(struct snd_pcm_substream *substream, 130062306a36Sopenharmony_ci struct snd_soc_dai *dai) 130162306a36Sopenharmony_ci{ 130262306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = dev_get_drvdata(dai->dev); 130362306a36Sopenharmony_ci 130462306a36Sopenharmony_ci sdw_stream_remove_slave(wsa883x->slave, wsa883x->sruntime); 130562306a36Sopenharmony_ci 130662306a36Sopenharmony_ci return 0; 130762306a36Sopenharmony_ci} 130862306a36Sopenharmony_ci 130962306a36Sopenharmony_cistatic int wsa883x_set_sdw_stream(struct snd_soc_dai *dai, 131062306a36Sopenharmony_ci void *stream, int direction) 131162306a36Sopenharmony_ci{ 131262306a36Sopenharmony_ci struct wsa883x_priv *wsa883x = dev_get_drvdata(dai->dev); 131362306a36Sopenharmony_ci 131462306a36Sopenharmony_ci wsa883x->sruntime = stream; 131562306a36Sopenharmony_ci 131662306a36Sopenharmony_ci return 0; 131762306a36Sopenharmony_ci} 131862306a36Sopenharmony_ci 131962306a36Sopenharmony_cistatic int wsa883x_digital_mute(struct snd_soc_dai *dai, int mute, int stream) 132062306a36Sopenharmony_ci{ 132162306a36Sopenharmony_ci struct snd_soc_component *component = dai->component; 132262306a36Sopenharmony_ci 132362306a36Sopenharmony_ci if (mute) { 132462306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_DRE_CTL_1, 132562306a36Sopenharmony_ci WSA883X_DRE_GAIN_EN_MASK, 0); 132662306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_PA_FSM_CTL, 132762306a36Sopenharmony_ci WSA883X_GLOBAL_PA_EN_MASK, 0); 132862306a36Sopenharmony_ci 132962306a36Sopenharmony_ci } else { 133062306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_DRE_CTL_1, 133162306a36Sopenharmony_ci WSA883X_DRE_GAIN_EN_MASK, 133262306a36Sopenharmony_ci WSA883X_DRE_GAIN_FROM_CSR); 133362306a36Sopenharmony_ci snd_soc_component_write_field(component, WSA883X_PA_FSM_CTL, 133462306a36Sopenharmony_ci WSA883X_GLOBAL_PA_EN_MASK, 133562306a36Sopenharmony_ci WSA883X_GLOBAL_PA_ENABLE); 133662306a36Sopenharmony_ci 133762306a36Sopenharmony_ci } 133862306a36Sopenharmony_ci 133962306a36Sopenharmony_ci return 0; 134062306a36Sopenharmony_ci} 134162306a36Sopenharmony_ci 134262306a36Sopenharmony_cistatic const struct snd_soc_dai_ops wsa883x_dai_ops = { 134362306a36Sopenharmony_ci .hw_params = wsa883x_hw_params, 134462306a36Sopenharmony_ci .hw_free = wsa883x_hw_free, 134562306a36Sopenharmony_ci .mute_stream = wsa883x_digital_mute, 134662306a36Sopenharmony_ci .set_stream = wsa883x_set_sdw_stream, 134762306a36Sopenharmony_ci .mute_unmute_on_trigger = true, 134862306a36Sopenharmony_ci}; 134962306a36Sopenharmony_ci 135062306a36Sopenharmony_cistatic struct snd_soc_dai_driver wsa883x_dais[] = { 135162306a36Sopenharmony_ci { 135262306a36Sopenharmony_ci .name = "SPKR", 135362306a36Sopenharmony_ci .playback = { 135462306a36Sopenharmony_ci .stream_name = "SPKR Playback", 135562306a36Sopenharmony_ci .rates = WSA883X_RATES | WSA883X_FRAC_RATES, 135662306a36Sopenharmony_ci .formats = WSA883X_FORMATS, 135762306a36Sopenharmony_ci .rate_min = 8000, 135862306a36Sopenharmony_ci .rate_max = 352800, 135962306a36Sopenharmony_ci .channels_min = 1, 136062306a36Sopenharmony_ci .channels_max = 1, 136162306a36Sopenharmony_ci }, 136262306a36Sopenharmony_ci .ops = &wsa883x_dai_ops, 136362306a36Sopenharmony_ci }, 136462306a36Sopenharmony_ci}; 136562306a36Sopenharmony_ci 136662306a36Sopenharmony_cistatic int wsa883x_probe(struct sdw_slave *pdev, 136762306a36Sopenharmony_ci const struct sdw_device_id *id) 136862306a36Sopenharmony_ci{ 136962306a36Sopenharmony_ci struct wsa883x_priv *wsa883x; 137062306a36Sopenharmony_ci struct device *dev = &pdev->dev; 137162306a36Sopenharmony_ci int ret; 137262306a36Sopenharmony_ci 137362306a36Sopenharmony_ci wsa883x = devm_kzalloc(dev, sizeof(*wsa883x), GFP_KERNEL); 137462306a36Sopenharmony_ci if (!wsa883x) 137562306a36Sopenharmony_ci return -ENOMEM; 137662306a36Sopenharmony_ci 137762306a36Sopenharmony_ci wsa883x->vdd = devm_regulator_get(dev, "vdd"); 137862306a36Sopenharmony_ci if (IS_ERR(wsa883x->vdd)) 137962306a36Sopenharmony_ci return dev_err_probe(dev, PTR_ERR(wsa883x->vdd), 138062306a36Sopenharmony_ci "No vdd regulator found\n"); 138162306a36Sopenharmony_ci 138262306a36Sopenharmony_ci ret = regulator_enable(wsa883x->vdd); 138362306a36Sopenharmony_ci if (ret) 138462306a36Sopenharmony_ci return dev_err_probe(dev, ret, "Failed to enable vdd regulator\n"); 138562306a36Sopenharmony_ci 138662306a36Sopenharmony_ci wsa883x->sd_n = devm_gpiod_get_optional(dev, "powerdown", 138762306a36Sopenharmony_ci GPIOD_FLAGS_BIT_NONEXCLUSIVE | GPIOD_OUT_HIGH); 138862306a36Sopenharmony_ci if (IS_ERR(wsa883x->sd_n)) { 138962306a36Sopenharmony_ci ret = dev_err_probe(dev, PTR_ERR(wsa883x->sd_n), 139062306a36Sopenharmony_ci "Shutdown Control GPIO not found\n"); 139162306a36Sopenharmony_ci goto err; 139262306a36Sopenharmony_ci } 139362306a36Sopenharmony_ci 139462306a36Sopenharmony_ci dev_set_drvdata(dev, wsa883x); 139562306a36Sopenharmony_ci wsa883x->slave = pdev; 139662306a36Sopenharmony_ci wsa883x->dev = dev; 139762306a36Sopenharmony_ci wsa883x->sconfig.ch_count = 1; 139862306a36Sopenharmony_ci wsa883x->sconfig.bps = 1; 139962306a36Sopenharmony_ci wsa883x->sconfig.direction = SDW_DATA_DIR_RX; 140062306a36Sopenharmony_ci wsa883x->sconfig.type = SDW_STREAM_PDM; 140162306a36Sopenharmony_ci 140262306a36Sopenharmony_ci pdev->prop.sink_ports = GENMASK(WSA883X_MAX_SWR_PORTS, 0); 140362306a36Sopenharmony_ci pdev->prop.simple_clk_stop_capable = true; 140462306a36Sopenharmony_ci pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; 140562306a36Sopenharmony_ci pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; 140662306a36Sopenharmony_ci gpiod_direction_output(wsa883x->sd_n, 0); 140762306a36Sopenharmony_ci 140862306a36Sopenharmony_ci wsa883x->regmap = devm_regmap_init_sdw(pdev, &wsa883x_regmap_config); 140962306a36Sopenharmony_ci if (IS_ERR(wsa883x->regmap)) { 141062306a36Sopenharmony_ci gpiod_direction_output(wsa883x->sd_n, 1); 141162306a36Sopenharmony_ci ret = dev_err_probe(dev, PTR_ERR(wsa883x->regmap), 141262306a36Sopenharmony_ci "regmap_init failed\n"); 141362306a36Sopenharmony_ci goto err; 141462306a36Sopenharmony_ci } 141562306a36Sopenharmony_ci pm_runtime_set_autosuspend_delay(dev, 3000); 141662306a36Sopenharmony_ci pm_runtime_use_autosuspend(dev); 141762306a36Sopenharmony_ci pm_runtime_mark_last_busy(dev); 141862306a36Sopenharmony_ci pm_runtime_set_active(dev); 141962306a36Sopenharmony_ci pm_runtime_enable(dev); 142062306a36Sopenharmony_ci 142162306a36Sopenharmony_ci ret = devm_snd_soc_register_component(dev, 142262306a36Sopenharmony_ci &wsa883x_component_drv, 142362306a36Sopenharmony_ci wsa883x_dais, 142462306a36Sopenharmony_ci ARRAY_SIZE(wsa883x_dais)); 142562306a36Sopenharmony_cierr: 142662306a36Sopenharmony_ci if (ret) 142762306a36Sopenharmony_ci regulator_disable(wsa883x->vdd); 142862306a36Sopenharmony_ci 142962306a36Sopenharmony_ci return ret; 143062306a36Sopenharmony_ci 143162306a36Sopenharmony_ci} 143262306a36Sopenharmony_ci 143362306a36Sopenharmony_cistatic int __maybe_unused wsa883x_runtime_suspend(struct device *dev) 143462306a36Sopenharmony_ci{ 143562306a36Sopenharmony_ci struct regmap *regmap = dev_get_regmap(dev, NULL); 143662306a36Sopenharmony_ci 143762306a36Sopenharmony_ci regcache_cache_only(regmap, true); 143862306a36Sopenharmony_ci regcache_mark_dirty(regmap); 143962306a36Sopenharmony_ci 144062306a36Sopenharmony_ci return 0; 144162306a36Sopenharmony_ci} 144262306a36Sopenharmony_ci 144362306a36Sopenharmony_cistatic int __maybe_unused wsa883x_runtime_resume(struct device *dev) 144462306a36Sopenharmony_ci{ 144562306a36Sopenharmony_ci struct regmap *regmap = dev_get_regmap(dev, NULL); 144662306a36Sopenharmony_ci 144762306a36Sopenharmony_ci regcache_cache_only(regmap, false); 144862306a36Sopenharmony_ci regcache_sync(regmap); 144962306a36Sopenharmony_ci 145062306a36Sopenharmony_ci return 0; 145162306a36Sopenharmony_ci} 145262306a36Sopenharmony_ci 145362306a36Sopenharmony_cistatic const struct dev_pm_ops wsa883x_pm_ops = { 145462306a36Sopenharmony_ci SET_RUNTIME_PM_OPS(wsa883x_runtime_suspend, wsa883x_runtime_resume, NULL) 145562306a36Sopenharmony_ci}; 145662306a36Sopenharmony_ci 145762306a36Sopenharmony_cistatic const struct sdw_device_id wsa883x_swr_id[] = { 145862306a36Sopenharmony_ci SDW_SLAVE_ENTRY(0x0217, 0x0202, 0), 145962306a36Sopenharmony_ci {}, 146062306a36Sopenharmony_ci}; 146162306a36Sopenharmony_ci 146262306a36Sopenharmony_ciMODULE_DEVICE_TABLE(sdw, wsa883x_swr_id); 146362306a36Sopenharmony_ci 146462306a36Sopenharmony_cistatic struct sdw_driver wsa883x_codec_driver = { 146562306a36Sopenharmony_ci .driver = { 146662306a36Sopenharmony_ci .name = "wsa883x-codec", 146762306a36Sopenharmony_ci .pm = &wsa883x_pm_ops, 146862306a36Sopenharmony_ci .suppress_bind_attrs = true, 146962306a36Sopenharmony_ci }, 147062306a36Sopenharmony_ci .probe = wsa883x_probe, 147162306a36Sopenharmony_ci .ops = &wsa883x_slave_ops, 147262306a36Sopenharmony_ci .id_table = wsa883x_swr_id, 147362306a36Sopenharmony_ci}; 147462306a36Sopenharmony_ci 147562306a36Sopenharmony_cimodule_sdw_driver(wsa883x_codec_driver); 147662306a36Sopenharmony_ci 147762306a36Sopenharmony_ciMODULE_DESCRIPTION("WSA883x codec driver"); 147862306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 1479