summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLogan_Liao <Logan_Liao@compal.corp-partner.google.com>2023-02-24 11:19:23 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-15 02:55:30 +0000
commit141fa4916511ee3162c8067041f4ee21b00f194e (patch)
treeb4de84b2689ac24f82e5075ad99b1ab5fd4fdb84 /include
parentb68720a8a6492445555253308fbcae7ab53ecea1 (diff)
downloadchrome-ec-141fa4916511ee3162c8067041f4ee21b00f194e.tar.gz
Zephyr: Correct Temp sensor F75303 read methond.
This patch correct F75303 read fail on zephyr. BUG=b:269786658 BRANCH=none TEST=test markarth console that temps show right value. Change-Id: I315d80e2166d0b5f4d69f4e671846abe52fccbba Signed-off-by: Logan_Liao <Logan_Liao@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290094 Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Tested-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Chao Gui <chaogui@google.com> Commit-Queue: Logan Liao <logan_liao@compal.corp-partner.google.com>
Diffstat (limited to 'include')
-rw-r--r--include/driver/temp_sensor/f75303.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/include/driver/temp_sensor/f75303.h b/include/driver/temp_sensor/f75303.h
new file mode 100644
index 0000000000..d306971f35
--- /dev/null
+++ b/include/driver/temp_sensor/f75303.h
@@ -0,0 +1,86 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_F75303_H
+#define __CROS_EC_F75303_H
+
+#include "i2c.h"
+
+#ifdef BOARD_MUSHU
+#define F75303_I2C_ADDR_FLAGS 0x4D
+#else
+#define F75303_I2C_ADDR_FLAGS 0x4C
+#endif
+
+/*
+ * I2C port and address information for all the board F75303 sensors should be
+ * defined in an array of the following structures, with an enum f75303_sensor
+ * indexing the array. The enum f75303_sensor shall end with a F75303_IDX_COUNT
+ * defining the maximum number of sensors for the board.
+ */
+
+struct f75303_sensor_t {
+ int i2c_port;
+ int i2c_addr_flags;
+};
+
+extern const struct f75303_sensor_t f75303_sensors[];
+
+/*
+ * The F75303 driver only supports a single device instance on the board.
+ * Each device supports 3 temperature sensor types: local, remote1, and
+ * remote2. The f75303_index selects the temperature sensor type to read.
+ */
+enum f75303_index {
+ F75303_IDX_LOCAL,
+ F75303_IDX_REMOTE1,
+ F75303_IDX_REMOTE2,
+ F75303_IDX_COUNT,
+};
+
+#define F75303_TEMP_LOCAL_REGISTER 0x00
+#define F75303_TEMP_REMOTE1_REGISTER 0x01
+#define F75303_TEMP_REMOTE2_REGISTER 0x23
+
+/**
+ * Get the last polled value of a sensor.
+ *
+ * @param idx Index to read. Idx indicates whether to read die
+ * temperature or external temperature.
+ * @param temp Destination for temperature in K.
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int f75303_get_val(int idx, int *temp);
+
+/**
+ * Get the last polled value of a sensor.
+ *
+ * @param idx Index to read, from board's enum f75303_sensor
+ * definition
+ *
+ * @param temp_k_ptr Destination for temperature in K.
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int f75303_get_val_k(int idx, int *temp_k_ptr);
+
+/**
+ * Get the last polled value of a sensor.
+ *
+ * @param idx Index to read, from board's enum f75303_sensor
+ * definition
+ *
+ * @param temp_mk_ptr Destination for temperature in mK.
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int f75303_get_val_mk(int idx, int *temp_mk_ptr);
+
+#ifdef CONFIG_ZEPHYR
+void f75303_update_temperature(int idx);
+#endif /* CONFIG_ZEPHYR */
+
+#endif /* __CROS_EC_F75303_H */