Staging: meilhaus: some checkpatch.pl cleanup
[safe/jmp/linux-2.6] / drivers / staging / meilhaus / me1400_device.h
1 /**
2  * @file me1400_device.c
3  *
4  * @brief ME-1400 device family instance.
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 _ME1400_DEVICE_H_
28 #define _ME1400_DEVICE_H_
29
30 #include "metypes.h"
31 #include "medefines.h"
32 #include "meinternal.h"
33
34 #include "medevice.h"
35
36 #ifdef __KERNEL__
37
38 /**
39  * @brief Structure to store device capabilities.
40  */
41 typedef struct me1400_version {
42         uint16_t device_id;                                     /**< The PCI device id of the device. */
43         unsigned int dio_chips;                         /**< The number of 8255 chips on the device. */
44         unsigned int ctr_chips;                         /**< The number of 8254 chips on the device. */
45         unsigned int ext_irq_subdevices;        /**< The number of external interrupt inputs on the device. */
46 } me1400_version_t;
47
48 /**
49   * @brief Defines for each ME-1400 device version its capabilities.
50  */
51 static me1400_version_t me1400_versions[] = {
52         {PCI_DEVICE_ID_MEILHAUS_ME1400, 1, 0, 0},
53         {PCI_DEVICE_ID_MEILHAUS_ME140A, 1, 1, 1},
54         {PCI_DEVICE_ID_MEILHAUS_ME140B, 2, 2, 1},
55         {PCI_DEVICE_ID_MEILHAUS_ME14E0, 1, 0, 0},
56         {PCI_DEVICE_ID_MEILHAUS_ME14EA, 1, 1, 1},
57         {PCI_DEVICE_ID_MEILHAUS_ME14EB, 2, 2, 1},
58         {PCI_DEVICE_ID_MEILHAUS_ME140C, 1, 5, 1},
59         {PCI_DEVICE_ID_MEILHAUS_ME140D, 2, 10, 1},
60         {0}
61 };
62
63 #define ME1400_DEVICE_VERSIONS (sizeof(me1400_versions) / sizeof(me1400_version_t) - 1) /**< Returns the number of entries in #me1400_versions. */
64
65 /**
66  * @brief Returns the index of the device entry in #me1400_versions.
67  *
68  * @param device_id The PCI device id of the device to query.
69  * @return The index of the device in #me1400_versions.
70  */
71 static inline unsigned int me1400_versions_get_device_index(uint16_t device_id)
72 {
73         unsigned int i;
74         for (i = 0; i < ME1400_DEVICE_VERSIONS; i++)
75                 if (me1400_versions[i].device_id == device_id)
76                         break;
77         return i;
78 }
79
80 #define ME1400_MAX_8254         10      /**< The maximum number of 8254 counter subdevices available on any ME-1400 device. */
81 #define ME1400_MAX_8255         2       /**< The maximum number of 8255 digital i/o subdevices available on any ME-1400 device. */
82
83 /**
84  * @brief The ME-1400 device class.
85  */
86 typedef struct me1400_device {
87         me_device_t base;                                                                       /**< The Meilhaus device base class. */
88
89         spinlock_t clk_src_reg_lock;                                            /**< Guards the 8254 clock source registers. */
90         spinlock_t ctr_ctrl_reg_lock[ME1400_MAX_8254];          /**< Guards the 8254 ctrl registers. */
91
92         int dio_current_mode[ME1400_MAX_8255];                          /**< Saves the current mode setting of a single 8255 DIO chip. */
93         spinlock_t dio_ctrl_reg_lock[ME1400_MAX_8255];          /**< Guards the 8255 ctrl register and #dio_current_mode. */
94 } me1400_device_t;
95
96 /**
97  * @brief The ME-1400 device class constructor.
98  *
99  * @param pci_device The pci device structure given by the PCI subsystem.
100  *
101  * @return On succes a new ME-1400 device instance. \n
102  *         NULL on error.
103  */
104 me_device_t *me1400_pci_constructor(struct pci_dev *pci_device)
105     __attribute__ ((weak));
106
107 #endif
108 #endif