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 07/12] mfd: flexcard: add UIO IRQ devices
Date: Wed, 14 Dec 2016 01:11:48 +0100	[thread overview]
Message-ID: <1481674313-30378-8-git-send-email-dengler@linutronix.de> (raw)
In-Reply-To: <1481674313-30378-1-git-send-email-dengler@linutronix.de>

Add an UIO device for each Flexcard Flexray related trigger. The trigger
devide into:
 - Flexray cycle start (CCYS)
 - Flexray timer 0 (CCxT0)
 - Bus wakeup (WAKE)

The UIO IRQ devices can be used to synchronize an application
with these events.

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 | 85 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/drivers/mfd/flexcard_core.c b/drivers/mfd/flexcard_core.c
index 55bcfec..fc5b033 100644
--- a/drivers/mfd/flexcard_core.c
+++ b/drivers/mfd/flexcard_core.c
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/uio_driver.h>
 
 #include <linux/mfd/core.h>
 #include <linux/mfd/flexcard.h>
@@ -47,6 +48,46 @@
 #define DMA_MIN_FW_MINOR	4
 #define DMA_MIN_FW_UPDATE	0
 
+#define FLEXCARD_IRQ_CC1CCYS_OFF	0
+#define FLEXCARD_IRQ_CC2CCYS_OFF	1
+#define FLEXCARD_IRQ_CC3CCYS_OFF	2
+#define FLEXCARD_IRQ_CC4CCYS_OFF	3
+#define FLEXCARD_IRQ_WAKE4A_OFF		4
+#define FLEXCARD_IRQ_WAKE4B_OFF		5
+#define FLEXCARD_IRQ_WAKE3A_OFF		6
+#define FLEXCARD_IRQ_WAKE3B_OFF		7
+#define FLEXCARD_IRQ_WAKE2A_OFF		8
+#define FLEXCARD_IRQ_WAKE2B_OFF		9
+#define FLEXCARD_IRQ_WAKE1A_OFF		10
+#define FLEXCARD_IRQ_WAKE1B_OFF		11
+#define FLEXCARD_IRQ_CC1T0_OFF		12
+#define FLEXCARD_IRQ_CC2T0_OFF		13
+#define FLEXCARD_IRQ_CC3T0_OFF		14
+#define FLEXCARD_IRQ_CC4T0_OFF		15
+
+#define flexcard_irq_resource(irq_name)					\
+	static struct resource flexcard_irq_res_##irq_name = {		\
+		.name = __stringify(fc_irq_##irq_name##_off),		\
+		.start  = FLEXCARD_IRQ_##irq_name##_OFF,		\
+		.end  = FLEXCARD_IRQ_##irq_name##_OFF,			\
+		.flags  = IORESOURCE_IRQ,				\
+	};								\
+									\
+	static struct uio_info flexcard_irq_pdata_##irq_name = {	\
+		.name   = __stringify(irq_name),			\
+		.version = "0",						\
+	}
+
+#define flexcard_irq_cell(irq_name, irq_id)				\
+	{								\
+		.id = irq_id,						\
+		.name = "uio_pdrv_genirq",				\
+		.platform_data = &flexcard_irq_pdata_##irq_name,	\
+		.pdata_size = sizeof(flexcard_irq_pdata_##irq_name),	\
+		.num_resources = 1,					\
+		.resources = &flexcard_irq_res_##irq_name		\
+	}
+
 static DEFINE_IDA(flexcard_ida);
 
 static struct resource flexcard_dma_res[] = {
@@ -163,6 +204,42 @@ static int flexcard_add_dma(struct flexcard_device *priv)
 	return 0;
 }
 
+flexcard_irq_resource(CC1CCYS);
+flexcard_irq_resource(CC2CCYS);
+flexcard_irq_resource(CC3CCYS);
+flexcard_irq_resource(CC4CCYS);
+flexcard_irq_resource(WAKE4A);
+flexcard_irq_resource(WAKE4B);
+flexcard_irq_resource(WAKE3A);
+flexcard_irq_resource(WAKE3B);
+flexcard_irq_resource(WAKE2A);
+flexcard_irq_resource(WAKE2B);
+flexcard_irq_resource(WAKE1A);
+flexcard_irq_resource(WAKE1B);
+flexcard_irq_resource(CC1T0);
+flexcard_irq_resource(CC2T0);
+flexcard_irq_resource(CC3T0);
+flexcard_irq_resource(CC4T0);
+
+static struct mfd_cell flexcard_uio_dev[] = {
+	flexcard_irq_cell(CC3CCYS, 0),
+	flexcard_irq_cell(CC4CCYS, 1),
+	flexcard_irq_cell(WAKE4A, 2),
+	flexcard_irq_cell(WAKE4B, 3),
+	flexcard_irq_cell(WAKE3A, 4),
+	flexcard_irq_cell(WAKE3B, 5),
+	flexcard_irq_cell(WAKE2A, 6),
+	flexcard_irq_cell(WAKE2B, 7),
+	flexcard_irq_cell(WAKE1A, 8),
+	flexcard_irq_cell(WAKE1B, 9),
+	flexcard_irq_cell(CC1CCYS, 10),
+	flexcard_irq_cell(CC2CCYS, 11),
+	flexcard_irq_cell(CC1T0, 12),
+	flexcard_irq_cell(CC2T0, 13),
+	flexcard_irq_cell(CC3T0, 14),
+	flexcard_irq_cell(CC4T0, 15),
+};
+
 static int flexcard_tiny_can(struct flexcard_device *priv,
 			     int idx, int id, u32 offset)
 {
@@ -334,6 +411,14 @@ static int flexcard_probe(struct pci_dev *pdev,
 		goto out_mfd_dev_remove;
 	}
 
+	ret = mfd_add_devices(&pdev->dev, 0, flexcard_uio_dev,
+			      ARRAY_SIZE(flexcard_uio_dev),
+			      NULL, 0, priv->irq_domain);
+	if (ret) {
+		dev_err(&pdev->dev, "unable to add irq UIO devices: %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 ` [PATCH 06/12] mfd: flexcard: add DMA device Holger Dengler
2016-12-14  0:11 ` Holger Dengler [this message]
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-8-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®