Permalink
Browse files

Add Encore charger and battery drivers.

  • Loading branch information...
verygreen committed Mar 12, 2011
1 parent c3598e3 commit 02099fe0a95eed68752d2d3eba9b3412ec8d1893
@@ -21,6 +21,10 @@
#include <linux/err.h>
#include <linux/clk.h>
+#ifdef CONFIG_BATTERY_MAX17042
+#include <linux/max17042.h>
+#endif
+
#include <linux/spi/spi.h>
#include <linux/i2c/twl.h>
#include <linux/interrupt.h>
@@ -34,6 +38,7 @@
#include <asm/mach/map.h>
#include <linux/mmc/host.h>
+#include <plat/board-encore.h>
#include <plat/mcspi.h>
#include <mach/gpio.h>
#include <plat/board.h>
@@ -152,11 +157,51 @@ static void __init omap_encore_init_irq(void)
omap_init_irq();
}
+#ifdef CONFIG_CHARGER_MAX8903
+static struct platform_device max8903_charger_device = {
+ .name = "max8903_charger",
+ .id = -1,
+};
+#endif
+
+#ifdef CONFIG_BATTERY_MAX17042
+static void max17042_dev_init(void)
+{
+ printk("board-encore.c: max17042_dev_init ...\n");
+
+ if (gpio_request(MAX17042_GPIO_FOR_IRQ, "max17042_irq") < 0) {
+ printk(KERN_ERR "Can't get GPIO for max17042 IRQ\n");
+ return;
+ }
+
+ printk("board-encore.c: max17042_dev_init > Init max17042 irq pin %d !\n", MAX17042_GPIO_FOR_IRQ);
+ gpio_direction_input(MAX17042_GPIO_FOR_IRQ);
+ gpio_set_debounce(MAX17042_GPIO_FOR_IRQ, 0);
+ printk("max17042 GPIO pin read %d\n", gpio_get_value(MAX17042_GPIO_FOR_IRQ));
+}
+
+struct max17042_platform_data max17042_platform_data_here = {
+
+ //fill in device specific data here
+ //load stored parameters from Rom Tokens?
+ //.val_FullCAP =
+ //.val_Cycles =
+ //.val_FullCAPNom =
+ //.val_SOCempty =
+ //.val_Iavg_empty =
+ //.val_RCOMP0 =
+ //.val_TempCo=
+ //.val_k_empty0 =
+ //.val_dQacc =
+ //.val_dPacc =
+
+ .gpio = MAX17042_GPIO_FOR_IRQ,
+};
+#endif
+
+
static struct twl4030_usb_data encore_usb_data = {
.usb_mode = T2_USB_MODE_ULPI,
-#ifdef CONFIG_REGULATOR_MAXIM_CHARGER
- .bci_supply = &bq24073_vcharge_supply,
-#endif
};
static struct regulator_consumer_supply encore_vmmc1_supply[] = {
@@ -864,6 +909,9 @@ static struct platform_device *encore_devices[] __initdata = {
&encore_ram_console_device,
&boxer_lcd_touch_regulator_device,
&encore_keys_gpio,
+#ifdef CONFIG_CHARGER_MAX8903
+ &max8903_charger_device,
+#endif
};
static void __init omap_encore_init(void)
@@ -887,6 +935,10 @@ static void __init omap_encore_init(void)
#endif
#endif
+#ifdef CONFIG_BATTERY_MAX17042
+ max17042_dev_init();
+#endif
+
BUG_ON(!cpu_is_omap3630());
}
@@ -0,0 +1,75 @@
+/*
+ * arch/arm/plat-omap/include/mach/board-boxer.h
+ *
+ * Hardware definitions for TI OMAP3-based Encore (B&N Nook Color).
+ *
+ * Copyright (C) 2008 Texas Instruments Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __ASM_ARCH_OMAP_BOXER_H
+#define __ASM_ARCH_OMAP_BOXER_H
+
+extern void ldp_flash_init(void);
+extern void twl4030_bci_battery_init(void);
+extern unsigned get_last_off_on_transaction_id(struct device *dev);
+
+#define TWL4030_IRQNUM INT_34XX_SYS_NIRQ
+#define LDP3430_NAND_CS 0
+
+#define OMAP3_WAKEUP (PRCM_WAKEUP_T2_KEYPAD |\
+ PRCM_WAKEUP_TOUCHSCREEN | PRCM_WAKEUP_UART)
+
+#ifdef CONFIG_BATTERY_MAX17042
+#define MAX17042_GPIO_FOR_IRQ 100
+#endif
+
+/*addition of MAXIM8903/TI GPIO mapping WRT schematics */
+#ifdef CONFIG_CHARGER_MAX8903
+#define MAX8903_UOK_GPIO_FOR_IRQ 115
+#define MAX8903_DOK_GPIO_FOR_IRQ 114
+#define MAX8903_GPIO_CHG_EN 110
+#define MAX8903_GPIO_CHG_STATUS 111
+#define MAX8903_GPIO_CHG_FLT 101
+#define MAX8903_GPIO_CHG_IUSB 102
+#define MAX8903_GPIO_CHG_USUS 104
+#define MAX8903_GPIO_CHG_ILM 61
+#endif
+
+#define BOARD_ENCORE_REV_EVT1A 0x1
+#define BOARD_ENCORE_REV_EVT1B 0x2
+#define BOARD_ENCORE_REV_EVT2 0x3
+#define BOARD_ENCORE_REV_DVT 0x4
+#define BOARD_ENCORE_REV_PVT 0x5
+#define BOARD_ENCORE_REV_UNKNOWN 0x6
+
+static inline int is_encore_board_evt2(void)
+{
+ return (system_rev >= BOARD_ENCORE_REV_EVT2);
+}
+
+static inline int is_encore_board_evt1b(void)
+{
+ return (system_rev == BOARD_ENCORE_REV_EVT1B);
+}
+
+#endif /* __ASM_ARCH_OMAP_BOXER_H */
View
@@ -162,4 +162,16 @@ config CHARGER_PCF50633
help
Say Y to include support for NXP PCF50633 Main Battery Charger.
+config BATTERY_MAX17042
+ tristate "MAX17042 gas gauge driver"
+ depends on I2C
+ help
+ Say Y here to enable support for chip MAX17042 gas gauge.
+
+config CHARGER_MAX8903
+ tristate "MAX8903 charger driver"
+ depends on BATTERY_MAX17042 && GENERIC_GPIO
+ help
+ Say Y here to enable support for MAXIM8903 charger
+
endif # POWER_SUPPLY
View
@@ -37,3 +37,5 @@ obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
obj-$(CONFIG_TWL4030_BCI_BATTERY) += twl4030_bci_battery.o
obj-$(CONFIG_TWL6030_BCI_BATTERY) += twl6030_bci_battery.o
obj-$(CONFIG_CHARGER_BQ2415x) += bq2415x_charger.o
+obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o
+obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o
Oops, something went wrong.

0 comments on commit 02099fe

Please sign in to comment.