2 * GE PIO2 Counter Driver
4 * Author: Martyn Welch <martyn.welch@ge.com>
5 * Copyright 2009 GE Intelligent Platforms Embedded Systems, Inc.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * The PIO-2 has 6 counters, currently this code just disables the interrupts
13 * and leaves them alone.
17 #include <linux/device.h>
18 #include <linux/types.h>
19 #include <linux/gpio.h>
20 #include <linux/vme.h>
24 static int pio2_cntr_irq_set(struct pio2_card
*card
, int id
)
29 data
= PIO2_CNTR_SC_DEV
[id
] | PIO2_CNTR_RW_BOTH
| card
->cntr
[id
].mode
;
30 retval
= vme_master_write(card
->window
, &data
, 1, PIO2_CNTR_CTRL
[id
]);
34 data
= card
->cntr
[id
].count
& 0xFF;
35 retval
= vme_master_write(card
->window
, &data
, 1, PIO2_CNTR_DATA
[id
]);
39 data
= (card
->cntr
[id
].count
>> 8) & 0xFF;
40 retval
= vme_master_write(card
->window
, &data
, 1, PIO2_CNTR_DATA
[id
]);
47 int pio2_cntr_reset(struct pio2_card
*card
)
52 /* Clear down all timers */
53 for (i
= 0; i
< 6; i
++) {
54 card
->cntr
[i
].mode
= PIO2_CNTR_MODE5
;
55 card
->cntr
[i
].count
= 0;
56 retval
= pio2_cntr_irq_set(card
, i
);
61 /* Ensure all counter interrupts are cleared */
63 retval
= vme_master_read(card
->window
, ®
, 1,
64 PIO2_REGS_INT_STAT_CNTR
);