From patchwork Tue Jul 18 12:19:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 704099 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 747DAEB64DC for ; Tue, 18 Jul 2023 12:19:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231661AbjGRMTV (ORCPT ); Tue, 18 Jul 2023 08:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbjGRMTT (ORCPT ); Tue, 18 Jul 2023 08:19:19 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22317E56 for ; Tue, 18 Jul 2023 05:19:18 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4faaaa476a9so9345160e87.2 for ; Tue, 18 Jul 2023 05:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689682756; x=1692274756; 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=UZHiNhlcnBcV/12CBhpoH4NhL4fdNzTRpHhX759efoE=; b=BkiQdJeW9f9DpFlueQzCM4Ay7onHhbx9JgqfOAtIlj6qfnKF/lOgQwvwtgAoWPkaJi Gj/7k/l5d7AD2S1DsoFaQJLMBBrtwHKkZfQwFE9dJY/DpkeuEIDrM/64dzXg0qXUh4rL l+Pvabu6upKPpJK9yUwQlTlqdYOgf5zM8ts37HjAKMn6BH7x2bZYrUB/aPSPxIcS3V3O Z8+cgfZpj/jdZYMHqwwbMunIX1SgadFdK8vzRApyRU/vr2aQ929GOhxL3tA5p99K178c SW/re6vJOs0bXvhLY1RgdnLO4Kn2pAf4PTHPVSjiti84kV9p/9VNqT4v7Bug7DhlqUxw 2mJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689682756; x=1692274756; 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=UZHiNhlcnBcV/12CBhpoH4NhL4fdNzTRpHhX759efoE=; b=YIuWZokemTqs9PGVRLJ+lgJCfh+CtD5LY9DQ4fj9NYfUokjiN+3yNJ2LmopI40QDhV h7np2BT5nZw4DIS91FbsAw2eSeC4UKOD/o7G2Y+g+VYuLQKKNTHzIvyyH7KDLox7rGTo bFPyNNHLb17LeQ/+PuL+WNGT51J58CWzcD+UbNICJKtj2BN+a5rNoNPXBjz7qYQTXJj1 AuXfFR3gUs9d+h3QG+ZQrO3hDCpahh63FPjIRQeBvoaJhs0YsvqfmwrK/2n6F1IP3rHN 0MhxndCfdU58mwVp04HnrggAhp/qUez70dbeNw0gy+qDetSgqmXg0uBsf6C9tA5pET7Y G/tA== X-Gm-Message-State: ABy/qLaqv5iCamwQptTiC9sO0sHdwVOE6bmmnYFCK6zOI52muM2n3ao8 /0oGCXM83CFr5UzIfodKvMGuu0bSHyElGXY7TmTKIQ== X-Google-Smtp-Source: APBJJlH6NnoSBJfilu2FTqtWGzALCPzNb/NSR8tEZkwUx5OLF0JfQhJZ9VBoH7NV4rKDhuUb8AY6pA== X-Received: by 2002:a19:5f1a:0:b0:4fb:8df5:8919 with SMTP id t26-20020a195f1a000000b004fb8df58919mr8634710lfb.23.1689682756309; Tue, 18 Jul 2023 05:19:16 -0700 (PDT) Received: from [192.168.1.101] (abyj181.neoplus.adsl.tpnet.pl. [83.9.29.181]) by smtp.gmail.com with ESMTPSA id w5-20020ac25d45000000b004fbc95a4db3sm418257lfd.28.2023.07.18.05.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 05:19:16 -0700 (PDT) From: Konrad Dybcio Date: Tue, 18 Jul 2023 14:19:11 +0200 Subject: [PATCH v4 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-v4-2-bae382dc0f92@linaro.org> References: <20230328-topic-msgram_mpm-v4-0-bae382dc0f92@linaro.org> In-Reply-To: <20230328-topic-msgram_mpm-v4-0-bae382dc0f92@linaro.org> To: Andy Gross , Bjorn Andersson , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Shawn Guo , Conor Dooley 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=1689682752; l=2751; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=yQx/+qerpXC0l+cy+Ejk8gpdBKyKLvnTn9FYud1Txtk=; b=5CXvh5t6cxxmX683kjykjDScpVxz5kvmakrM1qH3EXTb53Kw1A5IqAAzygFxf1rNF0/r/LGhJ v7Ay7ThPnocDBXcvdEegD7ivKBpaQ+GfHIY9l7jTm+5hNWk0ePtVgbK X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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. Acked-by: Shawn Guo Signed-off-by: Konrad Dybcio --- 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);