arm: tegra: cardhu: set CPU EDP limits
Varun Wadekar [Thu, 12 May 2011 08:55:01 +0000 (13:55 +0530)]
Original-Change-Id: I6282bbb63c34b8cc0d503cdd6eafe575fb78ef5f
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-on: http://git-master/r/31342
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: R71a8023042831f208803dd7d7cad84912db9d3c1

arch/arm/mach-tegra/board-cardhu-power.c
arch/arm/mach-tegra/board-cardhu-sensors.c
arch/arm/mach-tegra/board-cardhu.c
arch/arm/mach-tegra/board-cardhu.h

index f593d9f..6af7c4a 100644 (file)
@@ -33,6 +33,7 @@
 #include <mach/iomap.h>
 #include <mach/irqs.h>
 #include <mach/pinmux.h>
+#include <mach/edp.h>
 
 #include "gpio-names.h"
 #include "board.h"
@@ -943,3 +944,29 @@ int __init cardhu_power_off_init(void)
        return 0;
 }
 
+#ifdef CONFIG_TEGRA_EDP_LIMITS
+/*
+ * placeholder for now. needs to be changed with characterized data.
+ * step size cannot be less than 4C
+ */
+static struct tegra_edp_limits cardhu_edp_limits[] = {
+/* Temperature  1 CPU    2 CPUs   3 CPUs   4 CPUs */
+       {60,    {1400000, 1300000, 1300000, 1300000}},
+       {70,    {1400000, 1300000, 1300000, 1260000}},
+       {80,    {1400000, 1300000, 1300000, 1200000}},
+       {90,    {1400000, 1300000, 1300000, 1100000}},
+};
+
+void cardhu_thermal_zones_info(struct tegra_edp_limits **z, int *sz)
+{
+       *z = cardhu_edp_limits;
+       *sz = ARRAY_SIZE(cardhu_edp_limits);
+}
+
+int __init cardhu_edp_init(void)
+{
+       // FIXME: uncomment to override default EDP with above table
+       //tegra_init_cpu_edp_limits(cardhu_edp_limits, ARRAY_SIZE(cardhu_edp_limits));
+       return 0;
+}
+#endif
index 81f4ab8..b225c77 100644 (file)
@@ -35,6 +35,7 @@
 #include <media/sh532u.h>
 
 #include <mach/gpio.h>
+#include <mach/edp.h>
 
 #include "gpio-names.h"
 #include "board-cardhu.h"
@@ -428,6 +429,8 @@ static struct i2c_board_info cardhu_i2c8_board_info[] = {
        },
 };
 
+extern void tegra_throttling_enable(bool enable);
+
 static struct nct1008_platform_data cardhu_nct1008_pdata = {
        .supported_hwrev = true,
        .ext_range = false,
@@ -436,8 +439,8 @@ static struct nct1008_platform_data cardhu_nct1008_pdata = {
        .hysteresis = 5,
        .shutdown_ext_limit = 75,
        .shutdown_local_limit = 75,
-       .throttling_ext_limit = 60,
-       .alarm_fn = NULL,
+       .throttling_ext_limit = 90,
+       .alarm_fn = tegra_throttling_enable,
 };
 
 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
@@ -447,7 +450,7 @@ static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
        },
 };
 
-static struct i2c_board_info cardhu_i2c4_board_info[] = {
+static struct i2c_board_info cardhu_i2c4_nct1008_board_info[] = {
        {
                I2C_BOARD_INFO("nct1008", 0x4C),
                .platform_data = &cardhu_nct1008_pdata,
@@ -455,10 +458,19 @@ static struct i2c_board_info cardhu_i2c4_board_info[] = {
        }
 };
 
+#ifdef CONFIG_TEGRA_EDP_LIMITS
+extern void cardhu_thermal_zones_info(struct tegra_edp_limits **, int *);
+#endif
+
 static int cardhu_nct1008_init(void)
 {
        int nct1008_port = -1;
        int ret;
+#ifdef CONFIG_TEGRA_EDP_LIMITS
+       struct tegra_edp_limits *z;
+       int zones_sz;
+       int i;
+#endif
 
        if ((board_info.board_id == BOARD_E1198) ||
                (board_info.board_id == BOARD_E1291)) {
@@ -471,8 +483,7 @@ static int cardhu_nct1008_init(void)
 
        if (nct1008_port >= 0) {
                /* FIXME: enable irq when throttling is supported */
-               /* cardhu_i2c4_board_info[0].irq = */
-               /* TEGRA_GPIO_TO_IRQ(nct1008_port); */
+               cardhu_i2c4_nct1008_board_info[0].irq = TEGRA_GPIO_TO_IRQ(nct1008_port);
 
                ret = gpio_request(nct1008_port, "temp_alert");
                if (ret < 0)
@@ -483,8 +494,16 @@ static int cardhu_nct1008_init(void)
                        gpio_free(nct1008_port);
                else
                        tegra_gpio_enable(nct1008_port);
-
        }
+
+#ifdef CONFIG_TEGRA_EDP_LIMITS
+       cardhu_thermal_zones_info(&z, &zones_sz);
+       zones_sz = min(zones_sz, MAX_ZONES);
+       for (i = 0; i < zones_sz; i++)
+               cardhu_nct1008_pdata.thermal_zones[i] = z[i].temperature;
+
+       cardhu_nct1008_pdata.thermal_zones_sz = zones_sz;
+#endif
        return ret;
 }
 
@@ -622,9 +641,6 @@ int __init cardhu_sensors_init(void)
 
        pmu_tca6416_init();
 
-       i2c_register_board_info(4, cardhu_i2c4_board_info,
-               ARRAY_SIZE(cardhu_i2c4_board_info));
-
        if (board_info.board_id == BOARD_E1291)
                i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
                        ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
@@ -636,6 +652,9 @@ int __init cardhu_sensors_init(void)
        if (err)
                return err;
 
+       i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
+               ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
+
 #ifdef CONFIG_SENSORS_MPU3050
        cardhu_mpuirq_init();
 #endif
index 79e27d6..8091886 100644 (file)
@@ -470,6 +470,9 @@ static void __init tegra_cardhu_init(void)
        cardhu_pinmux_init();
        cardhu_i2c_init();
        cardhu_usb_init();
+#ifdef CONFIG_TEGRA_EDP_LIMITS
+       cardhu_edp_init();
+#endif
        platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
        cardhu_sdhci_init();
        cardhu_regulator_init();
index 0b424cd..8e68e12 100644 (file)
 #define TPS6591X_IRQ_BASE      TEGRA_NR_IRQS
 #define TPS6591X_IRQ_END       (TPS6591X_IRQ_BASE + 24)
 
-
-
 int cardhu_charge_init(void);
 int cardhu_regulator_init(void);
 int cardhu_suspend_init(void);
@@ -132,5 +130,6 @@ int cardhu_gpio_switch_regulator_init(void);
 int cardhu_pins_state_init(void);
 int cardhu_emc_init(void);
 int cardhu_power_off_init(void);
+int cardhu_edp_init(void);
 
 #endif