From patchwork Thu Nov 30 00:00:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 120051 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp13501qgn; Wed, 29 Nov 2017 16:00:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMbMPYjwWNSeRKq+fCPkgptXX6wLVm9i2OXKsF4X4MEi+tvlJ7Vta6AYycR428bGzfm7O2wu X-Received: by 10.101.78.2 with SMTP id r2mr611234pgt.320.1512000052815; Wed, 29 Nov 2017 16:00:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512000052; cv=none; d=google.com; s=arc-20160816; b=xEWngAGGPyNc2UoEy44FB2r3XJNL6My74vuyU6iLVO0aIV4RT0nkSpgk0XO9CBa0jO CEseCrJ6eRu0VXw08X9F38bMb7aFV5wsIX9DtBwVAmRQsW2m/kRylOPPwtuakQzqfIrW XflLtdSYK11aygpXr3hcpq/mikj4XNz29Lc46q3/XvKERZrQ6mIwGMhBnpTVQsqUzoAO 5JrXTIeXRP5l6FxFTj3+mDrYTf2AloBJvljyvAM8nJh93kmjKOL/5v3ZI3AdZwPW8vMC PBnw/gL06BNHqdEYWKtSuUqC6z6sAs70HGgPYjoSnDM8lERoZYJ49MTnyy9CYxN5ZCbl 7AYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=pPBZRmBi/6Rr7xBZJ7QaTYrq08JJIZrhDeikN1cmLi4=; b=wxuNP5WUeBG8/4+3HkC21xOAM1qMYIciwUIDOfLowUKogr9L713xvtFN0lR0wN4nLy X6PO/QFRdfsfRCwXdx6ZsmQGzshl3nQ8VTda3iBYBy1UfofYi1KJLY/K0Cy/Fs67OYmX SAeHRpfTh9ncu/gufSKiUyOCQeZGDZeslXQpxgEOT0aCRZSwkxxJgMgouuzPF4dT0gVf x6ruIG4NqF+GhdnU82a2g6M6Vov7VZ3B3lH0yLQEzE58urGkEErshkGJggL5ksrPkJvI z3PZnfdOiHmVil1RiR/RflHTwCa7wzg9/fHsQygteEzY5qSQXGiGYA4+tXTCjL4HKSuI decg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kA1XRKHs; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh1si2031615plb.93.2017.11.29.16.00.52; Wed, 29 Nov 2017 16:00:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kA1XRKHs; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344AbdK3AAv (ORCPT + 10 others); Wed, 29 Nov 2017 19:00:51 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:41310 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753457AbdK3AAs (ORCPT ); Wed, 29 Nov 2017 19:00:48 -0500 Received: by mail-pl0-f66.google.com with SMTP id g2so3099949pli.8 for ; Wed, 29 Nov 2017 16:00:48 -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; bh=+KpvlFhyz7Klz4URZ/Wz9AJjy+h2Gy+s3etJKpYi+gg=; b=kA1XRKHs2X8m/2savfieckQOwBvuOuOr8TGZhZvSza/KUDEaydSzzxXdGtgN9UU9k0 hZroVrB17fxpGcDmC+SFWOUQAeVw+RAjlfgpE8XmqhBQhDr9+MZT5RyM6wBQr40BkDQz 1kbPgvxRVoji1HIGVSXuQbfIVcKxtlr/lMi8U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+KpvlFhyz7Klz4URZ/Wz9AJjy+h2Gy+s3etJKpYi+gg=; b=WQ7l7geW3DnHf5RIaTxzEU5ILnhRrtbYpWNKDDTJOPwFP3Z8J2ipgF415d2X3uLBKf JwZizfl9UCdw11HeEOVHDg8PNkBXk5fQ+Bba66QSO3Z80Gqx1qvwCmNvL7frPv5YB1Li aJblBFk0QT9kWokJX9ZWsgv7r5ETY132AOe54z4JLGi5cwAbZW4z8oJboVILv9K3AweT k10HGmhanfnyq50fNbDlj/RaETeJJxfUGHnpS2mbMe6kkSptv5lJVo3hn/YuFteVqHyw 4pLIUWVXgERcsrEhSCqkUkuDDOGOcBS/dv456Z4k3RIzYATZxVT5stL4+0stcy0tesoE xumw== X-Gm-Message-State: AJaThX4bPYyPi2D1zL1Dfyoxkk/wgAzjRWvW/CKVX/pkBpbwbs1i5vq+ deucOKX5ALB2TknChBRky+a2/w== X-Received: by 10.159.252.204 with SMTP id o12mr627111pls.148.1512000047470; Wed, 29 Nov 2017 16:00:47 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id k23sm5543859pfj.22.2017.11.29.16.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 16:00:46 -0800 (PST) From: Bjorn Andersson To: Andy Gross , David Brown , Rob Herring , Mark Rutland Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Arun Kumar Neelakantam Subject: [PATCH v2] soc: qcom: smp2p: Access APCS as mailbox client Date: Wed, 29 Nov 2017 16:00:40 -0800 Message-Id: <20171130000040.23681-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Attempt to acquire the APCS IPC through the mailbox framework and fall back to the old syscon based approach, to allow us to move away from using the syscon. Signed-off-by: Bjorn Andersson --- Changes since v1: - Added dt binding update - Specifies knows_txdone on the mailbox client .../devicetree/bindings/soc/qcom/qcom,smp2p.txt | 8 ++++- drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/smp2p.c | 39 ++++++++++++++++++---- 3 files changed, 41 insertions(+), 7 deletions(-) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,smp2p.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,smp2p.txt index af9ca37221ce..a35af2dafdad 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,smp2p.txt +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,smp2p.txt @@ -17,9 +17,15 @@ processor ID) and a string identifier. Value type: Definition: one entry specifying the smp2p notification interrupt -- qcom,ipc: +- mboxes: Usage: required Value type: + Definition: reference to the associated doorbell in APCS, as described + in mailbox/mailbox.txt + +- qcom,ipc: + Usage: required, unless mboxes is specified + Value type: Definition: three entries specifying the outgoing ipc bit used for signaling the remote end of the smp2p edge: - phandle to a syscon node representing the apcs registers diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index b81374bb6713..40c711583f0d 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -75,6 +75,7 @@ config QCOM_SMEM_STATE config QCOM_SMP2P tristate "Qualcomm Shared Memory Point to Point support" + depends on MAILBOX depends on QCOM_SMEM select QCOM_SMEM_STATE help diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c index f51fb2ea7200..669c8baa971b 100644 --- a/drivers/soc/qcom/smp2p.c +++ b/drivers/soc/qcom/smp2p.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -126,6 +127,8 @@ struct smp2p_entry { * @ipc_regmap: regmap for the outbound ipc * @ipc_offset: offset within the regmap * @ipc_bit: bit in regmap@offset to kick to signal remote processor + * @mbox_client: mailbox client handle + * @mbox_chan: apcs ipc mailbox channel handle * @inbound: list of inbound entries * @outbound: list of outbound entries */ @@ -146,6 +149,9 @@ struct qcom_smp2p { int ipc_offset; int ipc_bit; + struct mbox_client mbox_client; + struct mbox_chan *mbox_chan; + struct list_head inbound; struct list_head outbound; }; @@ -154,7 +160,13 @@ static void qcom_smp2p_kick(struct qcom_smp2p *smp2p) { /* Make sure any updated data is written before the kick */ wmb(); - regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit)); + + if (smp2p->mbox_chan) { + mbox_send_message(smp2p->mbox_chan, NULL); + mbox_client_txdone(smp2p->mbox_chan, 0); + } else { + regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit)); + } } /** @@ -453,10 +465,6 @@ static int qcom_smp2p_probe(struct platform_device *pdev) platform_set_drvdata(pdev, smp2p); - ret = smp2p_parse_ipc(smp2p); - if (ret) - return ret; - key = "qcom,smem"; ret = of_property_read_u32_array(pdev->dev.of_node, key, smp2p->smem_items, 2); @@ -483,9 +491,23 @@ static int qcom_smp2p_probe(struct platform_device *pdev) return irq; } + smp2p->mbox_client.dev = &pdev->dev; + smp2p->mbox_client.knows_txdone = true; + smp2p->mbox_chan = mbox_request_channel(&smp2p->mbox_client, 0); + if (IS_ERR(smp2p->mbox_chan)) { + if (PTR_ERR(smp2p->mbox_chan) != -ENODEV) + return PTR_ERR(smp2p->mbox_chan); + + smp2p->mbox_chan = NULL; + + ret = smp2p_parse_ipc(smp2p); + if (ret) + return ret; + } + ret = qcom_smp2p_alloc_outbound_item(smp2p); if (ret < 0) - return ret; + goto release_mbox; for_each_available_child_of_node(pdev->dev.of_node, node) { entry = devm_kzalloc(&pdev->dev, sizeof(*entry), GFP_KERNEL); @@ -540,6 +562,9 @@ static int qcom_smp2p_probe(struct platform_device *pdev) smp2p->out->valid_entries = 0; +release_mbox: + mbox_free_channel(smp2p->mbox_chan); + return ret; } @@ -554,6 +579,8 @@ static int qcom_smp2p_remove(struct platform_device *pdev) list_for_each_entry(entry, &smp2p->outbound, node) qcom_smem_state_unregister(entry->state); + mbox_free_channel(smp2p->mbox_chan); + smp2p->out->valid_entries = 0; return 0;