[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1427277120-16924-9-git-send-email-dengler@linutronix.de>
Date: Wed, 25 Mar 2015 10:51:57 +0100
From: Holger Dengler <dengler@...utronix.de>
To: linux-kernel@...r.kernel.org
Cc: Peter Mahler <mahler@...ug.com>, Juergen Bubeck <bubeck@...ug.com>,
Benedikt Spranger <b.spranger@...utronix.de>,
Holger Dengler <dengler@...utronix.de>,
Samuel Ortiz <sameo@...ux.intel.com>,
Lee Jones <lee.jones@...aro.org>
Subject: [PATCH 08/11] mfd: flexcard: add DMA device
From: Benedikt Spranger <b.spranger@...utronix.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: Holger Dengler <dengler@...utronix.de>
Signed-off-by: Benedikt Spranger <b.spranger@...utronix.de>
cc: Samuel Ortiz <sameo@...ux.intel.com>
cc: Lee Jones <lee.jones@...aro.org>
---
drivers/mfd/flexcard/core.c | 60 +++++++++++++++++++++++++++++++++++++++++
drivers/mfd/flexcard/flexcard.h | 5 ++++
2 files changed, 65 insertions(+)
diff --git a/drivers/mfd/flexcard/core.c b/drivers/mfd/flexcard/core.c
index cd06854..39d1d4d 100644
--- a/drivers/mfd/flexcard/core.c
+++ b/drivers/mfd/flexcard/core.c
@@ -52,6 +52,34 @@ static struct mfd_cell flexcard_clk_dev[] = {
},
};
+static struct resource flexcard_dma_res[] = {
+ {
+ .name = "flexcard-dma",
+ .start = 0x500,
+ .end = 0x580,
+ .flags = IORESOURCE_MEM,
+ }, {
+ .name = "flexcard-dma",
+ .start = FLEXCARD_DMA_IRQ_CBL,
+ .end = FLEXCARD_DMA_IRQ_CBL,
+ .flags = IORESOURCE_IRQ,
+ }, {
+ .name = "flexcard-dma",
+ .start = FLEXCARD_DMA_IRQ_CO,
+ .end = FLEXCARD_DMA_IRQ_CO,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct mfd_cell flexcard_dma_dev[] = {
+ {
+ .id = 0,
+ .name = "flexcard-dma",
+ .num_resources = ARRAY_SIZE(flexcard_dma_res),
+ .resources = flexcard_dma_res,
+ },
+};
+
irq_res(CC1CCYS);
irq_res(CC2CCYS);
irq_res(CC3CCYS);
@@ -187,6 +215,32 @@ static int flexcard_clk_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;
+
+ /* check for a DMA capable firmware version*/
+ if (priv->conf->fc_fw_ver.maj < DMA_MIN_FW_MAJOR)
+ goto out;
+
+ if (priv->conf->fc_fw_ver.maj == DMA_MIN_FW_MAJOR) {
+ if (priv->conf->fc_fw_ver.min < DMA_MIN_FW_MINOR)
+ goto out;
+ if ((priv->conf->fc_fw_ver.min == DMA_MIN_FW_MINOR) &&
+ (priv->conf->fc_fw_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_add_uio(struct flexcard_device *priv)
{
struct pci_dev *pdev = priv->pdev;
@@ -330,6 +384,12 @@ static int flexcard_probe(struct pci_dev *pdev,
goto out_remove;
}
+ ret = flexcard_add_dma(priv);
+ if (ret) {
+ dev_err(&pdev->dev, "unable to add DMA device: %d", ret);
+ goto out_remove;
+ }
+
ret = flexcard_add_uio(priv);
if (ret) {
dev_err(&pdev->dev, "unable to add irq UIO devices: %d", ret);
diff --git a/drivers/mfd/flexcard/flexcard.h b/drivers/mfd/flexcard/flexcard.h
index 0d05f78..ee6b773 100644
--- a/drivers/mfd/flexcard/flexcard.h
+++ b/drivers/mfd/flexcard/flexcard.h
@@ -1,6 +1,11 @@
#ifndef __FLEXCARD_H
#define __FLEXCARD_H
+/* 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
+
int flexcard_misc_add_attrs(struct device *dev);
void flexcard_misc_del_attrs(struct device *dev);
int flexcard_setup_irq(struct pci_dev *pdev);
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists