added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / meilhaus / me8255.h
blob338230052b3cad6c2d00d54fce5cd99c21e98064
1 /**
2 * @file me8255.h
4 * @brief Meilhaus PIO 8255 implementation.
5 * @note Copyright (C) 2006 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
9 #ifndef _ME8255_H_
10 #define _ME8255_H_
12 #include "mesubdevice.h"
13 #include "meslock.h"
15 #ifdef __KERNEL__
17 /**
18 * @brief The 8255 subdevice class.
20 typedef struct me8255_subdevice {
21 /* Inheritance */
22 me_subdevice_t base; /**< The subdevice base class. */
24 /* Attributes */
25 spinlock_t subdevice_lock; /**< Spin lock to protect the subdevice from concurrent access. */
27 int *ctrl_reg_mirror; /**< Pointer to mirror of the control register. */
28 spinlock_t *ctrl_reg_lock; /**< Spin lock to protect #ctrl_reg and #ctrl_reg_mirror from concurrent access. */
30 uint32_t device_id; /**< The PCI device id of the device holding the 8255 chip. */
31 int me8255_idx; /**< The index of the 8255 chip on the device. */
32 int dio_idx; /**< The index of the DIO port on the 8255 chip. */
34 unsigned long port_reg; /**< Register to read or write a value from or to the port respectively. */
35 unsigned long ctrl_reg; /**< Register to configure the 8255 modes. */
36 } me8255_subdevice_t;
38 /**
39 * @brief The constructor to generate a 8255 instance.
41 * @param device_id The kind of Meilhaus device holding the 8255.
42 * @param reg_base The register base address of the device as returned by the PCI BIOS.
43 * @param me8255_idx The index of the 8255 chip on the Meilhaus device.
44 * @param dio_idx The index of the counter inside a 8255 chip.
45 * @param ctr_reg_mirror Pointer to mirror of control register.
46 * @param ctrl_reg_lock Pointer to spin lock protecting the 8255 control register and #ctrl_reg_mirror from concurrent access.
48 * @return Pointer to new instance on success.\n
49 * NULL on error.
51 me8255_subdevice_t *me8255_constructor(uint32_t device_id,
52 uint32_t reg_base,
53 unsigned int me8255_idx,
54 unsigned int dio_idx,
55 int *ctrl_reg_mirror,
56 spinlock_t * ctrl_reg_lock);
58 #endif
59 #endif