Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1679412pxm; Thu, 24 Feb 2022 07:29:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw86g01JaQvZGUtp8udgWCyONnf5kiV6QW5qdLABsoLu1ZSDG4pP4M80lHzV2XeaXFKtcqN X-Received: by 2002:aa7:9902:0:b0:4cb:95a7:a4c4 with SMTP id z2-20020aa79902000000b004cb95a7a4c4mr3123855pff.85.1645716594539; Thu, 24 Feb 2022 07:29:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645716594; cv=none; d=google.com; s=arc-20160816; b=rbMjvHzSSCidVn8Xu4awcB3FHIvg6RirIjucOhP82J2TrKwyiMkRp2uh5lxAVIf0c8 I82T2D3vuFYjCBxTtj39tDDRzoNakxizCnJhC7daokCtvXxQrG3IKje48GOhV4YNgmFh nqJYYtBIKdsPJsulWx5eX08KvxF4gPajSiVbqACyRJN2ZCu7G5br9Wm8lNY42dGPzCMI TBt8FI3cgZKk6OgxDT4DceuTsCackbALAO7Gj/1PWaLwYNKoVj5dCJM4QG+IHJiBFK4y UjSWvOvYxwFKRTO7Xh+YWBhDAbTsb63iRxod2RUHtWf1jrpVu91V4RXkW9AVZbxYI6Tc Qo6Q== 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=eOe0YnAdLFHik7V4l++pHUQcqVB92bCJ4fKDKTqumAI=; b=f6PePH123MRa6RwLm+xWKUA4PRTwgn1ApUe8podLx03R/DZURukBW4tpyukspzNn2N 8XR2OOZGPv7Oluxpp7ZzOwQ08gEKzrWcmnJVq6V49qG0EszJ/74TxYdAoOh9LwWogLS6 wgVf73N7Z6e0PiVZuq+BuATUb0+XBWbMym1HfJp7+tLq1aQoxQwdUF04OpvBe38sVmb4 ekZFrQ1oaxFxcEW+/Fg5SKCDdShBZnd++cY/qQeKFjEUrDIpFP2+9ZD2O2oIwR0yBN+A OLZLAmWSfMFbUNfeifjiWSgl3l1E6IAQSsvSw4FsgxOggAvg8PgTpjX9CFCykZuN5Nue qwrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d3jWz7NM; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10si2472210pjo.3.2022.02.24.07.29.33; Thu, 24 Feb 2022 07:29:54 -0800 (PST) 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=@linaro.org header.s=google header.b=d3jWz7NM; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235012AbiBXNcZ (ORCPT + 99 others); Thu, 24 Feb 2022 08:32:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234989AbiBXNcQ (ORCPT ); Thu, 24 Feb 2022 08:32:16 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F28A34B92 for ; Thu, 24 Feb 2022 05:31:45 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id d3so3089972wrf.1 for ; Thu, 24 Feb 2022 05:31:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eOe0YnAdLFHik7V4l++pHUQcqVB92bCJ4fKDKTqumAI=; b=d3jWz7NM9/ixBCcxoiUKpPidsC8v0hfIQsWzpdfC+4pBY+imxCFSOqqq0RtNqsOIPm bMjX1hp0/EPg3KY5TNxy3Srbo5ts/6mU9Pxpi1cLRuBajCRHjpBYDFtgRQ85nnLiRSOi 1+e5AYWvfQwTROpUGj6H+KIzBPwtSKv1DeU1KvZdnZgg7HBdtujX2ynmNE9fyZUv1Atp hAWwtZziOokMcVvmZsIuOhVi4Q6zcu32p9XnrEMa4TAKgEtmfdBkk+wRJDYROvOHCU9C yinaiGAAhxNInMFlwYjzRzvE/54mZ4aufUuu5coiwfiJSbzUmqtYphDBLHzpdGcU+WBj U0Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eOe0YnAdLFHik7V4l++pHUQcqVB92bCJ4fKDKTqumAI=; b=XCypYhcScI56xcilJ1Up8OrL6kAdJWl+2AatWJ5rYZ2718R1oviVLtnC1CfTW1YQDY Tl3ywrf8R5q1LY1Qrj951Eq9x9f2oaPutovMFvDjqdgznXsAfZ802Ycv7fjuzwhio6/p tlsvK/jyeBhENvbVkk0IRKdLbhhkyFh75Iw4HlCjqNh2uKrjmYUq61Z9l/b8i8ScAxHS 5jMpi0CI+aPCKud8yg3yZwpMf2XyejAeGZbHZQBVyiwoezDzGskvyWlXeDJi8poGV5FP dR7M0pao0YJhAzCPz/1JtddY2dIrpvdLPLPPcLc/autlXfC4gh1RNaqvpqr8S2cAeJ+g ggXQ== X-Gm-Message-State: AOAM5300zzED1ItUo0m7GzltymyogY4bCY5YblnIZgAbqSQmR+YRMd8k BZwAICiPAeQure+fBJIBNTvIbA== X-Received: by 2002:a05:6000:8b:b0:1ee:1c9d:92a0 with SMTP id m11-20020a056000008b00b001ee1c9d92a0mr1414602wrx.677.1645709503861; Thu, 24 Feb 2022 05:31:43 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id e33-20020a05600c4ba100b003810c690ba2sm2019142wmp.3.2022.02.24.05.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 05:31:43 -0800 (PST) From: Srinivas Kandagatla To: robh+dt@kernel.org, vkoul@kernel.org, yung-chuan.liao@linux.intel.com Cc: pierre-louis.bossart@linux.intel.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, quic_srivasam@quicinc.com, Srinivas Kandagatla Subject: [PATCH v2 3/3] soundwire: qcom: add in-band wake up interrupt support Date: Thu, 24 Feb 2022 13:31:25 +0000 Message-Id: <20220224133125.6674-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220224133125.6674-1-srinivas.kandagatla@linaro.org> References: <20220224133125.6674-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Some of the Qualcomm SoundWire Controller instances like the ones that are connected to RX path along with Headset connections support Waking up Controller from Low power clock stop state using SoundWire In-band interrupt. SoundWire Slave on the bus would intiate this by pulling the data line high, during clock stop condition. Add support to this wake up interrupt. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 2c763a9f088f..27cfe4e05206 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,7 @@ struct qcom_swrm_ctrl { u8 rd_cmd_id; int irq; unsigned int version; + int wake_irq; int num_din_ports; int num_dout_ports; int cols_index; @@ -503,6 +505,31 @@ static int qcom_swrm_enumerate(struct sdw_bus *bus) return 0; } +static irqreturn_t qcom_swrm_wake_irq_handler(int irq, void *dev_id) +{ + struct qcom_swrm_ctrl *swrm = dev_id; + int ret; + + ret = pm_runtime_get_sync(swrm->dev); + if (ret < 0 && ret != -EACCES) { + dev_err_ratelimited(swrm->dev, + "pm_runtime_get_sync failed in %s, ret %d\n", + __func__, ret); + pm_runtime_put_noidle(swrm->dev); + } + + if (swrm->wake_irq > 0) { + if (!irqd_irq_disabled(irq_get_irq_data(swrm->wake_irq))) + disable_irq_nosync(swrm->wake_irq); + } + + pm_runtime_mark_last_busy(swrm->dev); + pm_runtime_put_autosuspend(swrm->dev); + + return IRQ_HANDLED; +} + + static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) { struct qcom_swrm_ctrl *swrm = dev_id; @@ -1340,6 +1367,19 @@ static int qcom_swrm_probe(struct platform_device *pdev) goto err_clk; } + ctrl->wake_irq = of_irq_get(dev->of_node, 1); + if (ctrl->wake_irq > 0) { + ret = devm_request_threaded_irq(dev, ctrl->wake_irq, NULL, + qcom_swrm_wake_irq_handler, + IRQF_TRIGGER_HIGH | IRQF_ONESHOT, + "swr_wake_irq", ctrl); + if (ret) { + dev_err(dev, "Failed to request soundwire wake irq\n"); + goto err_init; + } + } + + ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode); if (ret) { dev_err(dev, "Failed to register Soundwire controller (%d)\n", @@ -1424,6 +1464,11 @@ static int swrm_runtime_resume(struct device *dev) struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev); int ret; + if (ctrl->wake_irq > 0) { + if (!irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq))) + disable_irq_nosync(ctrl->wake_irq); + } + clk_prepare_enable(ctrl->hclk); if (ctrl->clock_stop_not_supported) { @@ -1487,6 +1532,11 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev) usleep_range(300, 305); + if (ctrl->wake_irq > 0) { + if (irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq))) + enable_irq(ctrl->wake_irq); + } + return 0; } -- 2.21.0