From patchwork Thu Feb 9 13:13:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 652372 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 22E78C05027 for ; Thu, 9 Feb 2023 13:16:35 +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 0CD75E78; Thu, 9 Feb 2023 14:15:43 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0CD75E78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1675948593; bh=YpUC/NNZCttaGWgcQUrhszQEVYAmOb60e2JhlDsr2VE=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Mw2hgZSDrX+YX0HlC1FO3XGn73XU5Hq0R+QJI7fd2imIvyDzTLoHT3c3vefXVtBep qFjKuRfA+luCiqGEo6TRH+8IRZfY0I6sA1uWzwsBWiK8CPy11QAT5V7sLEuQ8tTEzr 6MthCs8TejIay1ixRI4fAgAKBxT8ow4UuZ+dzXyY= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 84167F8051F; Thu, 9 Feb 2023 14:14:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 06554F80557; Thu, 9 Feb 2023 14:14:44 +0100 (CET) Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 379C3F800E4 for ; Thu, 9 Feb 2023 14:13:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 379C3F800E4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Hm2UVZKn Received: by mail-wm1-x331.google.com with SMTP id l21-20020a05600c1d1500b003dfe462b7e4so4091593wms.0 for ; Thu, 09 Feb 2023 05:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=efw37swPmywJmQt7P4bh+b3QJPTdP5Sd+iv+/8BqF9I=; b=Hm2UVZKn8j00Xjy+/2jHbryM9Im/P1TEbXrvCJSQWCI6WDeX7JKZNB+r2LeTFR8Duw 52SEspmzdvCK7mZpMpE6Agh8BZZJihf+YT70iQ1F4ISTC7PC3AOpxn9ITwD8rZ+JfnoI HOvRf/nRzH9eqPec2J9G+fldT14gl3Rt7V/8u6ZrQ2pAJYnunMy+MIxLx219gj5BUEM7 6GKNHu1jwzOCT8D3gVJWXcntWIifvc4H8c9q/fdeGKyghfeMfbS9X5WY/dfG1PxFYu/i McaheEHsr8hGwE0cqZi0umwPzXKer2TiGkMMnBSXrisXnd3RzyOpGL/JY22nDtqROyfR Fg9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=efw37swPmywJmQt7P4bh+b3QJPTdP5Sd+iv+/8BqF9I=; b=b2NzH8Vv7C0WD2lpwrL35Mp8qMWM6+6D9jFCqJWSLMs3OhtXetIRnSj9MR8Bpi0155 di8UaWVUCYplxz5un1rLXcsJdAx9pH1PZwF1TcvxnjLIF/3uMX5NuC2il1RFu4namDSR IOHV3woh7Yvp3fYg/3duoUfmBz1k2X0qD4IRqR+WqprPbN12co5Z9QziRJcEawgU1UUu qvBOxbfsYruYPrqdW+5hfXYRumEqDzV2ZxnJaSXA6MuR46jY+sauqBE848L/wKqYgz66 Sc1sg0PxrfqoC1DMJGy5fWvI5ehAA37itjcbmvrlKKDrXQ/uOughcZlPGcP6VixmnwFS 8m0A== X-Gm-Message-State: AO0yUKXpiMcyMdrktVhvE5adUfenWpy6h5FDSJXOCx3XYgWXepmM+34v RovE0iB9xu63KT4AIM3+5+G/Ng== X-Google-Smtp-Source: AK7set/5t4R6vkbCi7xHYljKhRpCdrMwM173eSMG153XkPcECEZOP9zQsPoLSZqZJbWVxrvSBb6VEA== X-Received: by 2002:a05:600c:1686:b0:3db:2df0:f2b8 with SMTP id k6-20020a05600c168600b003db2df0f2b8mr5574813wmn.36.1675948432059; Thu, 09 Feb 2023 05:13:52 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id ja13-20020a05600c556d00b003dc4b4dea31sm1789394wmb.27.2023.02.09.05.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 05:13:51 -0800 (PST) From: Srinivas Kandagatla To: vkoul@kernel.org Subject: [PATCH 4/5] soundwire: qcom: add software workaround for bus clash interrupt assertion Date: Thu, 9 Feb 2023 13:13:35 +0000 Message-Id: <20230209131336.18252-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230209131336.18252-1-srinivas.kandagatla@linaro.org> References: <20230209131336.18252-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: FPJVOLVUDPPOWVOXBMOSJUGHMHZLBX3B X-Message-ID-Hash: FPJVOLVUDPPOWVOXBMOSJUGHMHZLBX3B X-MailFrom: srinivas.kandagatla@linaro.org 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 CC: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, steev@kali.org, johan+linaro@kernel.org, quic_bjorande@quicinc.com, Srinivas Kandagatla 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: Sometimes Hard reset does not clear some of the registers, this sometimes results in firing a bus clash interrupt. Add workaround for this during power up sequence, as suggested by hardware manual. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 55 ++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 465b2a2ef0d5..74e38c0d651b 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -697,6 +697,26 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) return ret; } +static bool swrm_wait_for_frame_gen_enabled(struct qcom_swrm_ctrl *swrm) +{ + int retry = SWRM_LINK_STATUS_RETRY_CNT; + int comp_sts; + + do { + swrm->reg_read(swrm, SWRM_COMP_STATUS, &comp_sts); + + if (comp_sts & SWRM_FRM_GEN_ENABLED) + return true; + + usleep_range(500, 510); + } while (retry--); + + dev_err(swrm->dev, "%s: link status %s\n", __func__, + comp_sts & SWRM_FRM_GEN_ENABLED ? "connected" : "disconnected"); + + return false; +} + static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) { u32 val; @@ -741,16 +761,27 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) SWRM_RD_WR_CMD_RETRIES); } + /* COMP Enable */ + ctrl->reg_write(ctrl, SWRM_COMP_CFG_ADDR, SWRM_COMP_CFG_ENABLE_MSK); + /* Set IRQ to PULSE */ ctrl->reg_write(ctrl, SWRM_COMP_CFG_ADDR, - SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_MSK | - SWRM_COMP_CFG_ENABLE_MSK); + SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_MSK); + + ctrl->reg_write(ctrl, SWRM_INTERRUPT_CLEAR, 0xFFFFFFFF); /* enable CPU IRQs */ if (ctrl->mmio) { ctrl->reg_write(ctrl, SWRM_INTERRUPT_CPU_EN, SWRM_INTERRUPT_STATUS_RMSK); } + + /* Set IRQ to PULSE */ + ctrl->reg_write(ctrl, SWRM_COMP_CFG_ADDR, + SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_MSK | + SWRM_COMP_CFG_ENABLE_MSK); + + swrm_wait_for_frame_gen_enabled(ctrl); ctrl->slave_status = 0; ctrl->reg_read(ctrl, SWRM_COMP_PARAMS, &val); ctrl->rd_fifo_depth = FIELD_GET(SWRM_COMP_PARAMS_RD_FIFO_DEPTH, val); @@ -1504,26 +1535,6 @@ static int qcom_swrm_remove(struct platform_device *pdev) return 0; } -static bool swrm_wait_for_frame_gen_enabled(struct qcom_swrm_ctrl *swrm) -{ - int retry = SWRM_LINK_STATUS_RETRY_CNT; - int comp_sts; - - do { - swrm->reg_read(swrm, SWRM_COMP_STATUS, &comp_sts); - - if (comp_sts & SWRM_FRM_GEN_ENABLED) - return true; - - usleep_range(500, 510); - } while (retry--); - - dev_err(swrm->dev, "%s: link status not %s\n", __func__, - comp_sts & SWRM_FRM_GEN_ENABLED ? "connected" : "disconnected"); - - return false; -} - static int __maybe_unused swrm_runtime_resume(struct device *dev) { struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev);