mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Holger Dengler <dengler@linutronix.de>
To: Lee Jones <lee.jones@linaro.org>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Vinod Koul <vinod.koul@intel.com>
Cc: linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Siewior <bigeasy@linutronix.de>,
	Juergen Bubeck <bubeck@xkrug.com>,
	Peter Mahler <mahler@xkrug.com>,
	Holger Dengler <dengler@linutronix.de>,
	Benedikt Spranger <b.spranger@linutronix.de>
Subject: [PATCH 06/12] mfd: flexcard: add DMA device
Date: Wed, 14 Dec 2016 01:11:47 +0100	[thread overview]
Message-ID: <1481674313-30378-7-git-send-email-dengler@linutronix.de> (raw)
In-Reply-To: <1481674313-30378-1-git-send-email-dengler@linutronix.de>

The Flexcard interface design split packet receive and transmit. All
received packets and card status information are multiplexed with a
Flexcard specific protocol and handled through a DMA capable ringbuffer.
The TX path has to poke each available component separate.

Add a platform device for the DMA receive channel.

Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
Signed-off-by: Holger Dengler <dengler@linutronix.de>
cc: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/flexcard_core.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/drivers/mfd/flexcard_core.c b/drivers/mfd/flexcard_core.c
index b7aead5..55bcfec 100644
--- a/drivers/mfd/flexcard_core.c
+++ b/drivers/mfd/flexcard_core.c
@@ -32,11 +32,41 @@
 #define FLEXCARD_CLKRST_SIZE	0x3
 #define FLEXCARD_NF_START	0x170
 #define FLEXCARD_NF_SIZE	0x7
+#define FLEXCARD_DMA_START	0x500
+#define FLEXCARD_DMA_SIZE	0x80
 #define FLEXCARD_CLK_START	0x700
 #define FLEXCARD_CLK_SIZE	0x13
 
+#define FLEXCARD_DMA_IRQ_CO	0
+#define FLEXCARD_DMA_IRQ_TE	1
+#define FLEXCARD_DMA_IRQ_TI	2
+#define FLEXCARD_DMA_IRQ_CBL	3
+
+/* The first FW Version supporting DMA is 6.4.0 */
+#define DMA_MIN_FW_MAJOR	6
+#define DMA_MIN_FW_MINOR	4
+#define DMA_MIN_FW_UPDATE	0
+
 static DEFINE_IDA(flexcard_ida);
 
+static struct resource flexcard_dma_res[] = {
+	DEFINE_RES_MEM_NAMED(FLEXCARD_DMA_START,
+			     FLEXCARD_DMA_SIZE,
+			     "flexcard-dma"),
+	DEFINE_RES_IRQ_NAMED(FLEXCARD_DMA_IRQ_CBL,
+			     "flexcard-dma-cbl"),
+	DEFINE_RES_IRQ_NAMED(FLEXCARD_DMA_IRQ_CO,
+			     "flexcard-dma-co"),
+};
+
+static struct mfd_cell flexcard_dma_dev[] = {
+	{
+		.name = "flexcard-dma",
+		.num_resources = ARRAY_SIZE(flexcard_dma_res),
+		.resources = flexcard_dma_res,
+	},
+};
+
 static struct resource flexcard_clk_res[] = {
 	DEFINE_RES_MEM_NAMED(FLEXCARD_CLK_START,
 			     FLEXCARD_CLK_SIZE,
@@ -102,6 +132,37 @@ static int flexcard_misc_setup(struct flexcard_device *priv)
 			       &pdev->resource[0], 0, NULL);
 }
 
