summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/build.mk2
-rw-r--r--common/chipset_haswell.c38
-rw-r--r--common/getset.c107
-rw-r--r--include/ec_commands.h19
-rw-r--r--include/getset.h26
-rw-r--r--include/getset_value_list.h11
-rw-r--r--util/ectool.c16
7 files changed, 60 insertions, 159 deletions
diff --git a/common/build.mk b/common/build.mk
index 3256982ef0..a31d2c8588 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -8,7 +8,7 @@
common-y=main.o util.o console_output.o uart_buffering.o
common-y+=memory_commands.o shared_mem.o system_common.o hooks.o
-common-y+=gpio_common.o version.o printf.o queue.o getset.o
+common-y+=gpio_common.o version.o printf.o queue.o
common-y+=throttle_ap.o
common-$(BOARD_bolt)+=battery_link.o
diff --git a/common/chipset_haswell.c b/common/chipset_haswell.c
index fcdd00bdc4..f90082508e 100644
--- a/common/chipset_haswell.c
+++ b/common/chipset_haswell.c
@@ -9,9 +9,10 @@
#include "chipset_x86_common.h"
#include "common.h"
#include "console.h"
-#include "getset.h"
+#include "ec_commands.h"
#include "gpio.h"
#include "hooks.h"
+#include "host_command.h"
#include "system.h"
#include "timer.h"
#include "util.h"
@@ -50,6 +51,7 @@
IN_PGOOD_ALL_CORE | IN_ALL_PM_SLP_DEASSERTED)
static int throttle_cpu; /* Throttle CPU? */
+static int pause_in_s5; /* Pause in S5 when shutting down? */
void chipset_force_shutdown(void)
{
@@ -319,7 +321,7 @@ enum x86_state x86_handle_state(enum x86_state state)
gpio_set_level(GPIO_PP5000_EN, 0);
/* Start shutting down */
- return gsv[GSV_PARAM_s5] ? X86_S5 : X86_S5G3;
+ return pause_in_s5 ? X86_S5 : X86_S5G3;
case X86_S5G3:
/* Deassert DPWROK, assert RSMRST# */
@@ -337,3 +339,35 @@ void haswell_interrupt(enum gpio_signal signal)
/* Pass through eDP VDD enable from PCH */
gpio_set_level(GPIO_EC_EDP_VDD_EN, gpio_get_level(GPIO_PCH_EDP_VDD_EN));
}
+
+static int host_command_gsv(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_get_set_value *p = args->params;
+ struct ec_response_get_set_value *r = args->response;
+
+ if (p->flags & EC_GSV_SET)
+ pause_in_s5 = p->value;
+
+ r->value = pause_in_s5;
+
+ args->response_size = sizeof(*r);
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_GSV_PAUSE_IN_S5,
+ host_command_gsv,
+ EC_VER_MASK(0));
+
+static int console_command_gsv(int argc, char **argv)
+{
+ if (argc > 1 && !parse_bool(argv[1], &pause_in_s5))
+ return EC_ERROR_INVAL;
+
+ ccprintf("pause_in_s5 = %s\n", pause_in_s5 ? "on" : "off");
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(pause_in_s5, console_command_gsv,
+ "[on|off]",
+ "Should the AP pause in S5 during shutdown?",
+ NULL);
+
diff --git a/common/getset.c b/common/getset.c
deleted file mode 100644
index 0ac5b840cd..0000000000
--- a/common/getset.c
+++ /dev/null
@@ -1,107 +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.
- */
-
-/* Generic get/set value stuff. */
-
-#include "common.h"
-#include "console.h"
-#include "getset.h"
-#include "host_command.h"
-#include "util.h"
-
-/* Declare and initialize the values */
-#define GSV_ITEM(n, v) v,
-#include "getset_value_list.h"
-uint32_t gsv[] = {
- GSV_LIST
-};
-#undef GSV_ITEM
-
-BUILD_ASSERT(ARRAY_SIZE(gsv) == NUM_GSV_PARAMS);
-
-static enum ec_status get_set_value(struct ec_cmd_get_set_value *ptr)
-{
- unsigned int index = ptr->flags & EC_GSV_PARAM_MASK;
- if (index >= NUM_GSV_PARAMS)
- return EC_RES_INVALID_PARAM;
-
- /* Handle flags correctly - we may add new ones some day */
- if (ptr->flags & EC_GSV_SET)
- gsv[index] = ptr->value;
-
- ptr->value = gsv[index];
- return EC_RES_SUCCESS;
-}
-
-static int host_command_get_set_value(struct host_cmd_handler_args *args)
-{
- const struct ec_cmd_get_set_value *p = args->params;
- struct ec_cmd_get_set_value *r = args->response;
- args->response_size = sizeof(*r);
-
- if (p != r)
- memcpy(r, p, sizeof(*p));
-
- return get_set_value(r);
-}
-DECLARE_HOST_COMMAND(EC_CMD_GET_SET_VALUE,
- host_command_get_set_value,
- EC_VER_MASK(0));
-
-
-#ifdef CONFIG_CMD_GSV
-
-#define STRINGIFY0(name) #name
-#define STRINGIFY(name) STRINGIFY0(name)
-#define GSV_ITEM(n, v) STRINGIFY(n),
-#include "getset_value_list.h"
-static const char const *gsv_name[] = {
- GSV_LIST
-};
-#undef GSV_ITEM
-
-static int console_command_get_set_value(int argc, char **argv)
-{
- unsigned int i;
- struct ec_cmd_get_set_value s = {0, 0};
- char *e;
- int ret;
-
- if (argc < 2) {
- for (i = 0; i < NUM_GSV_PARAMS; i++)
- ccprintf("%s = 0x%08x\n", gsv_name[i], gsv[i]);
- return EC_SUCCESS;
- }
-
- for (i = 0; i < NUM_GSV_PARAMS; i++)
- if (!strcasecmp(gsv_name[i], argv[1]))
- break;
-
- if (i >= NUM_GSV_PARAMS) {
- ccprintf("Can't find param \"%s\"\n", argv[1]);
- return EC_ERROR_UNKNOWN;
- }
- s.flags = i;
-
- if (argc > 2) {
- s.flags |= EC_GSV_SET;
- s.value = strtoi(argv[2], &e, 0);
- if (*e)
- return EC_ERROR_INVAL;
- }
-
- ret = get_set_value(&s);
-
- if (ret == EC_RES_SUCCESS)
- ccprintf("%s = 0x%08x\n", argv[1], s.value);
-
- return ret;
-}
-DECLARE_CONSOLE_COMMAND(gsv, console_command_get_set_value,
- "[name [value]]",
- "get/set the value of named parameters",
- NULL);
-
-#endif /* CONFIG_CMD_GSV */
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 0287e659ca..5225fc75b5 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -636,19 +636,30 @@ struct ec_response_get_protocol_info {
} __packed;
+/*****************************************************************************/
/* Get/Set miscellaneous values */
-#define EC_CMD_GET_SET_VALUE 0x0c
/* The upper byte of .flags tells what to do (nothing means "get") */
#define EC_GSV_SET 0x80000000
-/* The lower three bytes of .flags identifies the parameter */
+
+/* The lower three bytes of .flags identifies the parameter, if that has
+ meaning for an individual command. */
#define EC_GSV_PARAM_MASK 0x00ffffff
-/* The same struct is sent in both directions */
-struct ec_cmd_get_set_value {
+
+struct ec_params_get_set_value {
uint32_t flags;
uint32_t value;
} __packed;
+struct ec_response_get_set_value {
+ uint32_t flags;
+ uint32_t value;
+} __packed;
+
+/* More than one command can use these structs to get/set paramters. */
+#define EC_CMD_GSV_PAUSE_IN_S5 0x0c
+
+
/*****************************************************************************/
/* Flash commands */
diff --git a/include/getset.h b/include/getset.h
deleted file mode 100644
index d1721b3e6c..0000000000
--- a/include/getset.h
+++ /dev/null
@@ -1,26 +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.
- */
-
-/* List of valid params for the generic get/set value operation */
-
-#ifndef __CROS_EC_GETSET_H
-#define __CROS_EC_GETSET_H
-
-#include <stdint.h>
-#include "ec_commands.h"
-
-/* Define the params. */
-#define GSV_ITEM(n, v) GSV_PARAM_##n,
-#include "getset_value_list.h"
-enum gsv_param_id {
- GSV_LIST
- NUM_GSV_PARAMS
-};
-#undef GSV_ITEM
-
-/* Declare the storage where the values will be kept. */
-extern uint32_t gsv[];
-
-#endif /* __CROS_EC_GETSET_H */
diff --git a/include/getset_value_list.h b/include/getset_value_list.h
deleted file mode 100644
index b78dc25d14..0000000000
--- a/include/getset_value_list.h
+++ /dev/null
@@ -1,11 +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.
- */
-
-/**
- * List of get/set value items: <name, init_val>
- */
-#define GSV_LIST \
- GSV_ITEM(s5, 0) \
- /* end */
diff --git a/util/ectool.c b/util/ectool.c
index ddf1295baf..9d83d67c31 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -17,7 +17,6 @@
#include "compile_time_macros.h"
#include "ec_flash.h"
#include "ectool.h"
-#include "getset.h"
#include "lightbar.h"
#include "lock/gec_lock.h"
#include "misc_util.h"
@@ -319,23 +318,24 @@ int cmd_test(int argc, char *argv[])
int cmd_s5(int argc, char *argv[])
{
- struct ec_cmd_get_set_value s;
+ struct ec_params_get_set_value p;
+ struct ec_params_get_set_value r;
int rv;
- s.flags = GSV_PARAM_s5;
+ p.flags = 0;
if (argc > 1) {
- s.flags |= EC_GSV_SET;
- if (!parse_bool(argv[1], &s.value)) {
+ p.flags |= EC_GSV_SET;
+ if (!parse_bool(argv[1], &p.value)) {
fprintf(stderr, "invalid arg \"%s\"\n", argv[1]);
return -1;
}
}
- rv = ec_command(EC_CMD_GET_SET_VALUE, 0,
- &s, sizeof(s), &s, sizeof(s));
+ rv = ec_command(EC_CMD_GSV_PAUSE_IN_S5, 0,
+ &p, sizeof(p), &r, sizeof(r));
if (rv > 0)
- printf("%s\n", s.value ? "on" : "off");
+ printf("%s\n", r.value ? "on" : "off");
return rv < 0;
}