added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / meilhaus / me8200_device.h
blobcbd2a01ddb411e36e76486933871cbd8ffc026bd
1 /**
2 * @file me8200_device.h
4 * @brief ME-8200 device class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
9 /*
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.
27 #ifndef _ME8200_DEVICE_H
28 #define _ME8200_DEVICE_H
30 #include <linux/pci.h>
31 #include <linux/spinlock.h>
33 #include "medevice.h"
35 #ifdef __KERNEL__
37 /**
38 * @brief Structure holding ME-8200 device capabilities.
40 typedef struct me8200_version {
41 uint16_t device_id;
42 unsigned int di_subdevices;
43 unsigned int do_subdevices;
44 unsigned int dio_subdevices;
45 } me8200_version_t;
47 /**
48 * @brief Device capabilities.
50 static me8200_version_t me8200_versions[] = {
51 {PCI_DEVICE_ID_MEILHAUS_ME8200_A, 1, 1, 2},
52 {PCI_DEVICE_ID_MEILHAUS_ME8200_B, 2, 2, 2},
53 {0},
56 #define ME8200_DEVICE_VERSIONS (sizeof(me8200_versions) / sizeof(me8200_version_t) - 1) /**< Returns the number of entries in #me8200_versions. */
58 /**
59 * @brief Returns the index of the device entry in #me8200_versions.
61 * @param device_id The PCI device id of the device to query.
62 * @return The index of the device in #me8200_versions.
64 static inline unsigned int me8200_versions_get_device_index(uint16_t device_id)
66 unsigned int i;
67 for (i = 0; i < ME8200_DEVICE_VERSIONS; i++)
68 if (me8200_versions[i].device_id == device_id)
69 break;
70 return i;
73 /**
74 * @brief The ME-8200 device class structure.
76 typedef struct me8200_device {
77 me_device_t base; /**< The Meilhaus device base class. */
79 /* Child class attributes. */
80 spinlock_t irq_ctrl_lock; /**< Lock for the interrupt control register. */
81 spinlock_t irq_mode_lock; /**< Lock for the interrupt mode register. */
82 spinlock_t dio_ctrl_lock; /**< Lock for the digital i/o control register. */
83 } me8200_device_t;
85 /**
86 * @brief The ME-8200 device class constructor.
88 * @param pci_device The pci device structure given by the PCI subsystem.
90 * @return On succes a new ME-8200 device instance. \n
91 * NULL on error.
93 me_device_t *me8200_pci_constructor(struct pci_dev *pci_device)
94 __attribute__ ((weak));
96 #endif
97 #endif