From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751628AbbCYJxr (ORCPT ); Wed, 25 Mar 2015 05:53:47 -0400 Received: from www.linutronix.de ([62.245.132.108]:50573 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752514AbbCYJws (ORCPT ); Wed, 25 Mar 2015 05:52:48 -0400 From: Holger Dengler To: linux-kernel@vger.kernel.org Cc: Peter Mahler , Juergen Bubeck , Benedikt Spranger , Holger Dengler , Samuel Ortiz , Lee Jones Subject: [PATCH 08/11] mfd: flexcard: add DMA device Date: Wed, 25 Mar 2015 10:51:57 +0100 Message-Id: <1427277120-16924-9-git-send-email-dengler@linutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427277120-16924-1-git-send-email-dengler@linutronix.de> References: <1427277120-16924-1-git-send-email-dengler@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benedikt Spranger 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 Signed-off-by: Benedikt Spranger cc: Samuel Ortiz cc: Lee Jones --- 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