4 * @brief 8254 counter implementation.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
10 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
12 * This file is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include "mesubdevice.h"
36 * @brief The 8254 subdevice class.
38 typedef struct me8254_subdevice {
40 me_subdevice_t base; /**< The subdevice base class. */
43 spinlock_t subdevice_lock; /**< Spin lock to protect the subdevice from concurrent access. */
45 spinlock_t *ctrl_reg_lock; /**< Spin lock to protect the control register from concurrent access. */
46 spinlock_t *clk_src_reg_lock; /**< Spin lock to protect the clock source register from concurrent access. */
48 uint32_t device_id; /**< The Meilhaus device type carrying the 8254 chip. */
49 int me8254_idx; /**< The index of the 8254 chip on the device. */
50 int ctr_idx; /**< The index of the counter on the 8254 chip. */
52 int caps; /**< Holds the device capabilities. */
54 unsigned long val_reg; /**< Holds the actual counter value. */
55 unsigned long ctrl_reg; /**< Register to configure the 8254 modes. */
56 unsigned long clk_src_reg; /**< Register to configure the counter connections. */
60 * @brief The constructor to generate a 8254 instance.
62 * @param device_id The kind of Meilhaus device holding the 8254.
63 * @param reg_base The register base address of the device as returned by the PCI BIOS.
64 * @param me8254_idx The index of the 8254 chip on the Meilhaus device.
65 * @param ctr_idx The index of the counter inside a 8254 chip.
66 * @param ctrl_reg_lock Pointer to spin lock protecting the 8254 control register from concurrent access.
67 * @param clk_src_reg_lock Pointer to spin lock protecting the clock source register from concurrent access.
69 * @return Pointer to new instance on success.\n
72 me8254_subdevice_t *me8254_constructor(uint32_t device_id,
74 unsigned int me8254_idx,
76 spinlock_t * ctrl_reg_lock,
77 spinlock_t * clk_src_reg_lock);