Lines Matching refs:pcf

20 int pcf50633_register_irq(struct pcf50633 *pcf, int irq,  in pcf50633_register_irq()  argument
26 if (WARN_ON(pcf->irq_handler[irq].handler)) in pcf50633_register_irq()
29 mutex_lock(&pcf->lock); in pcf50633_register_irq()
30 pcf->irq_handler[irq].handler = handler; in pcf50633_register_irq()
31 pcf->irq_handler[irq].data = data; in pcf50633_register_irq()
32 mutex_unlock(&pcf->lock); in pcf50633_register_irq()
38 int pcf50633_free_irq(struct pcf50633 *pcf, int irq) in pcf50633_free_irq() argument
43 mutex_lock(&pcf->lock); in pcf50633_free_irq()
44 pcf->irq_handler[irq].handler = NULL; in pcf50633_free_irq()
45 mutex_unlock(&pcf->lock); in pcf50633_free_irq()
51 static int __pcf50633_irq_mask_set(struct pcf50633 *pcf, int irq, u8 mask) in __pcf50633_irq_mask_set() argument
60 pcf50633_reg_set_bit_mask(pcf, reg, bit, mask ? bit : 0); in __pcf50633_irq_mask_set()
62 mutex_lock(&pcf->lock); in __pcf50633_irq_mask_set()
65 pcf->mask_regs[idx] |= bit; in __pcf50633_irq_mask_set()
67 pcf->mask_regs[idx] &= ~bit; in __pcf50633_irq_mask_set()
69 mutex_unlock(&pcf->lock); in __pcf50633_irq_mask_set()
74 int pcf50633_irq_mask(struct pcf50633 *pcf, int irq) in pcf50633_irq_mask() argument
76 dev_dbg(pcf->dev, "Masking IRQ %d\n", irq); in pcf50633_irq_mask()
78 return __pcf50633_irq_mask_set(pcf, irq, 1); in pcf50633_irq_mask()
82 int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq) in pcf50633_irq_unmask() argument
84 dev_dbg(pcf->dev, "Unmasking IRQ %d\n", irq); in pcf50633_irq_unmask()
86 return __pcf50633_irq_mask_set(pcf, irq, 0); in pcf50633_irq_unmask()
90 int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq) in pcf50633_irq_mask_get() argument
97 return pcf->mask_regs[reg] & bits; in pcf50633_irq_mask_get()
101 static void pcf50633_irq_call_handler(struct pcf50633 *pcf, int irq) in pcf50633_irq_call_handler() argument
103 if (pcf->irq_handler[irq].handler) in pcf50633_irq_call_handler()
104 pcf->irq_handler[irq].handler(irq, pcf->irq_handler[irq].data); in pcf50633_irq_call_handler()
112 struct pcf50633 *pcf = data; in pcf50633_irq() local
117 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1, in pcf50633_irq()
120 dev_err(pcf->dev, "Error reading INT registers\n"); in pcf50633_irq()
130 pcf50633_reg_write(pcf, PCF50633_REG_OOCSHDWN, 0x04); in pcf50633_irq()
135 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2); in pcf50633_irq()
144 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2); in pcf50633_irq()
151 dev_dbg(pcf->dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x " in pcf50633_irq()
157 if ((pcf_int[0] & PCF50633_INT1_SECOND) && pcf->onkey1s_held) { in pcf50633_irq()
158 dev_info(pcf->dev, "ONKEY1S held for %d secs\n", in pcf50633_irq()
159 pcf->onkey1s_held); in pcf50633_irq()
160 if (pcf->onkey1s_held++ == PCF50633_ONKEY1S_TIMEOUT) in pcf50633_irq()
161 if (pcf->pdata->force_shutdown) in pcf50633_irq()
162 pcf->pdata->force_shutdown(pcf); in pcf50633_irq()
166 dev_info(pcf->dev, "ONKEY1S held\n"); in pcf50633_irq()
167 pcf->onkey1s_held = 1 ; in pcf50633_irq()
170 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT1M, in pcf50633_irq()
174 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT2M, in pcf50633_irq()
178 if ((pcf_int[1] & PCF50633_INT2_ONKEYR) && pcf->onkey1s_held) { in pcf50633_irq()
179 pcf->onkey1s_held = 0; in pcf50633_irq()
182 if (pcf->mask_regs[0] & PCF50633_INT1_SECOND) in pcf50633_irq()
183 pcf50633_reg_set_bit_mask(pcf, in pcf50633_irq()
188 if (pcf->mask_regs[1] & PCF50633_INT2_ONKEYR) in pcf50633_irq()
189 pcf50633_reg_set_bit_mask(pcf, in pcf50633_irq()
196 if (pcf->is_suspended) { in pcf50633_irq()
197 pcf->is_suspended = 0; in pcf50633_irq()
201 pcf->resume_reason[i] = pcf_int[i] & in pcf50633_irq()
202 pcf->pdata->resumers[i]; in pcf50633_irq()
211 pcf_int[i] &= ~pcf->mask_regs[i]; in pcf50633_irq()
215 pcf50633_irq_call_handler(pcf, (i * 8) + j); in pcf50633_irq()
225 struct pcf50633 *pcf = i2c_get_clientdata(client); in pcf50633_suspend() local
233 disable_irq(pcf->irq); in pcf50633_suspend()
236 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M, in pcf50633_suspend()
237 ARRAY_SIZE(pcf->suspend_irq_masks), in pcf50633_suspend()
238 pcf->suspend_irq_masks); in pcf50633_suspend()
240 dev_err(pcf->dev, "error saving irq masks\n"); in pcf50633_suspend()
246 res[i] = ~pcf->pdata->resumers[i]; in pcf50633_suspend()
248 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M, in pcf50633_suspend()
251 dev_err(pcf->dev, "error writing wakeup irq masks\n"); in pcf50633_suspend()
255 pcf->is_suspended = 1; in pcf50633_suspend()
264 struct pcf50633 *pcf = i2c_get_clientdata(client); in pcf50633_resume() local
268 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M, in pcf50633_resume()
269 ARRAY_SIZE(pcf->suspend_irq_masks), in pcf50633_resume()
270 pcf->suspend_irq_masks); in pcf50633_resume()
272 dev_err(pcf->dev, "Error restoring saved suspend masks\n"); in pcf50633_resume()
274 enable_irq(pcf->irq); in pcf50633_resume()
281 int pcf50633_irq_init(struct pcf50633 *pcf, int irq) in pcf50633_irq_init() argument
285 pcf->irq = irq; in pcf50633_irq_init()
288 pcf->mask_regs[0] = 0x80; in pcf50633_irq_init()
289 pcf50633_reg_write(pcf, PCF50633_REG_INT1M, pcf->mask_regs[0]); in pcf50633_irq_init()
290 pcf50633_reg_write(pcf, PCF50633_REG_INT2M, 0x00); in pcf50633_irq_init()
291 pcf50633_reg_write(pcf, PCF50633_REG_INT3M, 0x00); in pcf50633_irq_init()
292 pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00); in pcf50633_irq_init()
293 pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00); in pcf50633_irq_init()
297 "pcf50633", pcf); in pcf50633_irq_init()
300 dev_err(pcf->dev, "Failed to request IRQ %d\n", ret); in pcf50633_irq_init()
303 dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source" in pcf50633_irq_init()
309 void pcf50633_irq_free(struct pcf50633 *pcf) in pcf50633_irq_free() argument
311 free_irq(pcf->irq, pcf); in pcf50633_irq_free()