lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1427277120-16924-8-git-send-email-dengler@linutronix.de>
Date:	Wed, 25 Mar 2015 10:51:56 +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 07/11] mfd: flexcard: add UIO IRQ devices

From: Benedikt Spranger <b.spranger@...utronix.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: 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     | 52 +++++++++++++++++++++++++++++++++++++++++
 drivers/mfd/flexcard/flexcard.h | 23 ++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/drivers/mfd/flexcard/core.c b/drivers/mfd/flexcard/core.c
index a6f92b4..cd06854 100644
--- a/drivers/mfd/flexcard/core.c
+++ b/drivers/mfd/flexcard/core.c
@@ -19,6 +19,7 @@
 #include <linux/miscdevice.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>
 
@@ -51,6 +52,42 @@ static struct mfd_cell flexcard_clk_dev[] = {
 	},
 };
 
+irq_res(CC1CCYS);
+irq_res(CC2CCYS);
+irq_res(CC3CCYS);
+irq_res(CC4CCYS);
+irq_res(WAKE4A);
+irq_res(WAKE4B);
+irq_res(WAKE3A);
+irq_res(WAKE3B);
+irq_res(WAKE2A);
+irq_res(WAKE2B);
+irq_res(WAKE1A);
+irq_res(WAKE1B);
+irq_res(CC1T0);
+irq_res(CC2T0);
+irq_res(CC3T0);
+irq_res(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)
 {
@@ -150,6 +187,15 @@ static int flexcard_clk_setup(struct flexcard_device *priv)
 			       &pdev->resource[0], 0, NULL);
 }
 
+static int flexcard_add_uio(struct flexcard_device *priv)
+{
+	struct pci_dev *pdev = priv->pdev;
+
+	return mfd_add_devices(&pdev->dev, 0, flexcard_uio_dev,
+			       ARRAY_SIZE(flexcard_uio_dev),
+			       NULL, 0, priv->irq_domain);
+}
+
 static int flexcard_misc_open(struct inode *inode, struct file *filp)
 {
 	struct flexcard_device *priv =
@@ -284,6 +330,12 @@ static int flexcard_probe(struct pci_dev *pdev,
 		goto out_remove;
 	}
 
+	ret = flexcard_add_uio(priv);
+	if (ret) {
+		dev_err(&pdev->dev, "unable to add irq UIO devices: %d", ret);
+		goto out_remove;
+	}
+
 	ret = misc_register(&priv->dev);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to register miscdevice: %d\n", ret);
diff --git a/drivers/mfd/flexcard/flexcard.h b/drivers/mfd/flexcard/flexcard.h
index 038c138..0d05f78 100644
--- a/drivers/mfd/flexcard/flexcard.h
+++ b/drivers/mfd/flexcard/flexcard.h
@@ -6,4 +6,27 @@ void flexcard_misc_del_attrs(struct device *dev);
 int flexcard_setup_irq(struct pci_dev *pdev);
 void flexcard_remove_irq(struct pci_dev *pdev);
 
+#define irq_res(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		\
+	}
+
 #endif /* __FLEXCARD_H */
-- 
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