13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <linux/errno.h>
20 #include <linux/device.h>
21 #include <linux/ctype.h>
23 #include <linux/slab.h>
36 static int vector_num;
40 static int variant_num;
44 static int pio2_match(
struct vme_dev *);
72 card->
led = state ? 1 : 0;
95 PIO2_REGS_INT_STAT[vec - 1]);
98 "Unable to read IRQ status register\n");
101 for (i = 0; i < 8; i++) {
102 channel = ((vec - 1) * 8) +
i;
103 if (reg & PIO2_CHANNEL_BIT[channel])
105 "Interrupt on I/O channel %d\n",
117 "Counter interrupt\n");
127 static int pio2_reset_card(
struct pio2_card *card)
163 static int __init pio2_init(
void)
168 pr_err(
"No cards, skipping registration\n");
173 pr_err(
"Driver only able to handle %d PIO2 Cards\n",
190 static int pio2_match(
struct vme_dev *vdev)
193 if (vdev->
num >= bus_num) {
195 "The enumeration of the VMEbus to which the board is connected must be specified");
199 if (vdev->
num >= base_num) {
201 "The VME address for the cards registers must be specified");
205 if (vdev->
num >= vector_num) {
207 "The IRQ vector used by the card must be specified");
211 if (vdev->
num >= level_num) {
213 "The IRQ level used by the card must be specified");
217 if (vdev->
num >= variant_num) {
218 dev_err(&vdev->
dev,
"The variant of the card must be specified");
235 dev_err(&vdev->
dev,
"Unable to allocate card structure\n");
240 card->
id = vdev->
num;
263 "Invalid VME IRQ Vector, vector must not use lower 4 bits\n");
303 "Unable to assign VME master resource\n");
312 "Unable to configure VME master resource\n");
324 dev_err(&card->
vdev->dev,
"Unable to read from device\n");
328 dev_dbg(&card->
vdev->dev,
"ID Register:%x\n", reg);
335 retval = pio2_reset_card(card);
338 "Failed to reset card, is location valid?");
345 if (pio2_get_led(card))
363 &pio2_int, (
void *)card);
366 "Unable to attach VME interrupt vector0x%x, level 0x%x\n",
372 for (i = 0; i < 4; i++) {
376 &pio2_int, (
void *)card);
379 "Unable to attach VME interrupt vector0x%x, level 0x%x\n",
386 for (i = 0; i < 6; i++) {
390 &pio2_int, (
void *)card);
393 "Unable to attach VME interrupt vector0x%x, level 0x%x\n",
403 "Unable to register with GPIO framework\n");
408 retval = pio2_set_led(card, 0);
417 "PIO2 (variant %s) configured at 0x%lx\n", card->
variant,
444 pio2_reset_card(card);
467 for (i = 0; i < 6; i++) {
472 for (i = 0; i < 4; i++) {
480 pio2_reset_card(card);
491 static void __exit pio2_exit(
void)