ARM: tegra: roth: Enable INA3221 device
Anshul Jain [Tue, 4 Dec 2012 20:21:36 +0000 (12:21 -0800)]
Changes in board files to declare the INA3221 device and right
configuration parameters.There is only 1 INA3221 device on roth
which can measure power consumed over 3 rails.

Bug 1160066

Change-Id: Ic28041f08b2c878b4859455c08f5c691b4c224e9
Signed-off-by: Anshul Jain <anshulj@nvidia.com>
Reviewed-on: http://git-master/r/167599
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User

arch/arm/mach-tegra/board-roth-powermon.c
arch/arm/mach-tegra/board-roth.c

index 45eddf5..ec11803 100644 (file)
  */
 
 #include <linux/i2c.h>
-#include <linux/ina219.h>
+#include <linux/ina3221.h>
 
 #include "board.h"
 #include "board-roth.h"
 
-#define PRECISION_MULTIPLIER_ROTH 1000
-
 enum {
-       VDD_12V_DCIN_RS,
-       VDD_AC_BAT_VIN1,
-       VDD_5V0_SYS,
-       VDD_3V3_SYS,
-       VDD_3V3_SYS_VIN4_5_7,
-       AVDD_USB_HDMI,
-       VDD_AC_BAT_D1,
-       VDD_AO_SMPS12_IN,
-       VDD_3V3_SYS_SMPS45_IN,
-       VDD_AO_SMPS2_IN,
-       VDDIO_HV_AP,
-       VDD_1V8_LDO3_IN,
-       VDD_3V3_SYS_LDO4_IN,
-       VDD_AO_LDO8_IN,
-       VDD_1V8_AP,
-       VDD_1V8_DSM,
+       VDD_DDR_CORE_CPU,
 };
 
