diff options
| author | Evan Wilson <evan@oliodevices.com> | 2015-08-03 13:27:42 -0700 |
|---|---|---|
| committer | Evan Wilson <evan@oliodevices.com> | 2015-08-03 13:27:42 -0700 |
| commit | e67e4a3911a387f93f812331aa96046c0141f686 (patch) | |
| tree | 9d62b339470474e5fa61b36da12a37518bde728d | |
| parent | 96c073888c2a35f6133b109b333cedec6da4910b (diff) | |
| download | olio-linux-3.10-e67e4a3911a387f93f812331aa96046c0141f686.tar.xz olio-linux-3.10-e67e4a3911a387f93f812331aa96046c0141f686.zip | |
The charger now works off of an IRQ, instead of scheduling every minute.
Change-Id: Id3696474a3b23da5ae7479e175642cb5a7d81599
| -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 | 34 |
3 files changed, 42 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..86b4709b911 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c @@ -37,6 +37,8 @@ #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> @@ -279,6 +281,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 +1348,15 @@ 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; + 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 +1405,23 @@ static int __init bq27x00_powersupply_init(struct bq27x00_device_info *di) return ret; } + 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 +1443,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 +1718,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; |