13
* $Log: not supported by cvs2svn $
14
* Revision 1.7 2008-01-11 10:18:28 marcus
15
* Modified interrupt mechanism. Added atomic functions and queues, to address race conditions. Removed unused interrupt code.
17
* Revision 1.6 2007-11-04 20:58:22 marcus
18
* Added interrupt generator acknowledge.
19
* Fixed wrong operator.
21
* Revision 1.5 2007-10-31 15:42:21 marcus
22
* Added IG ack for testing, may be removed later.
24
* Revision 1.4 2007-07-17 13:15:56 marcus
26
* Using newest map for the ABB interrupts.
28
* Revision 1.3 2007-07-05 15:30:30 marcus
29
* Added support for both register maps of the ABB.
31
* Revision 1.2 2007-05-29 07:50:18 marcus
32
* Split code into 2 files. May get merged in the future again....
34
* Revision 1.1 2007/03/01 16:57:43 marcus
35
* Divided driver file to ease the interrupt hooks for the user of the driver.
36
* Modified Makefile accordingly.
40
10
#include <linux/version.h>
41
11
#include <linux/string.h>
42
12
#include <linux/types.h>
48
18
#include <linux/sched.h>
49
19
#include <stdbool.h>
55
#include "pciDriver.h"
62
* The ID between IRQ_SOURCE in irq_outstanding and the actual source is arbitrary.
63
* Therefore, be careful when communicating with multiple implementations.
71
/* See ABB user’s guide, register definitions (3.1) */
72
#define ABB_INT_ENABLE (0x0010 >> 2)
73
#define ABB_INT_STAT (0x0008 >> 2)
75
#define ABB_INT_CH1_TIMEOUT (1 << 4)
76
#define ABB_INT_CH0_TIMEOUT (1 << 5)
77
#define ABB_INT_IG (1 << 2)
78
#define ABB_INT_CH0 (1 << 1) /* downstream */
79
#define ABB_INT_CH1 (1) /* upstream */
81
#define ABB_CH0_CTRL (108 >> 2)
82
#define ABB_CH1_CTRL (72 >> 2)
83
#define ABB_CH_RESET (0x0201000A)
84
#define ABB_IG_CTRL (0x0080 >> 2)
85
#define ABB_IG_ACK (0x00F0)
25
* Acknowledges the receival of an interrupt to the card.
27
* @returns true if the card was acknowledget
28
* @returns false if the interrupt was not for one of our cards
30
* @see check_acknowlegde_channel
33
static bool pcidriver_irq_acknowledge(pcidriver_privdata_t *privdata)
37
atomic_inc(&(privdata->irq_outstanding[channel]));
38
wake_up_interruptible(&(privdata->irq_queues[channel]));
45
* Handles IRQs. At the moment, this acknowledges the card that this IRQ
46
* was received and then increases the driver's IRQ counter.
48
* @see pcidriver_irq_acknowledge
51
static irqreturn_t pcidriver_irq_handler(int irq, void *dev_id)
53
pcidriver_privdata_t *privdata = (pcidriver_privdata_t *)dev_id;
55
if (!pcidriver_irq_acknowledge(privdata))
58
privdata->irq_count++;
167
143
privdata->msi_mode = 1;
169
145
/* register interrupt handler */
170
if ((err = request_irq(privdata->pdev->irq, pcidriver_irq_handler, MODNAME, privdata)) != 0) {
146
if ((err = request_irq(privdata->pdev->irq, pcidriver_irq_handler, IRQF_SHARED, MODNAME, privdata)) != 0) {
171
147
mod_info("Error registering the interrupt handler. Disabling interrupts for this device\n");
220
* Acknowledges the receival of an interrupt to the card.
222
* @returns true if the card was acknowledget
223
* @returns false if the interrupt was not for one of our cards
225
* @see check_acknowlegde_channel
228
static bool pcidriver_irq_acknowledge(pcidriver_privdata_t *privdata)
231
// volatile unsigned int *bar;
232
// bar = privdata->bars_kmapped[0];
233
// mod_info_dbg("interrupt registers. ISR: %x, IER: %x\n", bar[ABB_INT_STAT], bar[ABB_INT_ENABLE]);
235
atomic_inc(&(privdata->irq_outstanding[channel]));
236
wake_up_interruptible(&(privdata->irq_queues[channel]));
243
* Handles IRQs. At the moment, this acknowledges the card that this IRQ
244
* was received and then increases the driver's IRQ counter.
246
* @see pcidriver_irq_acknowledge
249
IRQ_HANDLER_FUNC(pcidriver_irq_handler)
251
pcidriver_privdata_t *privdata = (pcidriver_privdata_t *)dev_id;
253
if (!pcidriver_irq_acknowledge(privdata))
256
privdata->irq_count++;