static void rk808_irq_sync_unlock(struct irq_data *data) { struct rk808 *rk808 = irq_data_get_irq_chip_data(data); u32 reg_mask; u8 reg; rk808_i2c_read(rk808, RK808_INT_STS_MSK_REG1, 1, ®); reg_mask = reg; rk808_i2c_read(rk808, RK808_INT_STS_MSK_REG2, 1, ®); reg_mask |= reg << 8; if (rk808->irq_mask != reg_mask) { reg = rk808->irq_mask & 0xff; // rk808_i2c_write(rk808, RK808_INT_STS_MSK_REG1, 1, reg); reg = rk808->irq_mask >> 8 & 0xff; // rk808_i2c_write(rk808, RK808_INT_STS_MSK_REG2, 1, reg); }
/* * This is a threaded IRQ handler so can access I2C/SPI. Since all * interrupts are clear on read the IRQ line will be reasserted and * the physical IRQ will be handled again if another interrupt is * asserted while we run - in the normal course of events this is a * rare occurrence so we save I2C/SPI reads. We're also assuming that * it's rare to get lots of interrupts firing simultaneously so try to * minimise I/O. */ static irqreturn_t rk808_irq(int irq, void *irq_data) { struct rk808 *rk808 = irq_data; u32 irq_sts; u32 irq_mask; u8 reg; int i, cur_irq; // printk("%s,line=%d\n", __func__,__LINE__); wake_lock(&rk808->irq_wake); rk808_i2c_read(rk808, RK808_INT_STS_REG1, 1, ®); irq_sts = reg; rk808_i2c_read(rk808, RK808_INT_STS_REG2, 1, ®); irq_sts |= reg << 8; rk808_i2c_read(rk808, RK808_INT_STS_MSK_REG1, 1, ®); irq_mask = reg; rk808_i2c_read(rk808, RK808_INT_STS_MSK_REG2, 1, ®); irq_mask |= reg << 8; irq_sts &= ~irq_mask; if (!irq_sts) { wake_unlock(&rk808->irq_wake); return IRQ_NONE; } for (i = 0; i < rk808->irq_num; i++) { if (!(irq_sts & (1 << i))) continue; cur_irq = irq_find_mapping(rk808->irq_domain, i); if (cur_irq) handle_nested_irq(cur_irq); } /* Write the STS register back to clear IRQs we handled */ reg = irq_sts & 0xFF; irq_sts >>= 8; rk808_i2c_write(rk808, RK808_INT_STS_REG1, 1, reg); reg = irq_sts & 0xFF; rk808_i2c_write(rk808, RK808_INT_STS_REG2, 1, reg); wake_unlock(&rk808->irq_wake); return IRQ_HANDLED; }
/* * This is a threaded IRQ handler so can access I2C/SPI. Since all * interrupts are clear on read the IRQ line will be reasserted and * the physical IRQ will be handled again if another interrupt is * asserted while we run - in the normal course of events this is a * rare occurrence so we save I2C/SPI reads. We're also assuming that * it's rare to get lots of interrupts firing simultaneously so try to * minimise I/O. */ static irqreturn_t rk808_irq(int irq, void *irq_data) { struct rk808 *rk808 = irq_data; u32 irq_sts; u32 irq_mask; u8 reg; int i; //printk(" rk808 irq %d \n",irq); wake_lock(&rk808->irq_wake); rk808_i2c_read(rk808, RK808_INT_STS_REG1, 1, ®); irq_sts = reg; rk808_i2c_read(rk808, RK808_INT_STS_REG2, 1, ®); irq_sts |= reg << 8; rk808_i2c_read(rk808, RK808_INT_STS_MSK_REG1, 1, ®); irq_mask = reg; rk808_i2c_read(rk808, RK808_INT_STS_MSK_REG2, 1, ®); irq_mask |= reg << 8; irq_sts &= ~irq_mask; if (!irq_sts) { wake_unlock(&rk808->irq_wake); return IRQ_NONE; } for (i = 0; i < rk808->irq_num; i++) { if (!(irq_sts & (1 << i))) continue; handle_nested_irq(rk808->irq_base + i); } /* Write the STS register back to clear IRQs we handled */ reg = irq_sts & 0xFF; irq_sts >>= 8; rk808_i2c_write(rk808, RK808_INT_STS_REG1, 1, reg); reg = irq_sts & 0xFF; rk808_i2c_write(rk808, RK808_INT_STS_REG2, 1, reg); wake_unlock(&rk808->irq_wake); return IRQ_HANDLED; }