summaryrefslogtreecommitdiff
path: root/drivers/staging/meilhaus/me8255.h
blob: 338230052b3cad6c2d00d54fce5cd99c21e98064 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
 * @file me8255.h
 *
 * @brief Meilhaus PIO 8255 implementation.
 * @note Copyright (C) 2006 Meilhaus Electronic GmbH (support@meilhaus.de)
 * @author Guenter Gebhardt
 */

#ifndef _ME8255_H_
#define _ME8255_H_

#include "mesubdevice.h"
#include "meslock.h"

#ifdef __KERNEL__

/**
 * @brief The 8255 subdevice class.
 */
typedef struct me8255_subdevice {
	/* Inheritance */
	me_subdevice_t base;			/**< The subdevice base class. */

	/* Attributes */
	spinlock_t subdevice_lock;		/**< Spin lock to protect the subdevice from concurrent access. */

	int *ctrl_reg_mirror;			/**< Pointer to mirror of the control register. */
	spinlock_t *ctrl_reg_lock;		/**< Spin lock to protect #ctrl_reg and #ctrl_reg_mirror from concurrent access. */

	uint32_t device_id;				/**< The PCI device id of the device holding the 8255 chip. */
	int me8255_idx;					/**< The index of the 8255 chip on the device. */
	int dio_idx;					/**< The index of the DIO port on the 8255 chip. */

	unsigned long port_reg;			/**< Register to read or write a value from or to the port respectively. */
	unsigned long ctrl_reg;			/**< Register to configure the 8255 modes. */
} me8255_subdevice_t;

/**
 * @brief The constructor to generate a 8255 instance.
 *
 * @param device_id The kind of Meilhaus device holding the 8255.
 * @param reg_base The register base address of the device as returned by the PCI BIOS.
 * @param me8255_idx The index of the 8255 chip on the Meilhaus device.
 * @param dio_idx The index of the counter inside a 8255 chip.
 * @param ctr_reg_mirror Pointer to mirror of control register.
 * @param ctrl_reg_lock Pointer to spin lock protecting the 8255 control register and #ctrl_reg_mirror from concurrent access.
 *
 * @return Pointer to new instance on success.\n
 * NULL on error.
 */
me8255_subdevice_t *me8255_constructor(uint32_t device_id,
				       uint32_t reg_base,
				       unsigned int me8255_idx,
				       unsigned int dio_idx,
				       int *ctrl_reg_mirror,
				       spinlock_t * ctrl_reg_lock);

#endif
#endif