From patchwork Fri Feb 19 16:01:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 62353 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1245452lbl; Fri, 19 Feb 2016 08:02:25 -0800 (PST) X-Received: by 10.66.62.134 with SMTP id y6mr19032732par.43.1455897739263; Fri, 19 Feb 2016 08:02:19 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m23si17303348pfj.133.2016.02.19.08.02.18; Fri, 19 Feb 2016 08:02:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1428051AbcBSQCG (ORCPT + 30 others); Fri, 19 Feb 2016 11:02:06 -0500 Received: from foss.arm.com ([217.140.101.70]:47010 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1427118AbcBSQBg (ORCPT ); Fri, 19 Feb 2016 11:01:36 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 58BFD4FD; Fri, 19 Feb 2016 08:00:45 -0800 (PST) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.207.150]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5E3B73F21A; Fri, 19 Feb 2016 08:01:35 -0800 (PST) From: Sudeep Holla To: Jassi Brar , linux-kernel@vger.kernel.org Cc: Sudeep Holla , Lee Jones Subject: [PATCH v2 4/4] mailbox: mailbox-test: add support for separate tx/rx buffer with single channel Date: Fri, 19 Feb 2016 16:01:18 +0000 Message-Id: <1455897678-28424-5-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455897678-28424-1-git-send-email-sudeep.holla@arm.com> References: <1455897678-28424-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds support for different MMIO region for Tx and Rx paths. If only one region is specified, it's assumed to be shared between Rx and Tx, thereby retaining backward compatibility. Also in order to support single channel dealing with both Tx and Rx with dedicated MMIO regions, Tx channel itself is assigned to Rx if MMIO regions are different and Rx is not specified. Cc: Jassi Brar Acked-by: Lee Jones Signed-off-by: Sudeep Holla --- drivers/mailbox/mailbox-test.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) -- 1.9.1 diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index f690f11969a1..dc11bbf27274 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -31,7 +31,8 @@ static struct dentry *root_debugfs_dir; struct mbox_test_device { struct device *dev; - void __iomem *mmio; + void __iomem *tx_mmio; + void __iomem *rx_mmio; struct mbox_chan *tx_channel; struct mbox_chan *rx_channel; char *rx_buffer; @@ -112,7 +113,7 @@ static ssize_t mbox_test_message_write(struct file *filp, * A separate signal is only of use if there is * MMIO to subsequently pass the message through */ - if (tdev->mmio && tdev->signal) { + if (tdev->tx_mmio && tdev->signal) { print_hex_dump_bytes("Client: Sending: Signal: ", DUMP_PREFIX_ADDRESS, tdev->signal, MBOX_MAX_SIG_LEN); @@ -220,8 +221,8 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message) unsigned long flags; spin_lock_irqsave(&tdev->lock, flags); - if (tdev->mmio) { - memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN); + if (tdev->rx_mmio) { + memcpy_fromio(tdev->rx_buffer, tdev->rx_mmio, MBOX_MAX_MSG_LEN); print_hex_dump_bytes("Client: Received [MMIO]: ", DUMP_PREFIX_ADDRESS, tdev->rx_buffer, MBOX_MAX_MSG_LEN); } else if (message) { @@ -236,11 +237,11 @@ static void mbox_test_prepare_message(struct mbox_client *client, void *message) { struct mbox_test_device *tdev = dev_get_drvdata(client->dev); - if (tdev->mmio) { + if (tdev->tx_mmio) { if (tdev->signal) - memcpy_toio(tdev->mmio, tdev->message, MBOX_MAX_MSG_LEN); + memcpy_toio(tdev->tx_mmio, tdev->message, MBOX_MAX_MSG_LEN); else - memcpy_toio(tdev->mmio, message, MBOX_MAX_MSG_LEN); + memcpy_toio(tdev->tx_mmio, message, MBOX_MAX_MSG_LEN); } } @@ -294,9 +295,15 @@ static int mbox_test_probe(struct platform_device *pdev) /* It's okay for MMIO to be NULL */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - tdev->mmio = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(tdev->mmio)) - tdev->mmio = NULL; + tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(tdev->tx_mmio)) + tdev->tx_mmio = NULL; + + /* If specified, second reg entry is Rx MMIO */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(tdev->rx_mmio)) + tdev->rx_mmio = tdev->tx_mmio; tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); tdev->rx_channel = mbox_test_request_channel(pdev, "rx"); @@ -304,6 +311,10 @@ static int mbox_test_probe(struct platform_device *pdev) if (!tdev->tx_channel && !tdev->rx_channel) return -EPROBE_DEFER; + /* If Rx is not specified but has Rx MMIO, then Rx = Tx */ + if (!tdev->rx_channel && (tdev->rx_mmio != tdev->tx_mmio)) + tdev->rx_channel = tdev->tx_channel; + tdev->dev = &pdev->dev; platform_set_drvdata(pdev, tdev);