From 6101cebb6a7b0d0aadf3df98e98284b60946c419 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Wed, 15 Feb 2012 15:05:35 -0800 Subject: [PATCH] Reduce LPC command parameters to 128 bytes; add LPC memory-mapped space This will allow more efficient access to EC-provided data (temperature, fan, battery) by the main processor. Signed-off-by: Randall Spangler BUG=chrome-os-partner:7857 TEST='ectool hello' from link main processor should still work Change-Id: I2dc683f3441b34de9fb4debf772e386b9fdcfa82 --- chip/lm4/lpc.c | 8 +++++++- include/lpc.h | 6 +++++- include/lpc_commands.h | 15 +++++++++------ util/ectool.c | 8 ++++---- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index 674d35aebd..23c4c4258c 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -163,7 +163,13 @@ int lpc_init(void) uint8_t *lpc_get_host_range(int slot) { - return (uint8_t *)LPC_POOL_CMD_DATA + 256 * slot; + return (uint8_t *)LPC_POOL_CMD_DATA + EC_LPC_PARAM_SIZE * slot; +} + + +uint8_t *lpc_get_memmap_range(void) +{ + return (uint8_t *)LPC_POOL_CMD_DATA + EC_LPC_PARAM_SIZE * 2; } diff --git a/include/lpc.h b/include/lpc.h index d87d9bab7c..69968dba99 100644 --- a/include/lpc.h +++ b/include/lpc.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 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. */ @@ -27,6 +27,10 @@ int lpc_init(void); * commands, 1 for usermode-originated commands. */ uint8_t *lpc_get_host_range(int slot); +/* Returns a pointer to the memory-mapped buffer. This buffer is writable at + * any time, and the host can read it at any time. */ +uint8_t *lpc_get_memmap_range(void); + /* Sends a response to a host command. The bottom 4 bits of * are sent in the status byte. is 0 for kernel-originated * commands, 1 for usermode-originated commands. */ diff --git a/include/lpc_commands.h b/include/lpc_commands.h index 151256cde5..16936cf043 100644 --- a/include/lpc_commands.h +++ b/include/lpc_commands.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 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. */ @@ -24,15 +24,18 @@ #define EC_LPC_ADDR_KERNEL_PARAM 0x800 #define EC_LPC_ADDR_USER_DATA 0x200 #define EC_LPC_ADDR_USER_CMD 0x204 -#define EC_LPC_ADDR_USER_PARAM 0x900 -#define EC_LPC_PARAM_SIZE 256 /* Size of param areas in bytes */ +#define EC_LPC_ADDR_USER_PARAM 0x880 +#define EC_LPC_PARAM_SIZE 128 /* Size of each param area in bytes */ + +#define EC_LPC_ADDR_MEMMAP 0x900 +#define EC_LPC_MEMMAP_SIZE 256 /* LPC command status byte masks */ /* EC is busy processing a command. This covers both bit 0x04, which * is the busy-bit, and 0x02, which is the bit which indicates the * host has written a byte but the EC hasn't picked it up yet. */ #define EC_LPC_BUSY_MASK 0x06 -#define EC_LPC_STATUS_MASK 0xF0 /* Mask for status codes in status byte */ +#define EC_LPC_STATUS_MASK 0xf0 /* Mask for status codes in status byte */ #define EC_LPC_GET_STATUS(x) (((x) & EC_LPC_STATUS_MASK) >> 4) /* LPC command response codes */ @@ -55,7 +58,7 @@ enum lpc_status { * busy, because the reboot command is processed at interrupt * level. Note that when the EC reboots, the host will reboot too, so * there is no response to this command. */ -#define EC_LPC_COMMAND_REBOOT 0xD1 /* Think "die" */ +#define EC_LPC_COMMAND_REBOOT 0xd1 /* Think "die" */ /* Hello. This is a simple command to test the EC is responsive to @@ -100,7 +103,7 @@ struct lpc_response_read_test { /* Flash commands */ /* Maximum bytes that can be read/written in a single command */ -#define EC_LPC_FLASH_SIZE_MAX 128 +#define EC_LPC_FLASH_SIZE_MAX 64 /* Get flash info */ #define EC_LPC_COMMAND_FLASH_INFO 0x10 diff --git a/util/ectool.c b/util/ectool.c index 3c377b4c18..49785ac1a1 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 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. */ @@ -42,10 +42,10 @@ const char help_str[] = " Set target fan RPM\n" "\n" "Not working for you? Make sure LPC I/O is configured:\n" - " pci_write32 0 0x1f 0 0x88 0x007c0801\n" - " pci_write32 0 0x1f 0 0x8c 0x007c0901\n" + " pci_write32 0 0x1f 0 0x88 0x00fc0801\n" + " pci_write32 0 0x1f 0 0x8c 0x00fc0901\n" " pci_write16 0 0x1f 0 0x80 0x0010\n" - " pci_write16 0 0x1f 0 0x82 0x3f02\n" + " pci_write16 0 0x1f 0 0x82 0x3d01\n" "";