From patchwork Fri May 10 17:58:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 796241 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 (alsa0.perex.cz [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 7ABAAC25B75 for ; Fri, 10 May 2024 18:01:12 +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 2C454DF8; Fri, 10 May 2024 20:01:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2C454DF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1715364070; bh=pnDcDTmwduPk+3gSuJLvXtZneABMTN2FxzqqHxNrUd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WOgEV7aui12tj8qiLCpvEOiH3oPpAIzdLsIt/Emr9drD6QWNt/N0mmnZezuudyY8c tTQcdMMdpulB+2cRpW5072sYTKMFTx7QAGitQtiKSXqzlZMXg30FZOBjLj44xCdXMf mrZchlaNTrgdtuUqlpaJOUvIQuSIKrelUyxU+Ed0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F2E78F80578; Fri, 10 May 2024 20:00:38 +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 645CEF8057A; Fri, 10 May 2024 20:00:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 04D41F8049C; Fri, 10 May 2024 19:58:42 +0200 (CEST) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 3C756F800E2 for ; Fri, 10 May 2024 19:58:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3C756F800E2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=TUG3cgMO Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-41fc2f7fbb5so12271805e9.1 for ; Fri, 10 May 2024 10:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715363919; x=1715968719; darn=alsa-project.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=chW8k3/UFKxLYywJHYuhDfax5Lmwls70ctPbfNY8aTk=; b=TUG3cgMOmzPzv4WeBD05xCVA6eVtSs7FHM4nzVhSlArk6CWyUYJUTGmCEo4hv2XExj olcChUKxOYxtOYKodQEG2Q4bCY2Xgu0R2k8keRvPjkp+R3Mz5cF5vqgdE90vUUGbLPM9 XS+1lu2zmyXVFfxnWIBD+NDqn5BQc4nrN+u4D0yf4pGcMtRclmhC5VTw4pPjgNTT3wIl ja85cu/TDLW/hMxM9Bx8+UvUZS/fV3BcBOSlS4xrIda9Y2gJsWZtaQMXBYul+7t+W+mn V4YSOAi5X+UuEZc2GgaTMLxwH8N0vWE9XkywZbjIiDiI6qFB8bCujeekXr2RdRuzvmkZ javA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715363919; x=1715968719; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=chW8k3/UFKxLYywJHYuhDfax5Lmwls70ctPbfNY8aTk=; b=aKiqO31k9gG4KNE4UJpi5OWn5x/Q/yNPSKNmawQqv6bA42cySdOKTyVWL///zZleHO osQozhFOzl3H7KcQ5yXe3KLLmDipolEk9txUQFd033ALSkDOSDKUsuM0JZjl97ElWgh+ qvTc9jlPiAb3b1ZTpAmtBB/1hiq642zwxCGRy8+dpNH31Xfomt+OxJvdVFyjWk5Nm8SD 84ZZY99inbdHUeSc6cZwwm+EaUm0esh1KuiqQCD7NN9nVNA5FWJ7NNawYtUDXanLTWem dC2bTOVygDU8Zc88RI4HGFAMwMysdGA5Z5amVH7d5ci5l2ikBtCn8EHz461unZ/yJXM1 nOZQ== X-Forwarded-Encrypted: i=1; AJvYcCVhxG1k83EwRpXafOshBIdKRn8K2TWK3JWG1TfcDKCmZfBSg+L7g0nQLKgyCcmVANYifWWoM2iyd57q5tbO7SmYz1zYSSVn830TLUA= X-Gm-Message-State: AOJu0Yx4AUYeg4iZBoryJULVz4AT3AAkO/ZgGxNEgc39d/O4GBgLtZnG lntqoN4KJ/eJA28m82P/rYr77jGGTZOV2L4HKacojF2bUMgqLNFuyfzOFuInKmQ= X-Google-Smtp-Source: AGHT+IGE6bbbjDSU3mmoZE2LM1xADxiiNXknFfC0dYuVXQiruME24SMVBRxrz9HhVsBKYYWngC7qYg== X-Received: by 2002:a05:600c:3b04:b0:418:f5a:580b with SMTP id 5b1f17b1804b1-41fbcfb8113mr57250545e9.18.1715363919122; Fri, 10 May 2024 10:58:39 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4200a8e6846sm11046755e9.15.2024.05.10.10.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 10:58:38 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, krzysztof.kozlowski@linaro.org, neil.armstrong@linaro.org, Srinivas Kandagatla Subject: [PATCH 1/2] ASoC: codecs: lpass-macro: add helpers to get codec version Date: Fri, 10 May 2024 18:58:34 +0100 Message-Id: <20240510175835.286775-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240510175835.286775-1-srinivas.kandagatla@linaro.org> References: <20240510175835.286775-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: LLQOPHLBP3GSSLY4GDML6VGQBXXG6GZ2 X-Message-ID-Hash: LLQOPHLBP3GSSLY4GDML6VGQBXXG6GZ2 X-MailFrom: srinivas.kandagatla@linaro.org 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; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header 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: From: Srinivas Kandagatla LPASS Digital codec have changes in register layout across multiple versions. Add a proper way read the codec version allowint all the lpass macro drivers (tx, rx, wsa, va) to configure the registers correctly. LPASS VA macro has the required registers to read the codec version. Read the the version and make it available to other lpass codec macros using the common helper functions. Existing method of using LPASS IP version is not accurate as the same the codec versioning is totally independent of LPASS IP block versions. These helper functions should be able to provide a convient way to get the codec version, and will help scale the drivers in right direction. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-macro-common.c | 14 +++++++++++ sound/soc/codecs/lpass-macro-common.h | 35 +++++++++++++++++++++++++++ sound/soc/codecs/lpass-va-macro.c | 29 ++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/sound/soc/codecs/lpass-macro-common.c b/sound/soc/codecs/lpass-macro-common.c index da1b422250b8..a640bf88a6cd 100644 --- a/sound/soc/codecs/lpass-macro-common.c +++ b/sound/soc/codecs/lpass-macro-common.c @@ -11,6 +11,8 @@ #include "lpass-macro-common.h" +static int lpass_codec_version; + struct lpass_macro *lpass_macro_pds_init(struct device *dev) { struct lpass_macro *l_pds; @@ -66,5 +68,17 @@ void lpass_macro_pds_exit(struct lpass_macro *pds) } EXPORT_SYMBOL_GPL(lpass_macro_pds_exit); +void lpass_macro_set_codec_version(int version) +{ + lpass_codec_version = version; +} +EXPORT_SYMBOL_GPL(lpass_macro_set_codec_version); + +int lpass_macro_get_codec_version(void) +{ + return lpass_codec_version; +} +EXPORT_SYMBOL_GPL(lpass_macro_get_codec_version); + MODULE_DESCRIPTION("Common macro driver"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/lpass-macro-common.h b/sound/soc/codecs/lpass-macro-common.h index d98718b3dc4b..f6f1bfe8eb77 100644 --- a/sound/soc/codecs/lpass-macro-common.h +++ b/sound/soc/codecs/lpass-macro-common.h @@ -18,6 +18,18 @@ enum lpass_version { LPASS_VER_11_0_0, }; +enum lpass_codec_version { + LPASS_CODEC_VERSION_1_0 = 1, + LPASS_CODEC_VERSION_1_1, + LPASS_CODEC_VERSION_1_2, + LPASS_CODEC_VERSION_2_0, + LPASS_CODEC_VERSION_2_1, + LPASS_CODEC_VERSION_2_5, + LPASS_CODEC_VERSION_2_6, + LPASS_CODEC_VERSION_2_7, + LPASS_CODEC_VERSION_2_8, +}; + struct lpass_macro { struct device *macro_pd; struct device *dcodec_pd; @@ -25,5 +37,28 @@ struct lpass_macro { struct lpass_macro *lpass_macro_pds_init(struct device *dev); void lpass_macro_pds_exit(struct lpass_macro *pds); +void lpass_macro_set_codec_version(int version); +int lpass_macro_get_codec_version(void); + +static inline const char *lpass_macro_get_codec_version_string(int version) +{ + switch (version) { + case LPASS_CODEC_VERSION_2_0: + return "v2.0"; + case LPASS_CODEC_VERSION_2_1: + return "v2.1"; + case LPASS_CODEC_VERSION_2_5: + return "v2.5"; + case LPASS_CODEC_VERSION_2_6: + return "v2.6"; + case LPASS_CODEC_VERSION_2_7: + return "v2.7"; + case LPASS_CODEC_VERSION_2_8: + return "v2.8"; + default: + break; + } + return "NA"; +} #endif /* __LPASS_MACRO_COMMON_H__ */ diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c index db6272ee2df5..a94a1d93c19d 100644 --- a/sound/soc/codecs/lpass-va-macro.c +++ b/sound/soc/codecs/lpass-va-macro.c @@ -1462,6 +1462,33 @@ static int va_macro_validate_dmic_sample_rate(u32 dmic_sample_rate, return dmic_sample_rate; } +static void va_macro_set_lpass_codec_version(struct va_macro *va) +{ + int core_id_0 = 0, core_id_1 = 0, core_id_2 = 0, version; + + regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_0, &core_id_0); + regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_1, &core_id_1); + regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_2, &core_id_2); + + if ((core_id_0 == 0x01) && (core_id_1 == 0x0F)) + version = LPASS_CODEC_VERSION_2_0; + if ((core_id_0 == 0x02) && (core_id_1 == 0x0E)) + version = LPASS_CODEC_VERSION_2_1; + if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x50 || core_id_2 == 0x51)) + version = LPASS_CODEC_VERSION_2_5; + if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x60 || core_id_2 == 0x61)) + version = LPASS_CODEC_VERSION_2_6; + if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x70 || core_id_2 == 0x71)) + version = LPASS_CODEC_VERSION_2_7; + if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x80 || core_id_2 == 0x81)) + version = LPASS_CODEC_VERSION_2_8; + + lpass_macro_set_codec_version(version); + + dev_info(va->dev, "LPASS Codec Version %s\n", + lpass_macro_get_codec_version_string(version)); +} + static int va_macro_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1555,6 +1582,8 @@ static int va_macro_probe(struct platform_device *pdev) goto err_npl; } + va_macro_set_lpass_codec_version(va); + if (va->has_swr_master) { /* Set default CLK div to 1 */ regmap_update_bits(va->regmap, CDC_VA_TOP_CSR_SWR_MIC_CTL0,