diff --git a/src/drivers/device/cdev.cpp b/src/drivers/device/cdev.cpp index 3eaf278f32..c0710df7bf 100644 --- a/src/drivers/device/cdev.cpp +++ b/src/drivers/device/cdev.cpp @@ -89,10 +89,9 @@ poll : cdev_poll }; CDev::CDev(const char *name, - const char *devname, - int irq) : + const char *devname) : // base class - Device(name, irq), + Device(name), // public // protected _pub_blocked(false), diff --git a/src/drivers/device/nuttx/device_nuttx.cpp b/src/drivers/device/nuttx/device_nuttx.cpp index 37906d5a05..fb642806bf 100644 --- a/src/drivers/device/nuttx/device_nuttx.cpp +++ b/src/drivers/device/nuttx/device_nuttx.cpp @@ -48,50 +48,11 @@ namespace device { -/** - * Interrupt dispatch table entry. - */ -struct irq_entry { - int irq; - Device *owner; -}; - -static const unsigned irq_nentries = 8; /**< size of the interrupt dispatch table */ -static irq_entry irq_entries[irq_nentries]; /**< interrupt dispatch table (XXX should be a vector) */ - -/** - * Register an interrupt to a specific device. - * - * @param irq The interrupt number to register. - * @param owner The device receiving the interrupt. - * @return OK if the interrupt was registered. - */ -static int register_interrupt(int irq, Device *owner); - -/** - * Unregister an interrupt. - * - * @param irq The previously-registered interrupt to be de-registered. - */ -static void unregister_interrupt(int irq); - -/** - * Handle an interrupt. - * - * @param irq The interrupt being invoked. - * @param context The interrupt register context. - * @return Always returns OK. - */ -static int interrupt(int irq, void *context, void *arg); - -Device::Device(const char *name, - int irq) : +Device::Device(const char *name) : // public // protected _name(name), - _debug_enabled(false), - // private - _irq(irq) + _debug_enabled(false) { sem_init(&_lock, 0, 1); @@ -107,10 +68,6 @@ Device::Device(const char *name, Device::~Device() { sem_destroy(&_lock); - - if (_irq) { - unregister_interrupt(_irq); - } } int @@ -118,93 +75,9 @@ Device::init() { int ret = OK; - // If assigned an interrupt, connect it - if (_irq) { - /* ensure it's disabled */ - up_disable_irq(_irq); - - /* register */ - ret = register_interrupt(_irq, this); - - if (ret != OK) { - _irq = 0; - } - } - return ret; } -void -Device::interrupt_enable() -{ - if (_irq) { - up_enable_irq(_irq); - } -} - -void -Device::interrupt_disable() -{ - if (_irq) { - up_disable_irq(_irq); - } -} - -void -Device::interrupt(void *context) -{ - // default action is to disable the interrupt so we don't get called again - interrupt_disable(); -} - -static int -register_interrupt(int irq, Device *owner) -{ - int ret = -ENOMEM; - - // look for a slot where we can register the interrupt - for (unsigned i = 0; i < irq_nentries; i++) { - if (irq_entries[i].irq == 0) { - - // great, we could put it here; try attaching it - ret = irq_attach(irq, &interrupt, owner); - - if (ret == OK) { - irq_entries[i].irq = irq; - irq_entries[i].owner = owner; - } - - break; - } - } - - return ret; -} - -static void -unregister_interrupt(int irq) -{ - for (unsigned i = 0; i < irq_nentries; i++) { - if (irq_entries[i].irq == irq) { - irq_entries[i].irq = 0; - irq_entries[i].owner = nullptr; - } - } -} - -static int -interrupt(int irq, void *context, void *arg) -{ - for (unsigned i = 0; i < irq_nentries; i++) { - if (irq_entries[i].irq == irq) { - irq_entries[i].owner->interrupt(context); - break; - } - } - - return OK; -} - int Device::read(unsigned offset, void *data, unsigned count) { diff --git a/src/drivers/device/nuttx/device_nuttx.h b/src/drivers/device/nuttx/device_nuttx.h index 166e172943..9e53238b42 100644 --- a/src/drivers/device/nuttx/device_nuttx.h +++ b/src/drivers/device/nuttx/device_nuttx.h @@ -81,11 +81,6 @@ public: */ virtual ~Device(); - /** - * Interrupt handler. - */ - virtual void interrupt(void *ctx); /**< interrupt handler */ - /* * Direct access methods. */ @@ -193,10 +188,8 @@ protected: * Constructor * * @param name Driver name - * @param irq Interrupt assigned to the device. */ - Device(const char *name, - int irq = 0); + Device(const char *name); /** * Enable the device interrupt @@ -235,7 +228,6 @@ protected: sem_t _lock; /**< lock to protect access to all class members (also for derived classes) */ private: - int _irq; /**< if non-zero, it's a valid IRQ */ /** disable copy construction for this and all subclasses */ Device(const Device &); @@ -243,27 +235,6 @@ private: /** disable assignment for this and all subclasses */ Device &operator = (const Device &); - /** - * Register ourselves as a handler for an interrupt - * - * @param irq The interrupt to claim - * @return OK if the interrupt was registered - */ - int dev_register_interrupt(int irq); - - /** - * Unregister ourselves as a handler for any interrupt - */ - void dev_unregister_interrupt(); - - /** - * Interrupt dispatcher - * - * @param irq The interrupt that has been triggered. - * @param context Pointer to the interrupted context. - */ - static void dev_interrupt(int irq, void *context); - }; /** @@ -277,9 +248,8 @@ public: * * @param name Driver name * @param devname Device node name - * @param irq Interrupt assigned to the device */ - CDev(const char *name, const char *devname, int irq = 0); + CDev(const char *name, const char *devname); /** * Destructor diff --git a/src/drivers/device/nuttx/i2c_nuttx.cpp b/src/drivers/device/nuttx/i2c_nuttx.cpp index 1b9c9ad115..e55109fa69 100644 --- a/src/drivers/device/nuttx/i2c_nuttx.cpp +++ b/src/drivers/device/nuttx/i2c_nuttx.cpp @@ -55,10 +55,9 @@ I2C::I2C(const char *name, const char *devname, int bus, uint16_t address, - uint32_t frequency, - int irq) : + uint32_t frequency) : // base class - CDev(name, devname, irq), + CDev(name, devname), // public // protected _retries(0), diff --git a/src/drivers/device/nuttx/i2c_nuttx.h b/src/drivers/device/nuttx/i2c_nuttx.h index 7aa8478040..9a2a2042a7 100644 --- a/src/drivers/device/nuttx/i2c_nuttx.h +++ b/src/drivers/device/nuttx/i2c_nuttx.h @@ -84,14 +84,12 @@ protected: * @param bus I2C bus on which the device lives * @param address I2C bus address, or zero if set_address will be used * @param frequency I2C bus frequency for the device (currently not used) - * @param irq Interrupt assigned to the device (or zero if none) */ I2C(const char *name, const char *devname, int bus, uint16_t address, - uint32_t frequency, - int irq = 0); + uint32_t frequency); virtual ~I2C(); virtual int init(); diff --git a/src/drivers/device/nuttx/spi.cpp b/src/drivers/device/nuttx/spi.cpp index 9459bc2cdd..945e928f3c 100644 --- a/src/drivers/device/nuttx/spi.cpp +++ b/src/drivers/device/nuttx/spi.cpp @@ -61,10 +61,9 @@ SPI::SPI(const char *name, int bus, uint32_t device, enum spi_mode_e mode, - uint32_t frequency, - int irq) : + uint32_t frequency) : // base class - CDev(name, devname, irq), + CDev(name, devname), // public // protected locking_mode(LOCK_PREEMPTION), diff --git a/src/drivers/device/posix/vdev.h b/src/drivers/device/posix/vdev.h index 650e6a6440..319af88dcb 100644 --- a/src/drivers/device/posix/vdev.h +++ b/src/drivers/device/posix/vdev.h @@ -449,75 +449,6 @@ private: //CDev operator=(const CDev&); }; -#if 0 -/** - * Abstract class for character device accessed via PIO - */ -class __EXPORT VPIO : public CDev -{ -public: - /** - * Constructor - * - * @param name Driver name - * @param devname Device node name - * @param base Base address of the device PIO area - * @param irq Interrupt assigned to the device (or zero if none) - */ - PIO(const char *name, - const char *devname, - unsigned long base - ); - virtual ~PIO(); - - virtual int init(); - -protected: - - /** - * Read a register - * - * @param offset Register offset in bytes from the base address. - */ - uint32_t reg(uint32_t offset) - { - return *(volatile uint32_t *)(_base + offset); - } - - /** - * Write a register - * - * @param offset Register offset in bytes from the base address. - * @param value Value to write. - */ - void reg(uint32_t offset, uint32_t value) - { - *(volatile uint32_t *)(_base + offset) = value; - } - - /** - * Modify a register - * - * Note that there is a risk of a race during the read/modify/write cycle - * that must be taken care of by the caller. - * - * @param offset Register offset in bytes from the base address. - * @param clearbits Bits to clear in the register - * @param setbits Bits to set in the register - */ - void modify(uint32_t offset, uint32_t clearbits, uint32_t setbits) - { - uint32_t val = reg(offset); - val &= ~clearbits; - val |= setbits; - reg(offset, val); - } - -private: - unsigned long _base; -}; -#endif - } // namespace device // class instance for primary driver of each class diff --git a/src/drivers/device/spi.h b/src/drivers/device/spi.h index be83303842..f7337d0396 100644 --- a/src/drivers/device/spi.h +++ b/src/drivers/device/spi.h @@ -62,15 +62,13 @@ protected: * @param device Device handle (used by SPI_SELECT) * @param mode SPI clock/data mode * @param frequency SPI clock frequency - * @param irq Interrupt assigned to the device (or zero if none) */ SPI(const char *name, const char *devname, int bus, uint32_t device, enum spi_mode_e mode, - uint32_t frequency, - int irq = 0); + uint32_t frequency); virtual ~SPI(); /**