platform/chrome: use macros for passthru indexes
Move passthru indexes for EC and PD devices to common header. Also use them instead of literal constants. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-4-tzungbi@kernel.org
This commit is contained in:
parent
b99eb596ef
commit
3db0c9e5de
|
@ -19,9 +19,6 @@
|
|||
|
||||
#include "cros_ec.h"
|
||||
|
||||
#define CROS_EC_DEV_EC_INDEX 0
|
||||
#define CROS_EC_DEV_PD_INDEX 1
|
||||
|
||||
static struct cros_ec_platform ec_p = {
|
||||
.ec_name = CROS_EC_DEV_NAME,
|
||||
.cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_EC_INDEX),
|
||||
|
|
|
@ -433,7 +433,7 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
|
|||
|
||||
/* First try sending with proto v3. */
|
||||
ec_dev->proto_version = 3;
|
||||
ret = cros_ec_host_command_proto_query(ec_dev, 0, proto_msg);
|
||||
ret = cros_ec_host_command_proto_query(ec_dev, CROS_EC_DEV_EC_INDEX, proto_msg);
|
||||
|
||||
if (ret == 0) {
|
||||
proto_info = (struct ec_response_get_protocol_info *)
|
||||
|
@ -459,7 +459,7 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
|
|||
/*
|
||||
* Check for PD
|
||||
*/
|
||||
ret = cros_ec_host_command_proto_query(ec_dev, 1, proto_msg);
|
||||
ret = cros_ec_host_command_proto_query(ec_dev, CROS_EC_DEV_PD_INDEX, proto_msg);
|
||||
|
||||
if (ret) {
|
||||
dev_dbg(ec_dev->dev, "no PD chip found: %d\n", ret);
|
||||
|
@ -609,7 +609,7 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, struct cros_ec_command *msg)
|
|||
msg->insize = ec_dev->max_response;
|
||||
}
|
||||
|
||||
if (msg->command < EC_CMD_PASSTHRU_OFFSET(1)) {
|
||||
if (msg->command < EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX)) {
|
||||
if (msg->outsize > ec_dev->max_request) {
|
||||
dev_err(ec_dev->dev,
|
||||
"request of size %u is too big (max: %u)\n",
|
||||
|
|
|
@ -281,7 +281,8 @@ static void cros_ec_proto_test_query_all_normal(struct kunit *test)
|
|||
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.command,
|
||||
EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO);
|
||||
EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
|
||||
EC_CMD_GET_PROTOCOL_INFO);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.insize,
|
||||
sizeof(struct ec_response_get_protocol_info));
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
|
||||
|
@ -396,7 +397,8 @@ static void cros_ec_proto_test_query_all_no_pd_return_error(struct kunit *test)
|
|||
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.command,
|
||||
EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO);
|
||||
EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
|
||||
EC_CMD_GET_PROTOCOL_INFO);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.insize,
|
||||
sizeof(struct ec_response_get_protocol_info));
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
|
||||
|
@ -685,7 +687,8 @@ static void cros_ec_proto_test_query_all_no_mkbp(struct kunit *test)
|
|||
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.command,
|
||||
EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO);
|
||||
EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
|
||||
EC_CMD_GET_PROTOCOL_INFO);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.insize,
|
||||
sizeof(struct ec_response_get_protocol_info));
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
|
||||
|
@ -783,7 +786,8 @@ static void cros_ec_proto_test_query_all_no_host_sleep(struct kunit *test)
|
|||
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.command,
|
||||
EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO);
|
||||
EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
|
||||
EC_CMD_GET_PROTOCOL_INFO);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.insize,
|
||||
sizeof(struct ec_response_get_protocol_info));
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
|
||||
|
@ -889,7 +893,8 @@ static void cros_ec_proto_test_query_all_default_wake_mask_return_error(struct k
|
|||
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.version, 0);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.command,
|
||||
EC_CMD_PASSTHRU_OFFSET(1) | EC_CMD_GET_PROTOCOL_INFO);
|
||||
EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX) |
|
||||
EC_CMD_GET_PROTOCOL_INFO);
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.insize,
|
||||
sizeof(struct ec_response_get_protocol_info));
|
||||
KUNIT_EXPECT_EQ(test, mock->msg.outsize, 0);
|
||||
|
|
|
@ -30,8 +30,8 @@ TRACE_EVENT(cros_ec_request_start,
|
|||
),
|
||||
TP_fast_assign(
|
||||
__entry->version = cmd->version;
|
||||
__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(1);
|
||||
__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(1);
|
||||
__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
|
||||
__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
|
||||
__entry->outsize = cmd->outsize;
|
||||
__entry->insize = cmd->insize;
|
||||
),
|
||||
|
@ -55,8 +55,8 @@ TRACE_EVENT(cros_ec_request_done,
|
|||
),
|
||||
TP_fast_assign(
|
||||
__entry->version = cmd->version;
|
||||
__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(1);
|
||||
__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(1);
|
||||
__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
|
||||
__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
|
||||
__entry->outsize = cmd->outsize;
|
||||
__entry->insize = cmd->insize;
|
||||
__entry->result = cmd->result;
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#define CROS_EC_DEV_SCP_NAME "cros_scp"
|
||||
#define CROS_EC_DEV_TP_NAME "cros_tp"
|
||||
|
||||
#define CROS_EC_DEV_EC_INDEX 0
|
||||
#define CROS_EC_DEV_PD_INDEX 1
|
||||
|
||||
/*
|
||||
* The EC is unresponsive for a time after a reboot command. Add a
|
||||
* simple delay to make sure that the bus stays locked.
|
||||
|
|
Loading…
Reference in New Issue