From patchwork Wed Jul 31 15:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Skladowski X-Patchwork-Id: 816060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (unknown [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2355C3DA64 for ; Thu, 1 Aug 2024 12:12:30 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4680C3EDE; Thu, 1 Aug 2024 14:12:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4680C3EDE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722514343; bh=b/S9uy+bIF3wHOM/WZrlrCVkMM4isQGv528aMZ3QO/A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lkESEq4pI1wvfCEwLUHTPQ5toafMLLEU3fWqoLCfPVmDQQ0VGnAjER46/PI89XO+W LsqPUvge8h6jJdWYoSvkTIRgASidanKUSfG5HnzSW6kOUqRS2EH+oFmDHDWm5IpPpM T6ixEI5MC/KsxX0DbYciIUPk1eXWtANCBwTPMo8Q= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4A8EDF805E0; Thu, 1 Aug 2024 14:11:32 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 17CF4F805E2; Thu, 1 Aug 2024 14:11:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5AAA8F8058C; Wed, 31 Jul 2024 17:26:58 +0200 (CEST) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A414DF802DB for ; Wed, 31 Jul 2024 17:26:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A414DF802DB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=l8CbVqu3 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4280b3a7efaso38996975e9.0 for ; Wed, 31 Jul 2024 08:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722439568; x=1723044368; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sURZDxH5XdiCOHMBbcEMdZ8vmUSUFBsPH3V2odo9HSw=; b=l8CbVqu39V3V93LiqQy9XnA5SXzIzp+EGVTEs5P+cpAxfkbOVC3oRTP9FJC3SgZnZE 5U7xSL1j07d7BhOmRr1lsuuI40RqGpBOU+Wja48Hi9sm9NkU4BHMY9ctjPfzjUQR6/r9 sGLsbwdWKULeknDO0ykhYRTUVl2/iKs+f357HKTgFTosM3K7NQCBwEGUZeEt+byrIDf/ PO4Bh6uRPtBqR8L8fFdrotr+lzQ0bTOKRipuyn/x28vuKWS9g3Dk8DNudJJXHs59pQ2v EjyjdbcML/cnBJlGl+EBD6/zsf+z0zLjXxmKBursofK9j4mC/9m1xMa6WeAHZGlX04f6 0mSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722439568; x=1723044368; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sURZDxH5XdiCOHMBbcEMdZ8vmUSUFBsPH3V2odo9HSw=; b=igDEk5fOXOF0P4dTcdWKFO2rWvBw6mPAehVkphTq6e9L6byGbl/2F80uT5OcR7yo98 7o4DpolLbWAi1cEMR+7FIYlhadz/Wcu21m9eOdVvTsf/gy761UA9pLC+TGg198r/gRkw toR8gWyT7JDDwT4Mkd8DRO2IZ1Pr8HaolPHS/Z5n6cSxaBPiTuz/YEiM2LxlxkMJUsey 8tbwoYXNSn0M2JgrtpG5WtdaaNX2yMY+GVtJjx7byhmngCBbdV0adrXjm0GThYnnko65 adeWn2tN+FD2yEql87KeVCZ0VN5juNiY8tcEDMCfDDouSL8bu8RUMCcPEx6V9BPmKxUD cl5g== X-Gm-Message-State: AOJu0YygXEtqf3F0xfnj5HypWBq+/hscv5NyUeg0yD/JKpL1aQqwHmJ1 EBOCyl05rOfuLriitGfwKvSDYDiLXE++gT0AA2QKyr6+hZQWBxrM X-Google-Smtp-Source: AGHT+IG1H5Bp8jT30iBFVbiEisWLixnQb+cAxq4bxDj2j3vvk6Vqxm5kMpTGRf+D6NJonYzOXpNGuw== X-Received: by 2002:a05:600c:190b:b0:428:1846:4f0 with SMTP id 5b1f17b1804b1-428184606e9mr83560415e9.16.1722439567835; Wed, 31 Jul 2024 08:26:07 -0700 (PDT) Received: from [127.0.1.1] (byv161.neoplus.adsl.tpnet.pl. [83.30.41.161]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4282bb64755sm25430985e9.36.2024.07.31.08.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 08:26:07 -0700 (PDT) From: Adam Skladowski Date: Wed, 31 Jul 2024 17:25:27 +0200 Subject: [PATCH v3 3/8] ASoC: msm8916-wcd-analog: add pm8950 codec MIME-Version: 1.0 Message-Id: <20240731-msm8953-msm8976-asoc-v3-3-163f23c3a28d@gmail.com> References: <20240731-msm8953-msm8976-asoc-v3-0-163f23c3a28d@gmail.com> In-Reply-To: <20240731-msm8953-msm8976-asoc-v3-0-163f23c3a28d@gmail.com> To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Stephan Gerhold Cc: alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Adam Skladowski X-Mailer: b4 0.14.0 X-MailFrom: a39.skl@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: EBIPLUKZIZ7REJXXJ4HIS3WAZ2UFXGOY X-Message-ID-Hash: EBIPLUKZIZ7REJXXJ4HIS3WAZ2UFXGOY X-Mailman-Approved-At: Thu, 01 Aug 2024 12:06:30 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add regs overrides for PM8950 codec and implement matching reg overrides via compatible. Signed-off-by: Adam Skladowski Reviewed-by: Dmitry Baryshkov --- sound/soc/codecs/msm8916-wcd-analog.c | 52 ++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 9ca381812975..13df60409857 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -232,6 +232,8 @@ #define RX_EAR_CTL_PA_SEL_MASK BIT(7) #define RX_EAR_CTL_PA_SEL BIT(7) +#define CDC_A_RX_EAR_STATUS (0xf1A1) + #define CDC_A_SPKR_DAC_CTL (0xf1B0) #define SPKR_DAC_CTL_DAC_RESET_MASK BIT(4) #define SPKR_DAC_CTL_DAC_RESET_NORMAL 0 @@ -250,6 +252,7 @@ SPKR_DRV_CAL_EN | SPKR_DRV_SETTLE_EN | \ SPKR_DRV_FW_EN | SPKR_DRV_BOOST_SET | \ SPKR_DRV_CMFB_SET | SPKR_DRV_GAIN_SET) +#define CDC_A_SPKR_ANA_BIAS_SET (0xf1B3) #define CDC_A_SPKR_OCP_CTL (0xf1B4) #define CDC_A_SPKR_PWRSTG_CTL (0xf1B5) #define SPKR_PWRSTG_CTL_DAC_EN_MASK BIT(0) @@ -264,6 +267,7 @@ #define CDC_A_SPKR_DRV_DBG (0xf1B7) #define CDC_A_CURRENT_LIMIT (0xf1C0) +#define CDC_A_BYPASS_MODE (0xf1C2) #define CDC_A_BOOST_EN_CTL (0xf1C3) #define CDC_A_SLOPE_COMP_IP_ZERO (0xf1C4) #define CDC_A_SEC_ACCESS (0xf1D0) @@ -286,6 +290,11 @@ static const char * const supply_names[] = { #define MBHC_MAX_BUTTONS (5) +struct wcd_reg_seq { + const struct reg_default *seq; + int seq_size; +}; + struct pm8916_wcd_analog_priv { u16 pmic_rev; u16 codec_version; @@ -715,9 +724,41 @@ static const struct reg_default wcd_reg_defaults_2_0[] = { {CDC_A_MASTER_BIAS_CTL, 0x30}, }; +static const struct wcd_reg_seq pm8916_data = { + .seq = wcd_reg_defaults_2_0, + .seq_size = ARRAY_SIZE(wcd_reg_defaults_2_0), +}; + +static const struct reg_default wcd_reg_defaults_pm8950[] = { + {CDC_A_RX_COM_OCP_CTL, 0xd1}, + {CDC_A_RX_COM_OCP_COUNT, 0xff}, + {CDC_D_SEC_ACCESS, 0xa5}, + {CDC_D_PERPH_RESET_CTL3, 0x0f}, + {CDC_A_TX_1_2_OPAMP_BIAS, 0x4c}, + {CDC_A_NCP_FBCTRL, 0xa8}, + {CDC_A_NCP_VCTRL, 0xa4}, + {CDC_A_SPKR_DRV_CTL, 0x69}, + {CDC_A_SPKR_DRV_DBG, 0x01}, + {CDC_A_SEC_ACCESS, 0xa5}, + {CDC_A_PERPH_RESET_CTL3, 0x0f}, + {CDC_A_CURRENT_LIMIT, 0x82}, + {CDC_A_SPKR_ANA_BIAS_SET, 0x41}, + {CDC_A_SPKR_DAC_CTL, 0x03}, + {CDC_A_SPKR_OCP_CTL, 0xe1}, + {CDC_A_RX_HPH_BIAS_PA, 0xfa}, + {CDC_A_MASTER_BIAS_CTL, 0x30}, + {CDC_A_MICB_1_INT_RBIAS, 0x00}, +}; + +static const struct wcd_reg_seq pm8950_data = { + .seq = wcd_reg_defaults_pm8950, + .seq_size = ARRAY_SIZE(wcd_reg_defaults_pm8950), +}; + static int pm8916_wcd_analog_probe(struct snd_soc_component *component) { struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev); + const struct wcd_reg_seq *wcd_reg_init_data; int err, reg; err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); @@ -738,9 +779,11 @@ static int pm8916_wcd_analog_probe(struct snd_soc_component *component) snd_soc_component_write(component, CDC_D_PERPH_RESET_CTL4, 0x01); snd_soc_component_write(component, CDC_A_PERPH_RESET_CTL4, 0x01); - for (reg = 0; reg < ARRAY_SIZE(wcd_reg_defaults_2_0); reg++) - snd_soc_component_write(component, wcd_reg_defaults_2_0[reg].reg, - wcd_reg_defaults_2_0[reg].def); + wcd_reg_init_data = of_device_get_match_data(component->dev); + + for (reg = 0; reg < wcd_reg_init_data->seq_size; reg++) + snd_soc_component_write(component, wcd_reg_init_data->seq[reg].reg, + wcd_reg_init_data->seq[reg].def); priv->component = component; @@ -1259,7 +1302,8 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev) } static const struct of_device_id pm8916_wcd_analog_spmi_match_table[] = { - { .compatible = "qcom,pm8916-wcd-analog-codec", }, + { .compatible = "qcom,pm8916-wcd-analog-codec", .data = &pm8916_data }, + { .compatible = "qcom,pm8950-wcd-analog-codec", .data = &pm8950_data }, { } };