summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-07-11 00:23:24 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-07-11 07:40:45 +0000
commit988468d17c8912c0f9a5345996b34f8848fdb739 (patch)
tree29ccf3070b5ae620e205fb59721c4a47e1a377de
parenta3c9f1332a421343837cc5048ccbb9f66ff4ae95 (diff)
downloadchrome-ec-stabilize-nocturne.10819.B.tar.gz
nocturne: Don't read gyro temp sensor in <= S5.stabilize-nocturne.10819.B
The gyro is not powered in S5 or lower, therefore we should not return any temperature value for those power states. BUG=none BRANCH=master TEST=flash nocturne, shut AP down, verify no prints are emitted about i2c unwedging. Change-Id: I3bcc1efca40b27ec571657274aab69dca4e414d7 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1132900 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/nocturne/board.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index f7da15cbf1..1d3cba9415 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -10,6 +10,7 @@
#include "charge_manager.h"
#include "charge_state.h"
#include "charge_state_v2.h"
+#include "chipset.h"
#include "common.h"
#include "console.h"
#include "compile_time_macros.h"
@@ -452,6 +453,18 @@ void board_overcurrent_event(int port)
CPRINTS("C%d: overcurrent!", port);
}
+static int read_gyro_sensor_temp(int idx, int *temp_ptr)
+{
+ /*
+ * The gyro is only powered in S0, so don't go and read it if the AP is
+ * off.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ return bmi160_get_sensor_temp(idx, temp_ptr);
+}
+
const struct temp_sensor_t temp_sensors[] = {
{"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp, 0, 4},
@@ -465,7 +478,7 @@ const struct temp_sensor_t temp_sensors[] = {
{"eMMC", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
BD99992GW_ADC_CHANNEL_SYSTHERM3, 4},
/* The Gyro temperature sensor is only readable in S0. */
- {"Gyro", TEMP_SENSOR_TYPE_BOARD, bmi160_get_sensor_temp, LID_GYRO, 1}
+ {"Gyro", TEMP_SENSOR_TYPE_BOARD, read_gyro_sensor_temp, LID_GYRO, 1}
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);