From patchwork Mon Jun 27 15:51:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 585860 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C0A5C43334 for ; Mon, 27 Jun 2022 15:52:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238692AbiF0PwB (ORCPT ); Mon, 27 Jun 2022 11:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238605AbiF0Pv5 (ORCPT ); Mon, 27 Jun 2022 11:51:57 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C652819C0C; Mon, 27 Jun 2022 08:51:51 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25RCSNNM017521; Mon, 27 Jun 2022 10:51:44 -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=cNlZorGv6JS7ckt03ISAuWh7D5us6y00SzunIsbrn6k=; b=K543wORAWqrSoMZDLFueXD+QpZq13i89k3H1uAFL/AarOwOX5XtqEOBRAvd01mSbGBas 1fEpjgP2pyhhSSNaNrjOdZSbzxNDmmivP4V29XT+ut3z8r3PLAiu/FMU1BH9Ejd+bC1b +ZP6gO0IvM7AWEAHAhnLxxnqORKn2cIbFIs+ORunGIBKEHeornjX8Rahsug2kRGAqwY4 3ouAzeecLPP2Nq0SofK4HJKBy9n7+0whBZpx6+zi0Ts3XEoVeQhgRYNav3B61OI/A1tX QYw3ubdATVCJsPQwUL4l7Z/pIxt0OaKuBgNQybML6ysZywqNvhZ5fwm/37DkWTnN7r43 vg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3gwys2k0uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 27 Jun 2022 10:51:44 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 27 Jun 2022 16:51:42 +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; Mon, 27 Jun 2022 16:51:42 +0100 Received: from sbinding-cirrus-dsktp.ad.cirrus.com (unknown [198.90.238.163]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 3C00A2A1; Mon, 27 Jun 2022 15:51:42 +0000 (UTC) From: Stefan Binding To: "Rafael J . Wysocki" , Len Brown , Mark Brown , Liam Girdwood CC: , , , , Stefan Binding Subject: [PATCH v3 1/2] ACPI: utils: Add api to read _SUB from ACPI Date: Mon, 27 Jun 2022 16:51:37 +0100 Message-ID: <20220627155138.807420-2-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220627155138.807420-1-sbinding@opensource.cirrus.com> References: <20220627155138.807420-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: DuqIE9-RarZwtpyVxb_Ga0837oESTzqD X-Proofpoint-GUID: DuqIE9-RarZwtpyVxb_Ga0837oESTzqD X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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..4ef9ee4ad0d8 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 %d 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 4f82a5bc6d98..968a187f14f0 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 Mon Jun 27 15:51:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 585313 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3348AC433EF for ; Mon, 27 Jun 2022 15:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238804AbiF0PwQ (ORCPT ); Mon, 27 Jun 2022 11:52:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238674AbiF0PwA (ORCPT ); Mon, 27 Jun 2022 11:52:00 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C752D1A04E; Mon, 27 Jun 2022 08:51:55 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25RCSNNN017521; Mon, 27 Jun 2022 10:51:45 -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=LBdjpKTcBhVvtkLLUBtkb/1VdJ7fQ8gDmZFGNTWayfE=; b=c0o3P4PcBbYyxm6ma7UiOlgpOXOy/8kMKDphJvtHrS57G6vD94kqdvWLq3cwIZ5BG1RA hZNQua5juIFMrh5mxBSh4e3aDs+EA9lS6ZQujOEeP1N6/fmjlftNE0u/YGSjRo14n+fN Igt3Hk05zZuPVcA96ogWYeRc/1Ei35xpDbO72PV7gI4KzE/t5GZJ4UvTTruEEI/RAoVq AaNEfm/gz6/aBTRL/4lQCAuyOoTwPvqPx6jEE2iReIYvCmBbSFi3KtDhVBu2BDG1OCQ3 55fIF+Ib0sB14k+a92d7SiOTfpYGPajMa56zesP2HEKuw3k7KybCL8gQCsb+ZTTgwDsJ ng== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3gwys2k0uh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 27 Jun 2022 10:51:45 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 27 Jun 2022 16:51:42 +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; Mon, 27 Jun 2022 16:51:42 +0100 Received: from sbinding-cirrus-dsktp.ad.cirrus.com (unknown [198.90.238.163]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 7A824458; Mon, 27 Jun 2022 15:51:42 +0000 (UTC) From: Stefan Binding To: "Rafael J . Wysocki" , Len Brown , Mark Brown , Liam Girdwood CC: , , , , Stefan Binding Subject: [PATCH v3 2/2] ASoC: cs35l41: Read System Name from ACPI _SUB to identify firmware Date: Mon, 27 Jun 2022 16:51:38 +0100 Message-ID: <20220627155138.807420-3-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220627155138.807420-1-sbinding@opensource.cirrus.com> References: <20220627155138.807420-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: M2HzhwYqUWoCzSSn_C-Krx8bqnoCz755 X-Proofpoint-GUID: M2HzhwYqUWoCzSSn_C-Krx8bqnoCz755 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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..9ab016094b32 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_probe_acpi(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_probe_acpi(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);