diff options
| -rw-r--r-- | arch/arm/boot/dts/omap3_h1.dts | 4 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/board-omap3h1.c | 5 | ||||
| -rw-r--r-- | drivers/power/bq27x00_battery.c | 40 | ||||
| -rw-r--r-- | drivers/rtc/rtc-tps65910.c | 5 |
4 files changed, 53 insertions, 1 deletions
diff --git a/arch/arm/boot/dts/omap3_h1.dts b/arch/arm/boot/dts/omap3_h1.dts index 090cd6f4362..a12cf478222 100644 --- a/arch/arm/boot/dts/omap3_h1.dts +++ b/arch/arm/boot/dts/omap3_h1.dts @@ -77,6 +77,7 @@ /* off IRQ handle */ ti,pad_irq = <0x150 88 1>, /* uart1 - BT input */ <0x9f6 143 1>, /* mpu6515 irq pin - is this offset correct? */ + <0x9ea 122 1>, /* bq27400 chg irq8 */ <0x9f4 123 1>, /* BT host wake */ <0x1b0 23 1>; /* sys_nirq */ }; @@ -232,7 +233,8 @@ pinctrl-single,pins = < 0x006 0x008 /* SYS_CLKREQ, MODE0 | PULLDOWN */ 0x018 0x000 /* SYS_OFF_MODE, MODE0 */ - 0x01a 0x10c /* SYS_CLKOUT1, MODE4 | INPUT_PULLDOWN */ + /* Fuel gauge interrupt */ + 0x01a 0x4104 /* SYS_CLKOUT1, MODE4 | OMAP_PIN_INPUT */ /* Wakeup from Bluetooth */ 0x024 0x410C /* JTAG_EMU0, OMAP_MUX_MODE4 | OMAP_PIN_INPUT | diff --git a/arch/arm/mach-omap2/board-omap3h1.c b/arch/arm/mach-omap2/board-omap3h1.c index 063b3851b4e..6a6e8b2bd45 100644 --- a/arch/arm/mach-omap2/board-omap3h1.c +++ b/arch/arm/mach-omap2/board-omap3h1.c @@ -79,6 +79,7 @@ #define TPS_SYS_NIRQ 0 #define USB_IRQ 124 #define USB_CS 17 +#define CHG_GPOUT 10 #define DEFAULT_RXDMA_POLLRATE 1 /* RX DMA polling rate (us) */ #define DEFAULT_RXDMA_BUFSIZE 4096 /* RX DMA buffer size */ @@ -397,6 +398,10 @@ static int __init omap3_h1_i2c_init(void) omap3h1_i2c1_board_info[1].irq = acc_irq; #endif +#if defined (CONFIG_MACH_OMAP3_H1_PV) + omap3h1_i2c2_board_info[4].irq = gpio_to_irq(CHG_GPOUT); +#endif + gpio_request_one(USB_CS, GPIOF_OUT_INIT_HIGH, "USB on"); /* Register buses */ diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index 7bed61e6229..c10f48b20c8 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c @@ -37,8 +37,11 @@ #include <linux/power_supply.h> #include <linux/idr.h> #include <linux/i2c.h> +#include <linux/irq.h> +#include <linux/interrupt.h> #include <linux/slab.h> #include <asm/unaligned.h> +#include <linux/wakelock.h> #include <linux/power/bq27x00_battery.h> @@ -67,6 +70,8 @@ enum bq27xxx_reg_index { NUM_REGS }; +struct wake_lock chg_wake_lock; + /* bq27500 registers */ static __initdata u8 bq27500_regs[NUM_REGS] = { 0x00, /* CONTROL */ @@ -279,6 +284,7 @@ struct bq27x00_device_info { struct device *dev; int id; enum bq27x00_chip chip; + int irq; struct bq27x00_reg_cache cache; int charge_design_full; @@ -1345,6 +1351,16 @@ static void bq27x00_external_power_changed(struct power_supply *psy) schedule_delayed_work(&di->work, 0); } +static irqreturn_t bq27x00_chg_isr(int irq, void *dev) { + + struct power_supply *ps = (struct power_supply*) dev; + wake_lock_timeout(&chg_wake_lock, msecs_to_jiffies(500)); + dev_dbg(ps->dev, "%s: Updating battery status\n", __func__); + bq27x00_external_power_changed(ps); + + return IRQ_HANDLED; +} + static void __init set_properties_array(struct bq27x00_device_info *di, enum power_supply_property *props, int num_props) { @@ -1393,6 +1409,25 @@ static int __init bq27x00_powersupply_init(struct bq27x00_device_info *di) return ret; } + wake_lock_init(&chg_wake_lock, WAKE_LOCK_SUSPEND, "chg_wake_lock"); + + if(di->irq) { + // If using an irq, disable poll interal + poll_interval = 0; + ret = request_irq(di->irq, bq27x00_chg_isr, IRQF_TRIGGER_RISING, + "bq27x00 chg", &di->bat); + if (ret) { + dev_err(di->dev, "failed to request irq: %d\n", di->irq); + return ret; + } + + ret = enable_irq_wake(di->irq); + if (ret) { + dev_err(di->dev, "failed to enable irq: %d, as wake\n", di->irq); + return ret; + } + } + dev_info(di->dev, "support ver. %s enabled\n", DRIVER_VERSION); bq27x00_update(di); @@ -1414,6 +1449,10 @@ static void bq27x00_powersupply_unregister(struct bq27x00_device_info *di) power_supply_unregister(&di->bat); + if(di->irq) { + free_irq(di->irq, di); + } + mutex_destroy(&di->lock); } @@ -1685,6 +1724,7 @@ static int __init bq27x00_battery_probe(struct i2c_client *client, di->bus.blk_write = bq27xxx_write_i2c_blk; di->dm_regs = NULL; di->dm_regs_count = 0; + di->irq = client->irq; if (di->chip == BQ27200) regs = bq27200_regs; diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index a9caf043b0c..cdbf1a2b251 100644 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c @@ -25,6 +25,9 @@ #include <linux/pm_runtime.h> #include <linux/interrupt.h> #include <linux/mfd/tps65910.h> +#include <linux/wakelock.h> + +struct wake_lock rtc_wake_lock; struct tps65910_rtc { struct rtc_device *rtc; @@ -197,6 +200,7 @@ static irqreturn_t tps65910_rtc_interrupt(int irq, void *rtc) int ret; u32 rtc_reg; + wake_lock_timeout(&rtc_wake_lock, msecs_to_jiffies(2000)); ret = regmap_read(tps->regmap, TPS65910_RTC_STATUS, &rtc_reg); if (ret) return IRQ_NONE; @@ -285,6 +289,7 @@ static int tps65910_rtc_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, tps_rtc); + wake_lock_init(&rtc_wake_lock, WAKE_LOCK_SUSPEND, "rtc_wake_lock"); return 0; } |