From patchwork Thu Oct 26 15:05:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 738348 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 3A71AC25B48 for ; Thu, 26 Oct 2023 15:08:32 +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 4E622846; Thu, 26 Oct 2023 17:07:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4E622846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698332910; bh=oxy2iICOTDyY+ulcEfSaLp4k8kQ/tM24iXLBUXT7URY=; 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=hm5+pBoC9SffcEuGjJ1yqIkW/IsXKhyYiVuDphDcg4g1bzCPSf9H2l7GqzvGNUR8u /oV+XEmkADkFaxCcM1p+cRWCyOoRpVZL7aZmbatAveJyrGqjicSAntUj4nut9/0aCE eaSgwg/WRAtWwfnvP42PcHvHbK+ur1kjp2XITjWQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 37837F8059F; Thu, 26 Oct 2023 17:06: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 244A0F8059F; Thu, 26 Oct 2023 17:06:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B457AF80567; Thu, 26 Oct 2023 17:06:25 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 B757DF80165 for ; Thu, 26 Oct 2023 17:06:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B757DF80165 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=F1bBjs5Z Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39Q5GUre011654; Thu, 26 Oct 2023 10:06:10 -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=HEYmwSUimQpCUbn2HslBt1VQ9u6Os9uGPZpmdnfD33s=; b= F1bBjs5ZcxfAlLAroOAqoB85Ty66qD/8tHrHOu7Cp25fmktx9NhBye/T8YYKa2FF zIBSlmPyeLYFSWFgLY7oe8nwTYwhLl7XTiVjIkjDmV61f54jBXT8Bkt5tT8R99Jk wqP+P1j79+fu7BuM89XIXmxlvCwuaX7Y4tfsJoGMi1CcLoaKzklahlhiSrVYR2bT Rf+ySMxSPSr7/+8qTR8AezoiGo/S4WYFNq8YF1Jg2xKSahNpM7Z7afrNSojwIc4h o8S954+4vNSJT3JF1SdJ9YL+xL4JiA59Ok2kRuWmS2opWqWOB9bvRRIWcqQS0mRK RdEenZqxuL2yDxI2h3bXaQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3tvc1x94k9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:10 -0500 (CDT) 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_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:07 +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.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:07 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 5C64711AA; Thu, 26 Oct 2023 15:06:07 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 1/8] ALSA: hda: cs35l41: Use reset label to get GPIO for HP Zbook Fury 17 G9 Date: Thu, 26 Oct 2023 16:05:51 +0100 Message-ID: <20231026150558.2105827-2-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: nUl2VjwxRNApK1UpUFXHASgEJ5J032wV X-Proofpoint-ORIG-GUID: nUl2VjwxRNApK1UpUFXHASgEJ5J032wV X-Proofpoint-Spam-Reason: safe Message-ID-Hash: BAZVBJYCOKZ4BA2EYPDWYURPTSLAQBCR X-Message-ID-Hash: BAZVBJYCOKZ4BA2EYPDWYURPTSLAQBCR X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: This laptop has an incorrect setting in its _DSD for boost type, but the rest of the _DSD is correct, and we can still use the reset label to obtain the reset gpio. Also fix channel map so that amp 0 is right, and amp 1 is left. Fixes: 581523ee3652 ("ALSA: hda: cs35l41: Override the _DSD for HP Zbook Fury 17 G9 to correct boost type") Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda_property.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda_property.c b/sound/pci/hda/cs35l41_hda_property.c index b62a4e6968e2..c83328971728 100644 --- a/sound/pci/hda/cs35l41_hda_property.c +++ b/sound/pci/hda/cs35l41_hda_property.c @@ -58,9 +58,16 @@ static int hp_vision_acpi_fix(struct cs35l41_hda *cs35l41, struct device *physde cs35l41->index = id; cs35l41->channel_index = 0; - cs35l41->reset_gpio = gpiod_get_index(physdev, NULL, 1, GPIOD_OUT_HIGH); + + /* + * This system has _DSD, it just contains an error, so we can still get the reset using + * the "reset" label. + */ + cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(cs35l41->dacpi), "reset", + cs35l41->index, GPIOD_OUT_LOW, + "cs35l41-reset"); cs35l41->speaker_id = -ENOENT; - hw_cfg->spk_pos = cs35l41->index ? 1 : 0; // right:left + hw_cfg->spk_pos = cs35l41->index ? 0 : 1; // right:left hw_cfg->gpio1.func = CS35L41_NOT_USED; hw_cfg->gpio1.valid = true; hw_cfg->gpio2.func = CS35L41_INTERRUPT; From patchwork Thu Oct 26 15:05:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 739098 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 AAA4FC25B48 for ; Thu, 26 Oct 2023 15:08:13 +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 B8D9184B; Thu, 26 Oct 2023 17:07:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B8D9184B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698332891; bh=REXGi6Y0o+M4RoopNT2vlJgbk6MBGbQMYkhgCPtm+Rk=; 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=gVBxkF/AmdZ6/Mvrg2xd9POJthiZO3fUqHFt6sGuDA7lLc3l0iNE7kzLI0tjJz+1a +q7pgE2haCBTTjB6vkj6vqU0w8lILcIRceK2zPDaj0Bg+WP/CpN3NvKF8gDjmNTFzP QDpj3f7u17Otc5tBXZ7dr7JejRni2mP8YDgNc83Y= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D183EF805A0; Thu, 26 Oct 2023 17:06:28 +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 DFF53F8057D; Thu, 26 Oct 2023 17:06:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1BE4FF8055A; Thu, 26 Oct 2023 17:06:22 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 B5F67F80152 for ; Thu, 26 Oct 2023 17:06:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B5F67F80152 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=aoy8gLob Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39Q5GUrf011654; Thu, 26 Oct 2023 10:06:12 -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=wdJIvP71kd5paaffy0gTBO9L9MC9c1x6VHLNrVDIlu8=; b= aoy8gLob0n1gsE5hx65kSnrRIzX7GY+l4uEKFt50502Nn3zHqPNsbTlVTlJedENh yXFqXGjsowQumsR8up5m9R8Quv82AVNPLJaA0ZUeJsJz0YFB6PQGZB+/U1kVlsHh okgtgrORXOsL9ujKuRmKgo2eDDUeCQMqepQJpqLPpkhy+9SvR0EAYQzg0mWcuZcF tcz02AZmTfCJcWQeTSfFhCfPMrdLceKJ+tYKDU+/cXKsxYMd9675duCu12lWNbv6 dEEwr++VX4jfICoZ4bQaG2Nf8fAUSJ49NDD15CAWGlNxOx3/WfMIeyddJeoU3tf9 fQ2C2wEnZVrv9GQGuJTAkA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3tvc1x94k9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:11 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:07 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:07 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 99D1A2A1; Thu, 26 Oct 2023 15:06:07 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 2/8] ALSA: hda: cs35l41: Assert reset before system suspend Date: Thu, 26 Oct 2023 16:05:52 +0100 Message-ID: <20231026150558.2105827-3-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: PrOE1fxLidsnV9ZeqmoNDjFQsX_MJZuV X-Proofpoint-ORIG-GUID: PrOE1fxLidsnV9ZeqmoNDjFQsX_MJZuV X-Proofpoint-Spam-Reason: safe Message-ID-Hash: YT72SZPXX5ZJA5V5Z7PQXBJL6F22IIQ3 X-Message-ID-Hash: YT72SZPXX5ZJA5V5Z7PQXBJL6F22IIQ3 X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: Some system suspend modes may remove power supplies. To ensure we are not running during this time, we should assert reset. Note: since the amps use a shared reset, asserting reset prior to system suspend only works if the amps are suspended in the reverse order to probe. Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 28cb10ddd191..919e38213975 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -813,14 +813,17 @@ static int cs35l41_system_suspend(struct device *dev) /* Shutdown DSP before system suspend */ ret = cs35l41_ready_for_reset(cs35l41); - if (ret) dev_err(dev, "System Suspend Failed, not ready for Reset: %d\n", ret); - /* - * Reset GPIO may be shared, so cannot reset here. - * However beyond this point, amps may be powered down. - */ + if (cs35l41->reset_gpio) { + dev_info(cs35l41->dev, "Asserting Reset\n"); + gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); + usleep_range(2000, 2100); + } + + dev_dbg(cs35l41->dev, "System Suspended\n"); + return ret; } From patchwork Thu Oct 26 15:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 738346 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 760BEC25B67 for ; Thu, 26 Oct 2023 15:09:56 +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 BB6A193A; Thu, 26 Oct 2023 17:09:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BB6A193A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698332994; bh=EPdyWsZRjOzG7RHrq4LSOjsgC2/D7YvZAsL5wLpder8=; 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=GBC566rYIZRj9DU8HnVUQIqtTpUdnOZ4/K6+WYwr+Tja5rnM9xjkp/9LNctsaTz3D YRlV7A5+RYNeJtEJbk1fo4xFrW+M9hEPF7j8IlgM0ZLUUF9WRcZhZD2CesoObjIJlq 2VEwl05YRBaZYc+BqjpnoVcoiNzt6olkNx2HtsUc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 80107F8057D; Thu, 26 Oct 2023 17:09:04 +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 E0F7CF8057A; Thu, 26 Oct 2023 17:09:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E2F7BF8028D; Thu, 26 Oct 2023 17:08:59 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 97966F8028D for ; Thu, 26 Oct 2023 17:06:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 97966F8028D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=Y2tQxHdD Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39Q5GUrg011654; Thu, 26 Oct 2023 10:06:14 -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=y/+iYEq7Uz9EyfpgC4lWXIhIUHrMcz4eog7gtduIurE=; b= Y2tQxHdDaqXmoe9FKYwcQLqkwBNM+NVEnK9gUoMq/ETN2DvzZsr9CQ8n+A6u3aCX wsOkXO21KwIsAlL60f1vFpDIvkxI8DA6GtIL6DXKXDaKIV9A5wGVNWn7FZE8KaYh +2wVTmiptV7q0qOxZ19mBcxJgf2kLVJb5x9H+qEc4/W4USgOkUHK+oK3wxjL6/CH lz161+ZhDMBS07gpwSRd7AD6/5HuD4InZu8dE3oHgz9GAEPPIO/EQ34PliRQwdVd CtEX7nedCc7JImkhLHU1foWNI10h0bUUbKOgOgSl9VcOhQKwe/bTV6aR5ab+kFA7 3tuWIUoLsjzfyL4nYQkDXQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3tvc1x94k9-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:13 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:08 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:08 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id E0E5611AA; Thu, 26 Oct 2023 15:06:07 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 3/8] ALSA: hda: cs35l41: Assert Reset prior to de-asserting in probe and system resume Date: Thu, 26 Oct 2023 16:05:53 +0100 Message-ID: <20231026150558.2105827-4-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: NaKD-yWniZCNpH7nPU9j1Sl85JO_MLNV X-Proofpoint-ORIG-GUID: NaKD-yWniZCNpH7nPU9j1Sl85JO_MLNV X-Proofpoint-Spam-Reason: safe Message-ID-Hash: 5ZCN5SW4MUWAIUSPEJ2TNPB2RTQHJUCN X-Message-ID-Hash: 5ZCN5SW4MUWAIUSPEJ2TNPB2RTQHJUCN X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: To ensure we are in a known state, exiting from reset at the point of probe or in system resume, assert reset before we de-assert it. Since the BIOS may enter into a pre-boot environment to control the amps (for example for boot beep), we need to ensure we start from a known, reset state prior to probe or system resume. Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 919e38213975..1ac721085fb5 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -840,6 +840,7 @@ static int cs35l41_system_resume(struct device *dev) } if (cs35l41->reset_gpio) { + gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); usleep_range(2000, 2100); gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); } @@ -1693,6 +1694,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i } } if (cs35l41->reset_gpio) { + gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); usleep_range(2000, 2100); gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); } From patchwork Thu Oct 26 15:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 739097 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 8912AC25B67 for ; Thu, 26 Oct 2023 15:08:53 +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 47C74868; Thu, 26 Oct 2023 17:08:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 47C74868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698332931; bh=0anmgiyNrKjdrb6Z7yG7bh3b9OrasmuJ7Hb0taKTT5k=; 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=MMOl1vzsWFpXz/8nnVQPyjZ9zUU7VqBgRcMWkx5ARZTS5MFVKzbn+3PyBNRgyQlOF A1ef2xSnctMp/9I1KvfQdBxXQR2ginp19S39M7MQyjq7PfnH6yDcrvtIVTeU0wE0z5 4mirRmMVTeOT5ATTHPsb5ngxZ8z3vwy4J7AlyN4Q= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B8383F805AE; Thu, 26 Oct 2023 17:06:36 +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 05472F805AE; Thu, 26 Oct 2023 17:06:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D35A7F805A8; Thu, 26 Oct 2023 17:06:31 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 08C66F8020D for ; Thu, 26 Oct 2023 17:06:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 08C66F8020D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=gnXeRITU Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39Q5GUrh011654; Thu, 26 Oct 2023 10:06:14 -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=rCtU+23iYhcqMYCBAuByfGZ6QMb+FTNaY4bVaU6dOEs=; b= gnXeRITUMh5bwbnUTjFumddLoJUgJcfbF3BQ9H+d2W62HErM0Df8y5hQe05dk4V2 NsUQchloXHv3fFCxVE0n0N7+zMa01IFzWW6cR5kd1rPTEjBh3VKHn0dv4vMVZm3j U5TdmtnrU2843evXxKaUExjVzXBd4s+z9ipZfiGHj4zpQEZQfej0yavDIzGRAIw8 p2Km3RJKFExpi3nhiFU8Tw/dL4eiNWdr7XbQAjV5OWfTGX2+P/n+6QojYzxnulaJ RnvLAB4Wl0c71HT5mS42jnCa6qeR4tNdrnWbBDTaQQtvwwlvs7neAZRn5dfmEcVF lXop0MkAp1wLDRMG5lSyCA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3tvc1x94k9-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:14 -0500 (CDT) 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_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:08 +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.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:08 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 3D25F2A1; Thu, 26 Oct 2023 15:06:08 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 4/8] ALSA: hda: cs35l41: Run boot process during resume callbacks Date: Thu, 26 Oct 2023 16:05:54 +0100 Message-ID: <20231026150558.2105827-5-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: uRqba9iLnbG5eomcHmDQNPytZqJWl7HG X-Proofpoint-ORIG-GUID: uRqba9iLnbG5eomcHmDQNPytZqJWl7HG X-Proofpoint-Spam-Reason: safe Message-ID-Hash: SWJ72IGNMZ2HU4226ANZ225R252BUYDE X-Message-ID-Hash: SWJ72IGNMZ2HU4226ANZ225R252BUYDE X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: During initial probe, after reset is asserted for the first time, the driver goes through a boot process to ensure the amp is ready to be used. This involves verifying a boot flag, as well as verifying the chip ids. This is necessary since it is possible for the amp to have been fully reset by the system suspend calls. Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 105 ++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 33 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 1ac721085fb5..e787788c1be2 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -730,6 +730,34 @@ static int cs35l41_hda_channel_map(struct device *dev, unsigned int tx_num, unsi rx_slot); } +int cs35l41_verify_id(struct cs35l41_hda *cs35l41, unsigned int *regid, unsigned int *reg_revid) +{ + unsigned int mtl_revid, chipid; + int ret; + + ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, regid); + if (ret) { + dev_err_probe(cs35l41->dev, ret, "Get Device ID failed\n"); + return ret; + } + + ret = regmap_read(cs35l41->regmap, CS35L41_REVID, reg_revid); + if (ret) { + dev_err_probe(cs35l41->dev, ret, "Get Revision ID failed\n"); + return ret; + } + + mtl_revid = *reg_revid & CS35L41_MTLREVID_MASK; + + chipid = (mtl_revid % 2) ? CS35L41R_CHIP_ID : CS35L41_CHIP_ID; + if (*regid != chipid) { + dev_err(cs35l41->dev, "CS35L41 Device ID (%X). Expected ID %X\n", *regid, chipid); + return -ENODEV; + } + + return 0; +} + static int cs35l41_ready_for_reset(struct cs35l41_hda *cs35l41) { int ret = 0; @@ -827,6 +855,30 @@ static int cs35l41_system_suspend(struct device *dev) return ret; } +static int cs35l41_wait_boot_done(struct cs35l41_hda *cs35l41) +{ + unsigned int int_status; + int ret; + + ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, int_status, + int_status & CS35L41_OTP_BOOT_DONE, 1000, 100000); + if (ret) { + dev_err(cs35l41->dev, "Failed waiting for OTP_BOOT_DONE\n"); + return ret; + } + + ret = regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status); + if (ret || (int_status & CS35L41_OTP_BOOT_ERR)) { + dev_err(cs35l41->dev, "OTP Boot status %x error\n", + int_status & CS35L41_OTP_BOOT_ERR); + if (!ret) + ret = -EIO; + return ret; + } + + return 0; +} + static int cs35l41_system_resume(struct device *dev) { struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); @@ -847,6 +899,14 @@ static int cs35l41_system_resume(struct device *dev) usleep_range(2000, 2100); + regcache_cache_only(cs35l41->regmap, false); + + ret = cs35l41_wait_boot_done(cs35l41); + if (ret) + return ret; + + regcache_cache_only(cs35l41->regmap, true); + ret = pm_runtime_force_resume(dev); if (ret) { dev_err(dev, "System Resume Failed: Unable to runtime resume: %d\n", ret); @@ -908,6 +968,7 @@ static int cs35l41_runtime_suspend(struct device *dev) static int cs35l41_runtime_resume(struct device *dev) { struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); + unsigned int regid, reg_revid; int ret = 0; dev_dbg(cs35l41->dev, "Runtime Resume\n"); @@ -929,6 +990,10 @@ static int cs35l41_runtime_resume(struct device *dev) } } + ret = cs35l41_verify_id(cs35l41, ®id, ®_revid); + if (ret) + goto err; + /* Test key needs to be unlocked to allow the OTP settings to re-apply */ cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); ret = regcache_sync(cs35l41->regmap); @@ -941,6 +1006,8 @@ static int cs35l41_runtime_resume(struct device *dev) if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); + dev_dbg(cs35l41->dev, "CS35L41 Resumed (%x), Revision: %02X\n", regid, reg_revid); + err: mutex_unlock(&cs35l41->fw_mutex); @@ -1660,7 +1727,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq, struct regmap *regmap) { - unsigned int int_sts, regid, reg_revid, mtl_revid, chipid, int_status; + unsigned int regid, reg_revid; struct cs35l41_hda *cs35l41; int ret; @@ -1701,41 +1768,13 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i usleep_range(2000, 2100); - ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, int_status, - int_status & CS35L41_OTP_BOOT_DONE, 1000, 100000); - if (ret) { - dev_err_probe(cs35l41->dev, ret, "Failed waiting for OTP_BOOT_DONE\n"); - goto err; - } - - ret = regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_sts); - if (ret || (int_sts & CS35L41_OTP_BOOT_ERR)) { - dev_err_probe(cs35l41->dev, ret, "OTP Boot status %x error\n", - int_sts & CS35L41_OTP_BOOT_ERR); - ret = -EIO; - goto err; - } - - ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, ®id); - if (ret) { - dev_err_probe(cs35l41->dev, ret, "Get Device ID failed\n"); - goto err; - } - - ret = regmap_read(cs35l41->regmap, CS35L41_REVID, ®_revid); - if (ret) { - dev_err_probe(cs35l41->dev, ret, "Get Revision ID failed\n"); + ret = cs35l41_wait_boot_done(cs35l41); + if (ret) goto err; - } - - mtl_revid = reg_revid & CS35L41_MTLREVID_MASK; - chipid = (mtl_revid % 2) ? CS35L41R_CHIP_ID : CS35L41_CHIP_ID; - if (regid != chipid) { - dev_err(cs35l41->dev, "CS35L41 Device ID (%X). Expected ID %X\n", regid, chipid); - ret = -ENODEV; + ret = cs35l41_verify_id(cs35l41, ®id, ®_revid); + if (ret) goto err; - } ret = cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); if (ret) From patchwork Thu Oct 26 15:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 738347 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 F203FC25B67 for ; Thu, 26 Oct 2023 15:09:10 +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 2A98AA4A; Thu, 26 Oct 2023 17:08:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2A98AA4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698332949; bh=E4rOKsCmjhyMP5zpr0mOKfnnZ05H650OLUN9PieHfDU=; 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=sIbDl3LzwgG9URtpNgdC7D1hLibcM9+SNa6Bxv9CZmD5a5kP/4XuoL27+luMaN9pg agbiVoA9uBqVrDRz2jVwBvCTUjXyPxma//YGZWrLa/cJeZ/9rx1tlJgGAg1S5NzkJv GvKG6SsONFx+aX/Bn5u7tNsQfz0vTOqvDdNjaAZY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51150F805C0; Thu, 26 Oct 2023 17:06:39 +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 6F985F805AA; Thu, 26 Oct 2023 17:06:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8634CF805AE; Thu, 26 Oct 2023 17:06:34 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 B16C8F8010B for ; Thu, 26 Oct 2023 17:06:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B16C8F8010B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=LOKuE4qu Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39Q5GUri011654; Thu, 26 Oct 2023 10:06:16 -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=ILs6etz2DZGvRnWZW360VpqOgkeIGeiUCrGgWU3P3jg=; b= LOKuE4qucJ4JrzB8JohVpUotheVt+aLHJWQ8vcG4gM8GkDCSdPnYfqahY9SXfgOm o5e2vtxqb6wBfNKjjfHO2+grne4r7SAENH5mU8YpC8d0zspc0DLn+GesHa5cqi9y NJ4bXyEABYdu76JkyDoysB1ANHzqLLrGqfMlub7UsMzchFO3wIXe4rNbXPrunDmN OVcMyGz6PcFXcIKLD+beQHc6/1J9b9btzs9LTE2iPwPDpD72mG1NleJ1LnDXkH4c TwIafWECKws0hlTywt3t4D+7iCa7ZQxUnF4CRL4JO4493ogZH5zMYftmCtlahu3k cXX7fve6sI1K7jsLU4h7LQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3tvc1x94k9-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:15 -0500 (CDT) 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_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:08 +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.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:08 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 8622115B6; Thu, 26 Oct 2023 15:06:08 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 5/8] ALSA: hda: cs35l41: Force a software reset after hardware reset Date: Thu, 26 Oct 2023 16:05:55 +0100 Message-ID: <20231026150558.2105827-6-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: PhKpDYQLrnEWcvB-Hheiv1SO1oOK2mEi X-Proofpoint-ORIG-GUID: PhKpDYQLrnEWcvB-Hheiv1SO1oOK2mEi X-Proofpoint-Spam-Reason: safe Message-ID-Hash: T4OEMGIINWZIXEXPE2IAVONVNUY3R7Z6 X-Message-ID-Hash: T4OEMGIINWZIXEXPE2IAVONVNUY3R7Z6 X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: To ensure the chip has correctly reset during probe and system suspend, we need to force a software reset, in case of systems where the hardware reset is not available. The software reset register was labelled as volatile but not readable, however, it is readable, (just returns 0x0). Adding it to readable registers means it will be correctly treated as volatile, and thus will not be cached. Signed-off-by: Stefan Binding --- include/sound/cs35l41.h | 1 + sound/pci/hda/cs35l41_hda.c | 5 +++++ sound/soc/codecs/cs35l41-lib.c | 1 + 3 files changed, 7 insertions(+) diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h index 2fe8c6b0d4cf..80df80fe31e2 100644 --- a/include/sound/cs35l41.h +++ b/include/sound/cs35l41.h @@ -735,6 +735,7 @@ #define CS35L41_REVID_B2 0xB2 #define CS35L41_HALO_CORE_RESET 0x00000200 +#define CS35L41_SOFTWARE_RESET 0x5A000000 #define CS35L41_FS1_WINDOW_MASK 0x000007FF #define CS35L41_FS2_WINDOW_MASK 0x00FFF800 diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index e787788c1be2..9746c64ff0dd 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -901,6 +901,9 @@ static int cs35l41_system_resume(struct device *dev) regcache_cache_only(cs35l41->regmap, false); + regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); + usleep_range(2000, 2100); + ret = cs35l41_wait_boot_done(cs35l41); if (ret) return ret; @@ -1766,6 +1769,8 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); } + usleep_range(2000, 2100); + regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); usleep_range(2000, 2100); ret = cs35l41_wait_boot_done(cs35l41); diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index 2ec5fdc875b1..ddedb7e63cb6 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -74,6 +74,7 @@ static bool cs35l41_readable_reg(struct device *dev, unsigned int reg) case CS35L41_FABID: case CS35L41_RELID: case CS35L41_OTPID: + case CS35L41_SFT_RESET: case CS35L41_TEST_KEY_CTL: case CS35L41_USER_KEY_CTL: case CS35L41_OTP_CTRL0: From patchwork Thu Oct 26 15:05:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 739095 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 B9338C25B6B for ; Thu, 26 Oct 2023 15:10:13 +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 BE801E11; Thu, 26 Oct 2023 17:09:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BE801E11 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698333011; bh=tfhftKsoLRYrjE2h6VK/g5frPbfbK/BcuYyMVN4Z+8Q=; 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=CflJsvixgiPjhEpU2faSucnllZzkYlXc+1D5+uB8akdob5GBNVTSfKIr4D1nW0LBP T3s7KXxbBk7VrbLXux/+pVlmg6vV7ns8krPukKHThNlFrBumfhMZ8y2TqvKhj/BuE1 Q+7oRC2fXMhaooqfrgo9AhW1Br7HwyyRJy/tp3Y0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A01F1F80580; Thu, 26 Oct 2023 17:09:07 +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 DD672F80580; Thu, 26 Oct 2023 17:09:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4E49FF8055A; Thu, 26 Oct 2023 17:09:00 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 72C7EF8019B for ; Thu, 26 Oct 2023 17:06:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 72C7EF8019B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=CqmUOW1Q Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39Q5GUrk011654; Thu, 26 Oct 2023 10:06:17 -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=aVS/k/o9GgQrl9MbNJJRmT2pCbqgdTBbMvRC49HEs3I=; b= CqmUOW1QFN+R8yYC1KTnwLmwDmYXbhma6M7+oX2skXH2fwCrvPIXlp3yvJtd8hZ9 A0pyADUxlmRqQiz9aygmctQXY6waCu8g0FNnwQFU+gAZVIeIRMUAzoiJ2WfHruqp 0mLSxpUtVWItzUQoH/8/hsuzkIUpWF0wFZctGjL7Q0la8LAsGiWjJGwIVMw8coHW sBhFsVpz6whzm2AKTm50X09iU1xO2fyqql3XKAbSQcgAUs084kL2LFrRZDcrJh4j 0qAqxMeLSQOB6Xu+DRs1YlJBDuwvkhitVJ/5Y3tXQ99qaSvwWO1SvrepEPJBQM0g Tx5/QLdHn2MyLy3T2pqH0w== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3tvc1x94k9-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:17 -0500 (CDT) 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_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:09 +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.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:09 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id CD6D7357D; Thu, 26 Oct 2023 15:06:08 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 6/8] ALSA: hda: cs35l41: Do not unload firmware before reset in system suspend Date: Thu, 26 Oct 2023 16:05:56 +0100 Message-ID: <20231026150558.2105827-7-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: 77tcB9QBMrf3J9m3UWL9pZxdtnLaMN5E X-Proofpoint-ORIG-GUID: 77tcB9QBMrf3J9m3UWL9pZxdtnLaMN5E X-Proofpoint-Spam-Reason: safe Message-ID-Hash: 35DGQPEGQRJNKARZMRTJKUAAPSIXE5DX X-Message-ID-Hash: 35DGQPEGQRJNKARZMRTJKUAAPSIXE5DX X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: Given the part is about to reset due to system suspend, and we are already in hibernate, there is no need to wake up the amp, just to get it ready to be reset. We just need to ensure cs_dsp is ready for reset by resetting the states. Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 9746c64ff0dd..69303888be1a 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -760,41 +760,16 @@ int cs35l41_verify_id(struct cs35l41_hda *cs35l41, unsigned int *regid, unsigned static int cs35l41_ready_for_reset(struct cs35l41_hda *cs35l41) { - int ret = 0; - mutex_lock(&cs35l41->fw_mutex); if (cs35l41->firmware_running) { - - regcache_cache_only(cs35l41->regmap, false); - - ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); - if (ret) { - dev_warn(cs35l41->dev, "Unable to exit Hibernate."); - goto err; - } - - /* Test key needs to be unlocked to allow the OTP settings to re-apply */ - cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); - ret = regcache_sync(cs35l41->regmap); - cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); - if (ret) { - dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); - goto err; - } - - if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) - cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); - - cs35l41_shutdown_dsp(cs35l41); - cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); + cs35l41->cs_dsp.running = false; + cs35l41->cs_dsp.booted = false; + cs35l41->firmware_running = false; } -err: - regcache_cache_only(cs35l41->regmap, true); regcache_mark_dirty(cs35l41->regmap); - mutex_unlock(&cs35l41->fw_mutex); - return ret; + return 0; } static int cs35l41_system_suspend_prep(struct device *dev) From patchwork Thu Oct 26 15:05:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 739096 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 838E9C25B67 for ; Thu, 26 Oct 2023 15:09:52 +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 76664DE5; Thu, 26 Oct 2023 17:09:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 76664DE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698332990; bh=25P9ZswVWSp9vE9ClIUpg82xKKnjD3qgHjGNVhvspP8=; 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=Ljxl6rlOhu2WrCtdYCJHvuBeu6+gTVN/01cCLg6CIveajN/DhFgD52CBmNOjy8BrM 9hSk93XhaM9qP3Oo2v3/x3KYJTmaHseWhOjADHsz5onV0c7CHII2knqQiwdOjslISt 5FHqA7KP+CljJ/ejcPZPLeKk58drckJ9Eb2PlFDQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3CEE3F80563; Thu, 26 Oct 2023 17:09:00 +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 31209F8055B; Thu, 26 Oct 2023 17:08:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29005F8055A; Thu, 26 Oct 2023 17:08:55 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 8C663F8024E for ; Thu, 26 Oct 2023 17:06:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8C663F8024E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=FgjtMwvK Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39Q5GUrl011654; Thu, 26 Oct 2023 10:06:18 -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=/q3Kw4t4VTC4/a9Bku2lCi/sAJC9uB56KwypnrOkogk=; b= FgjtMwvK7nk6mBpvrTLCcNfGZaWDFby7l95BNA5dY94YI2kYhLF7HuISpswtpBys 4jYov1hS7r+BXf1u3nvPwqKB6hec9hbmyXOYKKWkixwYRmpXociv/VemVrwifii+ AOE8nLLBxTDR5S1MoouemGf2jnGjGuVB72vVG5rWLiSWoMQDy4hWI4i4Ab7nIYTr Y5oCwXegDJhBSjeS55nLGTPxobqorZ5hDb1NOyGXUkZ9VZZnIDwir3ZnY5FXAIwn KqKBQc/Z4dyrZ2vpJKLpIAMs4HHgLfoenpZaA0ePAIO+aaC3m4MwBP9a+Qcpnnha WzG57rCP2a4zRBMZ1MfbSg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3tvc1x94k9-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:18 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:09 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:09 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 21CB0357E; Thu, 26 Oct 2023 15:06:09 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 7/8] ALSA: hda: cs35l41: Check CSPL state after loading firmware Date: Thu, 26 Oct 2023 16:05:57 +0100 Message-ID: <20231026150558.2105827-8-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: W4rZ6uY09kr0d8aBBrA7k6d90D77BfBy X-Proofpoint-ORIG-GUID: W4rZ6uY09kr0d8aBBrA7k6d90D77BfBy X-Proofpoint-Spam-Reason: safe Message-ID-Hash: ZFVZKJP54XOURY547C3ESYJSRC6KYVVX X-Message-ID-Hash: ZFVZKJP54XOURY547C3ESYJSRC6KYVVX X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: CSPL firmware should be in RUNNING or PAUSED state after loading. If not, the firmware has not been loaded correctly, and we can unload it and pass the error up. Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 69303888be1a..496ff6a9d300 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -994,6 +994,7 @@ static int cs35l41_runtime_resume(struct device *dev) static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) { + unsigned int fw_status; __be32 halo_sts; int ret; @@ -1027,6 +1028,23 @@ static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) goto clean_dsp; } + ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status); + if (ret < 0) { + dev_err(cs35l41->dev, + "Failed to read firmware status: %d\n", ret); + goto clean_dsp; + } + + switch (fw_status) { + case CSPL_MBOX_STS_RUNNING: + case CSPL_MBOX_STS_PAUSED: + break; + default: + dev_err(cs35l41->dev, "Firmware status is invalid: %u\n", + fw_status); + goto clean_dsp; + } + ret = cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, CSPL_MBOX_CMD_PAUSE); if (ret) { dev_err(cs35l41->dev, "Error waiting for DSP to pause: %u\n", ret); From patchwork Thu Oct 26 15:05:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 738349 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 42B4CC25B48 for ; Thu, 26 Oct 2023 15:08:04 +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 04C1693A; Thu, 26 Oct 2023 17:07:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 04C1693A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698332883; bh=w/WBIzk1c8Px22k6L+s4Kg78OXA0Ud9fG9jpz0Igzac=; 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=KG8RY+y/RwZHcZN11hK8tma25DwCSW4KQMRjCbf4BpshQE4GNaNLhippPBJWJWW7c vwU4aZZHoN3KJDquZPcWU8gXCF47ecHNBnoKDS+kGLpGgukFIi40YG0v//pUccH45e vBqG2RcBNTIlMGajoDxArMqd5xz+8APXMNBfyaXA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 41FC9F80165; Thu, 26 Oct 2023 17:06:24 +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 34D7AF8056F; Thu, 26 Oct 2023 17:06:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B815F8028D; Thu, 26 Oct 2023 17:06:20 +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 1A795F8019B for ; Thu, 26 Oct 2023 17:06:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1A795F8019B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=KvitG4L1 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39QF2DtX011762; Thu, 26 Oct 2023 10:06:12 -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=P2RZ5FPl+x4KIbUrLBvQodtbr+Kus6IGLLMqcPJmaeY=; b= KvitG4L1GV+7ZfKxNWN2mxEFrAf1OxqyEMvuS2j5d10rTK1ttAjT3if8guwQUEhe FkjQtu8KLhfeaxBAgW1FqV9zYmxn7ZB+FLDM+3v9zy9GKFjOUWEGoICZjrS7b/Hn upRUgOYVed7K/ng/GW2nEieN/ogKDH5I1jL0ugy4GqZzi2pY9YFerD21lt1j26ci ZsIuyd/VlsZy2ObrDfTN3jw9vdDDZx6CUknvTvTDfRqhbsijaW8ZfRo5l9TKWe+n ywRvJrvOsDVKU8y3X/4myxbO8iH+727YGY2pYv+/0IXGBnYVuqTXGcav+AvtzN9o M8haN7gnf6lXFB2XWkqcbg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3tvb2j6tep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Oct 2023 10:06:11 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Thu, 26 Oct 2023 16:06:09 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.37 via Frontend Transport; Thu, 26 Oct 2023 16:06:09 +0100 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.177]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 681BF11AA; Thu, 26 Oct 2023 15:06:09 +0000 (UTC) From: Stefan Binding To: Jaroslav Kysela , Takashi Iwai , "Mark Brown" CC: , , , , "Stefan Binding" Subject: [PATCH v1 8/8] ASoC: cs35l41: Detect CSPL errors when sending CSPL commands Date: Thu, 26 Oct 2023 16:05:58 +0100 Message-ID: <20231026150558.2105827-9-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> References: <20231026150558.2105827-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: 2mnMNV1ezLHzUEslcCyFHivS6CNyn6IL X-Proofpoint-ORIG-GUID: 2mnMNV1ezLHzUEslcCyFHivS6CNyn6IL X-Proofpoint-Spam-Reason: safe Message-ID-Hash: ETVRHJ5F3ANXK7UW2SQAWS4FG3Z7BKOL X-Message-ID-Hash: ETVRHJ5F3ANXK7UW2SQAWS4FG3Z7BKOL X-MailFrom: prvs=56633e4941=sbinding@opensource.cirrus.com 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.8 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: The existing code checks for the correct state transition after sending a command. However, it is possible for the message box to return -1, which indicates an error, if an error has occurred in the firmware. We can detect if the error has occurred, and return a different error. In addition, there is no recovering from a CSPL error, so the retry mechanism is not needed in this case, and we can return immediately. Signed-off-by: Stefan Binding --- include/sound/cs35l41.h | 2 ++ sound/soc/codecs/cs35l41-lib.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h index 80df80fe31e2..043f8ac65dbf 100644 --- a/include/sound/cs35l41.h +++ b/include/sound/cs35l41.h @@ -816,6 +816,8 @@ struct cs35l41_otp_map_element_t { }; enum cs35l41_cspl_mbox_status { + CSPL_MBOX_STS_ERROR = U32_MAX, + CSPL_MBOX_STS_ERROR2 = 0x00ffffff, // firmware not always sign-extending 24-bit value CSPL_MBOX_STS_RUNNING = 0, CSPL_MBOX_STS_PAUSED = 1, CSPL_MBOX_STS_RDY_FOR_REINIT = 2, diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index ddedb7e63cb6..4569e4f7cf7e 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -1474,6 +1474,11 @@ int cs35l41_set_cspl_mbox_cmd(struct device *dev, struct regmap *regmap, continue; } + if (sts == CSPL_MBOX_STS_ERROR || sts == CSPL_MBOX_STS_ERROR2) { + dev_err(dev, "CSPL Error Detected\n"); + return -EINVAL; + } + if (!cs35l41_check_cspl_mbox_sts(cmd, sts)) dev_dbg(dev, "[%u] cmd %u returned invalid sts %u", i, cmd, sts); else