diff options
Diffstat (limited to 'drivers/staging/meilhaus/me4600_device.h')
-rw-r--r-- | drivers/staging/meilhaus/me4600_device.h | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/drivers/staging/meilhaus/me4600_device.h b/drivers/staging/meilhaus/me4600_device.h new file mode 100644 index 00000000000..fa812d4cc6d --- /dev/null +++ b/drivers/staging/meilhaus/me4600_device.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /** | ||
2 | * @file me4600_device.h | ||
3 | * | ||
4 | * @brief ME-4600 device class. | ||
5 | * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de) | ||
6 | * @author Guenter Gebhardt | ||
7 | * @author Krzysztof Gantzke (k.gantzke@meilhaus.de) | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de) | ||
12 | * | ||
13 | * This file is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, write to the Free Software | ||
25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
26 | */ | ||
27 | |||
28 | #ifndef _ME4600_DEVICE_H | ||
29 | #define _ME4600_DEVICE_H | ||
30 | |||
31 | #include <linux/pci.h> | ||
32 | #include <linux/spinlock.h> | ||
33 | |||
34 | #include "medevice.h" | ||
35 | |||
36 | #ifdef __KERNEL__ | ||
37 | |||
38 | /** | ||
39 | * @brief Structure holding ME-4600 device capabilities. | ||
40 | */ | ||
41 | typedef struct me4600_version { | ||
42 | uint16_t device_id; | ||
43 | unsigned int do_subdevices; | ||
44 | unsigned int di_subdevices; | ||
45 | unsigned int dio_subdevices; | ||
46 | unsigned int ctr_subdevices; | ||
47 | unsigned int ai_subdevices; | ||
48 | unsigned int ai_channels; | ||
49 | unsigned int ai_ranges; | ||
50 | unsigned int ai_isolated; | ||
51 | unsigned int ai_sh; | ||
52 | unsigned int ao_subdevices; | ||
53 | unsigned int ao_fifo; //How many devices have FIFO | ||
54 | unsigned int ext_irq_subdevices; | ||
55 | } me4600_version_t; | ||
56 | |||
57 | /** | ||
58 | * @brief ME-4600 device capabilities. | ||
59 | */ | ||
60 | static me4600_version_t me4600_versions[] = { | ||
61 | {PCI_DEVICE_ID_MEILHAUS_ME4610, 0, 0, 4, 3, 1, 16, 1, 0, 0, 0, 0, 1}, | ||
62 | |||
63 | {PCI_DEVICE_ID_MEILHAUS_ME4650, 0, 0, 4, 0, 1, 16, 4, 0, 0, 0, 0, 1}, | ||
64 | |||
65 | {PCI_DEVICE_ID_MEILHAUS_ME4660, 0, 0, 4, 3, 1, 16, 4, 0, 0, 2, 0, 1}, | ||
66 | {PCI_DEVICE_ID_MEILHAUS_ME4660I, 1, 1, 2, 3, 1, 16, 4, 1, 0, 2, 0, 1}, | ||
67 | {PCI_DEVICE_ID_MEILHAUS_ME4660S, 0, 0, 4, 3, 1, 16, 4, 0, 1, 2, 0, 1}, | ||
68 | {PCI_DEVICE_ID_MEILHAUS_ME4660IS, 1, 1, 2, 3, 1, 16, 4, 1, 1, 2, 0, 1}, | ||
69 | |||
70 | {PCI_DEVICE_ID_MEILHAUS_ME4670, 0, 0, 4, 3, 1, 32, 4, 0, 0, 4, 0, 1}, | ||
71 | {PCI_DEVICE_ID_MEILHAUS_ME4670I, 1, 1, 2, 3, 1, 32, 4, 1, 0, 4, 0, 1}, | ||
72 | {PCI_DEVICE_ID_MEILHAUS_ME4670S, 0, 0, 4, 3, 1, 32, 4, 0, 1, 4, 0, 1}, | ||
73 | {PCI_DEVICE_ID_MEILHAUS_ME4670IS, 1, 1, 2, 3, 1, 32, 4, 1, 1, 4, 0, 1}, | ||
74 | |||
75 | {PCI_DEVICE_ID_MEILHAUS_ME4680, 0, 0, 4, 3, 1, 32, 4, 0, 0, 4, 4, 1}, | ||
76 | {PCI_DEVICE_ID_MEILHAUS_ME4680I, 1, 1, 2, 3, 1, 32, 4, 1, 0, 4, 4, 1}, | ||
77 | {PCI_DEVICE_ID_MEILHAUS_ME4680S, 0, 0, 4, 3, 1, 32, 4, 0, 1, 4, 4, 1}, | ||
78 | {PCI_DEVICE_ID_MEILHAUS_ME4680IS, 1, 1, 2, 3, 1, 32, 4, 1, 1, 4, 4, 1}, | ||
79 | |||
80 | {0}, | ||
81 | }; | ||
82 | |||
83 | #define ME4600_DEVICE_VERSIONS (sizeof(me4600_versions) / sizeof(me4600_version_t) - 1) /**< Returns the number of entries in #me4600_versions. */ | ||
84 | |||
85 | /** | ||
86 | * @brief Returns the index of the device entry in #me4600_versions. | ||
87 | * | ||
88 | * @param device_id The PCI device id of the device to query. | ||
89 | * @return The index of the device in #me4600_versions. | ||
90 | */ | ||
91 | static inline unsigned int me4600_versions_get_device_index(uint16_t device_id) | ||
92 | { | ||
93 | unsigned int i; | ||
94 | for (i = 0; i < ME4600_DEVICE_VERSIONS; i++) | ||
95 | if (me4600_versions[i].device_id == device_id) | ||
96 | break; | ||
97 | return i; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * @brief The ME-4600 device class structure. | ||
102 | */ | ||
103 | typedef struct me4600_device { | ||
104 | me_device_t base; /**< The Meilhaus device base class. */ | ||
105 | |||
106 | /* Child class attributes. */ | ||
107 | spinlock_t preload_reg_lock; /**< Guards the preload register of the anaolog output devices. */ | ||
108 | unsigned int preload_flags; /**< Used in conjunction with #preload_reg_lock. */ | ||
109 | spinlock_t dio_lock; /**< Locks the control register of the digital input/output subdevices. */ | ||
110 | spinlock_t ai_ctrl_lock; /**< Locks the control register of the analog input subdevice. */ | ||
111 | spinlock_t ctr_ctrl_reg_lock; /**< Locks the counter control register. */ | ||
112 | spinlock_t ctr_clk_src_reg_lock; /**< Not used on this device but needed for the me8254 subdevice constructor call. */ | ||
113 | } me4600_device_t; | ||
114 | |||
115 | /** | ||
116 | * @brief The ME-4600 device class constructor. | ||
117 | * | ||
118 | * @param pci_device The pci device structure given by the PCI subsystem. | ||
119 | * @param me_bosch_fw If set the device shall use the bosch firmware. (Only for special BOSCH build) | ||
120 | * | ||
121 | * @return On succes a new ME-4600 device instance. \n | ||
122 | * NULL on error. | ||
123 | */ | ||
124 | |||
125 | #ifdef BOSCH | ||
126 | /** | ||
127 | * @brief The ME-4600 device class constructor. | ||
128 | * | ||
129 | * @param pci_device The pci device structure given by the PCI subsystem. | ||
130 | * @param me_bosch_fw If set the device shall use the bosch firmware. | ||
131 | * | ||
132 | * @return On succes a new ME-4600 device instance. \n | ||
133 | * NULL on error. | ||
134 | */ | ||
135 | me_device_t *me4600_pci_constructor(struct pci_dev *pci_device, int me_bosch_fw) | ||
136 | __attribute__ ((weak)); | ||
137 | #else //~BOSCH | ||
138 | /** | ||
139 | * @brief The ME-4600 device class constructor. | ||
140 | * | ||
141 | * @param pci_device The pci device structure given by the PCI subsystem. | ||
142 | * | ||
143 | * @return On succes a new ME-4600 device instance. \n | ||
144 | * NULL on error. | ||
145 | */ | ||
146 | me_device_t *me4600_pci_constructor(struct pci_dev *pci_device) | ||
147 | __attribute__ ((weak)); | ||
148 | #endif | ||
149 | |||
150 | #endif | ||
151 | #endif | ||