Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10940268rwp; Fri, 21 Jul 2023 07:09:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlGeC5rKjngPj2czK52vdjWqlTHAiYl9KiKUC2AzVZcMYGM0+DOg0Q8E7gho7nI4kCgPLkil X-Received: by 2002:a17:902:ecc9:b0:1b8:8702:1e7c with SMTP id a9-20020a170902ecc900b001b887021e7cmr3928487plh.33.1689948542287; Fri, 21 Jul 2023 07:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689948542; cv=none; d=google.com; s=arc-20160816; b=KusM8qziRolyHbWLzZTk5y4gq0i0+nMVoPdaQn/JvO7d0BGIcfL2ROw+gOxNdwxgn0 xCkbmwkFQvy6NFmD2dWaQpE3mHHW/Yfl4HWmXk5yGCDk6scHA6YLbsKtE42LwLOjP9lv nESW6rmr128hk0Wouz+FjL2Hm784tuQwjFTQBXtagSjJf7z3PmTojCcho7YDVpQ9Z8CG iCc9yyTC7bZQcWJzA9h75pxu5/CcpUJw9Ebf6dGPpAi7MzZtStY9QHW49Jca+cp2JhRO EwnfmjUc565XE7XhiWmIHqXdPU4IInRYDFt9tL8prCMn0ZtEKGEhdYWi1jrBGv7Cyzjb ezTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z5eELqrUPimZhcyI9qZ8KUmBZfzfQMg7d/8kt8QGigM=; fh=QvXx5lDpQknB9PDD6mOm+E8djX72AmxBQwiVxLDXEAM=; b=g/wvu84suhaA+lOI9Yb9Ft2bh4qUPHQrQMBOrhTnAKOYkS2Ef1fm+M0qkcScLfPHbT Gz3fm1q+IY2Za5z9bOINCfF7hrUJAsOHlEzmiWuHfEbF21sG89g7o1Li3YkLXek//n9n CMm+8emZZvyiRDQoTYQiH0M2E/MCvTOnmsmni152CHH5BHxzCHGnIIU6P2sfwrAAemE5 Ejqmi9Zkbuxc0uWfCYcg0DuDdnrXMYvCULkZN7zCrMZY6Vjf4FlnhGCuNDhREC5ozOJi eCqYSpMC00lyuZZ8xz7fa1k5iFmw6rsXuc2qXtmHWiFNxTlxllV/2YMU6CYEi3RUWqGy qKPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=iKYXOtxz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a17090301c400b001b8ba81d04dsi3326934plh.395.2023.07.21.07.08.49; Fri, 21 Jul 2023 07:09:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=iKYXOtxz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231608AbjGUNW6 (ORCPT + 99 others); Fri, 21 Jul 2023 09:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231439AbjGUNW1 (ORCPT ); Fri, 21 Jul 2023 09:22:27 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF2E13C0D for ; Fri, 21 Jul 2023 06:21:52 -0700 (PDT) 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 36LBeOqM003184; Fri, 21 Jul 2023 08:21:30 -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=z5eELqrUPimZhcyI9qZ8KUmBZfzfQMg7d/8kt8QGigM=; b= iKYXOtxz3hRf+/ZsSG5FQ8m+yPUj8eLF+mpPAYMzik7JK5Y93nbDlhlNrAD0PADA 6VzQsODetoHuxvbE3E3s7YGl36kLH4CAumMFhzGp8L6I0S0ztgbKtk8Cb6D4WYkD hN0aF7pqruFIGYKCzZ7Fs9Y32VCtBkO9udBEwDAW/0ii5UrSrM0yaHHteb1bXuR+ 37EuhDLZHn8EBFnLRHrTe/kEL/gf50wfmz0suGhGDOoL6vMcZLjhg9CU/v1J7TuC 5ms1CZBPW5IGARJL8GneEVP8DKtWxpffuhLhQDmzdmulBxalZ9mfW0/9R6g+vvdq wuYSJfhI4IPfja3aUEEkbA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3rus62y4hx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 08:21:30 -0500 (CDT) 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_256_GCM_SHA384) id 15.2.1118.30; Fri, 21 Jul 2023 14:21:27 +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.30 via Frontend Transport; Fri, 21 Jul 2023 14:21:27 +0100 Received: from work-debian.ad.cirrus.com (unknown [198.61.64.172]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 2EF0046B; Fri, 21 Jul 2023 13:21:27 +0000 (UTC) From: Richard Fitzgerald To: , CC: , , , , Simon Trimmer , Richard Fitzgerald Subject: [PATCH v5 09/11] ASoC: cs35l56: Make a common function to shutdown the DSP Date: Fri, 21 Jul 2023 14:21:18 +0100 Message-ID: <20230721132120.5523-10-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230721132120.5523-1-rf@opensource.cirrus.com> References: <20230721132120.5523-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 5JKmFXj-6A12U5Pm6jtgZdy8xmC1P-wT X-Proofpoint-ORIG-GUID: 5JKmFXj-6A12U5Pm6jtgZdy8xmC1P-wT X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Simon Trimmer Move issuing of a CS35L56_MBOX_CMD_SHUTDOWN command and then waiting for the DSP to reach CS35L56_HALO_STATE_SHUTDOWN in the register appropriate for the hardware revision into a common function. Signed-off-by: Simon Trimmer Signed-off-by: Richard Fitzgerald Acked-by: Mark Brown --- include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56-shared.c | 26 ++++++++++++++++++++++++++ sound/soc/codecs/cs35l56.c | 17 +---------------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h index 79e117abee06..3950322bf3cb 100644 --- a/include/sound/cs35l56.h +++ b/include/sound/cs35l56.h @@ -274,6 +274,7 @@ extern const unsigned int cs35l56_tx_input_values[CS35L56_NUM_INPUT_SRC]; int cs35l56_set_patch(struct cs35l56_base *cs35l56_base); int cs35l56_mbox_send(struct cs35l56_base *cs35l56_base, unsigned int command); +int cs35l56_firmware_shutdown(struct cs35l56_base *cs35l56_base); int cs35l56_wait_for_firmware_boot(struct cs35l56_base *cs35l56_base); void cs35l56_wait_control_port_ready(void); void cs35l56_wait_min_reset_pulse(void); diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c index 4e3becb9581d..ae373f335ea8 100644 --- a/sound/soc/codecs/cs35l56-shared.c +++ b/sound/soc/codecs/cs35l56-shared.c @@ -213,6 +213,32 @@ int cs35l56_mbox_send(struct cs35l56_base *cs35l56_base, unsigned int command) } EXPORT_SYMBOL_NS_GPL(cs35l56_mbox_send, SND_SOC_CS35L56_SHARED); +int cs35l56_firmware_shutdown(struct cs35l56_base *cs35l56_base) +{ + int ret; + unsigned int reg; + unsigned int val; + + ret = cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_SHUTDOWN); + if (ret) + return ret; + + if (cs35l56_base->rev < CS35L56_REVID_B0) + reg = CS35L56_DSP1_PM_CUR_STATE_A1; + else + reg = CS35L56_DSP1_PM_CUR_STATE; + + ret = regmap_read_poll_timeout(cs35l56_base->regmap, reg, + val, (val == CS35L56_HALO_STATE_SHUTDOWN), + CS35L56_HALO_STATE_POLL_US, + CS35L56_HALO_STATE_TIMEOUT_US); + if (ret < 0) + dev_err(cs35l56_base->dev, "Failed to poll PM_CUR_STATE to 1 is %d (ret %d)\n", + val, ret); + return ret; +} +EXPORT_SYMBOL_NS_GPL(cs35l56_firmware_shutdown, SND_SOC_CS35L56_SHARED); + int cs35l56_wait_for_firmware_boot(struct cs35l56_base *cs35l56_base) { unsigned int reg; diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index d06b83dfc462..19b6b4fbe5de 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -673,8 +673,6 @@ static void cs35l56_secure_patch(struct cs35l56_private *cs35l56) static void cs35l56_patch(struct cs35l56_private *cs35l56) { - unsigned int reg; - unsigned int val; int ret; /* @@ -691,23 +689,10 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56) flush_work(&cs35l56->sdw_irq_work); } - ret = cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_SHUTDOWN); + ret = cs35l56_firmware_shutdown(&cs35l56->base); if (ret) goto err; - if (cs35l56->base.rev < CS35L56_REVID_B0) - reg = CS35L56_DSP1_PM_CUR_STATE_A1; - else - reg = CS35L56_DSP1_PM_CUR_STATE; - - ret = regmap_read_poll_timeout(cs35l56->base.regmap, reg, - val, (val == CS35L56_HALO_STATE_SHUTDOWN), - CS35L56_HALO_STATE_POLL_US, - CS35L56_HALO_STATE_TIMEOUT_US); - if (ret < 0) - dev_err(cs35l56->base.dev, "Failed to poll PM_CUR_STATE to 1 is %d (ret %d)\n", - val, ret); - /* Use wm_adsp to load and apply the firmware patch and coefficient files */ ret = wm_adsp_power_up(&cs35l56->dsp); if (ret) { -- 2.30.2