From patchwork Thu Jun 30 15:01:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 586889 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 D4182C43334 for ; Thu, 30 Jun 2022 15:03:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 16BBF16BF; Thu, 30 Jun 2022 17:02:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 16BBF16BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1656601395; bh=3Gw8mNBaMVaHjZFQT4QI2XXL9OzIW3W+zawyP1YjZDY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RyXsTKMBGM5slU15DAza4a4s9c8YrxYp2od+Seil5ewAuBn5D1jYbsxfP8oaxVDKg eGkkaMpD4JH1myYn0v6j5pe2m82XIpSEk6ooxQGLN3yiB3FxGujIzYBWb6FNj1ZjnB zCe88tkTD0voMo3uKuOCjNTNf47IwC5H/E2hL5rk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9234FF800F5; Thu, 30 Jun 2022 17:01:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3C3CEF80107; Thu, 30 Jun 2022 17:01:55 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6489DF80107 for ; Thu, 30 Jun 2022 17:01:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6489DF80107 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="gFn8y3W0" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25UDjbTf004680; Thu, 30 Jun 2022 10:01:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=o9h3Q2NuFGYiveug+sv1cJnnsi9uUYbi5OiOlMr7DjE=; b=gFn8y3W0M3iFDzL2JcgRxbGQkqs9I2a9CqGkoLsBPspRMZEKbI4wI4c8ZH/yPILgSzkG vhkFybQCemeCqiNcqDQTzfEOSoN4oKet2M0Xk0lTU5f1EIx7LplfDwSTh92z0yGkXnMm GmdPO8+C9SrMD++D0kaJYxcLuDGs7PhTiZDEF8DGI4BE7rIZctBe64B1NHaHV1aEfBj+ B0MqjjBJDwpPgpQHjrmgIsnjrgYANOceUH0vgEAGo2BBtVjxpXiwO1VUCu5zS/l3V7O+ NSwbc2jVChECdpF2kXR+tNWM0AuQ0yt2Xg3aLFzk0sKNYkQh0HyU2/BTC101LN0LdOzH tg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3gwxsq6r1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 30 Jun 2022 10:01:42 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 30 Jun 2022 16:01:40 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.28 via Frontend Transport; Thu, 30 Jun 2022 16:01:40 +0100 Received: from sbinding-cirrus-dsktp.ad.cirrus.com (unknown [198.90.238.163]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 336BB2D4; Thu, 30 Jun 2022 15:01:40 +0000 (UTC) From: Stefan Binding To: "Rafael J . Wysocki" , Len Brown , Mark Brown , Liam Girdwood Subject: [PATCH v5 1/2] ACPI: utils: Add api to read _SUB from ACPI Date: Thu, 30 Jun 2022 16:01:34 +0100 Message-ID: <20220630150135.1799535-2-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220630150135.1799535-1-sbinding@opensource.cirrus.com> References: <20220630150135.1799535-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: hOXpgJi2F5kzzZg_5sT1pWmu-NyWAcLI X-Proofpoint-ORIG-GUID: hOXpgJi2F5kzzZg_5sT1pWmu-NyWAcLI X-Proofpoint-Spam-Reason: safe Cc: linux-acpi@vger.kernel.org, alsa-devel@alsa-project.org, Stefan Binding , linux-kernel@vger.kernel.org, patches@opensource.cirrus.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add a wrapper function to read the _SUB string from ACPI. Signed-off-by: Stefan Binding --- drivers/acpi/utils.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 6 ++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 3a9773a09e19..394954f4b6ef 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -291,6 +291,44 @@ int acpi_get_local_address(acpi_handle handle, u32 *addr) } EXPORT_SYMBOL(acpi_get_local_address); +#define ACPI_MAX_SUB_BUF_SIZE 9 + +const char *acpi_get_subsystem_id(acpi_handle handle) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; + acpi_status status; + const char *sub; + + status = acpi_evaluate_object(handle, METHOD_NAME__SUB, NULL, &buffer); + if (ACPI_FAILURE(status)) { + acpi_handle_debug(handle, "Reading ACPI _SUB failed: %#x\n", status); + return ERR_PTR(-ENODATA); + } + + obj = buffer.pointer; + if (obj->type == ACPI_TYPE_STRING) { + if (strlen(obj->string.pointer) < ACPI_MAX_SUB_BUF_SIZE && + strlen(obj->string.pointer) > 0) { + sub = kstrdup(obj->string.pointer, GFP_KERNEL); + if (!sub) + sub = ERR_PTR(-ENOMEM); + } else { + acpi_handle_err(handle, "ACPI _SUB Length %zu is Invalid\n", + strlen(obj->string.pointer)); + sub = ERR_PTR(-EINVAL); + } + } else { + acpi_handle_warn(handle, "Warning ACPI _SUB did not return a string\n"); + sub = ERR_PTR(-EINVAL); + } + + acpi_os_free(buffer.pointer); + + return sub; +} +EXPORT_SYMBOL_GPL(acpi_get_subsystem_id); + acpi_status acpi_evaluate_reference(acpi_handle handle, acpi_string pathname, diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 7b96a8bff6d2..7651198ad6f5 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -762,6 +762,7 @@ static inline u64 acpi_arch_get_root_pointer(void) #endif int acpi_get_local_address(acpi_handle handle, u32 *addr); +const char *acpi_get_subsystem_id(acpi_handle handle); #else /* !CONFIG_ACPI */ @@ -1023,6 +1024,11 @@ static inline int acpi_get_local_address(acpi_handle handle, u32 *addr) return -ENODEV; } +static inline const char *acpi_get_subsystem_id(acpi_handle handle) +{ + return ERR_PTR(-ENODEV); +} + static inline int acpi_register_wakeup_handler(int wake_irq, bool (*wakeup)(void *context), void *context) { From patchwork Thu Jun 30 15:01:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 586100 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 DD97CC43334 for ; Thu, 30 Jun 2022 15:03:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 21DA316CE; Thu, 30 Jun 2022 17:02:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 21DA316CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1656601416; bh=3xQ9CzBni7zi0kyyPevXPmZUYoaZ+stOD6vT8qfsc5E=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=COH2TphBDI5JU1VbtSMAv1DUsu8rcgj4oz4HM8FIBbaitSay9RPjx3ZYcgfTrOqcu o7lnIyCGOL9GUfxTiUC3ZjOvLhU2X9YrEPNhRvFE/suuxEgP3mh0exfFLtbg9/z8UU pQkcK4Ahk1CNTdBk3+Bi+BafZb/CtWOvsfCjlxhA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 19F99F8052E; Thu, 30 Jun 2022 17:02:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 05C37F804D8; Thu, 30 Jun 2022 17:01:58 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E26A4F804D2 for ; Thu, 30 Jun 2022 17:01:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E26A4F804D2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="gUNhs2ml" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25UDjbTg004680; Thu, 30 Jun 2022 10:01:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=eUFIBn32/4AE0bsYFNoFa6geYFLK7LX9E8EbxcjuROM=; b=gUNhs2mlhL4ytGX8rMIJQE3oLliDfmTJz8G47Jc/dQst+dPOXUQcgFHlsv5amtXZZChQ er0FjRpxjbFQZvfS9A5HcIXXr8ZnxbzFJrrcqQXfVw+hnDsupasXqvjfhdUbxepA7BB9 7FdAFV/aELM+l01aa0eiXHWIoO7J0na4z7FJe6HfztkcL3JKjstZWqSUvEmPX/smRbNi Az2oXQMohLD1AlDiqsd3PCymE32ybudu0oYE9852NoOy7fiiiDj0Ikj1EsaE3HR9jbdo mn/DE671N/3fBEXf4rhXewSFhobr++IsfkiTXOh1Vj+EgK/6Tm/xhDBy7wfH57AUFk08 TQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3gwxsq6r1h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 30 Jun 2022 10:01:43 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 30 Jun 2022 16:01:40 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.28 via Frontend Transport; Thu, 30 Jun 2022 16:01:40 +0100 Received: from sbinding-cirrus-dsktp.ad.cirrus.com (unknown [198.90.238.163]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 7A07B46A; Thu, 30 Jun 2022 15:01:40 +0000 (UTC) From: Stefan Binding To: "Rafael J . Wysocki" , Len Brown , Mark Brown , Liam Girdwood Subject: [PATCH v5 2/2] ASoC: cs35l41: Read System Name from ACPI _SUB to identify firmware Date: Thu, 30 Jun 2022 16:01:35 +0100 Message-ID: <20220630150135.1799535-3-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220630150135.1799535-1-sbinding@opensource.cirrus.com> References: <20220630150135.1799535-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: qaqZULxm7vhwt3r8Iyd-SJXD7cQ_FbdH X-Proofpoint-ORIG-GUID: qaqZULxm7vhwt3r8Iyd-SJXD7cQ_FbdH X-Proofpoint-Spam-Reason: safe Cc: linux-acpi@vger.kernel.org, alsa-devel@alsa-project.org, Stefan Binding , linux-kernel@vger.kernel.org, patches@opensource.cirrus.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" When loading firmware, wm_adsp uses a number of parameters to determine the path of the firmware and tuning files to load. One of these parameters is system_name. Add support in cs35l41 to read this system name from the ACPI _SUB ID in order to uniquely identify the firmware and tuning mapped to a particular system. Signed-off-by: Stefan Binding --- sound/soc/codecs/cs35l41.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index 8766e19d85f1..d70469686699 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -6,6 +6,7 @@ // // Author: David Rhodes +#include #include #include #include @@ -1142,6 +1143,24 @@ static int cs35l41_dsp_init(struct cs35l41_private *cs35l41) return ret; } +static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41) +{ + acpi_handle handle = ACPI_HANDLE(cs35l41->dev); + const char *sub; + + /* If there is no ACPI_HANDLE, there is no ACPI for this system, return 0 */ + if (!handle) + return 0; + + sub = acpi_get_subsystem_id(handle); + if (IS_ERR(sub)) + return PTR_ERR(sub); + + cs35l41->dsp.system_name = sub; + dev_dbg(cs35l41->dev, "Susystem ID: %s\n", cs35l41->dsp.system_name); + return 0; +} + int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg) { u32 regid, reg_revid, i, mtl_revid, int_status, chipid_match; @@ -1270,6 +1289,10 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg * goto err; } + ret = cs35l41_acpi_get_name(cs35l41); + if (ret < 0) + goto err; + ret = cs35l41_dsp_init(cs35l41); if (ret < 0) goto err; @@ -1316,6 +1339,7 @@ void cs35l41_remove(struct cs35l41_private *cs35l41) pm_runtime_disable(cs35l41->dev); regmap_write(cs35l41->regmap, CS35L41_IRQ1_MASK1, 0xFFFFFFFF); + kfree(cs35l41->dsp.system_name); wm_adsp2_remove(&cs35l41->dsp); cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type);