David Kiliani | 3fedd14 | 2008-11-01 00:39:12 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @file me8255.h |
| 3 | * |
| 4 | * @brief Meilhaus PIO 8255 implementation. |
| 5 | * @note Copyright (C) 2006 Meilhaus Electronic GmbH (support@meilhaus.de) |
| 6 | * @author Guenter Gebhardt |
| 7 | */ |
| 8 | |
| 9 | #ifndef _ME8255_H_ |
| 10 | #define _ME8255_H_ |
| 11 | |
| 12 | #include "mesubdevice.h" |
| 13 | #include "meslock.h" |
| 14 | |
| 15 | #ifdef __KERNEL__ |
| 16 | |
| 17 | /** |
| 18 | * @brief The 8255 subdevice class. |
| 19 | */ |
| 20 | typedef struct me8255_subdevice { |
| 21 | /* Inheritance */ |
| 22 | me_subdevice_t base; /**< The subdevice base class. */ |
| 23 | |
| 24 | /* Attributes */ |
| 25 | spinlock_t subdevice_lock; /**< Spin lock to protect the subdevice from concurrent access. */ |
| 26 | |
| 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. */ |
| 29 | |
| 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. */ |
| 33 | |
| 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; |
| 37 | |
| 38 | /** |
| 39 | * @brief The constructor to generate a 8255 instance. |
| 40 | * |
| 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. |
| 47 | * |
| 48 | * @return Pointer to new instance on success.\n |
| 49 | * NULL on error. |
| 50 | */ |
| 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); |
| 57 | |
| 58 | #endif |
| 59 | #endif |