2 * @file me4600_device.h
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)
11 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
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.
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.
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.
28 #ifndef _ME4600_DEVICE_H
29 #define _ME4600_DEVICE_H
31 #include <linux/pci.h>
32 #include <linux/spinlock.h>
39 * @brief Structure holding ME-4600 device capabilities.
41 typedef struct me4600_version {
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;
52 unsigned int ao_subdevices;
53 unsigned int ao_fifo; //How many devices have FIFO
54 unsigned int ext_irq_subdevices;
58 * @brief ME-4600 device capabilities.
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},
63 {PCI_DEVICE_ID_MEILHAUS_ME4650, 0, 0, 4, 0, 1, 16, 4, 0, 0, 0, 0, 1},
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},
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},
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},
83 #define ME4600_DEVICE_VERSIONS (sizeof(me4600_versions) / sizeof(me4600_version_t) - 1) /**< Returns the number of entries in #me4600_versions. */
86 * @brief Returns the index of the device entry in #me4600_versions.
88 * @param device_id The PCI device id of the device to query.
89 * @return The index of the device in #me4600_versions.
91 static inline unsigned int me4600_versions_get_device_index(uint16_t device_id)
94 for (i = 0; i < ME4600_DEVICE_VERSIONS; i++)
95 if (me4600_versions[i].device_id == device_id)
101 * @brief The ME-4600 device class structure.
103 typedef struct me4600_device {
104 me_device_t base; /**< The Meilhaus device base class. */
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. */
116 * @brief The ME-4600 device class constructor.
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)
121 * @return On succes a new ME-4600 device instance. \n
127 * @brief The ME-4600 device class constructor.
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.
132 * @return On succes a new ME-4600 device instance. \n
135 me_device_t *me4600_pci_constructor(struct pci_dev *pci_device, int me_bosch_fw)
136 __attribute__ ((weak));
139 * @brief The ME-4600 device class constructor.
141 * @param pci_device The pci device structure given by the PCI subsystem.
143 * @return On succes a new ME-4600 device instance. \n
146 me_device_t *me4600_pci_constructor(struct pci_dev *pci_device)
147 __attribute__ ((weak));