arm: tegra: enterprise: Initialize battery peak current management device
Anshul Jain [Fri, 9 Dec 2011 01:33:32 +0000 (17:33 -0800)]
Register the battery peak current management device, that can trigger
cpu frequency/voltage change when GPIO is triggered by battery current
monitoring device.

Change-Id: I5a79ed2d3e057a51a7dc3953b8c252f4ee5b9a6a
Signed-off-by: Anshul Jain <anshulj@nvidia.com>
Reviewed-on: http://git-master/r/68816
Reviewed-on: http://git-master/r/69104
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Lokesh Pathak <lpathak@nvidia.com>
Tested-by: Lokesh Pathak <lpathak@nvidia.com>

Rebase-Id: Rc9ac75546db549f950e8d035816585b2643763e4

arch/arm/mach-tegra/board-enterprise-power.c
arch/arm/mach-tegra/board-enterprise.c
arch/arm/mach-tegra/board-enterprise.h

index 470a8b1..ac7864b 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/tps80031-charger.h>
 #include <linux/gpio.h>
 #include <linux/io.h>
+#include <linux/cpumask.h>
+#include <linux/platform_data/tegra_bpc_mgmt.h>
 
 #include <mach/edp.h>
 #include <mach/iomap.h>
@@ -580,3 +582,33 @@ int __init enterprise_edp_init(void)
        return 0;
 }
 #endif
+
+static struct tegra_bpc_mgmt_platform_data bpc_mgmt_platform_data = {
+       .gpio_trigger = TEGRA_BPC_TRIGGER,
+       .bpc_mgmt_timeout = TEGRA_BPC_TIMEOUT,
+};
+
+static struct platform_device enterprise_bpc_mgmt_device = {
+       .name           = "tegra-bpc-mgmt",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &bpc_mgmt_platform_data,
+       },
+};
+
+void __init enterprise_bpc_mgmt_init(void)
+{
+       int int_gpio = TEGRA_GPIO_TO_IRQ(TEGRA_BPC_TRIGGER);
+
+       tegra_gpio_enable(TEGRA_BPC_TRIGGER);
+
+#ifdef CONFIG_SMP
+       cpumask_setall(&(bpc_mgmt_platform_data.affinity_mask));
+       irq_set_affinity_hint(int_gpio,
+                               &(bpc_mgmt_platform_data.affinity_mask));
+       irq_set_affinity(int_gpio, &(bpc_mgmt_platform_data.affinity_mask));
+#endif
+       platform_device_register(&enterprise_bpc_mgmt_device);
+
+       return;
+}
index fd654dc..dcdd18f 100644 (file)
@@ -774,6 +774,7 @@ static void __init tegra_enterprise_init(void)
        enterprise_emc_init();
        enterprise_sensors_init();
        enterprise_suspend_init();
+       enterprise_bpc_mgmt_init();
        tegra_release_bootloader_fb();
        enterprise_nfc_init();
 }
index eb835db..bb5b524 100644 (file)
@@ -51,6 +51,7 @@ int enterprise_modem_init(void);
 int enterprise_suspend_init(void);
 int enterprise_edp_init(void);
 void __init enterprise_tsensor_init(void);
+void enterprise_bpc_mgmt_init(void);
 
 /* PCA954x I2C bus expander bus addresses */
 #define PCA954x_I2C_BUS_BASE   6
@@ -95,4 +96,8 @@ void __init enterprise_tsensor_init(void);
 
 #define TDIODE_OFFSET  (9000)  /* in millicelsius */
 
-#endif
+/* Battery Peak Current Management */
+#define TEGRA_BPC_TRIGGER              TEGRA_GPIO_PR3
+#define TEGRA_BPC_TIMEOUT              100 /* ms */
+
+#endif /*_MACH_TEGRA_BOARD_ENTERPRISE_H */