-static struct ina219_platform_data power_mon_info[] = {
-       [VDD_12V_DCIN_RS] = {
-               .calibration_data  = 0xaec0,
-               .power_lsb = 1.8311874106 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_12V_DCIN_RS",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_AC_BAT_VIN1] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_AC_BAT_VIN1",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_5V0_SYS] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 2.5000762963 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_5V0_SYS",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_3V3_SYS] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 2.5000762963 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_3V3_SYS",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_3V3_SYS_VIN4_5_7] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_3V3_SYS_VIN4_5_7",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [AVDD_USB_HDMI] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "AVDD_USB_HDMI",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_AC_BAT_D1] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 12.50038148 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_AC_BAT_D1",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_AO_SMPS12_IN] = {
-               .calibration_data  = 0xaec0,
-               .power_lsb = 1.8311874106 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_AO_SMPS12_IN",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_3V3_SYS_SMPS45_IN] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_3V3_SYS_SMPS45_IN",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_AO_SMPS2_IN] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_AO_SMPS2_IN",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDDIO_HV_AP] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDDIO_HV_AP",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_1V8_LDO3_IN] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_1V8_LDO3_IN",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_3V3_SYS_LDO4_IN] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_3V3_SYS_LDO4_IN",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_AO_LDO8_IN] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_AO_LDO8_IN",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_1V8_AP] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_1V8_AP",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
-       },
-
-       [VDD_1V8_DSM] = {
-               .calibration_data  = 0xfffe,
-               .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_ROTH,
-               .rail_name = "VDD_1V8_DSM",
-               .divisor = 20,
-               .precision_multiplier = PRECISION_MULTIPLIER_ROTH,
+static struct ina3221_platform_data power_mon_info[] = {
+       [VDD_DDR_CORE_CPU] = {
+               .rail_name = {"VDD_SYS_DDR_IN", "VDD_SYS_SOC_IN",
+                                                       "VDD_SYS_CPU_IN"},
+               .shunt_resistor = {10, 10, 10},
+               .cont_conf_data = INA3221_CONT_CONFIG_DATA,
+               .trig_conf_data = INA3221_TRIG_CONFIG_DATA,
        },
 };
 
 enum {
        INA_I2C_ADDR_40,
-       INA_I2C_ADDR_41,
-       INA_I2C_ADDR_42,
-       INA_I2C_ADDR_43,
-       INA_I2C_ADDR_44,
-       INA_I2C_ADDR_45,
-       INA_I2C_ADDR_46,
-       INA_I2C_ADDR_47,
-       INA_I2C_ADDR_48,
-       INA_I2C_ADDR_49,
-       INA_I2C_ADDR_4A,
-       INA_I2C_ADDR_4B,
-       INA_I2C_ADDR_4C,
-       INA_I2C_ADDR_4D,
-       INA_I2C_ADDR_4E,
-       INA_I2C_ADDR_4F,
 };
 
-static struct i2c_board_info roth_i2c0_ina219_board_info[] = {
+static struct i2c_board_info roth_i2c1_ina3221_board_info[] = {
        [INA_I2C_ADDR_40] = {
-               I2C_BOARD_INFO("ina219", 0x40),
-               .platform_data = &power_mon_info[VDD_12V_DCIN_RS],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_41] = {
-               I2C_BOARD_INFO("ina219", 0x41),
-               .platform_data = &power_mon_info[VDD_AC_BAT_VIN1],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_42] = {
-               I2C_BOARD_INFO("ina219", 0x42),
-               .platform_data = &power_mon_info[VDD_5V0_SYS],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_43] = {
-               I2C_BOARD_INFO("ina219", 0x43),
-               .platform_data = &power_mon_info[VDD_3V3_SYS],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_44] = {
-               I2C_BOARD_INFO("ina219", 0x44),
-               .platform_data = &power_mon_info[VDD_3V3_SYS_VIN4_5_7],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_45] = {
-               I2C_BOARD_INFO("ina219", 0x45),
-               .platform_data = &power_mon_info[AVDD_USB_HDMI],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_46] = {
-               I2C_BOARD_INFO("ina219", 0x46),
-               .platform_data = &power_mon_info[VDD_AC_BAT_D1],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_47] = {
-               I2C_BOARD_INFO("ina219", 0x47),
-               .platform_data = &power_mon_info[VDD_AO_SMPS12_IN],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_48] = {
-               I2C_BOARD_INFO("ina219", 0x48),
-               .platform_data = &power_mon_info[VDD_3V3_SYS_SMPS45_IN],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_49] = {
-               I2C_BOARD_INFO("ina219", 0x49),
-               .platform_data = &power_mon_info[VDD_AO_SMPS2_IN],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_4A] = {
-               I2C_BOARD_INFO("ina219", 0x4A),
-               .platform_data = &power_mon_info[VDDIO_HV_AP],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_4B] = {
-               I2C_BOARD_INFO("ina219", 0x4B),
-               .platform_data = &power_mon_info[VDD_1V8_LDO3_IN],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_4C] = {
-               I2C_BOARD_INFO("ina219", 0x4C),
-               .platform_data = &power_mon_info[VDD_3V3_SYS_LDO4_IN],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_4D] = {
-               I2C_BOARD_INFO("ina219", 0x4D),
-               .platform_data = &power_mon_info[VDD_AO_LDO8_IN],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_4E] = {
-               I2C_BOARD_INFO("ina219", 0x4E),
-               .platform_data = &power_mon_info[VDD_1V8_AP],
-               .irq = -1,
-       },
-
-       [INA_I2C_ADDR_4F] = {
-               I2C_BOARD_INFO("ina219", 0x4F),
-               .platform_data = &power_mon_info[VDD_1V8_DSM],
+               I2C_BOARD_INFO("ina3221", 0x40),
+               .platform_data = &power_mon_info[VDD_DDR_CORE_CPU],
                .irq = -1,
        },
 };
 
 int __init roth_pmon_init(void)
 {
-       i2c_register_board_info(1, roth_i2c0_ina219_board_info,
-               ARRAY_SIZE(roth_i2c0_ina219_board_info));
+       pr_info("INA3221: registering device\n");
+       i2c_register_board_info(1, roth_i2c1_ina3221_board_info,
+               ARRAY_SIZE(roth_i2c1_ina3221_board_info));
 
        return 0;
 }
-
index 13a6754..47cc55b 100644 (file)
@@ -552,6 +552,7 @@ static void __init tegra_roth_init(void)
        roth_edp_init();
        roth_panel_init();
        roth_kbc_init();
+       roth_pmon_init();
 #ifdef CONFIG_BT_BLUESLEEP
        roth_setup_bluesleep();
        roth_setup_bt_rfkill();