From c0e32b0beab7f08c968fe4fa04a3f015899c3d48 Mon Sep 17 00:00:00 2001 From: Kyle Tso Date: Mon, 5 Aug 2024 18:41:26 +0800 Subject: [PATCH 1/2] dumpstate: Modify dumpTcpc path and content Ported from I248fb250b94cbd4078e7f3c44da83f62002b53fb with some modifications. Bug: 357543284 Test: checked the content in dumpstate Flag: EXEMPT bugfix Change-Id: I35502167baedb96b58f214cb6842fb1ea4dee3e0 Signed-off-by: Kyle Tso --- dumpstate/dump_power.cpp | 64 ++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/dumpstate/dump_power.cpp b/dumpstate/dump_power.cpp index 95d2b72..79cf28a 100644 --- a/dumpstate/dump_power.cpp +++ b/dumpstate/dump_power.cpp @@ -268,48 +268,42 @@ void dumpLogBufferTcpm() { } void dumpTcpc() { - int ret; - const char* max77759TcpcHead = "TCPC"; - const char* i2cSubDirMatch = "i2c-"; - const char* directory = "/sys/devices/platform/10d60000.hsi2c/"; - const char* max77759Tcpc [][2] { - {"registers:", "/i2c-max77759tcpc/registers"}, - {"frs:", "/i2c-max77759tcpc/frs"}, - {"auto_discharge:", "/i2c-max77759tcpc/auto_discharge"}, - {"bcl2_enabled:", "/i2c-max77759tcpc/bcl2_enabled"}, - {"cc_toggle_enable:", "/i2c-max77759tcpc/cc_toggle_enable"}, - {"containment_detection:", "/i2c-max77759tcpc/containment_detection"}, - {"containment_detection_status:", "/i2c-max77759tcpc/containment_detection_status"}, + const char* max77759TcpcHead = "TCPC Device Attributes"; + const char* directory = "/sys/class/typec/port0/device"; + const char* max77759Tcpc [] { + "auto_discharge", + "bc12_enabled", + "cc_toggle_enable", + "contaminant_detection", + "contaminant_detection_status", + "frs", + "irq_hpd_count", + "non_compliant_reasons", + "sbu_pullup", + "update_sdp_enum_timeout", + "usb_limit_accessory_current", + "usb_limit_accessory_enable", + "usb_limit_sink_current", + "usb_limit_sink_enable", + "usb_limit_source_enable", }; - std::vector files; std::string content; + std::string tcpcRegistersPath(std::string(directory) + "/registers"); + + dumpFileContent("TCPC Registers", tcpcRegistersPath.c_str()); printTitle(max77759TcpcHead); - ret = getFilesInDir(directory, &files); - if (ret < 0) { - for (auto &tcpcVal : max77759Tcpc) - printf("%s\n", tcpcVal[0]); - return; - } - - for (auto &file : files) { - for (auto &tcpcVal : max77759Tcpc) { - printf("%s ", tcpcVal[0]); - if (std::string::npos == std::string(file).find(i2cSubDirMatch)) { - continue; - } - - std::string fileName = directory + file + "/" + std::string(tcpcVal[1]); - - if (!android::base::ReadFileToString(fileName, &content)) { - continue; - } - - printf("%s\n", content.c_str()); - } + for (auto& tcpcVal : max77759Tcpc) { + std::string filename = std::string(directory) + "/" + std::string(tcpcVal); + printf("%s: ", tcpcVal); + android::base::ReadFileToString(filename, &content); + if (!content.empty() && (content.back() == '\n' || content.back() == '\r')) + content.pop_back(); + printf("%s\n", content.c_str()); } + printf("\n"); } void dumpPdEngine() { From b616d05cca35308d596176bdeaccf80e8c5e56d5 Mon Sep 17 00:00:00 2001 From: Kyle Tso Date: Mon, 5 Aug 2024 19:22:26 +0800 Subject: [PATCH 2/2] dumpstate: Dump manual_disable_vbus in TCPC Bug: 335368150 Bug: 344686002 Bug: 352490157 Flag: EXEMPT bugfix Change-Id: I1f6cc8bc830d4e23e86b0fc93fa49f2944835cda Signed-off-by: Kyle Tso --- dumpstate/dump_power.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dumpstate/dump_power.cpp b/dumpstate/dump_power.cpp index 79cf28a..0c54118 100644 --- a/dumpstate/dump_power.cpp +++ b/dumpstate/dump_power.cpp @@ -270,6 +270,7 @@ void dumpLogBufferTcpm() { void dumpTcpc() { const char* max77759TcpcHead = "TCPC Device Attributes"; const char* directory = "/sys/class/typec/port0/device"; + // alphabetic order const char* max77759Tcpc [] { "auto_discharge", "bc12_enabled", @@ -278,6 +279,7 @@ void dumpTcpc() { "contaminant_detection_status", "frs", "irq_hpd_count", + "manual_disable_vbus", "non_compliant_reasons", "sbu_pullup", "update_sdp_enum_timeout",