mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Brandon Philips <brandon@ifup.org>,
	"Hans J. Koch" <hjk@linutronix.de>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 36/61] uio: add the uio_aec driver
Date: Tue, 24 Mar 2009 17:26:40 -0700	[thread overview]
Message-ID: <1237940825-22904-36-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20090325001659.GA22461@kroah.com>

From: Brandon Philips <brandon@ifup.org>

UIO driver for the Adrienne Electronics Corporation PCI time code
device.

This device differs from other UIO devices since it uses I/O ports instead of
memory mapped I/O. In order to make it possible for UIO to work with this
device a utility, uioport, can be used to read and write the ports.

uioport is designed to be a setuid program and checks the permissions of
the /dev/uio* node and if the user has write permissions it will use
iopl and out*/in* to access the device.

[1] git clone git://ifup.org/philips/uioport.git

Signed-off-by: Brandon Philips <brandon@ifup.org>
Signed-off-by: Hans J. Koch <hjk@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/uio/Kconfig   |   18 +++++
 drivers/uio/Makefile  |    1 +
 drivers/uio/uio_aec.c |  175 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_aec.c

diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 04b954c..7f86534 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -58,6 +58,24 @@ config UIO_SMX
 
 	  If you compile this as a module, it will be called uio_smx.
 
+config UIO_AEC
+	tristate "AEC video timestamp device"
+	depends on PCI
+	default n
+	help
+
+	  UIO driver for the Adrienne Electronics Corporation PCI time
+	  code device.
+
+	  This device differs from other UIO devices since it uses I/O
+	  ports instead of memory mapped I/O. In order to make it
+	  possible for UIO to work with this device a utility, uioport,
+	  can be used to read and write the ports:
+
+	    git clone git://ifup.org/philips/uioport.git
+
+	  If you compile this as a module, it will be called uio_aec.
+
 config UIO_SERCOS3
 	tristate "Automata Sercos III PCI card driver"
 	default n
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index e695581..5c2586d 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -3,4 +3,5 @@ obj-$(CONFIG_UIO_CIF)	+= uio_cif.o
 obj-$(CONFIG_UIO_PDRV)	+= uio_pdrv.o
 obj-$(CONFIG_UIO_PDRV_GENIRQ)	+= uio_pdrv_genirq.o
 obj-$(CONFIG_UIO_SMX)	+= uio_smx.o
+obj-$(CONFIG_UIO_AEC)	+= uio_aec.o
 obj-$(CONFIG_UIO_SERCOS3)	+= uio_sercos3.o
