summaryrefslogtreecommitdiff
path: root/include/peci.h
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2019-03-08 17:29:45 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-05-28 10:44:36 -0700
commit148145c4457e70b0da517b4b9f961338fc21bd46 (patch)
tree08c8a5d7d2ccee44919d3d586f961d5cf4cfe41e /include/peci.h
parent68763771658af368ceaa07803e8dfb5b841c9cf6 (diff)
downloadchrome-ec-148145c4457e70b0da517b4b9f961338fc21bd46.tar.gz
PECI: Move non-chipset specific PECI code to common folder
The Platform Environment Control Interface (PECI) is a thermal management standard with one-wire bus interface that provides a communication channel between Intel processor and chipset components to external monitoring or control devices. As we can read the CPU temperature over PECI more accurately than the thermistors, we can eliminate usage of thermistors for reading CPU temperature. BUG=b:128666114 BRANCH=none TEST=Manually tested on Dragonegg, able read CPU temperature. Change-Id: Ie0845ca776e6a7e14511dc9315d6d83cdd5f09a6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/1622740 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include/peci.h')
-rw-r--r--include/peci.h50
1 files changed, 41 insertions, 9 deletions
diff --git a/include/peci.h b/include/peci.h
index c3bb4d62b2..c553eac40d 100644
--- a/include/peci.h
+++ b/include/peci.h
@@ -10,15 +10,38 @@
#include "common.h"
-/**
- * Get the current CPU temperature.
- *
- * Note that the PECI interface is currently a little flaky; if you get an
- * error, retry a bit later.
- *
- * @return the CPU temperature in degrees K, or -1 if error.
- */
-int peci_get_cpu_temp(void);
+#define PECI_TARGET_ADDRESS 0x30
+#define PECI_WRITE_DATA_FIFO_SIZE 15
+#define PECI_READ_DATA_FIFO_SIZE 16
+
+#define PECI_GET_TEMP_READ_LENGTH 2
+#define PECI_GET_TEMP_WRITE_LENGTH 0
+#define PECI_GET_TEMP_TIMEOUT_US 200
+
+/* PECI Command Code */
+enum peci_command_code {
+ PECI_CMD_PING = 0x00,
+ PECI_CMD_GET_DIB = 0xF7,
+ PECI_CMD_GET_TEMP = 0x01,
+ PECI_CMD_RD_PKG_CFG = 0xA1,
+ PECI_CMD_WR_PKG_CFG = 0xA5,
+ PECI_CMD_RD_IAMSR = 0xB1,
+ PECI_CMD_WR_IAMSR = 0xB5,
+ PECI_CMD_RD_PCI_CFG = 0x61,
+ PECI_CMD_WR_PCI_CFG = 0x65,
+ PECI_CMD_RD_PCI_CFG_LOCAL = 0xE1,
+ PECI_CMD_WR_PCI_CFG_LOCAL = 0xE5,
+};
+
+struct peci_data {
+ enum peci_command_code cmd_code; /* command code */
+ uint8_t addr; /* client address */
+ uint8_t w_len; /* write length */
+ uint8_t r_len; /* read length */
+ uint8_t *w_buf; /* buffer pointer of write data */
+ uint8_t *r_buf; /* buffer pointer of read data */
+ int timeout_us; /* transaction timeout unit:us */
+};
/**
* Get the last polled value of the PECI temp sensor.
@@ -30,4 +53,13 @@ int peci_get_cpu_temp(void);
*/
int peci_temp_sensor_get_val(int idx, int *temp_ptr);
+/**
+ * Start a PECI transaction
+ *
+ * @param peci transaction data
+ *
+ * @return zero if successful, non-zero if error
+ */
+int peci_transaction(struct peci_data *peci);
+
#endif /* __CROS_EC_PECI_H */