ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / board-ardbeg-powermon.c
index 55fcc6b..f6f6713 100644 (file)
@@ -18,9 +18,7 @@
  */
 
 #include <linux/i2c.h>
-#include <linux/ina219.h>
 #include <linux/platform_data/ina230.h>
-#include <linux/i2c/pca954x.h>
 
 #include "board.h"
 #include "board-ardbeg.h"
 #define VDD_CPU_BUCKCPU_REWORKED       10
 #define VDD_1V35_SD2_REWORKED          10
 
-#define AVG_32_SAMPLES (4 << 9)
+#define AVG_SAMPLES (2 << 9) /* 16 samples */
 
 /* AVG is specified from platform data */
-#define INA230_CONT_CONFIG     (AVG_32_SAMPLES | INA230_VBUS_CT | \
+#define INA230_CONT_CONFIG     (AVG_SAMPLES | INA230_VBUS_CT | \
                                INA230_VSH_CT | INA230_CONT_MODE)
-#define INA230_TRIG_CONFIG     (AVG_32_SAMPLES | INA230_VBUS_CT | \
+#define INA230_TRIG_CONFIG     (AVG_SAMPLES | INA230_VBUS_CT | \
                                INA230_VSH_CT | INA230_TRIG_MODE)
 
-/* unused rail */
+/* rails on i2c2_0 */
 enum {
-       UNUSED_RAIL,
+       VDD_BAT_0,
+       VDD_SYS_BUCKCPU_0,
+       VDD_SYS_BUCKSOC_0,
+       VDD_SYS_BUCKGPU_0,
 };
 
 /* following rails are present on Ardbeg */
@@ -95,14 +96,47 @@ enum {
        ARDBEG_A01_VDD_SYS_BL,
 };
 
