2 * Support for power detection code on the HTC Apache phone.
4 * (c) Copyright 2006 Kevin O'Connor <kevin@koconnor.net>
6 * This file may be distributed under the terms of the GNU GPL license.
9 #include <linux/kernel.h>
10 #include <linux/interrupt.h> // request_irq
12 #include <asm/arch/htcapache-gpio.h>
15 /****************************************************************
17 ****************************************************************/
19 // Interrupt handler called when plugging/unplugging mini-usb port
21 power_isr(int irq
, void *dev_id
, struct pt_regs
*regs
)
23 int haspower
= !htcapache_egpio_isset(EGPIO_NR_HTCAPACHE_PWR_IN_PWR
);
24 int hashigh
= !htcapache_egpio_isset(EGPIO_NR_HTCAPACHE_PWR_IN_HIGHPWR
);
25 if (haspower
&& !hashigh
) {
26 // USB plug - activate usb transceiver.
27 htcapache_egpio_set(EGPIO_NR_HTCAPACHE_USB_PWR
);
29 htcapache_egpio_clear(EGPIO_NR_HTCAPACHE_USB_PWR
);
31 printk("USB mini plug event (pwr=%d ac=%d)\n"
37 /****************************************************************
39 ****************************************************************/
42 htcapache_power_init(void)
46 // Setup plug interrupt
47 result
= request_irq(IRQ_EGPIO(EGPIO_NR_HTCAPACHE_PWR_IN_PWR
)
48 , power_isr
, SA_SAMPLE_RANDOM
,
51 printk("unable to claim irq %d for usb plug event. Got %d\n"
52 , IRQ_EGPIO(EGPIO_NR_HTCAPACHE_PWR_IN_PWR
), result
);
54 // Run the interrupt handler to initialize.
55 power_isr(0, NULL
, NULL
);