diff options
author | loganliao <Logan_Liao@compal.corp-partner.google.com> | 2020-04-01 16:58:33 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-24 20:55:24 +0000 |
commit | e34fca5653e120cac7dcc45dc5d735148a71f3d2 (patch) | |
tree | ba1a6ee30e4f9b8c52934bd826352ef408d8b6e1 /driver | |
parent | 574a6e121a29a69aa67b5927a5b24c4251158f5c (diff) | |
download | chrome-ec-e34fca5653e120cac7dcc45dc5d735148a71f3d2.tar.gz |
Mushu : Modify GPU slave address and Cmd protocol.
The proto address config and protocol that can't read GPU temperature.
This patch correct the GPU address and Cmd protocol. Make the EC read
GPU with I2C successfully.
BUG=b:148968367
BRANCH=none
TEST=read temperature success in Mushu Pre-build machine.
Change-Id: I39b8c3f55d0b4fea06736545ff76bf8e44abfece
Signed-off-by: loganliao <Logan_Liao@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2142846
Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com>
Reviewed-by: Bob Moragues <moragues@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Tested-by: Logan Liao <logan_liao@compal.corp-partner.google.com>
Commit-Queue: Logan Liao <logan_liao@compal.corp-partner.google.com>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/temp_sensor/amd_r19me4070.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/driver/temp_sensor/amd_r19me4070.c b/driver/temp_sensor/amd_r19me4070.c index 5da1129052..79d5c387d6 100644 --- a/driver/temp_sensor/amd_r19me4070.c +++ b/driver/temp_sensor/amd_r19me4070.c @@ -16,30 +16,25 @@ #define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) /* GPU I2C address */ -#define GPU_ADDR_FLAGS 0x82 +#define GPU_ADDR_FLAGS 0x0041 -/* - * Tell SMBus slave which register to read before GPU read - * temperature, call it "GPU INIT". - */ #define GPU_INIT_OFFSET 0x01 #define GPU_TEMPERATURE_OFFSET 0x03 -#define GPU_INIT_WRITE_VALUE 0x0F01665A static int initialized; - -static int read_gpu_temp(int *temp) -{ - return i2c_read32(I2C_PORT_GPU, GPU_ADDR_FLAGS, GPU_TEMPERATURE_OFFSET, - temp); -} +/* + * Tell SMBus we want to read 4 Byte from register offset(0x01665A) + */ +static const uint8_t gpu_init_write_value[5] = { + 0x04, 0x0F, 0x01, 0x66, 0x5A, +}; static void gpu_init_temp_sensor(void) { int rv; - - rv = i2c_write32(I2C_PORT_GPU, GPU_ADDR_FLAGS, GPU_INIT_OFFSET, - GPU_INIT_WRITE_VALUE); + rv = i2c_write_block(I2C_PORT_GPU, GPU_ADDR_FLAGS, GPU_INIT_OFFSET, + gpu_init_write_value, + ARRAY_SIZE(gpu_init_write_value)); if (rv == EC_SUCCESS) { initialized = 1; return; @@ -51,14 +46,16 @@ DECLARE_HOOK(HOOK_INIT, gpu_init_temp_sensor, HOOK_PRIO_INIT_I2C + 1); /* INIT GPU first before read the GPU's die tmeperature. */ int get_temp_R19ME4070(int idx, int *temp_ptr) { - int reg, rv; + uint8_t reg[5]; + int rv; /* if no INIT GPU, must init it first and wait 1 sec. */ if (!initialized) { gpu_init_temp_sensor(); return EC_ERROR_BUSY; } - rv = read_gpu_temp(®); + rv = i2c_read_block(I2C_PORT_GPU, GPU_ADDR_FLAGS, + GPU_TEMPERATURE_OFFSET, reg, ARRAY_SIZE(reg)); if (rv) { CPRINTS("read GPU Temperature fail"); return rv; @@ -70,7 +67,13 @@ int get_temp_R19ME4070(int idx, int *temp_ptr) * 0x002 : 2 ゚C * ... * 0x1FF : 511 ゚C + * ------------------------------- + * reg[4] = bit0 - bit7 + * reg[3] = bit8 - bit15 + * reg[2] = bit16 - bit23 + * reg[1] = bit24 - bit31 + * reg[0] = 0x04 */ - *temp_ptr = C_TO_K((reg >> 9) & (0x1ff)); + *temp_ptr = C_TO_K(reg[3] >> 1); return EC_SUCCESS; } |