MERGE-master-patchset-edits
[linux-2.6/openmoko-kernel.git] / drivers / staging / meilhaus / me6000_device.h
blob18cc7d1e14f19c39858a60db33415211b18719dc
1 /**
2 * @file me6000_device.h
4 * @brief ME-6000 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 _ME6000_DEVICE_H
28 #define _ME6000_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-6000 device capabilities.
40 typedef struct me6000_version {
41 uint16_t device_id;
42 unsigned int dio_subdevices;
43 unsigned int ao_subdevices;
44 unsigned int ao_fifo; //How many devices have FIFO
45 } me6000_version_t;
47 /**
48 * @brief ME-6000 device capabilities.
50 static me6000_version_t me6000_versions[] = {
51 {PCI_DEVICE_ID_MEILHAUS_ME6004, 0, 4, 0},
52 {PCI_DEVICE_ID_MEILHAUS_ME6008, 0, 8, 0},
53 {PCI_DEVICE_ID_MEILHAUS_ME600F, 0, 16, 0},
55 {PCI_DEVICE_ID_MEILHAUS_ME6014, 0, 4, 0},
56 {PCI_DEVICE_ID_MEILHAUS_ME6018, 0, 8, 0},
57 {PCI_DEVICE_ID_MEILHAUS_ME601F, 0, 16, 0},
59 {PCI_DEVICE_ID_MEILHAUS_ME6034, 0, 4, 0},
60 {PCI_DEVICE_ID_MEILHAUS_ME6038, 0, 8, 0},
61 {PCI_DEVICE_ID_MEILHAUS_ME603F, 0, 16, 0},
63 {PCI_DEVICE_ID_MEILHAUS_ME6104, 0, 4, 4},
64 {PCI_DEVICE_ID_MEILHAUS_ME6108, 0, 8, 4},
65 {PCI_DEVICE_ID_MEILHAUS_ME610F, 0, 16, 4},
67 {PCI_DEVICE_ID_MEILHAUS_ME6114, 0, 4, 4},
68 {PCI_DEVICE_ID_MEILHAUS_ME6118, 0, 8, 4},
69 {PCI_DEVICE_ID_MEILHAUS_ME611F, 0, 16, 4},
71 {PCI_DEVICE_ID_MEILHAUS_ME6134, 0, 4, 4},
72 {PCI_DEVICE_ID_MEILHAUS_ME6138, 0, 8, 4},
73 {PCI_DEVICE_ID_MEILHAUS_ME613F, 0, 16, 4},
75 {PCI_DEVICE_ID_MEILHAUS_ME6044, 2, 4, 0},
76 {PCI_DEVICE_ID_MEILHAUS_ME6048, 2, 8, 0},
77 {PCI_DEVICE_ID_MEILHAUS_ME604F, 2, 16, 0},
79 {PCI_DEVICE_ID_MEILHAUS_ME6054, 2, 4, 0},
80 {PCI_DEVICE_ID_MEILHAUS_ME6058, 2, 8, 0},
81 {PCI_DEVICE_ID_MEILHAUS_ME605F, 2, 16, 0},
83 {PCI_DEVICE_ID_MEILHAUS_ME6074, 2, 4, 0},
84 {PCI_DEVICE_ID_MEILHAUS_ME6078, 2, 8, 0},
85 {PCI_DEVICE_ID_MEILHAUS_ME607F, 2, 16, 0},
87 {PCI_DEVICE_ID_MEILHAUS_ME6144, 2, 4, 4},
88 {PCI_DEVICE_ID_MEILHAUS_ME6148, 2, 8, 4},
89 {PCI_DEVICE_ID_MEILHAUS_ME614F, 2, 16, 4},
91 {PCI_DEVICE_ID_MEILHAUS_ME6154, 2, 4, 4},
92 {PCI_DEVICE_ID_MEILHAUS_ME6158, 2, 8, 4},
93 {PCI_DEVICE_ID_MEILHAUS_ME615F, 2, 16, 4},
95 {PCI_DEVICE_ID_MEILHAUS_ME6174, 2, 4, 4},
96 {PCI_DEVICE_ID_MEILHAUS_ME6178, 2, 8, 4},
97 {PCI_DEVICE_ID_MEILHAUS_ME617F, 2, 16, 4},
99 {PCI_DEVICE_ID_MEILHAUS_ME6259, 2, 9, 0},
101 {PCI_DEVICE_ID_MEILHAUS_ME6359, 2, 9, 4},
103 {0},
106 #define ME6000_DEVICE_VERSIONS (sizeof(me6000_versions) / sizeof(me6000_version_t) - 1) /**< Returns the number of entries in #me6000_versions. */
109 * @brief Returns the index of the device entry in #me6000_versions.
111 * @param device_id The PCI device id of the device to query.
112 * @return The index of the device in #me6000_versions.
114 static inline unsigned int me6000_versions_get_device_index(uint16_t device_id)
116 unsigned int i;
117 for (i = 0; i < ME6000_DEVICE_VERSIONS; i++)
118 if (me6000_versions[i].device_id == device_id)
119 break;
120 return i;
124 * @brief The ME-6000 device class structure.
126 typedef struct me6000_device {
127 me_device_t base; /**< The Meilhaus device base class. */
129 /* Child class attributes. */
130 spinlock_t preload_reg_lock; /**< Guards the preload register. */
131 uint32_t preload_flags;
132 uint32_t triggering_flags;
134 spinlock_t dio_ctrl_reg_lock;
135 } me6000_device_t;
138 * @brief The ME-6000 device class constructor.
140 * @param pci_device The pci device structure given by the PCI subsystem.
142 * @return On succes a new ME-6000 device instance. \n
143 * NULL on error.
145 me_device_t *me6000_pci_constructor(struct pci_dev *pci_device)
146 __attribute__ ((weak));
148 #endif
149 #endif