Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3010432pxm; Mon, 28 Feb 2022 10:13:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBTHKa0g4ZPbyk90yd8wVyyvB9E1GtcUQdN363UUzYqy9fKIndXU4dk4gcVsbES7rhwyTd X-Received: by 2002:a05:6402:1c03:b0:413:3ff:91a5 with SMTP id ck3-20020a0564021c0300b0041303ff91a5mr20630221edb.139.1646072011199; Mon, 28 Feb 2022 10:13:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646072011; cv=none; d=google.com; s=arc-20160816; b=SguMXgJppzb0+VwSLhfwcbWrpK7iU/JQPc4TJu2oKMQ5yvbk12UozRsAd0a/v+xZk+ QkWJRd7umB1vm3bVa6H0anuukXDOs/G6qwnz5sPCd52D54z6v1/psm4+WfGTrNZv+ImQ 1I33dbtkXdTAJGPp/7Wejt5XNU9iWUN20KzDHrTefb4ZOjaXImDrfidDwwbmhzsfb+Wi a4iZlZNTBE/5d7NEfkwkjzQXYqu9lkW/zubmStDT9MSdY5NGvh1HOrejuxuMispGrbjY V830DGS9RI41EyFwB/UszPJWhDAwy5NK3I+ew2tsluOwCxZ5N23VQqRxynCb9hEcEjdZ v02Q== 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=FmiziqktK1UrOgPFNs78A4lHVO3Bduu86Seb9OC3k1c=; b=z45TILFIQYHGko9RlfDECpQPJjHW+p4BVihQSrrJC9WTj7xIzMuekrvtRRL7UV9onk 9CCn5YN/u0/3DpAYgv/3u3DdASej2lI3q7nVuVDlf9ipsDyCLNK0eHwK05trhYGhg+A+ uS9er/Qej37fEP6nQwHlmc0zhbnMgHYvcRlVf5orstWvr+oXCL98pEPyTq6cGRdY+Ogg xY+RZQ0KkFRwuN4WEqC2XCuZhSE5xR7vTZU0b9rXynKlRu4yAgkNDFgOZJ3SjGeVe3CV rma4GUTpYgxZ24aaHc2zBh/CAYgQ/2K3j3DlezgmKHinbBH05/ohm4EuZxnd5uGgQFKv 4aXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K+n/iswA"; 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 jz3-20020a17090775e300b006d003fd96a9si6306273ejc.237.2022.02.28.10.13.08; Mon, 28 Feb 2022 10:13:31 -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="K+n/iswA"; 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 S233776AbiB1R0b (ORCPT + 99 others); Mon, 28 Feb 2022 12:26:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233513AbiB1R0X (ORCPT ); Mon, 28 Feb 2022 12:26:23 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9751875E62 for ; Mon, 28 Feb 2022 09:25:44 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id i20so6103306wmc.3 for ; Mon, 28 Feb 2022 09:25:44 -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=FmiziqktK1UrOgPFNs78A4lHVO3Bduu86Seb9OC3k1c=; b=K+n/iswAmZ36iYyamoHmNZHrTZnMxXeQtaEPylc+co1LNZ4a0PiQWszAfkrk8SLwgj HCd2KxQ/G3O9OyJS7ymWIl4DC5VZss/oUTAU1gCJ9P5qmWtAOyYwtL1GQ+HOPxT1VyGa mTZ98GgZfeK8KzcF2OuMNNVGU0JvX0GWJPeF2hIzxYZ+C1GOSRj5kK/5vmEGOFG2QFXv JJzemBOuNiDULBbVfeJlFYvUXHmPzptAXh/JGE0VDQRxCJIaz/tgPKO2+kcgdfIdfVas SxUeFz5WHIj/n4HAKEeZI3zoH82nusaeWDdLacpkBlBKjQKUvun0I+L/jXpqZPf8JlE9 VJSw== 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=FmiziqktK1UrOgPFNs78A4lHVO3Bduu86Seb9OC3k1c=; b=VK1q1gST3y0A/kPuUiB/2WNYv/0Z3WtTU4bD/JeXIW/isLb1WIhRQaJgi9P8QHr2Gx QamTsBIEvOlSI/nHe+u90BklUrZETbPov5r2h+YhHn60T+KkxBGqiLZjGdpQTlc1uHEI DhVt8T1z/t8Z8T2LwavOwpxTh6EBwO5rxQzdEr/7abJTpgs3RIMM9V052t80GrCDZ37k uELgiJqdRyz97GMdOstFozb7TXPRaaMDrSLxoeO/sICOsXAm/2VSFzU4hVmSb55VaVAw avKTAzd5WqfoDdKaJ5m3PGWhJSmi6XVIdVZaKTCUc4EPmnirmWoKJq0p26cKTXcTlqfF fHSw== X-Gm-Message-State: AOAM532sfYFI4UQjzg4iJolyGOMx10iDMKgHOfiMjhqIFC2NH9rDvSYo YHxusLaey/yTW9p+yfAWWo2eIA== X-Received: by 2002:a05:600c:4615:b0:381:c68:e8f8 with SMTP id m21-20020a05600c461500b003810c68e8f8mr14077589wmo.117.1646069143234; Mon, 28 Feb 2022 09:25: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 f21-20020a7bcd15000000b0034efd01ee16sm11514124wmj.42.2022.02.28.09.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 09:25:42 -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 v3 3/3] soundwire: qcom: add in-band wake up interrupt support Date: Mon, 28 Feb 2022 17:25:28 +0000 Message-Id: <20220228172528.3489-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220228172528.3489-1-srinivas.kandagatla@linaro.org> References: <20220228172528.3489-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=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 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 initiate this by pulling the data line high, while the clock is stopped. 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 810232686196..e893aee1b057 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) { @@ -1491,6 +1536,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