summaryrefslogtreecommitdiff
path: root/battery_mitigation
diff options
context:
space:
mode:
authorGeorge Lee <geolee@google.com>2022-05-18 19:44:36 -0700
committerGeorge Lee <geolee@google.com>2022-05-27 08:40:21 -0700
commita5fa72f57be07c5affd39df521ba8eef28af74d0 (patch)
tree178b33341ce3d1013306e7486ac7e6e9bc9c2287 /battery_mitigation
parent267f8c4fdfa7f258383f2cb9f6ebe5549c3a8641 (diff)
downloadgs201-a5fa72f57be07c5affd39df521ba8eef28af74d0.tar.gz
bcl: Add Mitigation Logger - Binary
Mitigation Logger logs battery related information for 1 second when it is triggered by under voltage or over current interrupts. Information collected is to help debug system brownout. Bug: 228383769 Test: Boot and Test Signed-off-by: George Lee <geolee@google.com> Change-Id: Icc5bf599eff7715545ed66d352ec00ae5d633aa0
Diffstat (limited to 'battery_mitigation')
-rw-r--r--battery_mitigation/Android.bp45
-rw-r--r--battery_mitigation/battery_mitigation.cpp64
-rw-r--r--battery_mitigation/battery_mitigation.rc9
3 files changed, 118 insertions, 0 deletions
diff --git a/battery_mitigation/Android.bp b/battery_mitigation/Android.bp
new file mode 100644
index 0000000..f9d429f
--- /dev/null
+++ b/battery_mitigation/Android.bp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package {
+ default_applicable_licenses: [
+ "//device/google/gs201:device_google_gs201_license",
+ ],
+}
+
+cc_binary {
+ name: "battery_mitigation",
+ relative_install_path: "hw",
+ proprietary: true,
+ init_rc: ["battery_mitigation.rc"],
+ shared_libs: [
+ "libpixelmitigation",
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "libhardware",
+ "libhidlbase",
+ "liblog",
+ "libutils",
+ "android.hardware.thermal@2.0"
+ ],
+ srcs: [
+ "battery_mitigation.cpp",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/battery_mitigation/battery_mitigation.cpp b/battery_mitigation/battery_mitigation.cpp
new file mode 100644
index 0000000..fa18d93
--- /dev/null
+++ b/battery_mitigation/battery_mitigation.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "battery-mitigation"
+
+#include <battery_mitigation/BatteryMitigation.h>
+
+using android::hardware::google::pixel::BatteryMitigation;
+using android::hardware::google::pixel::MitigationConfig;
+
+android::sp<BatteryMitigation> bmSp;
+
+const struct MitigationConfig::Config cfg = {
+ .SystemPath = {
+ "/dev/thermal/tz-by-name/batoilo/temp",
+ "/dev/thermal/tz-by-name/smpl_gm/temp",
+ "/dev/thermal/tz-by-name/soc/temp",
+ "/dev/thermal/tz-by-name/vdroop1/temp",
+ "/dev/thermal/tz-by-name/vdroop2/temp",
+ "/dev/thermal/tz-by-name/ocp_gpu/temp",
+ "/dev/thermal/tz-by-name/ocp_tpu/temp",
+ "/dev/thermal/tz-by-name/soft_ocp_cpu2/temp",
+ "/dev/thermal/tz-by-name/soft_ocp_cpu1/temp",
+ "/dev/thermal/tz-by-name/battery/temp",
+ "/dev/thermal/tz-by-name/battery_cycle/temp",
+ "/sys/bus/iio/devices/iio:device0/lpf_power",
+ "/sys/bus/iio/devices/iio:device1/lpf_power",
+ "/sys/class/power_supply/battery/voltage_now",
+ "/sys/class/power_supply/battery/current_now",
+ },
+ .FilteredZones = {
+ "batoilo",
+ "vdroop1",
+ "vdroop2",
+ "smpl_gm",
+ },
+ .SystemName = {
+ "batoilo", "smpl_gm", "soc", "vdroop1", "vdroop2", "ocp_gpu",
+ "ocp_tpu", "soft_ocp_cpu2", "soft_ocp_cpu1", "battery", "battery_cycle",
+ "main", "sub", "voltage_now", "current_now",
+ },
+ .LogFilePath = "/data/vendor/mitigation/lastmeal.txt",
+};
+
+int main(int /*argc*/, char ** /*argv*/) {
+ bmSp = new BatteryMitigation(cfg);
+ while (true) {
+ pause();
+ }
+ return 0;
+}
diff --git a/battery_mitigation/battery_mitigation.rc b/battery_mitigation/battery_mitigation.rc
new file mode 100644
index 0000000..7b9ef4f
--- /dev/null
+++ b/battery_mitigation/battery_mitigation.rc
@@ -0,0 +1,9 @@
+on property:vendor.thermal.link_ready=1
+ mkdir /data/vendor/mitigation 0755 system system
+ chown system system /data/vendor/mitigation
+ start vendor.battery_mitigation
+
+service vendor.battery_mitigation /vendor/bin/hw/battery_mitigation
+ user system
+ group system
+ capabilities WAKE_ALARM BLOCK_SUSPEND