summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin K Wong <kevin.k.wong@intel.com>2016-03-22 11:07:38 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-03 10:27:40 -0700
commitbf24d5b26421aff81a8ea032f16e65df10a842dc (patch)
tree897aaada06a947573670d2af73c55e0965d8d744
parent9406cf384aba9554dd49eef17a3d4a4eb2947972 (diff)
downloadchrome-ec-bf24d5b26421aff81a8ea032f16e65df10a842dc.tar.gz
temp sensor: add support for G782
modify g781.c/.h to g78x.c/.h to suppor both G781/G782 temp sensor based on CONFIG_TEMP_SENSOR_G781 or CONFIG_TEMP_SENSOR_G782 BUG=none BRANCH=none TEST=make buildall; able to get temperature data on board with G782 Change-Id: Ia32c85e9964bfd7c0c5263f04368bc001a27fe10 Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/334228 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/auron/board.c10
-rw-r--r--driver/build.mk3
-rw-r--r--driver/temp_sensor/g781.c216
-rw-r--r--driver/temp_sensor/g781.h70
-rw-r--r--driver/temp_sensor/g78x.c235
-rw-r--r--driver/temp_sensor/g78x.h140
-rw-r--r--include/config.h1
7 files changed, 383 insertions, 292 deletions
diff --git a/board/auron/board.c b/board/auron/board.c
index 1a56ac5492..5657ff6907 100644
--- a/board/auron/board.c
+++ b/board/auron/board.c
@@ -9,7 +9,7 @@
#include "backlight.h"
#include "chipset.h"
#include "common.h"
-#include "driver/temp_sensor/g781.h"
+#include "driver/temp_sensor/g78x.h"
#include "extpower.h"
#include "fan.h"
#include "gpio.h"
@@ -89,10 +89,10 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct temp_sensor_t temp_sensors[] = {
{"PECI", TEMP_SENSOR_TYPE_CPU, peci_temp_sensor_get_val, 0, 2},
{"ECInternal", TEMP_SENSOR_TYPE_BOARD, chip_temp_sensor_get_val, 0, 4},
- {"G781Internal", TEMP_SENSOR_TYPE_BOARD, g781_get_val,
- G781_IDX_INTERNAL, 4},
- {"G781External", TEMP_SENSOR_TYPE_BOARD, g781_get_val,
- G781_IDX_EXTERNAL, 4},
+ {"G781Internal", TEMP_SENSOR_TYPE_BOARD, g78x_get_val,
+ G78X_IDX_INTERNAL, 4},
+ {"G781External", TEMP_SENSOR_TYPE_BOARD, g78x_get_val,
+ G78X_IDX_EXTERNAL1, 4},
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
diff --git a/driver/build.mk b/driver/build.mk
index 13aae200bc..19e108eb89 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -65,7 +65,8 @@ driver-$(CONFIG_REGULATOR_IR357X)+=regulator_ir357x.o
# Temperature sensors
driver-$(CONFIG_TEMP_SENSOR_BD99992GW)+=temp_sensor/bd99992gw.o
driver-$(CONFIG_TEMP_SENSOR_EC_ADC)+=temp_sensor/ec_adc.o
-driver-$(CONFIG_TEMP_SENSOR_G781)+=temp_sensor/g781.o
+driver-$(CONFIG_TEMP_SENSOR_G781)+=temp_sensor/g78x.o
+driver-$(CONFIG_TEMP_SENSOR_G782)+=temp_sensor/g78x.o
driver-$(CONFIG_TEMP_SENSOR_TMP006)+=temp_sensor/tmp006.o
driver-$(CONFIG_TEMP_SENSOR_TMP432)+=temp_sensor/tmp432.o
diff --git a/driver/temp_sensor/g781.c b/driver/temp_sensor/g781.c
deleted file mode 100644
index c301588637..0000000000
--- a/driver/temp_sensor/g781.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Copyright (c) 2013 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.
- */
-
-/* G781 temperature sensor module for Chrome EC */
-
-#include "common.h"
-#include "console.h"
-#include "g781.h"
-#include "gpio.h"
-#include "i2c.h"
-#include "hooks.h"
-#include "util.h"
-
-static int temp_val_local;
-static int temp_val_remote;
-
-/**
- * Determine whether the sensor is powered.
- *
- * @return non-zero the g781 sensor is powered.
- */
-static int has_power(void)
-{
-#ifdef CONFIG_TEMP_SENSOR_POWER_GPIO
- return gpio_get_level(CONFIG_TEMP_SENSOR_POWER_GPIO);
-#else
- return 1;
-#endif
-}
-
-static int raw_read8(const int offset, int *data_ptr)
-{
- return i2c_read8(I2C_PORT_THERMAL, G781_I2C_ADDR, offset, data_ptr);
-}
-
-#ifdef CONFIG_CMD_TEMP_SENSOR
-static int raw_write8(const int offset, int data)
-{
- return i2c_write8(I2C_PORT_THERMAL, G781_I2C_ADDR, offset, data);
-}
-#endif
-
-static int get_temp(const int offset, int *temp_ptr)
-{
- int rv;
- int temp_raw = 0;
-
- rv = raw_read8(offset, &temp_raw);
- if (rv < 0)
- return rv;
-
- *temp_ptr = (int)(int8_t)temp_raw;
- return EC_SUCCESS;
-}
-
-#ifdef CONFIG_CMD_TEMP_SENSOR
-static int set_temp(const int offset, int temp)
-{
- if (temp < -127 || temp > 127)
- return EC_ERROR_INVAL;
-
- return raw_write8(offset, (uint8_t)temp);
-}
-#endif
-
-int g781_get_val(int idx, int *temp_ptr)
-{
- if (!has_power())
- return EC_ERROR_NOT_POWERED;
-
- switch (idx) {
- case G781_IDX_INTERNAL:
- *temp_ptr = temp_val_local;
- break;
- case G781_IDX_EXTERNAL:
- *temp_ptr = temp_val_remote;
- break;
- default:
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-
-static void temp_sensor_poll(void)
-{
- if (!has_power())
- return;
-
- get_temp(G781_TEMP_LOCAL, &temp_val_local);
- temp_val_local = C_TO_K(temp_val_local);
-
- get_temp(G781_TEMP_REMOTE, &temp_val_remote);
- temp_val_remote = C_TO_K(temp_val_remote);
-}
-DECLARE_HOOK(HOOK_SECOND, temp_sensor_poll, HOOK_PRIO_TEMP_SENSOR);
-
-#ifdef CONFIG_CMD_TEMP_SENSOR
-static int print_status(void)
-{
- int value;
- int rv;
-
-
- rv = get_temp(G781_TEMP_LOCAL, &value);
- if (rv < 0)
- return rv;
- ccprintf("Local Temp: %3dC\n", value);
-
- rv = get_temp(G781_LOCAL_TEMP_THERM_LIMIT, &value);
- if (rv < 0)
- return rv;
- ccprintf(" Therm Trip: %3dC\n", value);
-
- rv = get_temp(G781_LOCAL_TEMP_HIGH_LIMIT_R, &value);
- if (rv < 0)
- return rv;
- ccprintf(" High Alarm: %3dC\n", value);
-
- rv = get_temp(G781_LOCAL_TEMP_LOW_LIMIT_R, &value);
- if (rv < 0)
- return rv;
- ccprintf(" Low Alarm: %3dC\n", value);
-
- rv = get_temp(G781_TEMP_REMOTE, &value);
- if (rv < 0)
- return rv;
- ccprintf("Remote Temp: %3dC\n", value);
-
- rv = get_temp(G781_REMOTE_TEMP_THERM_LIMIT, &value);
- if (rv < 0)
- return rv;
- ccprintf(" Therm Trip: %3dC\n", value);
-
- rv = get_temp(G781_REMOTE_TEMP_HIGH_LIMIT_R, &value);
- if (rv < 0)
- return rv;
- ccprintf(" High Alarm: %3dC\n", value);
-
- rv = get_temp(G781_REMOTE_TEMP_LOW_LIMIT_R, &value);
- if (rv < 0)
- return rv;
- ccprintf(" Low Alarm: %3dC\n", value);
-
- rv = raw_read8(G781_STATUS, &value);
- if (rv < 0)
- return rv;
- ccprintf("\nSTATUS: %08b\n", value);
-
- rv = raw_read8(G781_CONFIGURATION_R, &value);
- if (rv < 0)
- return rv;
- ccprintf("CONFIG: %08b\n", value);
-
- return EC_SUCCESS;
-}
-
-static int command_g781(int argc, char **argv)
-{
- char *command;
- char *e;
- int data;
- int offset;
- int rv;
-
- if (!has_power()) {
- ccprintf("ERROR: Temp sensor not powered.\n");
- return EC_ERROR_NOT_POWERED;
- }
-
- /* If no args just print status */
- if (argc == 1)
- return print_status();
-
- if (argc < 3)
- return EC_ERROR_PARAM_COUNT;
-
- command = argv[1];
- offset = strtoi(argv[2], &e, 0);
- if (*e || offset < 0 || offset > 255)
- return EC_ERROR_PARAM2;
-
- if (!strcasecmp(command, "getbyte")) {
- rv = raw_read8(offset, &data);
- if (rv < 0)
- return rv;
- ccprintf("Byte at offset 0x%02x is %08b\n", offset, data);
- return rv;
- }
-
- /* Remaining commands are of the form "g781 set-command offset data" */
- if (argc != 4)
- return EC_ERROR_PARAM_COUNT;
-
- data = strtoi(argv[3], &e, 0);
- if (*e)
- return EC_ERROR_PARAM3;
-
- if (!strcasecmp(command, "settemp")) {
- ccprintf("Setting 0x%02x to %dC\n", offset, data);
- rv = set_temp(offset, data);
- } else if (!strcasecmp(command, "setbyte")) {
- ccprintf("Setting 0x%02x to 0x%02x\n", offset, data);
- rv = raw_write8(offset, data);
- } else
- return EC_ERROR_PARAM1;
-
- return rv;
-}
-DECLARE_CONSOLE_COMMAND(g781, command_g781,
- "[settemp|setbyte <offset> <value>] or [getbyte <offset>]. "
- "Temps in Celsius.",
- "Print g781 temp sensor status or set parameters.", NULL);
-#endif
diff --git a/driver/temp_sensor/g781.h b/driver/temp_sensor/g781.h
deleted file mode 100644
index c9069749d2..0000000000
--- a/driver/temp_sensor/g781.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (c) 2013 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.
- */
-
-/* G781 temperature sensor module for Chrome EC */
-
-#ifndef __CROS_EC_G781_H
-#define __CROS_EC_G781_H
-
-#define G781_I2C_ADDR 0x98 /* 7-bit address is 0x4C */
-
-#define G781_IDX_INTERNAL 0
-#define G781_IDX_EXTERNAL 1
-
-/* Chip-specific commands */
-#define G781_TEMP_LOCAL 0x00
-#define G781_TEMP_REMOTE 0x01
-#define G781_STATUS 0x02
-#define G781_CONFIGURATION_R 0x03
-#define G781_CONVERSION_RATE_R 0x04
-#define G781_LOCAL_TEMP_HIGH_LIMIT_R 0x05
-#define G781_LOCAL_TEMP_LOW_LIMIT_R 0x06
-#define G781_REMOTE_TEMP_HIGH_LIMIT_R 0x07
-#define G781_REMOTE_TEMP_LOW_LIMIT_R 0x08
-#define G781_CONFIGURATION_W 0x09
-#define G781_CONVERSION_RATE_W 0x0a
-#define G781_LOCAL_TEMP_HIGH_LIMIT_W 0x0b
-#define G781_LOCAL_TEMP_LOW_LIMIT_W 0x0c
-#define G781_REMOTE_TEMP_HIGH_LIMIT_W 0x0d
-#define G781_REMOTE_TEMP_LOW_LIMIT_W 0x0e
-#define G781_ONESHOT 0x0f
-#define G781_REMOTE_TEMP_EXTENDED 0x10
-#define G781_REMOTE_TEMP_OFFSET_HIGH 0x11
-#define G781_REMOTE_TEMP_OFFSET_EXTD 0x12
-#define G781_REMOTE_T_HIGH_LIMIT_EXTD 0x13
-#define G781_REMOTE_T_LOW_LIMIT_EXTD 0x14
-#define G781_REMOTE_TEMP_THERM_LIMIT 0x19
-#define G781_LOCAL_TEMP_THERM_LIMIT 0x20
-#define G781_THERM_HYSTERESIS 0x21
-#define G781_ALERT_FAULT_QUEUE_CODE 0x22
-#define G781_MANUFACTURER_ID 0xFE
-#define G781_DEVICE_ID 0xFF
-
-/* Config register bits */
-#define G781_CONFIGURATION_STANDBY (1 << 6)
-#define G781_CONFIGURATION_ALERT_MASK (1 << 7)
-
-/* Status register bits */
-#define G781_STATUS_LOCAL_TEMP_THERM_ALARM (1 << 0)
-#define G781_STATUS_REMOTE_TEMP_THERM_ALARM (1 << 1)
-#define G781_STATUS_REMOTE_TEMP_FAULT (1 << 2)
-#define G781_STATUS_REMOTE_TEMP_LOW_ALARM (1 << 3)
-#define G781_STATUS_REMOTE_TEMP_HIGH_ALARM (1 << 4)
-#define G781_STATUS_LOCAL_TEMP_LOW_ALARM (1 << 5)
-#define G781_STATUS_LOCAL_TEMP_HIGH_ALARM (1 << 6)
-#define G781_STATUS_BUSY (1 << 7)
-
-/**
- * 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_ptr Destination for temperature in K.
- *
- * @return EC_SUCCESS if successful, non-zero if error.
- */
-int g781_get_val(int idx, int *temp_ptr);
-
-#endif /* __CROS_EC_G781_H */
diff --git a/driver/temp_sensor/g78x.c b/driver/temp_sensor/g78x.c
new file mode 100644
index 0000000000..858ae38769
--- /dev/null
+++ b/driver/temp_sensor/g78x.c
@@ -0,0 +1,235 @@
+/* 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.
+ */
+
+/* G781/G782 temperature sensor module for Chrome EC */
+
+#include "common.h"
+#include "console.h"
+#include "g78x.h"
+#include "gpio.h"
+#include "i2c.h"
+#include "hooks.h"
+#include "util.h"
+
+static int temp_val_local;
+static int temp_val_remote1;
+#ifdef CONFIG_TEMP_SENSOR_G782
+static int temp_val_remote2;
+#endif
+
+/**
+ * Determine whether the sensor is powered.
+ *
+ * @return non-zero the g781/g782 sensor is powered.
+ */
+static int has_power(void)
+{
+#ifdef CONFIG_TEMP_SENSOR_POWER_GPIO
+ return gpio_get_level(CONFIG_TEMP_SENSOR_POWER_GPIO);
+#else
+ return 1;
+#endif
+}
+
+static int raw_read8(const int offset, int *data_ptr)
+{
+ return i2c_read8(I2C_PORT_THERMAL, G78X_I2C_ADDR, offset, data_ptr);
+}
+
+#ifdef CONFIG_CMD_TEMP_SENSOR
+static int raw_write8(const int offset, int data)
+{
+ return i2c_write8(I2C_PORT_THERMAL, G78X_I2C_ADDR, offset, data);
+}
+#endif
+
+static int get_temp(const int offset, int *temp_ptr)
+{
+ int rv;
+ int temp_raw = 0;
+
+ rv = raw_read8(offset, &temp_raw);
+ if (rv < 0)
+ return rv;
+
+ *temp_ptr = (int)(int8_t)temp_raw;
+ return EC_SUCCESS;
+}
+
+#ifdef CONFIG_CMD_TEMP_SENSOR
+static int set_temp(const int offset, int temp)
+{
+ if (temp < -127 || temp > 127)
+ return EC_ERROR_INVAL;
+
+ return raw_write8(offset, (uint8_t)temp);
+}
+#endif
+
+int g78x_get_val(int idx, int *temp_ptr)
+{
+ if (!has_power())
+ return EC_ERROR_NOT_POWERED;
+
+ switch (idx) {
+ case G78X_IDX_INTERNAL:
+ *temp_ptr = temp_val_local;
+ break;
+ case G78X_IDX_EXTERNAL1:
+ *temp_ptr = temp_val_remote1;
+ break;
+#ifdef CONFIG_TEMP_SENSOR_G782
+ case G78X_IDX_EXTERNAL2:
+ *temp_ptr = temp_val_remote2;
+ break;
+#endif
+ default:
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
+
+static void temp_sensor_poll(void)
+{
+ if (!has_power())
+ return;
+
+ get_temp(G78X_TEMP_LOCAL, &temp_val_local);
+ temp_val_local = C_TO_K(temp_val_local);
+
+ get_temp(G78X_TEMP_REMOTE1, &temp_val_remote1);
+ temp_val_remote1 = C_TO_K(temp_val_remote1);
+
+#ifdef CONFIG_TEMP_SENSOR_G782
+ get_temp(G78X_TEMP_REMOTE2, &temp_val_remote2);
+ temp_val_remote2 = C_TO_K(temp_val_remote2);
+#endif
+}
+DECLARE_HOOK(HOOK_SECOND, temp_sensor_poll, HOOK_PRIO_TEMP_SENSOR);
+
+#ifdef CONFIG_CMD_TEMP_SENSOR
+static void print_temps(const char *name,
+ const int temp_reg,
+ const int therm_limit_reg,
+ const int high_limit_reg,
+ const int low_limit_reg)
+{
+ int value;
+
+ ccprintf("%s:\n", name);
+
+ if (get_temp(temp_reg, &value) == EC_SUCCESS)
+ ccprintf(" Temp: %3dC\n", value);
+
+ if (get_temp(therm_limit_reg, &value) == EC_SUCCESS)
+ ccprintf(" Therm Trip: %3dC\n", value);
+
+ if (get_temp(high_limit_reg, &value) == EC_SUCCESS)
+ ccprintf(" High Alarm: %3dC\n", value);
+
+ if (get_temp(low_limit_reg, &value) == EC_SUCCESS)
+ ccprintf(" Low Alarm: %3dC\n", value);
+}
+
+static int print_status(void)
+{
+ int value;
+
+ if (!has_power()) {
+ ccprintf("ERROR: Temp sensor not powered.\n");
+ return EC_ERROR_NOT_POWERED;
+ }
+
+ print_temps("Local", G78X_TEMP_LOCAL,
+ G78X_LOCAL_TEMP_THERM_LIMIT,
+ G78X_LOCAL_TEMP_HIGH_LIMIT_R,
+ G78X_LOCAL_TEMP_LOW_LIMIT_R);
+
+ print_temps("Remote1", G78X_TEMP_REMOTE1,
+ G78X_REMOTE1_TEMP_THERM_LIMIT,
+ G78X_REMOTE1_TEMP_HIGH_LIMIT_R,
+ G78X_REMOTE1_TEMP_LOW_LIMIT_R);
+
+#ifdef CONFIG_TEMP_SENSOR_G782
+ print_temps("Remote2", G78X_TEMP_REMOTE1,
+ G78X_REMOTE2_TEMP_THERM_LIMIT,
+ G78X_REMOTE2_TEMP_HIGH_LIMIT_R,
+ G78X_REMOTE2_TEMP_LOW_LIMIT_R);
+#endif
+
+ ccprintf("\n");
+
+ if (raw_read8(G78X_STATUS, &value) == EC_SUCCESS)
+ ccprintf("STATUS: %08b\n", value);
+
+#ifdef CONFIG_TEMP_SENSOR_G782
+ if (raw_read8(G78X_STATUS1, &value) == EC_SUCCESS)
+ ccprintf("STATUS1: %08b\n", value);
+#endif
+
+ if (raw_read8(G78X_CONFIGURATION_R, &value) == EC_SUCCESS)
+ ccprintf("CONFIG: %08b\n", value);
+
+ return EC_SUCCESS;
+}
+
+static int command_g78x(int argc, char **argv)
+{
+ char *command;
+ char *e;
+ int data;
+ int offset;
+ int rv;
+
+ if (!has_power()) {
+ ccprintf("ERROR: Temp sensor not powered.\n");
+ return EC_ERROR_NOT_POWERED;
+ }
+
+ /* If no args just print status */
+ if (argc == 1)
+ return print_status();
+
+ if (argc < 3)
+ return EC_ERROR_PARAM_COUNT;
+
+ command = argv[1];
+ offset = strtoi(argv[2], &e, 0);
+ if (*e || offset < 0 || offset > 255)
+ return EC_ERROR_PARAM2;
+
+ if (!strcasecmp(command, "getbyte")) {
+ rv = raw_read8(offset, &data);
+ if (rv < 0)
+ return rv;
+ ccprintf("Byte at offset 0x%02x is %08b\n", offset, data);
+ return rv;
+ }
+
+ /* Remaining commands are of the form "g78x set-command offset data" */
+ if (argc != 4)
+ return EC_ERROR_PARAM_COUNT;
+
+ data = strtoi(argv[3], &e, 0);
+ if (*e)
+ return EC_ERROR_PARAM3;
+
+ if (!strcasecmp(command, "settemp")) {
+ ccprintf("Setting 0x%02x to %dC\n", offset, data);
+ rv = set_temp(offset, data);
+ } else if (!strcasecmp(command, "setbyte")) {
+ ccprintf("Setting 0x%02x to 0x%02x\n", offset, data);
+ rv = raw_write8(offset, data);
+ } else
+ return EC_ERROR_PARAM1;
+
+ return rv;
+}
+DECLARE_CONSOLE_COMMAND(g78x, command_g78x,
+ "[settemp|setbyte <offset> <value>] or [getbyte <offset>]. "
+ "Temps in Celsius.",
+ "Print g781/g782 temp sensor status or set parameters.", NULL);
+#endif
diff --git a/driver/temp_sensor/g78x.h b/driver/temp_sensor/g78x.h
new file mode 100644
index 0000000000..8fa78ffa83
--- /dev/null
+++ b/driver/temp_sensor/g78x.h
@@ -0,0 +1,140 @@
+/* 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.
+ */
+
+/* G781/G782 temperature sensor module for Chrome EC */
+
+#ifndef __CROS_EC_G78X_H
+#define __CROS_EC_G78X_H
+
+#if defined(CONFIG_TEMP_SENSOR_G781) && defined(CONFIG_TEMP_SENSOR_G782)
+#error Cannot support both G781 and G782 together!
+#endif
+
+#define G78X_I2C_ADDR 0x98 /* 7-bit address is 0x4C */
+
+#define G78X_IDX_INTERNAL 0
+#define G78X_IDX_EXTERNAL1 1
+#define G78X_IDX_EXTERNAL2 2
+
+#if defined(CONFIG_TEMP_SENSOR_G781)
+/* G781 register */
+#define G78X_TEMP_LOCAL 0x00
+#define G78X_TEMP_REMOTE1 0x01
+#define G78X_STATUS 0x02
+#define G78X_CONFIGURATION_R 0x03
+#define G78X_CONVERSION_RATE_R 0x04
+#define G78X_LOCAL_TEMP_HIGH_LIMIT_R 0x05
+#define G78X_LOCAL_TEMP_LOW_LIMIT_R 0x06
+#define G78X_REMOTE1_TEMP_HIGH_LIMIT_R 0x07
+#define G78X_REMOTE1_TEMP_LOW_LIMIT_R 0x08
+#define G78X_CONFIGURATION_W 0x09
+#define G78X_CONVERSION_RATE_W 0x0a
+#define G78X_LOCAL_TEMP_HIGH_LIMIT_W 0x0b
+#define G78X_LOCAL_TEMP_LOW_LIMIT_W 0x0c
+#define G78X_REMOTE1_TEMP_HIGH_LIMIT_W 0x0d
+#define G78X_REMOTE1_TEMP_LOW_LIMIT_W 0x0e
+#define G78X_ONESHOT 0x0f
+#define G78X_REMOTE1_TEMP_EXTENDED 0x10
+#define G78X_REMOTE1_TEMP_OFFSET_HIGH 0x11
+#define G78X_REMOTE1_TEMP_OFFSET_EXTD 0x12
+#define G78X_REMOTE1_T_HIGH_LIMIT_EXTD 0x13
+#define G78X_REMOTE1_T_LOW_LIMIT_EXTD 0x14
+#define G78X_REMOTE1_TEMP_THERM_LIMIT 0x19
+#define G78X_LOCAL_TEMP_THERM_LIMIT 0x20
+#define G78X_THERM_HYSTERESIS 0x21
+#define G78X_ALERT_FAULT_QUEUE_CODE 0x22
+#define G78X_MANUFACTURER_ID 0xFE
+#define G78X_DEVICE_ID 0xFF
+
+/* Config register bits */
+#define G78X_CONFIGURATION_STANDBY (1 << 6)
+#define G78X_CONFIGURATION_ALERT_MASK (1 << 7)
+
+/* Status register bits */
+#define G78X_STATUS_LOCAL_TEMP_THERM_ALARM (1 << 0)
+#define G78X_STATUS_REMOTE1_TEMP_THERM_ALARM (1 << 1)
+#define G78X_STATUS_REMOTE1_TEMP_FAULT (1 << 2)
+#define G78X_STATUS_REMOTE1_TEMP_LOW_ALARM (1 << 3)
+#define G78X_STATUS_REMOTE1_TEMP_HIGH_ALARM (1 << 4)
+#define G78X_STATUS_LOCAL_TEMP_LOW_ALARM (1 << 5)
+#define G78X_STATUS_LOCAL_TEMP_HIGH_ALARM (1 << 6)
+#define G78X_STATUS_BUSY (1 << 7)
+
+#elif defined(CONFIG_TEMP_SENSOR_G782)
+/* G782 register */
+#define G78X_TEMP_LOCAL 0x00
+#define G78X_TEMP_REMOTE1 0x01
+#define G78X_TEMP_REMOTE2 0x02
+#define G78X_STATUS 0x03
+#define G78X_CONFIGURATION_R 0x04
+#define G78X_CONFIGURATION_W 0x04
+#define G78X_CONVERSION_RATE_R 0x05
+#define G78X_CONVERSION_RATE_W 0x05
+#define G78X_LOCAL_TEMP_HIGH_LIMIT_R 0x06
+#define G78X_LOCAL_TEMP_HIGH_LIMIT_W 0x06
+#define G78X_LOCAL_TEMP_LOW_LIMIT_R 0x07
+#define G78X_LOCAL_TEMP_LOW_LIMIT_W 0x07
+#define G78X_REMOTE1_TEMP_HIGH_LIMIT_R 0x08
+#define G78X_REMOTE1_TEMP_HIGH_LIMIT_W 0x08
+#define G78X_REMOTE1_TEMP_LOW_LIMIT_R 0x09
+#define G78X_REMOTE1_TEMP_LOW_LIMIT_W 0x09
+#define G78X_REMOTE2_TEMP_HIGH_LIMIT_R 0x0a
+#define G78X_REMOTE2_TEMP_HIGH_LIMIT_W 0x0a
+#define G78X_REMOTE2_TEMP_LOW_LIMIT_R 0x0b
+#define G78X_REMOTE2_TEMP_LOW_LIMIT_W 0x0b
+#define G78X_ONESHOT 0x0c
+#define G78X_REMOTE1_TEMP_EXTENDED 0x0d
+#define G78X_REMOTE1_TEMP_OFFSET_HIGH 0x0e
+#define G78X_REMOTE1_TEMP_OFFSET_EXTD 0x0f
+#define G78X_REMOTE1_T_HIGH_LIMIT_EXTD 0x10
+#define G78X_REMOTE1_T_LOW_LIMIT_EXTD 0x11
+#define G78X_REMOTE1_TEMP_THERM_LIMIT 0x12
+#define G78X_REMOTE2_TEMP_EXTENDED 0x13
+#define G78X_REMOTE2_TEMP_OFFSET_HIGH 0x14
+#define G78X_REMOTE2_TEMP_OFFSET_EXTD 0x15
+#define G78X_REMOTE2_T_HIGH_LIMIT_EXTD 0x16
+#define G78X_REMOTE2_T_LOW_LIMIT_EXTD 0x17
+#define G78X_REMOTE2_TEMP_THERM_LIMIT 0x18
+#define G78X_STATUS1 0x19
+#define G78X_LOCAL_TEMP_THERM_LIMIT 0x20
+#define G78X_THERM_HYSTERESIS 0x21
+#define G78X_ALERT_FAULT_QUEUE_CODE 0x22
+#define G78X_MANUFACTURER_ID 0xFE
+#define G78X_DEVICE_ID 0xFF
+
+/* Config register bits */
+#define G78X_CONFIGURATION_REMOTE2_DIS (1 << 5)
+#define G78X_CONFIGURATION_STANDBY (1 << 6)
+#define G78X_CONFIGURATION_ALERT_MASK (1 << 7)
+
+/* Status register bits */
+#define G78X_STATUS_LOCAL_TEMP_LOW_ALARM (1 << 0)
+#define G78X_STATUS_LOCAL_TEMP_HIGH_ALARM (1 << 1)
+#define G78X_STATUS_LOCAL_TEMP_THERM_ALARM (1 << 2)
+#define G78X_STATUS_REMOTE2_TEMP_THERM_ALARM (1 << 3)
+#define G78X_STATUS_REMOTE1_TEMP_THERM_ALARM (1 << 4)
+#define G78X_STATUS_REMOTE2_TEMP_FAULT (1 << 5)
+#define G78X_STATUS_REMOTE1_TEMP_FAULT (1 << 6)
+#define G78X_STATUS_BUSY (1 << 7)
+
+/* Status1 register bits */
+#define G78X_STATUS_REMOTE2_TEMP_LOW_ALARM (1 << 4)
+#define G78X_STATUS_REMOTE2_TEMP_HIGH_ALARM (1 << 5)
+#define G78X_STATUS_REMOTE1_TEMP_LOW_ALARM (1 << 6)
+#define G78X_STATUS_REMOTE1_TEMP_HIGH_ALARM (1 << 7)
+#endif
+
+/**
+ * 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_ptr Destination for temperature in K.
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int g78x_get_val(int idx, int *temp_ptr);
+
+#endif /* __CROS_EC_G78X_H */
diff --git a/include/config.h b/include/config.h
index df57da65b9..8181bbb532 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1677,6 +1677,7 @@
#undef CONFIG_TEMP_SENSOR_BD99992GW /* BD99992GW PMIC, on I2C bus */
#undef CONFIG_TEMP_SENSOR_EC_ADC /* Thermistors on EC's own ADC */
#undef CONFIG_TEMP_SENSOR_G781 /* G781 sensor, on I2C bus */
+#undef CONFIG_TEMP_SENSOR_G782 /* G782 sensor, on I2C bus */
#undef CONFIG_TEMP_SENSOR_TMP006 /* TI TMP006 sensor, on I2C bus */
#undef CONFIG_TEMP_SENSOR_TMP432 /* TI TMP432 sensor, on I2C bus */