+static int flexcard_add_dma(struct flexcard_device *priv)
+{
+	struct pci_dev *pdev = priv->pdev;
+	union {
+		struct fc_version ver;
+		u32 reg;
+	} fw_ver;
+
+	/* check for a DMA capable firmware version*/
+	fw_ver.reg = readl(&priv->bar0->conf.fc_fw_ver);
+	if (fw_ver.ver.maj < DMA_MIN_FW_MAJOR)
+		goto out;
+
+	if (fw_ver.ver.maj == DMA_MIN_FW_MAJOR) {
+		if (fw_ver.ver.min < DMA_MIN_FW_MINOR)
+			goto out;
+		if ((fw_ver.ver.min == DMA_MIN_FW_MINOR) &&
+		    (fw_ver.ver.dev < DMA_MIN_FW_UPDATE))
+			goto out;
+	}
+
+	return mfd_add_devices(&pdev->dev, 0, flexcard_dma_dev,
+			       ARRAY_SIZE(flexcard_dma_dev),
+			       &pdev->resource[0], 0, priv->dma_domain);
+
+out:
+	dev_info(&pdev->dev, "Firmware is not DMA capable\n");
+
+	return 0;
+}
+
 static int flexcard_tiny_can(struct flexcard_device *priv,
 			     int idx, int id, u32 offset)
 {
@@ -267,6 +328,12 @@ static int flexcard_probe(struct pci_dev *pdev,
 		goto out_mfd_dev_remove;
 	}
 
+	ret = flexcard_add_dma(priv);
+	if (ret) {
+		dev_err(&pdev->dev, "unable to add DMA device: %d", ret);
+		goto out_mfd_dev_remove;
+	}
+
 	dev_info(&pdev->dev, "HW %02x.%02x.%02x FW %02x.%02x.%02x\n",
 		 hw_ver.ver.maj, hw_ver.ver.min, hw_ver.ver.dev,
 		 fw_ver.ver.maj, fw_ver.ver.min, fw_ver.ver.dev);
-- 
2.1.4

  parent reply	other threads:[~2016-12-14  0:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14  0:11 [PATCH 00/12] Eberspaecher Flexcard PMC II base support Holger Dengler
2016-12-14  0:11 ` [PATCH 01/12] mfd: Eberspaecher Flexcard PMC II Carrier Board support Holger Dengler
2016-12-14  8:38   ` Arnd Bergmann
2017-01-05 13:52     ` Holger Dengler
2016-12-14  0:11 ` [PATCH 02/12] mfd: flexcard: add flexcard misc mfd-cell Holger Dengler
2016-12-14  0:11 ` [PATCH 03/12] mfd: flexcard: add posix clock mfd-cell Holger Dengler
2016-12-14  0:11 ` [PATCH 04/12] mfd: flexcard: add interrupt support Holger Dengler
2016-12-14  2:47   ` kbuild test robot
2016-12-14  3:37   ` kbuild test robot
2016-12-14  0:11 ` [PATCH 05/12] mfd: flexcard: add DMA interrupts Holger Dengler
2016-12-14  3:08   ` kbuild test robot
2016-12-14  0:11 ` Holger Dengler [this message]
2016-12-14  0:11 ` [PATCH 07/12] mfd: flexcard: add UIO IRQ devices Holger Dengler
2016-12-14  0:11 ` [PATCH 08/12] misc: Flexcard misc device support Holger Dengler
2016-12-14  8:42   ` Arnd Bergmann
2016-12-14  9:28     ` Holger Dengler
2017-01-10 16:59       ` Greg Kroah-Hartman
2016-12-14  0:11 ` [PATCH 09/12] misc: flexcard: add device attributes Holger Dengler
2016-12-14  1:33   ` kbuild test robot
2017-01-10 16:58   ` Greg Kroah-Hartman
2016-12-14  0:11 ` [PATCH 10/12] misc: Flexcard basic timestamp counter support Holger Dengler
2016-12-14  3:28   ` kbuild test robot
2016-12-14  8:46   ` Arnd Bergmann
2016-12-14  9:16     ` Thomas Gleixner
2016-12-14  0:11 ` [PATCH 11/12] misc: flexcard: Support timestamp trigger selection Holger Dengler
2016-12-14  0:11 ` [PATCH 12/12] dma: Flexcard DMA ringbuffer demux driver Holger Dengler
2016-12-14  1:54   ` kbuild test robot
2016-12-15  4:38   ` Vinod Koul
2016-12-19 10:54     ` Holger Dengler
2017-01-04  9:43 ` [PATCH 00/12] Eberspaecher Flexcard PMC II base support Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481674313-30378-7-git-send-email-dengler@linutronix.de \
    --to=dengler@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=b.spranger@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=bubeck@xkrug.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mahler@xkrug.com \
    --cc=tglx@linutronix.de \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®