arm: tegra: tn8: register battery monitor through DT
Kerwin Wan [Thu, 5 Dec 2013 15:10:45 +0000 (23:10 +0800)]
Bug 1391872

Change-Id: I393bb2ebbad8692769be515831222514502519b5
Signed-off-by: Kerwin Wan <kerwinw@nvidia.com>
Reviewed-on: http://git-master/r/338796
Reviewed-by: Timo Alho <talho@nvidia.com>
Tested-by: Timo Alho <talho@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

arch/arm/boot/dts/tegra124-platforms/tegra124-tn8-sysedp.dtsi [new file with mode: 0644]
arch/arm/boot/dts/tegra124-tn8-a03-00-battery.dts
arch/arm/boot/dts/tegra124-tn8-a03-01-battery.dts
arch/arm/boot/dts/tegra124-tn8-battery.dts
arch/arm/mach-tegra/board-ardbeg.c
arch/arm/mach-tegra/board-ardbeg.h
arch/arm/mach-tegra/board-tn8-sysedp.c

diff --git a/arch/arm/boot/dts/tegra124-platforms/tegra124-tn8-sysedp.dtsi b/arch/arm/boot/dts/tegra124-platforms/tegra124-tn8-sysedp.dtsi
new file mode 100644 (file)
index 0000000..af7ddb8
--- /dev/null
@@ -0,0 +1,23 @@
+
+/ {
+       sysedp_batmon_calc {
+               compatible = "sysedp_batmon_calc";
+               ibat_lut = <
+                       60    6150
+                       40    6150
+                       0     6150
+                       (-30) 0
+               >;
+               rbat_data = <
+                       110000
+                       110000
+                       150000
+                       170000
+               >;
+               temp_axis = <25>;
+               capacity_axis = <100 25 10 0>;
+               power_supply = "battery";
+               r_const = <60000>;
+               vsys_min = <3000000>;
+       };
+};
index b88533c..ba000f6 100644 (file)
@@ -9,6 +9,7 @@
 #include "tegra124-platforms/tegra124-e1780-pinmux.dtsi"
 #include "tegra124-platforms/tegra124-e1780-keys.dtsi"
 #include "tegra124-platforms/tegra124-e1845-senosr.dtsi"
+#include "tegra124-platforms/tegra124-tn8-sysedp.dtsi"
 
 / {
        model = "NVIDIA Tegra124 TN8";
index 396b250..51f6adc 100644 (file)
@@ -8,6 +8,7 @@
 #include "tegra124-platforms/tegra124-e1780-gpio-default.dtsi"
 #include "tegra124-platforms/tegra124-e1780-pinmux.dtsi"
 #include "tegra124-platforms/tegra124-e1780-keys.dtsi"
+#include "tegra124-platforms/tegra124-tn8-sysedp.dtsi"
 
 / {
        model = "NVIDIA Tegra124 TN8";
index e8772fd..1bfe62c 100644 (file)
@@ -9,7 +9,7 @@
 #include "tegra124-platforms/tegra124-e1780-pinmux.dtsi"
 #include "tegra124-platforms/tegra124-e1780-keys.dtsi"
 #include "tegra124-platforms/tegra124-e1794-sensor.dtsi"
-
+#include "tegra124-platforms/tegra124-tn8-sysedp.dtsi"
 
 / {
        model = "NVIDIA Tegra124 TN8";
index 0ae4608..23c5165 100644 (file)
@@ -1025,9 +1025,7 @@ static void __init ardbeg_sysedp_batmon_init(void)
 
        switch (bi.board_id) {
        case BOARD_E1780:
-               if (bi.sku == 1100)
-                       tn8_sysedp_batmon_init();
-               else
+               if (bi.sku != 1100)
                        shield_sysedp_batmon_init();
                break;
        case BOARD_PM358:
index 8c3b00b..217b02a 100644 (file)
@@ -180,7 +180,6 @@ int tn8_fixed_regulator_init(void);
 int tn8_edp_init(void);
 void tn8_new_sysedp_init(void);
 void tn8_sysedp_dynamic_capping_init(void);
-void tn8_sysedp_batmon_init(void);
 
 int tn8_p1761_pmon_init(void);
 
index 34f6d81..4f7ce37 100644 (file)
@@ -82,67 +82,6 @@ void __init tn8_new_sysedp_init(void)
        WARN_ON(r);
 }
 
-/* --- Battery monitor data --- */
-static struct sysedp_batmon_ibat_lut tn8_ibat_lut[] = {
-       {  60, 6150 }, /* TODO until battery temp is fixed*/
-       {  40, 6150 },
-       {   0, 6150 },
-       { -30,    0 }
-};
-
-#if 0
-/* TODO: use this table when battery temp sensing is fixed */
-/*                           60C    40C    25C    0C      -20C      */
-static int rbat_data[] = {  90000, 60000, 70000,  90000, 110000,   /* 100% */
-                           90000, 60000, 70000,  90000, 110000,   /*  13% */
-                          110000, 80000, 90000, 110000, 130000 }; /*   0% */
-static int rbat_temp_axis[] = { 60, 40, 25, 0, -20 };
-static int rbat_capacity_axis[] = { 100, 13, 0 };
-#else
-static int rbat_data[] = { 110000,   /* 100% */
-                          110000,   /*  25% */
-                          150000,   /*  10% */
-                          170000 }; /*   0% */
-static int rbat_temp_axis[] = { 25 };
-static int rbat_capacity_axis[] = { 100, 25, 10, 0 };
-#endif
-struct sysedp_batmon_rbat_lut tn8_rbat_lut = {
-       .temp_axis = rbat_temp_axis,
-       .temp_size = ARRAY_SIZE(rbat_temp_axis),
-       .capacity_axis = rbat_capacity_axis,
-       .capacity_size = ARRAY_SIZE(rbat_capacity_axis),
-       .data = rbat_data,
-       .data_size = ARRAY_SIZE(rbat_data),
-};
-
-static struct sysedp_batmon_calc_platform_data tn8_batmon_pdata = {
-       .power_supply = "battery",
-       .r_const = 60000,
-       .vsys_min = 3000000,
-       .ibat_lut = tn8_ibat_lut,
-       .rbat_lut = &tn8_rbat_lut,
-};
-
-static struct platform_device tn8_batmon_device = {
-       .name = "sysedp_batmon_calc",
-       .id = -1,
-       .dev = { .platform_data = &tn8_batmon_pdata }
-};
-
-void __init tn8_sysedp_batmon_init(void)
-{
-       int r;
-
-       if (get_power_supply_type() != POWER_SUPPLY_TYPE_BATTERY) {
-               /* modify platform data on-the-fly to enable virtual battery */
-               tn8_batmon_pdata.power_supply = "test_battery";
-               tn8_batmon_pdata.update_interval = 2000;
-       }
-
-       r = platform_device_register(&tn8_batmon_device);
-       WARN_ON(r);
-}
-
 static struct tegra_sysedp_platform_data tn8_sysedp_dynamic_capping_platdata = {
        .corecap = td570d_sysedp_corecap,
        .corecap_size = td570d_sysedp_corecap_sz,