David Kiliani | 3fedd14 | 2008-11-01 00:39:12 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @file me8254.h |
| 3 | * |
| 4 | * @brief 8254 counter implementation. |
| 5 | * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de) |
| 6 | * @author Guenter Gebhardt |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de) |
| 11 | * |
| 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. |
| 16 | * |
| 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. |
| 21 | * |
| 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. |
| 25 | */ |
| 26 | |
| 27 | #ifndef _ME8254_H_ |
| 28 | #define _ME8254_H_ |
| 29 | |
| 30 | #include "mesubdevice.h" |
| 31 | #include "meslock.h" |
| 32 | |
| 33 | #ifdef __KERNEL__ |
| 34 | |
| 35 | /** |
| 36 | * @brief The 8254 subdevice class. |
| 37 | */ |
| 38 | typedef struct me8254_subdevice { |
| 39 | /* Inheritance */ |
| 40 | me_subdevice_t base; /**< The subdevice base class. */ |
| 41 | |
| 42 | /* Attributes */ |
| 43 | spinlock_t subdevice_lock; /**< Spin lock to protect the subdevice from concurrent access. */ |
| 44 | |
| 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. */ |
| 47 | |
| 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. */ |
| 51 | |
| 52 | int caps; /**< Holds the device capabilities. */ |
| 53 | |
| 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. */ |
| 57 | } me8254_subdevice_t; |
| 58 | |
| 59 | /** |
| 60 | * @brief The constructor to generate a 8254 instance. |
| 61 | * |
| 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. |
| 68 | * |
| 69 | * @return Pointer to new instance on success.\n |
| 70 | * NULL on error. |
| 71 | */ |
| 72 | me8254_subdevice_t *me8254_constructor(uint32_t device_id, |
| 73 | uint32_t reg_base, |
| 74 | unsigned int me8254_idx, |
| 75 | unsigned int ctr_idx, |
| 76 | spinlock_t * ctrl_reg_lock, |
| 77 | spinlock_t * clk_src_reg_lock); |
| 78 | |
| 79 | #endif |
| 80 | #endif |