2 * @file me1600_device.h
4 * @brief ME-1600 device class.
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 <linux/pci.h>
31 #include <linux/spinlock.h>
34 #include "me1600_ao.h"
35 #include "me1600_ao_reg.h"
40 * @brief Structure to store device capabilities.
42 typedef struct me1600_version {
43 uint16_t device_id; /**< The PCI device id of the device. */
44 unsigned int ao_chips; /**< The number of analog outputs on the device. */
45 int curr; /**< Flag to identify amounts of current output. */
49 * @brief Defines for each ME-1600 device version its capabilities.
51 static me1600_version_t me1600_versions[] = {
52 {PCI_DEVICE_ID_MEILHAUS_ME1600_4U, 4, 0},
53 {PCI_DEVICE_ID_MEILHAUS_ME1600_8U, 8, 0},
54 {PCI_DEVICE_ID_MEILHAUS_ME1600_12U, 12, 0},
55 {PCI_DEVICE_ID_MEILHAUS_ME1600_16U, 16, 0},
56 {PCI_DEVICE_ID_MEILHAUS_ME1600_16U_8I, 16, 8},
60 /**< Returns the number of entries in #me1600_versions. */
61 #define ME1600_DEVICE_VERSIONS (sizeof(me1600_versions) / sizeof(me1600_version_t) - 1)
64 * @brief Returns the index of the device entry in #me1600_versions.
66 * @param device_id The PCI device id of the device to query.
67 * @return The index of the device in #me1600_versions.
69 static inline unsigned int me1600_versions_get_device_index(uint16_t device_id)
72 for (i = 0; i < ME1600_DEVICE_VERSIONS; i++)
73 if (me1600_versions[i].device_id == device_id)
79 * @brief The ME-1600 device class structure.
81 typedef struct me1600_device {
82 me_device_t base; /**< The Meilhaus device base class. */
83 spinlock_t config_regs_lock; /**< Protects the configuration registers. */
85 me1600_ao_shadow_t ao_regs_shadows; /**< Addresses and shadows of output's registers. */
86 spinlock_t ao_shadows_lock; /**< Protects the shadow's struct. */
90 * @brief The ME-1600 device class constructor.
92 * @param pci_device The pci device structure given by the PCI subsystem.
94 * @return On succes a new ME-1600 device instance. \n
97 me_device_t *me1600_pci_constructor(struct pci_dev *pci_device)
98 __attribute__ ((weak));