blob: 18cc7d1e14f19c39858a60db33415211b18719dc [file] [log] [blame]
David Kiliani3fedd142008-11-01 00:39:12 +01001/**
2 * @file me6000_device.h
3 *
4 * @brief ME-6000 device class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
8
9/*
10 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
11 *
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.
16 *
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.
21 *
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.
25 */
26
27#ifndef _ME6000_DEVICE_H
28#define _ME6000_DEVICE_H
29
30#include <linux/pci.h>
31#include <linux/spinlock.h>
32
33#include "medevice.h"
34
35#ifdef __KERNEL__
36
37/**
38 * @brief Structure holding ME-6000 device capabilities.
39 */
40typedef 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;
46
47/**
48 * @brief ME-6000 device capabilities.
49 */
50static 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},
54
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},
58
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},
62
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},
66
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},
70
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},
74
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},
78
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},
82
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},
86
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},
90
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},
94
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},
98
99 {PCI_DEVICE_ID_MEILHAUS_ME6259, 2, 9, 0},
100
101 {PCI_DEVICE_ID_MEILHAUS_ME6359, 2, 9, 4},
102
103 {0},
104};
105
106#define ME6000_DEVICE_VERSIONS (sizeof(me6000_versions) / sizeof(me6000_version_t) - 1) /**< Returns the number of entries in #me6000_versions. */
107
108/**
109 * @brief Returns the index of the device entry in #me6000_versions.
110 *
111 * @param device_id The PCI device id of the device to query.
112 * @return The index of the device in #me6000_versions.
113 */
114static inline unsigned int me6000_versions_get_device_index(uint16_t device_id)
115{
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;
121}
122
123/**
124 * @brief The ME-6000 device class structure.
125 */
126typedef struct me6000_device {
127 me_device_t base; /**< The Meilhaus device base class. */
128
129 /* Child class attributes. */
130 spinlock_t preload_reg_lock; /**< Guards the preload register. */
131 uint32_t preload_flags;
132 uint32_t triggering_flags;
133
134 spinlock_t dio_ctrl_reg_lock;
135} me6000_device_t;
136
137/**
138 * @brief The ME-6000 device class constructor.
139 *
140 * @param pci_device The pci device structure given by the PCI subsystem.
141 *
142 * @return On succes a new ME-6000 device instance. \n
143 * NULL on error.
144 */
145me_device_t *me6000_pci_constructor(struct pci_dev *pci_device)
146 __attribute__ ((weak));
147
148#endif
149#endif