|
|
@ -85,7 +85,7 @@ protected: |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Device(const char *name, |
|
|
|
Device(const char *name, |
|
|
|
int irq = 0); |
|
|
|
int irq = 0); |
|
|
|
~Device(); |
|
|
|
virtual ~Device(); |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Initialise the driver and make it ready for use. |
|
|
|
* Initialise the driver and make it ready for use. |
|
|
@ -189,7 +189,7 @@ public: |
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Destructor |
|
|
|
* Destructor |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
~CDev(); |
|
|
|
virtual ~CDev(); |
|
|
|
|
|
|
|
|
|
|
|
virtual int init(); |
|
|
|
virtual int init(); |
|
|
|
|
|
|
|
|
|
|
@ -287,6 +287,43 @@ public: |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool is_open() { return _open_count > 0; } |
|
|
|
bool is_open() { return _open_count > 0; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Direct access methods. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Read directly from the device. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* The actual size of each unit quantity is device-specific. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param offset The device offset at which to start reading |
|
|
|
|
|
|
|
* @param data The buffer into which the read values should be placed. |
|
|
|
|
|
|
|
* @param count The number of items to read, defaults to 1. |
|
|
|
|
|
|
|
* @return count on success, < 0 on error. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual int read(unsigned offset, void *data, unsigned count = 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Write directly to the device. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* The actual size of each unit quantity is device-specific. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param address The device address at which to start writing. |
|
|
|
|
|
|
|
* @param data The buffer from which values should be read. |
|
|
|
|
|
|
|
* @param count The number of registers to write, defaults to 1. |
|
|
|
|
|
|
|
* @return count on success, < 0 on error. |
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
virtual int write(unsigned address, void *data, unsigned count = 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Perform a device-specific operation. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param operation The operation to perform |
|
|
|
|
|
|
|
* @param arg An argument to the operation. |
|
|
|
|
|
|
|
* @return < 0 on error |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual int ioctl(unsigned operation, unsigned &arg); |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Pointer to the default cdev file operations table; useful for |
|
|
|
* Pointer to the default cdev file operations table; useful for |
|
|
@ -396,9 +433,9 @@ public: |
|
|
|
const char *devname, |
|
|
|
const char *devname, |
|
|
|
uint32_t base, |
|
|
|
uint32_t base, |
|
|
|
int irq = 0); |
|
|
|
int irq = 0); |
|
|
|
~PIO(); |
|
|
|
virtual ~PIO(); |
|
|
|
|
|
|
|
|
|
|
|
int init(); |
|
|
|
virtual int init(); |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
|
|
|
|
|
|
|
@ -407,7 +444,7 @@ protected: |
|
|
|
* |
|
|
|
* |
|
|
|
* @param offset Register offset in bytes from the base address. |
|
|
|
* @param offset Register offset in bytes from the base address. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
uint32_t reg(uint32_t offset) { |
|
|
|
uint32_t reg(uint32_t offset) { |
|
|
|
return *(volatile uint32_t *)(_base + offset); |
|
|
|
return *(volatile uint32_t *)(_base + offset); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|