From patchwork Thu Apr 14 15:21:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 562203 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41719C433F5 for ; Thu, 14 Apr 2022 15:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346293AbiDNQBa (ORCPT ); Thu, 14 Apr 2022 12:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354449AbiDNPlE (ORCPT ); Thu, 14 Apr 2022 11:41:04 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44060DF493 for ; Thu, 14 Apr 2022 08:21:37 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id 14so3290989ily.11 for ; Thu, 14 Apr 2022 08:21:37 -0700 (PDT) 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=edIWwPKPDITXLPsh4Wu0h7S7XlZhTTuZiRx0vaBerYE=; b=sODaZuzK6WFQwdSPsSvBlmvjyC6uQsBG6yaQonMlvj+BWLAWXowycsPUCs3gEkIfos +3IRShz1y5QLm0C4clEjtjDUqmiUZw7dYFg7SkcEDDSKlBlmuthHMZ4wbrJJ5xGhRF2g 6+FbEeg+13WMR+MBoBbZldVLQB5Jg//bS7qjVligSpjcSthJw9QefQFOkopFHDRQq65h UTz3simjnU1R0zcKFiljfah+lXMZ80cn/BRts7k1WzPOQYxUp63IJcGU2wSyfLFpUT7u xq+zffIJXzQYu74Abg/eHf1j8HVZmOfE060yOwVVPTFWV6I3PMU054CLFraVv+eF3IhL 36uQ== 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=edIWwPKPDITXLPsh4Wu0h7S7XlZhTTuZiRx0vaBerYE=; b=gyeqo8KFB8UdogAfkzbzGNMDDsnn0aYYqKdMs4YGwGfE3GO5jb3YrbZnhmnVl+X/In uaEOu9w/CwifPu7lcF2lzlqqPqjBC1WnB6AnRMyzds7laTEeEH7kQiDMib7hrVvPwfs8 UXS6irc7Y4p39mB51X3L1b4NOn/pwOQJfkhjCDIKlncMUKFA9wyTqFkCUeGsMNnLn5or Czg5fZ02sNq2fXHFvOa+X6gXc8IHoVInN3yUyb3zbJLGzR3mR20WfO1uTEITowy5xIDy LNz9faBenwkji1e5tu1m4ujP8QMt1QyCnINecWeSbYeN7T07gIq/Al3A+YBjusKtjtnX vMqQ== X-Gm-Message-State: AOAM532VILwC7R82BIzpHUpIWfIjaZb0yo2FHWjKgDWO+wJjQqxXVQhw zSFk85kD0mo6M1A9IuokvohzB/9Dlt2lLw== X-Google-Smtp-Source: ABdhPJxPF3hsNkxjcclHg68S4IqDQdJbmqDUlzpmwr3KIPxP5d9SL5wHmXW19c7JOnL+LdTpTiDD1A== X-Received: by 2002:a05:6e02:12e9:b0:2c9:f576:8951 with SMTP id l9-20020a056e0212e900b002c9f5768951mr1310684iln.204.1649949696279; Thu, 14 Apr 2022 08:21:36 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id x2-20020a056602160200b006463c1977f9sm1365395iow.22.2022.04.14.08.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 08:21:35 -0700 (PDT) From: Alex Elder To: stable@vger.kernel.org Cc: Deepak Kumar Singh , quic_clew@quicinc.com, quic_deesin@quicinc.com, swboyd@chromium.org, kuba@kernel.org, bjorn.andersson@linaro.org, elder@kernel.org, gregkh@linuxfoundation.org Subject: [PATCH v2 1/3] soc: qcom: aoss: Expose send for generic usecase Date: Thu, 14 Apr 2022 10:21:29 -0500 Message-Id: <20220414152131.713724-2-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220414152131.713724-1-elder@linaro.org> References: <20220414152131.713724-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Deepak Kumar Singh commit 8c75d585b931ac874fbe4ee5a8f1811d20c2817f upstream. Not all upcoming usecases will have an interface to allow the aoss driver to hook onto. Expose the send api and create a get function to enable drivers to send their own messages to aoss. Signed-off-by: Chris Lew Signed-off-by: Deepak Kumar Singh Reviewed-by: Stephen Boyd Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/1630420228-31075-2-git-send-email-deesin@codeaurora.org Signed-off-by: Alex Elder --- drivers/soc/qcom/qcom_aoss.c | 54 +++++++++++++++++++++++++++++- include/linux/soc/qcom/qcom_aoss.h | 38 +++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 include/linux/soc/qcom/qcom_aoss.h diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c index a0659cf278456..d40d8e20ceb46 100644 --- a/drivers/soc/qcom/qcom_aoss.c +++ b/drivers/soc/qcom/qcom_aoss.c @@ -8,10 +8,12 @@ #include #include #include +#include #include #include #include #include +#include #define QMP_DESC_MAGIC 0x0 #define QMP_DESC_VERSION 0x4 @@ -223,11 +225,14 @@ static bool qmp_message_empty(struct qmp *qmp) * * Return: 0 on success, negative errno on failure */ -static int qmp_send(struct qmp *qmp, const void *data, size_t len) +int qmp_send(struct qmp *qmp, const void *data, size_t len) { long time_left; int ret; + if (WARN_ON(IS_ERR_OR_NULL(qmp) || !data)) + return -EINVAL; + if (WARN_ON(len + sizeof(u32) > qmp->size)) return -EINVAL; @@ -261,6 +266,7 @@ static int qmp_send(struct qmp *qmp, const void *data, size_t len) return ret; } +EXPORT_SYMBOL(qmp_send); static int qmp_qdss_clk_prepare(struct clk_hw *hw) { @@ -519,6 +525,51 @@ static void qmp_cooling_devices_remove(struct qmp *qmp) thermal_cooling_device_unregister(qmp->cooling_devs[i].cdev); } +/** + * qmp_get() - get a qmp handle from a device + * @dev: client device pointer + * + * Return: handle to qmp device on success, ERR_PTR() on failure + */ +struct qmp *qmp_get(struct device *dev) +{ + struct platform_device *pdev; + struct device_node *np; + struct qmp *qmp; + + if (!dev || !dev->of_node) + return ERR_PTR(-EINVAL); + + np = of_parse_phandle(dev->of_node, "qcom,qmp", 0); + if (!np) + return ERR_PTR(-ENODEV); + + pdev = of_find_device_by_node(np); + of_node_put(np); + if (!pdev) + return ERR_PTR(-EINVAL); + + qmp = platform_get_drvdata(pdev); + + return qmp ? qmp : ERR_PTR(-EPROBE_DEFER); +} +EXPORT_SYMBOL(qmp_get); + +/** + * qmp_put() - release a qmp handle + * @qmp: qmp handle obtained from qmp_get() + */ +void qmp_put(struct qmp *qmp) +{ + /* + * Match get_device() inside of_find_device_by_node() in + * qmp_get() + */ + if (!IS_ERR_OR_NULL(qmp)) + put_device(qmp->dev); +} +EXPORT_SYMBOL(qmp_put); + static int qmp_probe(struct platform_device *pdev) { struct resource *res; @@ -615,6 +666,7 @@ static struct platform_driver qmp_driver = { .driver = { .name = "qcom_aoss_qmp", .of_match_table = qmp_dt_match, + .suppress_bind_attrs = true, }, .probe = qmp_probe, .remove = qmp_remove, diff --git a/include/linux/soc/qcom/qcom_aoss.h b/include/linux/soc/qcom/qcom_aoss.h new file mode 100644 index 0000000000000..3c2a82e606f81 --- /dev/null +++ b/include/linux/soc/qcom/qcom_aoss.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2021, The Linux Foundation. All rights reserved. + */ + +#ifndef __QCOM_AOSS_H__ +#define __QCOM_AOSS_H__ + +#include +#include + +struct qmp; + +#if IS_ENABLED(CONFIG_QCOM_AOSS_QMP) + +int qmp_send(struct qmp *qmp, const void *data, size_t len); +struct qmp *qmp_get(struct device *dev); +void qmp_put(struct qmp *qmp); + +#else + +static inline int qmp_send(struct qmp *qmp, const void *data, size_t len) +{ + return -ENODEV; +} + +static inline struct qmp *qmp_get(struct device *dev) +{ + return ERR_PTR(-ENODEV); +} + +static inline void qmp_put(struct qmp *qmp) +{ +} + +#endif + +#endif From patchwork Thu Apr 14 15:21:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 561520 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07C30C433F5 for ; Thu, 14 Apr 2022 15:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350236AbiDNQBJ (ORCPT ); Thu, 14 Apr 2022 12:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354496AbiDNPlE (ORCPT ); Thu, 14 Apr 2022 11:41:04 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64872DF4A7 for ; Thu, 14 Apr 2022 08:21:38 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id o127so431947iof.12 for ; Thu, 14 Apr 2022 08:21:38 -0700 (PDT) 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=mfrhGGBj0Sk85zrOhsdb8TtI3LhLRBO2IGMEqKkv48Y=; b=S34Elk1ApvpkJYWjF40GIat8OsWthtJZVaaQGOfyyMsoRkpWWfPhz+BGcDu0yXKbJm tQBqFQ+v+Zu1Zy5uiYcG5ru9LNtmq2c0A1x64SKmy1iVcf+wkSi3v2wEHePjckeuvoBz vtxoSHAPBu6l/NBpL4zCXIc9DeA/2zERopU5u1PpbB2iSgsTuZW6kGSdYpaCmTqlUC/0 Uf5i4/mXresmUMDdUgmMc0wGQUsjNCqeTy3/Z8bV4D30vD7+qz9hukLnb3GA6glPn5yZ Eox4WzPThJZ0zOvHYH/BESKx6Y22gzL4p0xUNzEHQB66G990Eo+ENmYiDwEJ1X+1Dd/c KTYA== 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=mfrhGGBj0Sk85zrOhsdb8TtI3LhLRBO2IGMEqKkv48Y=; b=fSKs3aclwnhOojuX6nESjvHV89P+A+AesVwkZCV+JkOT6pWMSX82eycOJHR7AfnWBG zAnemSicW7uKgjpZ4Q3nLcbVxqjsMy+MjY/KIYkbkCFIYq9BZpm5QbvycOScb5qLZcbK XkKDd+TzGu5Xjftg9Vx5DnkRyE+2N87KtERI+asOuo1pGGx+pGa6bZ51LLvXXdAcn0+L 6qceSIa66LIaNU+Cdmu0Xrxd7S5TOCyF084JBhX106UNoUDjt6WWRatL6RzHAVPU1p6D 3U2qqRPU+NIZpjTlB+u8SvH3iHuqOWtf5sEm44crxSmGIY/rwFG0z2iBwK+ucVDtIKhD vhww== X-Gm-Message-State: AOAM532ATeqwmujteLvqsrqqA/UGYN48aym8cV24iDIYlm5qOnqtZYuy KJCke0nDKGhdwFkfYivPdGvJFm2gyFhsIw== X-Google-Smtp-Source: ABdhPJy33AvCrKBtk/iHu+c2VcZfpcqk2g1NKM3zYoTSgu0WRa1bNyPfjLX0zL2sd1UFFSW7boouiQ== X-Received: by 2002:a05:6602:1648:b0:647:9f39:1272 with SMTP id y8-20020a056602164800b006479f391272mr1296453iow.146.1649949697494; Thu, 14 Apr 2022 08:21:37 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id x2-20020a056602160200b006463c1977f9sm1365395iow.22.2022.04.14.08.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 08:21:36 -0700 (PDT) From: Alex Elder To: stable@vger.kernel.org Cc: kuba@kernel.org, bjorn.andersson@linaro.org, quic_clew@quicinc.com, quic_deesin@quicinc.com, swboyd@chromium.org, elder@kernel.org, gregkh@linuxfoundation.org Subject: [PATCH v2 2/3] dt-bindings: net: qcom,ipa: add optional qcom,qmp property Date: Thu, 14 Apr 2022 10:21:30 -0500 Message-Id: <20220414152131.713724-3-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220414152131.713724-1-elder@linaro.org> References: <20220414152131.713724-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org commit ac62a0174d62ae0f4447c0c8cf35a8e5d793df56 upstream. For some systems, the IPA driver must make a request to ensure that its registers are retained across power collapse of the IPA hardware. On such systems, we'll use the existence of the "qcom,qmp" property as a signal that this request is required. Signed-off-by: Alex Elder Signed-off-by: Jakub Kicinski --- Documentation/devicetree/bindings/net/qcom,ipa.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/net/qcom,ipa.yaml b/Documentation/devicetree/bindings/net/qcom,ipa.yaml index b8a0b392b24ea..c52ec1ee7df6e 100644 --- a/Documentation/devicetree/bindings/net/qcom,ipa.yaml +++ b/Documentation/devicetree/bindings/net/qcom,ipa.yaml @@ -106,6 +106,10 @@ properties: - const: imem - const: config + qcom,qmp: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle to the AOSS side-channel message RAM + qcom,smem-states: $ref: /schemas/types.yaml#/definitions/phandle-array description: State bits used in by the AP to signal the modem. @@ -221,6 +225,8 @@ examples: "imem", "config"; + qcom,qmp = <&aoss_qmp>; + qcom,smem-states = <&ipa_smp2p_out 0>, <&ipa_smp2p_out 1>; qcom,smem-state-names = "ipa-clock-enabled-valid", From patchwork Thu Apr 14 15:21:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 562204 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAFC4C43217 for ; Thu, 14 Apr 2022 15:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241295AbiDNQB0 (ORCPT ); Thu, 14 Apr 2022 12:01:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354500AbiDNPlE (ORCPT ); Thu, 14 Apr 2022 11:41:04 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F38FDEB86 for ; Thu, 14 Apr 2022 08:21:39 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id p21so5744695ioj.4 for ; Thu, 14 Apr 2022 08:21:39 -0700 (PDT) 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=X5sSdpjUHCfybVwprx6qx71sk3MsE1l8j38zhRYOgvA=; b=Moo6XNM3QFQ6RSDOTHIY7p+uNAfyOR/+d8vU6R9FIgI2Tlmb+epkdj40Q5/MfpeKav 6gmOeHsMvuycp/Irnrm+ZZfU9u9xdpnKz64tlvq6isd+GcN1hwH6FxjoQtt70RTMdk2n uFdKDCsNWCxQ7TwhNvyxaSKpnvg7wJVJXIXi6SU4tRwS20eS8lmUUppROMYsBhYIETp0 TZXdivJOYzXbFhSF0LfFSOhhLdYxKMlQIhTIsPfwd85B/mKShFz4nAL51P0zAyIKZCMt bQ/s2rcXX8iONafoZZMCDOL9N8kzhUuq9HJFpxdV1wqa6gM50VpDK0by+dkOipo0Pj+0 HAcA== 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=X5sSdpjUHCfybVwprx6qx71sk3MsE1l8j38zhRYOgvA=; b=U2QeB1hLs2D5U0qHUWGrftOgMK5pWrbAuBtKDQmJ4l8DKpskUqcMNdVR6RiiSgdE5J u49VHGyhfN3OgmtMa2KEpkyBalOy0zcShoDk3hI9HNk8QdCniu7fnLDyxxm9Bfg4Fgab StNOKWQKTNYDrpZstW3dYMbJ4PdByA94RuANu6dJvhWNUSdtGu4pU/WeLXSEHzqbNgVy 5xYRd4ZsY/YlXy+zPXyEWFyTi+I4iwhzonOf2x2+329WP2IQsrqYIPtahhq+MjLc1r/a GETW/0KsR72vsMEDgGdzaqDq13xs3oRdJbxJyTGSEj/K6wFw9avrl9OVeOKLOeWMtFN3 0o/A== X-Gm-Message-State: AOAM533MEvAZw0F+0vfhEtJ2xC6bZ1jkpzcGXQQLo1gXnFw8M7B192bq vMgiyzqyzXjFRJ/9bRU0OuVICTbKp/VxnQ== X-Google-Smtp-Source: ABdhPJzkaPuFMxPPSJ68GRGOVPeU9uwrRgiopfVGEf0IUCxq48MruByWzdztYpC2h3bYVdHU2+kHGw== X-Received: by 2002:a05:6602:27c5:b0:631:a30f:143a with SMTP id l5-20020a05660227c500b00631a30f143amr1378062ios.40.1649949698601; Thu, 14 Apr 2022 08:21:38 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id x2-20020a056602160200b006463c1977f9sm1365395iow.22.2022.04.14.08.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 08:21:38 -0700 (PDT) From: Alex Elder To: stable@vger.kernel.org Cc: kuba@kernel.org, bjorn.andersson@linaro.org, quic_clew@quicinc.com, quic_deesin@quicinc.com, swboyd@chromium.org, elder@kernel.org, gregkh@linuxfoundation.org Subject: [PATCH v2 3/3] net: ipa: request IPA register values be retained Date: Thu, 14 Apr 2022 10:21:31 -0500 Message-Id: <20220414152131.713724-4-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220414152131.713724-1-elder@linaro.org> References: <20220414152131.713724-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org commit 34a081761e4e3c35381cbfad609ebae2962fe2f8 upstream. In some cases, the IPA hardware needs to request the always-on subsystem (AOSS) to coordinate with the IPA microcontroller to retain IPA register values at power collapse. This is done by issuing a QMP request to the AOSS microcontroller. A similar request ondoes that request. We must get and hold the "QMP" handle early, because we might get back EPROBE_DEFER for that. But the actual request should be sent while we know the IPA clock is active, and when we know the microcontroller is operational. Fixes: 1aac309d3207 ("net: ipa: use autosuspend") Signed-off-by: Alex Elder Signed-off-by: Jakub Kicinski --- drivers/net/ipa/ipa_power.c | 52 +++++++++++++++++++++++++++++++++++++ drivers/net/ipa/ipa_power.h | 7 +++++ drivers/net/ipa/ipa_uc.c | 5 ++++ 3 files changed, 64 insertions(+) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index b1c6c0fcb654f..f2989aac47a62 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -11,6 +11,8 @@ #include #include +#include "linux/soc/qcom/qcom_aoss.h" + #include "ipa.h" #include "ipa_power.h" #include "ipa_endpoint.h" @@ -64,6 +66,7 @@ enum ipa_power_flag { * struct ipa_power - IPA power management information * @dev: IPA device pointer * @core: IPA core clock + * @qmp: QMP handle for AOSS communication * @spinlock: Protects modem TX queue enable/disable * @flags: Boolean state flags * @interconnect_count: Number of elements in interconnect[] @@ -72,6 +75,7 @@ enum ipa_power_flag { struct ipa_power { struct device *dev; struct clk *core; + struct qmp *qmp; spinlock_t spinlock; /* used with STOPPED/STARTED power flags */ DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); u32 interconnect_count; @@ -382,6 +386,47 @@ void ipa_power_modem_queue_active(struct ipa *ipa) clear_bit(IPA_POWER_FLAG_STARTED, ipa->power->flags); } +static int ipa_power_retention_init(struct ipa_power *power) +{ + struct qmp *qmp = qmp_get(power->dev); + + if (IS_ERR(qmp)) { + if (PTR_ERR(qmp) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + /* We assume any other error means it's not defined/needed */ + qmp = NULL; + } + power->qmp = qmp; + + return 0; +} + +static void ipa_power_retention_exit(struct ipa_power *power) +{ + qmp_put(power->qmp); + power->qmp = NULL; +} + +/* Control register retention on power collapse */ +void ipa_power_retention(struct ipa *ipa, bool enable) +{ + static const char fmt[] = "{ class: bcm, res: ipa_pc, val: %c }"; + struct ipa_power *power = ipa->power; + char buf[36]; /* Exactly enough for fmt[]; size a multiple of 4 */ + int ret; + + if (!power->qmp) + return; /* Not needed on this platform */ + + (void)snprintf(buf, sizeof(buf), fmt, enable ? '1' : '0'); + + ret = qmp_send(power->qmp, buf, sizeof(buf)); + if (ret) + dev_err(power->dev, "error %d sending QMP %sable request\n", + ret, enable ? "en" : "dis"); +} + int ipa_power_setup(struct ipa *ipa) { int ret; @@ -438,12 +483,18 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data) if (ret) goto err_kfree; + ret = ipa_power_retention_init(power); + if (ret) + goto err_interconnect_exit; + pm_runtime_set_autosuspend_delay(dev, IPA_AUTOSUSPEND_DELAY); pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); return power; +err_interconnect_exit: + ipa_interconnect_exit(power); err_kfree: kfree(power); err_clk_put: @@ -460,6 +511,7 @@ void ipa_power_exit(struct ipa_power *power) pm_runtime_disable(dev); pm_runtime_dont_use_autosuspend(dev); + ipa_power_retention_exit(power); ipa_interconnect_exit(power); kfree(power); clk_put(clk); diff --git a/drivers/net/ipa/ipa_power.h b/drivers/net/ipa/ipa_power.h index 2151805d7fbb0..6f84f057a2095 100644 --- a/drivers/net/ipa/ipa_power.h +++ b/drivers/net/ipa/ipa_power.h @@ -40,6 +40,13 @@ void ipa_power_modem_queue_wake(struct ipa *ipa); */ void ipa_power_modem_queue_active(struct ipa *ipa); +/** + * ipa_power_retention() - Control register retention on power collapse + * @ipa: IPA pointer + * @enable: Whether retention should be enabled or disabled + */ +void ipa_power_retention(struct ipa *ipa, bool enable); + /** * ipa_power_setup() - Set up IPA power management * @ipa: IPA pointer diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index 856e55a080a7f..fe11910518d95 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -11,6 +11,7 @@ #include "ipa.h" #include "ipa_uc.h" +#include "ipa_power.h" /** * DOC: The IPA embedded microcontroller @@ -154,6 +155,7 @@ static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) case IPA_UC_RESPONSE_INIT_COMPLETED: if (ipa->uc_powered) { ipa->uc_loaded = true; + ipa_power_retention(ipa, true); pm_runtime_mark_last_busy(dev); (void)pm_runtime_put_autosuspend(dev); ipa->uc_powered = false; @@ -184,6 +186,9 @@ void ipa_uc_deconfig(struct ipa *ipa) ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_1); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_0); + if (ipa->uc_loaded) + ipa_power_retention(ipa, false); + if (!ipa->uc_powered) return;