diff --git a/drivers/uio/uio_aec.c b/drivers/uio/uio_aec.c
new file mode 100644
index 0000000..b7830e9
--- /dev/null
+++ b/drivers/uio/uio_aec.c
@@ -0,0 +1,175 @@
+/*
+ * uio_aec.c -- simple driver for Adrienne Electronics Corp time code PCI device
+ *
+ * Copyright (C) 2008 Brandon Philips <brandon@ifup.org>
+ *
+ *   This program is free software; you can redistribute it and/or modify it
+ *   under the terms of the GNU General Public License version 2 as published
+ *   by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License along
+ *   with this program; if not, write to the Free Software Foundation, Inc., 59
+ *   Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/cdev.h>
+#include <linux/fs.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
+#include <linux/uio_driver.h>
+
+#define PCI_VENDOR_ID_AEC 0xaecb
+#define PCI_DEVICE_ID_AEC_VITCLTC 0x6250
+
+#define INT_ENABLE_ADDR		0xFC
+#define INT_ENABLE		0x10
+#define INT_DISABLE		0x0
+
+#define INT_MASK_ADDR		0x2E
+#define INT_MASK_ALL		0x3F
+
+#define INTA_DRVR_ADDR		0xFE
+#define INTA_ENABLED_FLAG	0x08
+#define INTA_FLAG		0x01
+
+#define MAILBOX			0x0F
+
+static struct pci_device_id ids[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_AEC, PCI_DEVICE_ID_AEC_VITCLTC), },
+	{ 0, }
+};
+MODULE_DEVICE_TABLE(pci, ids);
+
+static irqreturn_t aectc_irq(int irq, struct uio_info *dev_info)
+{
+	void __iomem *int_flag = dev_info->priv + INTA_DRVR_ADDR;
+	unsigned char status = ioread8(int_flag);
+
+
+	if ((status & INTA_ENABLED_FLAG) && (status & INTA_FLAG)) {
+		/* application writes 0x00 to 0x2F to get next interrupt */
+		status = ioread8(dev_info->priv + MAILBOX);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
+static void print_board_data(struct pci_dev *pdev, struct uio_info *i)
+{
+	dev_info(&pdev->dev, "PCI-TC board vendor: %x%x number: %x%x"
+		" revision: %c%c\n",
+		ioread8(i->priv + 0x01),
+		ioread8(i->priv + 0x00),
+		ioread8(i->priv + 0x03),
+		ioread8(i->priv + 0x02),
+		ioread8(i->priv + 0x06),
+		ioread8(i->priv + 0x07));
+}
+
+static int __devinit probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	struct uio_info *info;
+	int ret;
+
+	info = kzalloc(sizeof(struct uio_info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	if (pci_enable_device(pdev))
+		goto out_free;
+
+	if (pci_request_regions(pdev, "aectc"))
+		goto out_disable;
+
+	info->name = "aectc";
+	info->port[0].start = pci_resource_start(pdev, 0);
+	if (!info->port[0].start)
+		goto out_release;
+	info->priv = pci_iomap(pdev, 0, 0);
+	if (!info->priv)
+		goto out_release;
+	info->port[0].size = pci_resource_len(pdev, 0);
+	info->port[0].porttype = UIO_PORT_GPIO;
+
+	info->version = "0.0.1";
+	info->irq = pdev->irq;
+	info->irq_flags = IRQF_SHARED;
+	info->handler = aectc_irq;
+
+	print_board_data(pdev, info);
+	ret = uio_register_device(&pdev->dev, info);
+	if (ret)
+		goto out_unmap;
+
+	iowrite32(INT_ENABLE, info->priv + INT_ENABLE_ADDR);
+	iowrite8(INT_MASK_ALL, info->priv + INT_MASK_ADDR);
+	if (!(ioread8(info->priv + INTA_DRVR_ADDR)
+			& INTA_ENABLED_FLAG))
+		dev_err(&pdev->dev, "aectc: interrupts not enabled\n");
+
+	pci_set_drvdata(pdev, info);
+
+	return 0;
+
+out_unmap:
+	pci_iounmap(pdev, info->priv);
+out_release:
+	pci_release_regions(pdev);
+out_disable:
+	pci_disable_device(pdev);
+out_free:
+	kfree(info);
+	return -ENODEV;
+}
+
+static void remove(struct pci_dev *pdev)
+{
+	struct uio_info *info = pci_get_drvdata(pdev);
+
+	/* disable interrupts */
+	iowrite8(INT_DISABLE, info->priv + INT_MASK_ADDR);
+	iowrite32(INT_DISABLE, info->priv + INT_ENABLE_ADDR);
+	/* read mailbox to ensure board drops irq */
+	ioread8(info->priv + MAILBOX);
+
+	uio_unregister_device(info);
+	pci_release_regions(pdev);
+	pci_disable_device(pdev);
+	pci_set_drvdata(pdev, NULL);
+	iounmap(info->priv);
+
+	kfree(info);
+}
+
+static struct pci_driver pci_driver = {
+	.name = "aectc",
+	.id_table = ids,
+	.probe = probe,
+	.remove = remove,
+};
+
+static int __init aectc_init(void)
+{
+	return pci_register_driver(&pci_driver);
+}
+
+static void __exit aectc_exit(void)
+{
+	pci_unregister_driver(&pci_driver);
+}
+
+MODULE_LICENSE("GPL");
+
+module_init(aectc_init);
+module_exit(aectc_exit);
-- 
1.6.2


  parent reply	other threads:[~2009-03-25  0:43 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-25  0:16 [GIT PATCH] driver core patches for 2.6.30 merge window Greg KH
2009-03-25  0:26 ` [PATCH 01/61] edac: struct device - replace bus_id with dev_name(), dev_set_name() Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 02/61] spi: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 03/61] video: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 04/61] zorro: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 05/61] mmc: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 06/61] mtd: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 07/61] pci: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 08/61] rapidio: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 09/61] s390: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 10/61] serial: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 11/61] sh: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 12/61] tc: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 13/61] pcmcia: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 14/61] rtc: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 15/61] net: " Greg Kroah-Hartman
2009-03-25  3:31   ` Stephen Hemminger
2009-03-25  4:18     ` Greg KH
2009-03-25  6:29   ` David Miller
2009-03-25  9:34     ` Kay Sievers
2009-03-25  0:26 ` [PATCH 16/61] drm: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 17/61] v4l: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 18/61] amba: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 19/61] dio: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 20/61] dma: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 21/61] eisa: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 22/61] gpio: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 23/61] mca: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 24/61] mfd: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 25/61] wimax: " Greg Kroah-Hartman
2009-03-25  1:22   ` Perez-Gonzalez, Inaky
2009-03-25  0:26 ` [PATCH 26/61] usb: " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 27/61] PS3: replace bus_id usage Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 28/61] USB: FHCI: use dev_name() in place of bus_id Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 29/61] driver core: get rid of struct device's bus_id string array Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 30/61] SYSFS: use standard magic.h for sysfs Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 31/61] sysfs: Take sysfs_mutex when fetching the root inode Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 32/61] driver core: check bus->match without holding device lock Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 33/61] platform: make better use of to_platform_{device,driver}() macros Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 34/61] platform: introduce module id table for platform devices Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 35/61] UIO: Add name attributes for mappings and port regions Greg Kroah-Hartman
2009-03-25  0:26 ` Greg Kroah-Hartman [this message]
2009-03-25  0:26 ` [PATCH 37/61] UIO: Take offset into account when determining number of pages that can be mapped Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 38/61] platform driver: fix incorrect use of 'platform_bus_type' with 'struct device_driver' Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 39/61] scsi/m68k: Kill NCR_700_detect() warnings Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 40/61] driver-core: do not register a driver with bus_type not registered Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 41/61] sysfs: sysfs_add_one WARNs with full path to duplicate filename Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 42/61] sysfs: reference sysfs_dirent from sysfs inodes Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 43/61] driver core: remove polling for driver_probe_done(v5) Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 44/61] driver core: create a private portion of struct device Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 45/61] driver core: move klist_children into private structure Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 46/61] driver core: move knode_driver " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 47/61] driver core: move knode_bus " Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 48/61] sysfs: don't block indefinitely for unmapped files Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 49/61] driver core: move platform_data into platform_device Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 50/61] driver core: fix passing platform_data Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 51/61] vcs: hook sysfs devices into object lifetime instead of "binding" Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 52/61] Driver core: implement uevent suppress in kobject Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 53/61] Driver core: some cleanup on drivers/base/sys.c Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 54/61] Driver core: Fix device_move() vs. dpm list ordering, v2 Greg Kroah-Hartman
2009-03-25  0:26 ` [PATCH 55/61] sysfs: only allow one scheduled removal callback per kobj Greg Kroah-Hartman
2009-03-25  0:27 ` [PATCH 56/61] kobject: don't block for each kobject_uevent Greg Kroah-Hartman
2009-03-25  0:27 ` [PATCH 57/61] sysfs: fix some bin_vm_ops errors Greg Kroah-Hartman
2009-03-25  0:27 ` [PATCH 58/61] dynamic debug: combine dprintk and dynamic printk Greg Kroah-Hartman
2009-03-25 10:50   ` Ingo Molnar
2009-03-25 13:20     ` Jason Baron
2009-03-25  0:27 ` [PATCH 59/61] dynamic debug: update docs Greg Kroah-Hartman
2009-03-25  0:27 ` [PATCH 60/61] Dynamic debug: allow simple quoting of words Greg Kroah-Hartman
2009-03-25  0:27 ` [PATCH 61/61] Dynamic debug: fix pr_fmt() build error Greg Kroah-Hartman

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=1237940825-22904-36-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=brandon@ifup.org \
    --cc=hjk@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    /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®