16 #include <linux/kernel.h>
18 #include <linux/export.h>
19 #include <linux/slab.h>
25 void (*handler) (
int,
void *),
void *
data)
55 static int __pcf50633_irq_mask_set(
struct pcf50633 *pcf,
int irq,
u8 mask)
62 bit = 1 << (irq & 0x07);
82 return __pcf50633_irq_mask_set(pcf, irq, 1);
90 return __pcf50633_irq_mask_set(pcf, irq, 0);
99 bits = 1 << (irq & 0x07);
105 static void pcf50633_irq_call_handler(
struct pcf50633 *pcf,
int irq)
112 #define PCF50633_ONKEY1S_TIMEOUT 8
118 u8 pcf_int[5], chgstat;
124 dev_err(pcf->
dev,
"Error reading INT registers\n");
140 if (chgstat & (0x3 << 4))
149 if (chgstat & (0x3 << 4))
155 dev_dbg(pcf->
dev,
"INT1=0x%02x INT2=0x%02x INT3=0x%02x "
156 "INT4=0x%02x INT5=0x%02x\n", pcf_int[0],
157 pcf_int[1], pcf_int[2], pcf_int[3], pcf_int[4]);
165 if (pcf->
pdata->force_shutdown)
166 pcf->
pdata->force_shutdown(pcf);
175 PCF50633_INT1_SECOND);
186 if (pcf->
mask_regs[0] & PCF50633_INT1_SECOND)
189 PCF50633_INT1_SECOND,
190 PCF50633_INT1_SECOND);
192 if (pcf->
mask_regs[1] & PCF50633_INT2_ONKEYR)
195 PCF50633_INT2_ONKEYR,
196 PCF50633_INT2_ONKEYR);
206 pcf->
pdata->resumers[i];
217 for (j = 0; j < 8 ; j++)
218 if (pcf_int[i] & (1 << j))
219 pcf50633_irq_call_handler(pcf, (i * 8) +
j);
228 int pcf50633_irq_suspend(
struct pcf50633 *pcf)
244 dev_err(pcf->
dev,
"error saving irq masks\n");
250 res[i] = ~pcf->
pdata->resumers[i];
255 dev_err(pcf->
dev,
"error writing wakeup irq masks\n");
265 int pcf50633_irq_resume(
struct pcf50633 *pcf)
274 dev_err(pcf->
dev,
"Error restoring saved suspend masks\n");
302 dev_err(pcf->
dev,
"Failed to request IRQ %d\n", ret);
304 if (enable_irq_wake(irq) < 0)
305 dev_err(pcf->
dev,
"IRQ %u cannot be enabled as wake-up source"
306 "in this hardware revision", irq);