-static struct ina219_platform_data power_mon_info_0[] = {
-       /* All unused INA219 devices use below data */
-       [UNUSED_RAIL] = {
-               .calibration_data = 0x369c,
-               .power_lsb = 3.051979018 * PRECISION_MULTIPLIER_ARDBEG,
-               .rail_name = "unused_rail",
-               .divisor = 20,
+static struct ina230_platform_data power_mon_info_0[] = {
+       /* E1780-A02 (Shield ERS) */
+       [VDD_BAT_0] = {
+               .calibration_data = 0x1366,
+               .power_lsb = 2.577527185 * PRECISION_MULTIPLIER_ARDBEG,
+               .rail_name = "__VDD_BAT",
+               .trig_conf = INA230_TRIG_CONFIG,
+               .cont_conf = INA230_CONT_CONFIG,
+               .divisor = 25,
+               .precision_multiplier = PRECISION_MULTIPLIER_ARDBEG,
+               .resistor = 10,
+       },
+       [VDD_SYS_BUCKCPU_0] = {
+               .calibration_data = 0x1AC5,
+               .power_lsb = 1.867795126 * PRECISION_MULTIPLIER_ARDBEG,
+               .rail_name = "__VDD_SYS_BUCKCPU",
+               .trig_conf = INA230_TRIG_CONFIG,
+               .cont_conf = INA230_CONT_CONFIG,
+               .divisor = 25,
                .precision_multiplier = PRECISION_MULTIPLIER_ARDBEG,
+               .resistor = 10,
+       },
+       [VDD_SYS_BUCKSOC_0] = {
+               .calibration_data = 0x2802,
+               .power_lsb = 0.624877954 * PRECISION_MULTIPLIER_ARDBEG,
+               .rail_name = "__VDD_SYS_BUCKSOC",
+               .trig_conf = INA230_TRIG_CONFIG,
+               .cont_conf = INA230_CONT_CONFIG,
+               .divisor = 25,
+               .precision_multiplier = PRECISION_MULTIPLIER_ARDBEG,
+               .resistor = 20,
+       },
+       [VDD_SYS_BUCKGPU_0] = {
+               .calibration_data = 0x1F38,
+               .power_lsb = 1.601601602 * PRECISION_MULTIPLIER_ARDBEG,
+               .rail_name = "__VDD_SYS_BUCKGPU",
+               .trig_conf = INA230_TRIG_CONFIG,
+               .cont_conf = INA230_CONT_CONFIG,
+               .divisor = 25,
+               .precision_multiplier = PRECISION_MULTIPLIER_ARDBEG,
+               .resistor = 10,
        },
 };
 
@@ -512,28 +546,28 @@ enum {
 };
 
 /* following is the i2c board info for Ardbeg */
-static struct i2c_board_info ardbeg_i2c2_0_ina219_board_info[] = {
+static struct i2c_board_info ardbeg_i2c2_0_ina230_board_info[] = {
        [INA_I2C_2_0_ADDR_40] = {
-               I2C_BOARD_INFO("ina219", 0x40),
-               .platform_data = &power_mon_info_0[UNUSED_RAIL],
+               I2C_BOARD_INFO("ina230", 0x40),
+               .platform_data = &power_mon_info_0[VDD_BAT_0],
                .irq = -1,
        },
 
        [INA_I2C_2_0_ADDR_41] = {
-               I2C_BOARD_INFO("ina219", 0x41),
-               .platform_data = &power_mon_info_0[UNUSED_RAIL],
+               I2C_BOARD_INFO("ina230", 0x41),
+               .platform_data = &power_mon_info_0[VDD_SYS_BUCKCPU_0],
                .irq = -1,
        },
 
        [INA_I2C_2_0_ADDR_42] = {
-               I2C_BOARD_INFO("ina219", 0x42),
-               .platform_data = &power_mon_info_0[UNUSED_RAIL],
+               I2C_BOARD_INFO("ina230", 0x42),
+               .platform_data = &power_mon_info_0[VDD_SYS_BUCKSOC_0],
                .irq = -1,
        },
 
        [INA_I2C_2_0_ADDR_43] = {
-               I2C_BOARD_INFO("ina219", 0x43),
-               .platform_data = &power_mon_info_0[UNUSED_RAIL],
+               I2C_BOARD_INFO("ina230", 0x43),
+               .platform_data = &power_mon_info_0[VDD_SYS_BUCKGPU_0],
                .irq = -1,
        },
 };
@@ -756,25 +790,6 @@ static struct i2c_board_info ardbeg_A01_i2c2_2_ina230_board_info[] = {
        },
 };
 
-static struct pca954x_platform_mode ardbeg_pca954x_modes[] = {
-       { .adap_id = PCA954x_I2C_BUS0, .deselect_on_exit = true, },
-       { .adap_id = PCA954x_I2C_BUS1, .deselect_on_exit = true, },
-       { .adap_id = PCA954x_I2C_BUS2, .deselect_on_exit = true, },
-       { .adap_id = PCA954x_I2C_BUS3, .deselect_on_exit = true, },
-};
-
-static struct pca954x_platform_data ardbeg_pca954x_data = {
-       .modes    = ardbeg_pca954x_modes,
-       .num_modes      = ARRAY_SIZE(ardbeg_pca954x_modes),
-};
-
-static const struct i2c_board_info ardbeg_i2c2_board_info[] = {
-       {
-               I2C_BOARD_INFO("pca9546", 0x71),
-               .platform_data = &ardbeg_pca954x_data,
-       },
-};
-
 static void __init register_devices_ardbeg_A01(void)
 {
        i2c_register_board_info(PCA954x_I2C_BUS1,
@@ -837,6 +852,20 @@ static void modify_tn8_rail_data(void)
                .power_lsb = 0.390636921 * PRECISION_MULTIPLIER_ARDBEG;
        ardbeg_A01_power_mon_info_2[ARDBEG_A01_VDD_1V8A_LDO2_5_7]
                .resistor = 10;
+
+       power_mon_info_0[VDD_BAT_0]
+               .calibration_data = 0x1FF7;
+       power_mon_info_0[VDD_BAT_0]
+               .power_lsb = 3.128437004 * PRECISION_MULTIPLIER_ARDBEG;
+       power_mon_info_0[VDD_BAT_0]
+               .resistor = 5;
+
+       power_mon_info_0[VDD_SYS_BUCKSOC_0]
+               .calibration_data = 0x2ED7;
+       power_mon_info_0[VDD_SYS_BUCKSOC_0]
+               .power_lsb = 1.067467267 * PRECISION_MULTIPLIER_ARDBEG;
+       power_mon_info_0[VDD_SYS_BUCKSOC_0]
+               .resistor = 10;
 }
 
 int __init ardbeg_pmon_init(void)
@@ -858,16 +887,15 @@ int __init ardbeg_pmon_init(void)
        if (bi.sku == 1100)
                modify_tn8_rail_data();
 
-       i2c_register_board_info(1, ardbeg_i2c2_board_info,
-               ARRAY_SIZE(ardbeg_i2c2_board_info));
-
        i2c_register_board_info(PCA954x_I2C_BUS0,
-                       ardbeg_i2c2_0_ina219_board_info,
-                       ARRAY_SIZE(ardbeg_i2c2_0_ina219_board_info));
+                       ardbeg_i2c2_0_ina230_board_info,
+                       ARRAY_SIZE(ardbeg_i2c2_0_ina230_board_info));
 
        if (bi.fab >= BOARD_FAB_A01)
                register_devices_ardbeg_A01();
-       else
+       else if ((bi.board_id != BOARD_E1784) &&
+               (bi.board_id != BOARD_E1922) &&
+               (bi.board_id != BOARD_E1923))
                register_devices_ardbeg();
 
        return 0;