diff options
Diffstat (limited to 'drivers/uio')
-rw-r--r-- | drivers/uio/Kconfig | 18 | ||||
-rw-r--r-- | drivers/uio/Makefile | 1 | ||||
-rw-r--r-- | drivers/uio/uio.c | 25 | ||||
-rw-r--r-- | drivers/uio/uio_aec.c | 175 |
4 files changed, 218 insertions, 1 deletions
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 04b954cfce76..7f86534de269 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig | |||
@@ -58,6 +58,24 @@ config UIO_SMX | |||
58 | 58 | ||
59 | If you compile this as a module, it will be called uio_smx. | 59 | If you compile this as a module, it will be called uio_smx. |
60 | 60 | ||
61 | config UIO_AEC | ||
62 | tristate "AEC video timestamp device" | ||
63 | depends on PCI | ||
64 | default n | ||
65 | help | ||
66 | |||
67 | UIO driver for the Adrienne Electronics Corporation PCI time | ||
68 | code device. | ||
69 | |||
70 | This device differs from other UIO devices since it uses I/O | ||
71 | ports instead of memory mapped I/O. In order to make it | ||
72 | possible for UIO to work with this device a utility, uioport, | ||
73 | can be used to read and write the ports: | ||
74 | |||
75 | git clone git://ifup.org/philips/uioport.git | ||
76 | |||
77 | If you compile this as a module, it will be called uio_aec. | ||
78 | |||
61 | config UIO_SERCOS3 | 79 | config UIO_SERCOS3 |
62 | tristate "Automata Sercos III PCI card driver" | 80 | tristate "Automata Sercos III PCI card driver" |
63 | default n | 81 | default n |
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index e69558149859..5c2586d75797 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile | |||
@@ -3,4 +3,5 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o | |||
3 | obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o | 3 | obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o |
4 | obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o | 4 | obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o |
5 | obj-$(CONFIG_UIO_SMX) += uio_smx.o | 5 | obj-$(CONFIG_UIO_SMX) += uio_smx.o |
6 | obj-$(CONFIG_UIO_AEC) += uio_aec.o | ||
6 | obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o | 7 | obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o |
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 4ca85a113aa2..03efb065455f 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -61,6 +61,14 @@ struct uio_map { | |||
61 | }; | 61 | }; |
62 | #define to_map(map) container_of(map, struct uio_map, kobj) | 62 | #define to_map(map) container_of(map, struct uio_map, kobj) |
63 | 63 | ||
64 | static ssize_t map_name_show(struct uio_mem *mem, char *buf) | ||
65 | { | ||
66 | if (unlikely(!mem->name)) | ||
67 | mem->name = ""; | ||
68 | |||
69 | return sprintf(buf, "%s\n", mem->name); | ||
70 | } | ||
71 | |||
64 | static ssize_t map_addr_show(struct uio_mem *mem, char *buf) | 72 | static ssize_t map_addr_show(struct uio_mem *mem, char *buf) |
65 | { | 73 | { |
66 | return sprintf(buf, "0x%lx\n", mem->addr); | 74 | return sprintf(buf, "0x%lx\n", mem->addr); |
@@ -82,6 +90,8 @@ struct map_sysfs_entry { | |||
82 | ssize_t (*store)(struct uio_mem *, const char *, size_t); | 90 | ssize_t (*store)(struct uio_mem *, const char *, size_t); |
83 | }; | 91 | }; |
84 | 92 | ||
93 | static struct map_sysfs_entry name_attribute = | ||
94 | __ATTR(name, S_IRUGO, map_name_show, NULL); | ||
85 | static struct map_sysfs_entry addr_attribute = | 95 | static struct map_sysfs_entry addr_attribute = |
86 | __ATTR(addr, S_IRUGO, map_addr_show, NULL); | 96 | __ATTR(addr, S_IRUGO, map_addr_show, NULL); |
87 | static struct map_sysfs_entry size_attribute = | 97 | static struct map_sysfs_entry size_attribute = |
@@ -90,6 +100,7 @@ static struct map_sysfs_entry offset_attribute = | |||
90 | __ATTR(offset, S_IRUGO, map_offset_show, NULL); | 100 | __ATTR(offset, S_IRUGO, map_offset_show, NULL); |
91 | 101 | ||
92 | static struct attribute *attrs[] = { | 102 | static struct attribute *attrs[] = { |
103 | &name_attribute.attr, | ||
93 | &addr_attribute.attr, | 104 | &addr_attribute.attr, |
94 | &size_attribute.attr, | 105 | &size_attribute.attr, |
95 | &offset_attribute.attr, | 106 | &offset_attribute.attr, |
@@ -133,6 +144,14 @@ struct uio_portio { | |||
133 | }; | 144 | }; |
134 | #define to_portio(portio) container_of(portio, struct uio_portio, kobj) | 145 | #define to_portio(portio) container_of(portio, struct uio_portio, kobj) |
135 | 146 | ||
147 | static ssize_t portio_name_show(struct uio_port *port, char *buf) | ||
148 | { | ||
149 | if (unlikely(!port->name)) | ||
150 | port->name = ""; | ||
151 | |||
152 | return sprintf(buf, "%s\n", port->name); | ||
153 | } | ||
154 | |||
136 | static ssize_t portio_start_show(struct uio_port *port, char *buf) | 155 | static ssize_t portio_start_show(struct uio_port *port, char *buf) |
137 | { | 156 | { |
138 | return sprintf(buf, "0x%lx\n", port->start); | 157 | return sprintf(buf, "0x%lx\n", port->start); |
@@ -159,6 +178,8 @@ struct portio_sysfs_entry { | |||
159 | ssize_t (*store)(struct uio_port *, const char *, size_t); | 178 | ssize_t (*store)(struct uio_port *, const char *, size_t); |
160 | }; | 179 | }; |
161 | 180 | ||
181 | static struct portio_sysfs_entry portio_name_attribute = | ||
182 | __ATTR(name, S_IRUGO, portio_name_show, NULL); | ||
162 | static struct portio_sysfs_entry portio_start_attribute = | 183 | static struct portio_sysfs_entry portio_start_attribute = |
163 | __ATTR(start, S_IRUGO, portio_start_show, NULL); | 184 | __ATTR(start, S_IRUGO, portio_start_show, NULL); |
164 | static struct portio_sysfs_entry portio_size_attribute = | 185 | static struct portio_sysfs_entry portio_size_attribute = |
@@ -167,6 +188,7 @@ static struct portio_sysfs_entry portio_porttype_attribute = | |||
167 | __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL); | 188 | __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL); |
168 | 189 | ||
169 | static struct attribute *portio_attrs[] = { | 190 | static struct attribute *portio_attrs[] = { |
191 | &portio_name_attribute.attr, | ||
170 | &portio_start_attribute.attr, | 192 | &portio_start_attribute.attr, |
171 | &portio_size_attribute.attr, | 193 | &portio_size_attribute.attr, |
172 | &portio_porttype_attribute.attr, | 194 | &portio_porttype_attribute.attr, |
@@ -686,7 +708,8 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma) | |||
686 | return -EINVAL; | 708 | return -EINVAL; |
687 | 709 | ||
688 | requested_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 710 | requested_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; |
689 | actual_pages = (idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; | 711 | actual_pages = ((idev->info->mem[mi].addr & ~PAGE_MASK) |
712 | + idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; | ||
690 | if (requested_pages > actual_pages) | 713 | if (requested_pages > actual_pages) |
691 | return -EINVAL; | 714 | return -EINVAL; |
692 | 715 | ||
diff --git a/drivers/uio/uio_aec.c b/drivers/uio/uio_aec.c new file mode 100644 index 000000000000..b7830e9a3baa --- /dev/null +++ b/drivers/uio/uio_aec.c | |||
@@ -0,0 +1,175 @@ | |||
1 | /* | ||
2 | * uio_aec.c -- simple driver for Adrienne Electronics Corp time code PCI device | ||
3 | * | ||
4 | * Copyright (C) 2008 Brandon Philips <brandon@ifup.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published | ||
8 | * by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
17 | * Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/pci.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/cdev.h> | ||
26 | #include <linux/fs.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <linux/uaccess.h> | ||
29 | #include <linux/uio_driver.h> | ||
30 | |||
31 | #define PCI_VENDOR_ID_AEC 0xaecb | ||
32 | #define PCI_DEVICE_ID_AEC_VITCLTC 0x6250 | ||
33 | |||
34 | #define INT_ENABLE_ADDR 0xFC | ||
35 | #define INT_ENABLE 0x10 | ||
36 | #define INT_DISABLE 0x0 | ||
37 | |||
38 | #define INT_MASK_ADDR 0x2E | ||
39 | #define INT_MASK_ALL 0x3F | ||
40 | |||
41 | #define INTA_DRVR_ADDR 0xFE | ||
42 | #define INTA_ENABLED_FLAG 0x08 | ||
43 | #define INTA_FLAG 0x01 | ||
44 | |||
45 | #define MAILBOX 0x0F | ||
46 | |||
47 | static struct pci_device_id ids[] = { | ||
48 | { PCI_DEVICE(PCI_VENDOR_ID_AEC, PCI_DEVICE_ID_AEC_VITCLTC), }, | ||
49 | { 0, } | ||
50 | }; | ||
51 | MODULE_DEVICE_TABLE(pci, ids); | ||
52 | |||
53 | static irqreturn_t aectc_irq(int irq, struct uio_info *dev_info) | ||
54 | { | ||
55 | void __iomem *int_flag = dev_info->priv + INTA_DRVR_ADDR; | ||
56 | unsigned char status = ioread8(int_flag); | ||
57 | |||
58 | |||
59 | if ((status & INTA_ENABLED_FLAG) && (status & INTA_FLAG)) { | ||
60 | /* application writes 0x00 to 0x2F to get next interrupt */ | ||
61 | status = ioread8(dev_info->priv + MAILBOX); | ||
62 | return IRQ_HANDLED; | ||
63 | } | ||
64 | |||
65 | return IRQ_NONE; | ||
66 | } | ||
67 | |||
68 | static void print_board_data(struct pci_dev *pdev, struct uio_info *i) | ||
69 | { | ||
70 | dev_info(&pdev->dev, "PCI-TC board vendor: %x%x number: %x%x" | ||
71 | " revision: %c%c\n", | ||
72 | ioread8(i->priv + 0x01), | ||
73 | ioread8(i->priv + 0x00), | ||
74 | ioread8(i->priv + 0x03), | ||
75 | ioread8(i->priv + 0x02), | ||
76 | ioread8(i->priv + 0x06), | ||
77 | ioread8(i->priv + 0x07)); | ||
78 | } | ||
79 | |||
80 | static int __devinit probe(struct pci_dev *pdev, const struct pci_device_id *id) | ||
81 | { | ||
82 | struct uio_info *info; | ||
83 | int ret; | ||
84 | |||
85 | info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); | ||
86 | if (!info) | ||
87 | return -ENOMEM; | ||
88 | |||
89 | if (pci_enable_device(pdev)) | ||
90 | goto out_free; | ||
91 | |||
92 | if (pci_request_regions(pdev, "aectc")) | ||
93 | goto out_disable; | ||
94 | |||
95 | info->name = "aectc"; | ||
96 | info->port[0].start = pci_resource_start(pdev, 0); | ||
97 | if (!info->port[0].start) | ||
98 | goto out_release; | ||
99 | info->priv = pci_iomap(pdev, 0, 0); | ||
100 | if (!info->priv) | ||
101 | goto out_release; | ||
102 | info->port[0].size = pci_resource_len(pdev, 0); | ||
103 | info->port[0].porttype = UIO_PORT_GPIO; | ||
104 | |||
105 | info->version = "0.0.1"; | ||
106 | info->irq = pdev->irq; | ||
107 | info->irq_flags = IRQF_SHARED; | ||
108 | info->handler = aectc_irq; | ||
109 | |||
110 | print_board_data(pdev, info); | ||
111 | ret = uio_register_device(&pdev->dev, info); | ||
112 | if (ret) | ||
113 | goto out_unmap; | ||
114 | |||
115 | iowrite32(INT_ENABLE, info->priv + INT_ENABLE_ADDR); | ||
116 | iowrite8(INT_MASK_ALL, info->priv + INT_MASK_ADDR); | ||
117 | if (!(ioread8(info->priv + INTA_DRVR_ADDR) | ||
118 | & INTA_ENABLED_FLAG)) | ||
119 | dev_err(&pdev->dev, "aectc: interrupts not enabled\n"); | ||
120 | |||
121 | pci_set_drvdata(pdev, info); | ||
122 | |||
123 | return 0; | ||
124 | |||
125 | out_unmap: | ||
126 | pci_iounmap(pdev, info->priv); | ||
127 | out_release: | ||
128 | pci_release_regions(pdev); | ||
129 | out_disable: | ||
130 | pci_disable_device(pdev); | ||
131 | out_free: | ||
132 | kfree(info); | ||
133 | return -ENODEV; | ||
134 | } | ||
135 | |||
136 | static void remove(struct pci_dev *pdev) | ||
137 | { | ||
138 | struct uio_info *info = pci_get_drvdata(pdev); | ||
139 | |||
140 | /* disable interrupts */ | ||
141 | iowrite8(INT_DISABLE, info->priv + INT_MASK_ADDR); | ||
142 | iowrite32(INT_DISABLE, info->priv + INT_ENABLE_ADDR); | ||
143 | /* read mailbox to ensure board drops irq */ | ||
144 | ioread8(info->priv + MAILBOX); | ||
145 | |||
146 | uio_unregister_device(info); | ||
147 | pci_release_regions(pdev); | ||
148 | pci_disable_device(pdev); | ||
149 | pci_set_drvdata(pdev, NULL); | ||
150 | iounmap(info->priv); | ||
151 | |||
152 | kfree(info); | ||
153 | } | ||
154 | |||
155 | static struct pci_driver pci_driver = { | ||
156 | .name = "aectc", | ||
157 | .id_table = ids, | ||
158 | .probe = probe, | ||
159 | .remove = remove, | ||
160 | }; | ||
161 | |||
162 | static int __init aectc_init(void) | ||
163 | { | ||
164 | return pci_register_driver(&pci_driver); | ||
165 | } | ||
166 | |||
167 | static void __exit aectc_exit(void) | ||
168 | { | ||
169 | pci_unregister_driver(&pci_driver); | ||
170 | } | ||
171 | |||
172 | MODULE_LICENSE("GPL"); | ||
173 | |||
174 | module_init(aectc_init); | ||
175 | module_exit(aectc_exit); | ||