summaryrefslogtreecommitdiff
path: root/driver/temp_sensor/tmp112.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /driver/temp_sensor/tmp112.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-252457d4b21f46889eebad61d4c0a65331919cec.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'driver/temp_sensor/tmp112.c')
-rw-r--r--driver/temp_sensor/tmp112.c124
1 files changed, 0 insertions, 124 deletions
diff --git a/driver/temp_sensor/tmp112.c b/driver/temp_sensor/tmp112.c
deleted file mode 100644
index 4da5c4e0e8..0000000000
--- a/driver/temp_sensor/tmp112.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* TMP112 temperature sensor module for Chrome EC */
-
-#include "common.h"
-#include "console.h"
-#include "tmp112.h"
-#include "i2c.h"
-#include "hooks.h"
-#include "math_util.h"
-#include "util.h"
-
-#define TMP112_RESOLUTION 12
-#define TMP112_SHIFT1 (16 - TMP112_RESOLUTION)
-#define TMP112_SHIFT2 (TMP112_RESOLUTION - 8)
-
-#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args)
-
-static int temp_mk_local[TMP112_COUNT];
-
-static int raw_read16(int sensor, const int offset, int *data_ptr)
-{
-#ifdef CONFIG_I2C_BUS_MAY_BE_UNPOWERED
- /*
- * Don't try to read if the port is unpowered
- */
- if (!board_is_i2c_port_powered(tmp112_sensors[sensor].i2c_port))
- return EC_ERROR_NOT_POWERED;
-#endif
- return i2c_read16(tmp112_sensors[sensor].i2c_port,
- tmp112_sensors[sensor].i2c_addr_flags,
- offset, data_ptr);
-}
-
-static int raw_write16(int sensor, const int offset, int data)
-{
-#ifdef CONFIG_I2C_BUS_MAY_BE_UNPOWERED
- /*
- * Don't try to write if the port is unpowered
- */
- if (!board_is_i2c_port_powered(tmp112_sensors[sensor].i2c_port))
- return EC_ERROR_NOT_POWERED;
-#endif
- return i2c_write16(tmp112_sensors[sensor].i2c_port,
- tmp112_sensors[sensor].i2c_addr_flags,
- offset, data);
-}
-
-static int get_reg_temp(int sensor, int *temp_ptr)
-{
- int rv;
- int temp_raw = 0;
-
- rv = raw_read16(sensor, TMP112_REG_TEMP, &temp_raw);
- if (rv)
- return rv;
-
- *temp_ptr = (int)(int16_t)temp_raw;
- return EC_SUCCESS;
-}
-
-static inline int tmp112_reg_to_mk(int16_t reg)
-{
- int temp_mc;
-
- temp_mc = (((reg >> TMP112_SHIFT1) * 1000) >> TMP112_SHIFT2);
-
- return MILLI_CELSIUS_TO_MILLI_KELVIN(temp_mc);
-}
-
-int tmp112_get_val_k(int idx, int *temp_k_ptr)
-{
- if (idx >= TMP112_COUNT)
- return EC_ERROR_INVAL;
-
- *temp_k_ptr = MILLI_KELVIN_TO_KELVIN(temp_mk_local[idx]);
- return EC_SUCCESS;
-}
-
-int tmp112_get_val_mk(int idx, int *temp_mk_ptr)
-{
- if (idx >= TMP112_COUNT)
- return EC_ERROR_INVAL;
-
- *temp_mk_ptr = temp_mk_local[idx];
- return EC_SUCCESS;
-}
-
-static void tmp112_poll(void)
-{
- int s;
- int temp_reg = 0;
-
- for (s = 0; s < TMP112_COUNT; s++) {
- if (get_reg_temp(s, &temp_reg) == EC_SUCCESS)
- temp_mk_local[s] = tmp112_reg_to_mk(temp_reg);
- }
-}
-DECLARE_HOOK(HOOK_SECOND, tmp112_poll, HOOK_PRIO_TEMP_SENSOR);
-
-void tmp112_init(void)
-{
- int tmp, s, rv;
- int set_mask, clr_mask;
-
- /* 12 bit mode */
- set_mask = (3 << 5);
-
- /* not oneshot mode */
- clr_mask = BIT(7);
-
- for (s = 0; s < TMP112_COUNT; s++) {
- rv = raw_read16(s, TMP112_REG_CONF, &tmp);
- if (rv != EC_SUCCESS) {
- CPRINTS("TMP112-%d: Failed to init (rv %d)", s, rv);
- continue;
- }
- raw_write16(s, TMP112_REG_CONF, (tmp & ~clr_mask) | set_mask);
- }
-}
-DECLARE_HOOK(HOOK_INIT, tmp112_init, HOOK_PRIO_DEFAULT);