Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp583170lqp; Wed, 12 Jun 2024 09:58:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV80zfp+u18MtUFxZOTINGKacc5m5OVvsTHIUtbCqE05zZxE1O8jsfAlq73hQq1zScHzZYVKHiKS2e60Byu59Q+RKEpwwaZTHolpO42iA== X-Google-Smtp-Source: AGHT+IG++9YaU66BOYS+OSE7+zblWO1XHvDWO7f53K1oPY7cBe6Qf3q2cJLDDN+HreA5rHjZlxw9 X-Received: by 2002:a05:6214:5b0c:b0:6ae:2a6b:de8d with SMTP id 6a1803df08f44-6b1a7eb2272mr23351106d6.64.1718211486607; Wed, 12 Jun 2024 09:58:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718211486; cv=pass; d=google.com; s=arc-20160816; b=wvUfEKyEMaD5cI9iFLC/iNvoppOszK30t10mNh9ulVC6zDsfFC0zpty0SRidZyXFQe k/OV2CmuL22/srBJGByd8DyCJbbYYE/NH2DzC0im3MeFexzlpKXNXK9I1EhhyGlRGGYk 8NWAryAUiOovtsSJkNK6EuTiuUvcevpWzcT34q6brSF49D7fiIVNjdA+Wjfc/kQk18x3 TY63GYgkK/1a+MFhTYE/Fh/WiBR+uhBh0oY8Zpq+ddOLVhSZPgCpOdunjRUwNUUTiX0Y izW5zxukfHiFAX1EFRC2PfVoQcTwkrikJW/XV5xcWNO+HSRiKoIJYtZj4yMK1UeFMKsA e4aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=R2VscKvagWv42zk0rH8fHiJS5R2BnPnKyuPT4PU71oU=; fh=yejfcUdkv5bHaeGI7DTAvjLE+EzlUkSNXrD1rMpXVoQ=; b=ObcCnRo7ejRvIX1BxSt+MXC/IMvs6q7FCTBPCRNZBWPsY15lFzG4M7/Lces7x8OwJr Qg83w7Dfyp/10Jj9Dq33wHNpJmiqMJ2xNV6e1Ae1J9ZG76/MgvQQOvHpv4o7RJEArU1f 6O2wSTNRJGkJluEIBpoDki/KYPX3caXu3fRHDdeoxKcLvHUCGB5JX+m8esPQ1RPk9fQ1 RFrEmeodxX1Y9BjgfTlX7wcPNvt8cweOWAaAu7+GBN6OKr+0VtIi6r+lMK4XdQG9qzSK dTYC3byOvg+4gS3cxM7k4MjjTfoRqvveQF88yhzL5pSvlKiIZt3vOVW7LWHniMQficLE De7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w66GMBTi; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-211948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211948-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b0922845bfsi31204556d6.301.2024.06.12.09.58.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 09:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w66GMBTi; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-211948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211948-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 465601C2122F for ; Wed, 12 Jun 2024 16:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 495181822E4; Wed, 12 Jun 2024 16:57:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="w66GMBTi" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 655551822CA for ; Wed, 12 Jun 2024 16:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718211464; cv=none; b=J8NhJ1GL5lPCsST97Gmn6pUegGyOU2J1Yq0jQm9Fs6BDaiQUU66ZdAyOpvs+B5VcTdoEst5NTrOwDlPzkpKbZSuo2QDhLxvyUdKlUCtWw6G8wVgQcFUw82SrgLUshJctpQrEAGuNqIYuHjBgNGzH+Hy2jr7/gVdPwDPiqPYfh28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718211464; c=relaxed/simple; bh=QS7ScGSvChG6xp5GTpKBp7tDBC6NTj2IN1ffDCw9zis=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cEWWPKA8vtY+xo3eVLGebj5YBZy6qwej9uQmLDl09OfjVRS+w/+3HIYb4nVyPxF0cgR0076PLDJGtIKagRIa5GO0K7zcPrkcJQM0tSc831MDv040tT36Q2/WU+pdq+mnVnVI45NsIV0/d/OXD6ZkNKUrT8486u2onSLaMz8v5OI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=w66GMBTi; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-57a44c2ce80so3323310a12.0 for ; Wed, 12 Jun 2024 09:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718211461; x=1718816261; darn=vger.kernel.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=R2VscKvagWv42zk0rH8fHiJS5R2BnPnKyuPT4PU71oU=; b=w66GMBTiIYuIDfgPKTHcum3wACTdPXqf3w2VjA3iLAJ4eirOHseKYynyMxNHgfoYl5 eXXyZykW6sq0FQQlUJL4FuGYa9bu8lVaIp6KMSQvrVy7Ngiqn6uKg1vWvzLcTv8pvnNP Rhr27Vu027ke89qQ0VzByWDx7s9syTsqyEIkFDbVR1+0vZ0NHu83n8/LIR7N6RgLgW7A h3aeagMKP6T1M0bpjlAVwK0bhJHuqQJEciV0h55VE0uTBRVJckcppRTWHzXU0u1+7g/y 7f/CdSLTpbx1KUAaJDIKTV8dhdHECvFeqeLfKkKv39qgQoxKCAXoAUBgisQWctLnYzyY pvEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718211461; x=1718816261; 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=R2VscKvagWv42zk0rH8fHiJS5R2BnPnKyuPT4PU71oU=; b=cFPuSEVRD/NkNqewK0mScMAx01GuBmAAkBWk/X3sZSlk9bChqFILlSWoCmPXzqXKmy 0XBpmleG0Wo8onHybM4MDLjRukqbcRJe7BP5M7JqOUtC0Ej6jl32+qvJ0X1E2uTH7b2I U1V5BdTBmH3TBJk/kRfwOvq+JqvH1yhJIn9nCN1GQI7PALS4cNsefBbPW9cp8LJ3xrii OyAxzX2P/TEKMQ6CNyj6eQe28i9KzSGpF2tWx01t6OqdDDdH/ymLB1wpTPQkTVFiGPWC RU8bWhJgrNLoDhdvvzMZZ8kD1JrNyv1L+EWo7hu3FhyYcv0C0hxc4HQAdMLn5jV2Rn7S 9oGg== X-Forwarded-Encrypted: i=1; AJvYcCW8wMR3lZpAKUQ4LkhnOJbM7PwySwgfBjG2qLmNrs7+WDO+aG9SGyc57eENrKT6k1b+vRg3DTHTzLkWE0IJGuOcalqKcNNkT9FAX66n X-Gm-Message-State: AOJu0Yy9Yw1BSJyR+8IBuKXYTOmCl0NcGXB7Ckah+UdEeEVMMZk2JIvE yAtxjPYFIQsrF7v+9m16K3zFHWd5rVimiFc8I1CnUcJs/Dq1pmkgtxxsjkEuMIt3gBye9SChc+d 5fqE= X-Received: by 2002:a50:9308:0:b0:57c:947c:f9cf with SMTP id 4fb4d7f45d1cf-57ca975348cmr1464177a12.11.1718211460623; Wed, 12 Jun 2024 09:57:40 -0700 (PDT) Received: from [192.168.1.195] ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57ca8caed84sm1564048a12.43.2024.06.12.09.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 09:57:39 -0700 (PDT) From: Srinivas Kandagatla Date: Wed, 12 Jun 2024 17:57:21 +0100 Subject: [PATCH v3 1/3] ASoC: codecs: lpass-macro: add helpers to get codec version Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240612-lpass-codec-v25-v1-1-9f40611a1370@linaro.org> References: <20240612-lpass-codec-v25-v1-0-9f40611a1370@linaro.org> In-Reply-To: <20240612-lpass-codec-v25-v1-0-9f40611a1370@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Banajit Goswami Cc: neil.armstrong@linaro.org, linux-arm-msm@vger.kernel.org, krzysztof.kozlowski@linaro.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5501; i=srinivas.kandagatla@linaro.org; h=from:subject:message-id; bh=QS7ScGSvChG6xp5GTpKBp7tDBC6NTj2IN1ffDCw9zis=; b=owEBbQGS/pANAwAKAXqh/VnHNFU3AcsmYgBmadOCpFW8pCZXDP3+balgrD4sCE41Hm01FCb6R YVwEt0s1/eJATMEAAEKAB0WIQQi509axvzi9vce3Y16of1ZxzRVNwUCZmnTggAKCRB6of1ZxzRV N6i9CACT/QlUOPB5omYnZ6qstzzmu6b25APVOmiYf+JCWDUIxwQ1FQlxpvwCljpgqCEyDZNZ9KY cd65GUmNVF6q/5hnX8IDu6J+OIXEEwIOQ1QQPS7hGPPd+mrEQeKrm9GD0EajMrkpyfRz3DeE+0s tgTdnOejrCM7VbgN3RqvnHnMVBlS/4kvZw/Id+z0X2rB86Jzg0JjRDNM1SGhsR+1GkRh17bUAlQ vuZUh8tn+pKbLWKWKJpV5V5y6QHgb+MtDkstVcpgvPyA2gnuKzFhie1sBgmxQrMkTEm85uw3Ecu VEVFPhyMAxkiPgLAXlhY/eGVIyDHeyCiuNpBhSvkIKPqvWYL X-Developer-Key: i=srinivas.kandagatla@linaro.org; a=openpgp; fpr=ED6472765AB36EC43B3EF97AD77E3FC0562560D6 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 | 23 +++++++++++++++++++++++ sound/soc/codecs/lpass-macro-common.h | 35 +++++++++++++++++++++++++++++++++++ sound/soc/codecs/lpass-va-macro.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/sound/soc/codecs/lpass-macro-common.c b/sound/soc/codecs/lpass-macro-common.c index da1b422250b8..8b038a99a8f9 100644 --- a/sound/soc/codecs/lpass-macro-common.c +++ b/sound/soc/codecs/lpass-macro-common.c @@ -11,6 +11,9 @@ #include "lpass-macro-common.h" +static DEFINE_MUTEX(lpass_codec_mutex); +static int lpass_codec_version; + struct lpass_macro *lpass_macro_pds_init(struct device *dev) { struct lpass_macro *l_pds; @@ -66,5 +69,25 @@ void lpass_macro_pds_exit(struct lpass_macro *pds) } EXPORT_SYMBOL_GPL(lpass_macro_pds_exit); +void lpass_macro_set_codec_version(int version) +{ + mutex_lock(&lpass_codec_mutex); + lpass_codec_version = version; + mutex_unlock(&lpass_codec_mutex); +} +EXPORT_SYMBOL_GPL(lpass_macro_set_codec_version); + +int lpass_macro_get_codec_version(void) +{ + int ver; + + mutex_lock(&lpass_codec_mutex); + ver = lpass_codec_version; + mutex_unlock(&lpass_codec_mutex); + + return ver; +} +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 6eceeff10bf6..0ae9e6377e3a 100644 --- a/sound/soc/codecs/lpass-va-macro.c +++ b/sound/soc/codecs/lpass-va-macro.c @@ -1461,6 +1461,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; @@ -1554,6 +1581,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, -- 2.25.1