diff options
| author | Evan Wilson <evan@oliodevices.com> | 2015-08-05 06:25:17 +0000 | 
|---|---|---|
| committer | Gerrit Code Review <gerrit2@ip-172-31-25-77.us-west-1.compute.internal> | 2015-04-16 10:08:13 +0000 | 
| commit | 905802fa542d99e1e517d6a9cfbdb24824b3651b (patch) | |
| tree | 518a3c59c48fe5d8341c2c2ab178d76787e0f960 | |
| parent | 818daae7bec16f8e5ed436f1bc79e79f30467e89 (diff) | |
| parent | de3d691b61a9302d3284d790a630d720a906753b (diff) | |
| download | olio-linux-3.10-905802fa542d99e1e517d6a9cfbdb24824b3651b.tar.xz olio-linux-3.10-905802fa542d99e1e517d6a9cfbdb24824b3651b.zip | |
Merge changes I061a6a86,Id3696474 into android-3.10-bringup
* changes:
  Adding timed wakelock to the charger irq, so it has time to notify Android
  The charger now works off of an IRQ, instead of scheduling every minute.
| -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 | 
3 files changed, 48 insertions, 1 deletions
| diff --git a/arch/arm/boot/dts/omap3_h1.dts b/arch/arm/boot/dts/omap3_h1.dts index 5f200367193..481ec5e1976 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 = <0x152  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 6f089952c8f..06b150f4956 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; |