From patchwork Wed Apr 5 10:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 79557 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp208024vqo; Wed, 5 Apr 2023 03:56:07 -0700 (PDT) X-Google-Smtp-Source: AKy350YAL7Ahtf6mMYttbIDs/6PEyTN5E4NPA3LKpcEbth6lRgQyRR2RhLReuZo/PZ7B05JGw9kN X-Received: by 2002:a17:906:17c7:b0:944:5d34:2111 with SMTP id u7-20020a17090617c700b009445d342111mr2383296eje.66.1680692167200; Wed, 05 Apr 2023 03:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680692167; cv=none; d=google.com; s=arc-20160816; b=SpX0D4JByKJrd3uG5Hxr/dB4hNEx374BuKlLtzLSuoxlZJVVLhwAKUOgFSqIDS9V7l wzUhgmtLBRV8njh90M6Sm0a+LmilYaTO6aEWpMwc0Zn8WQPkzpTsjVr7oyEBEqvwV+PH X5BYMCYl6tiddacYdrI+gHMDVtajQVSJUgxapvrF2bGMPO3fTnTfG2sdIhGUpRbiYLGB mtteXesB8wLxegOH31S2xzvx3cCdNLRaWEg8ItvQElsA31/dMraR6mH996iVghG+lR6F r27yb6tHgmq7e+5FNkEX1KQ2d/VPMDdPWa+3S8rm9vtJL+Vf+BdkmKFUsUZq+hGVWEEI 4/4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Bi/GSYXJQcjk80svXbFmJoU1UjMsZTTC+SEAdd/i1LY=; b=cxn8SsJPuc8qM5dlo3xqNEXmcPwZCFGpjD5WoXaWRspMmS240++P2iPXw/C5Q0aTts SnyLWzqFqP6p6cjDrOjtxDp4zqgbg7+1mvxtVP/9N5gMLFxEBXYeXJ5LEV0V1LCEtxzC /dNeeNjtp8xGMh7g7wvcyRqTOWaEWbU/CXFZwNyZKWfALTPDgin82I94AUBvTGCXBZdc Y0108XwQwu4gJ1aRWL1CD0EEwaU0AJnXiNPTRKgcOIvSLQ21qUPhgDxaWlGR4lZ7py5Y oMpaa3N0L80Nq9dSrHjaUcSkaILjem1Kx2t5wPewMa6+UxcGw3bCENr7+01fQNgkYWQE pUZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lDpNpPU/"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt8-20020a170907728800b00947ae261e12si556841ejc.74.2023.04.05.03.55.43; Wed, 05 Apr 2023 03:56:07 -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=@linaro.org header.s=google header.b="lDpNpPU/"; 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 S237646AbjDEKs7 (ORCPT + 99 others); Wed, 5 Apr 2023 06:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237868AbjDEKsw (ORCPT ); Wed, 5 Apr 2023 06:48:52 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A6ED59F9 for ; Wed, 5 Apr 2023 03:48:41 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id q14so36825653ljm.11 for ; Wed, 05 Apr 2023 03:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680691719; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Bi/GSYXJQcjk80svXbFmJoU1UjMsZTTC+SEAdd/i1LY=; b=lDpNpPU/sZW7bLLj1ZFbDpJv3+R4eMawwRJDLZepNw+5/VjEdqU8RnqMBVDC15Zq9u 7ywUet+vVNobAme2sa20rI9m6/cmDh9ARkNdz4XNIQ0Zk8MAHQYOZTl3cyW3t/OyHgps pe7ZmzWf3I2hc1O4NJ6Pqm/gx9xIax/PJdz2qygTcEcgAyEYcjrFsYLSsyHEYzMq7Rau YfP9aCvLDG7cW4DLuvNv97cf3JkbkEjRhPYKOCIh8P9Cn/ROzRDkPDVQGiwS7m+MKIlK gola5j+WtHTVjF6rzp+1QowTmp33xA16jOPfRY1p+tZY00g13Y2XVkm3D9VgnXZPt0Ua cTpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680691719; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bi/GSYXJQcjk80svXbFmJoU1UjMsZTTC+SEAdd/i1LY=; b=U/8EEzRaYUdkRVSoy5w6owbehWdLhXYH9D6AxibCX1jZUcoCOC07on0HwaWHCjtFwh 9RRnODTl5awDlTKSTzjIKAtLP9rp0qzxPPCKFFDZHWubM6a918m+5QlxxAQdcUZz19Dl FsOiBtZXuG9dDIq6TGdKSA0SFAW4qUOBaRVTHwVlGyRLbiBKbTUEK+ZRSCtx4P4vECZi vuJionz+HcthYR9oymYzXtba/PLNJbbtmN2b0v1CtLxaPPt4P5CO3HWoIq5JZxi+wklM mx/ugVDuXCK1X68LioxQfLCSQ/abFAKTYTT1SgBJ7LcpFzvpdBJaHhetoQ1kWmL68m8D W8Pg== X-Gm-Message-State: AAQBX9du3SThUlt/x4MbO24zZBUoy2KfnNy6zLTOhZ7CvJILSRUe41d/ N21sg+LMhYbxmZvo0jWlbiKuGA== X-Received: by 2002:a2e:998c:0:b0:2a6:146:b121 with SMTP id w12-20020a2e998c000000b002a60146b121mr1737704lji.7.1680691719188; Wed, 05 Apr 2023 03:48:39 -0700 (PDT) Received: from [192.168.1.101] (abxh37.neoplus.adsl.tpnet.pl. [83.9.1.37]) by smtp.gmail.com with ESMTPSA id u4-20020a2e9b04000000b00295a3a64816sm2777299lji.2.2023.04.05.03.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 03:48:38 -0700 (PDT) From: Konrad Dybcio Date: Wed, 05 Apr 2023 12:48:35 +0200 Subject: [PATCH v2 2/2] irqchip: irq-qcom-mpm: Support passing a slice of SRAM as reg space MIME-Version: 1.0 Message-Id: <20230328-topic-msgram_mpm-v2-2-e24a48e57f0d@linaro.org> References: <20230328-topic-msgram_mpm-v2-0-e24a48e57f0d@linaro.org> In-Reply-To: <20230328-topic-msgram_mpm-v2-0-e24a48e57f0d@linaro.org> To: Andy Gross , Bjorn Andersson , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Shawn Guo Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1680691715; l=2707; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=xu+OxnOnfyyQMV5yk+DxmYZEKxx2j9CzQ4gEX4sggZE=; b=b5jBE4w42Kljvzt3wJ/kG4dpvf/EjVnoTaczlavfH3f0MIArqyLKYL45E1WPEzxoOJTZuEwwAJer dDrQD0elDtxV/bMNIElqW15WfoMD5c5TQnZ20Lr0cQgZhZ1JU6fF X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762333470245836113?= X-GMAIL-MSGID: =?utf-8?q?1762333470245836113?= The MPM hardware is accessible to us from the ARM CPUs through a shared memory region (RPM MSG RAM) that's also concurrently accessed by other kinds of cores on the system (like modem, ADSP etc.). Modeling this relation in a (somewhat) sane manner in the device tree basically requires us to either present the MPM as a child of said memory region (which makes little sense, as a mapped memory carveout is not a bus), define nodes which bleed their register spaces into one another, or passing their slice of the MSG RAM through some kind of a property. Go with the third option and add a way to map a region passed through the "qcom,rpm-msg-ram" property as our register space. The current way of using 'reg' is preserved for ABI reasons. Signed-off-by: Konrad Dybcio Acked-by: Shawn Guo --- drivers/irqchip/irq-qcom-mpm.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-qcom-mpm.c b/drivers/irqchip/irq-qcom-mpm.c index d30614661eea..ee5f39a4a42a 100644 --- a/drivers/irqchip/irq-qcom-mpm.c +++ b/drivers/irqchip/irq-qcom-mpm.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -322,8 +323,10 @@ static int qcom_mpm_init(struct device_node *np, struct device_node *parent) struct device *dev = &pdev->dev; struct irq_domain *parent_domain; struct generic_pm_domain *genpd; + struct device_node *msgram_np; struct qcom_mpm_priv *priv; unsigned int pin_cnt; + struct resource res; int i, irq; int ret; @@ -374,9 +377,21 @@ static int qcom_mpm_init(struct device_node *np, struct device_node *parent) raw_spin_lock_init(&priv->lock); - priv->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); + /* If we have a handle to an RPM message ram partition, use it. */ + msgram_np = of_parse_phandle(np, "qcom,rpm-msg-ram", 0); + if (msgram_np) { + ret = of_address_to_resource(msgram_np, 0, &res); + /* Don't use devm_ioremap_resource, as we're accessing a shared region. */ + priv->base = devm_ioremap(dev, res.start, resource_size(&res)); + of_node_put(msgram_np); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + } else { + /* Otherwise, fall back to simple MMIO. */ + priv->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + } for (i = 0; i < priv->reg_stride; i++) { qcom_mpm_write(priv, MPM_REG_ENABLE, i, 0);