ec/google/wilco: Add mailbox commands
Add basic supported mailbox commands for this embedded contrlller, and define some command functions to retrieve and print information about the EC. Change-Id: Ibcef7d58e1852fdb2e52b97acd4b51a26dd8cd77 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://review.coreboot.org/29115 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
committed by
Duncan Laurie
parent
5f6f1dab7d
commit
b0bf280be4
@ -1,5 +1,5 @@
|
|||||||
ifeq ($(CONFIG_EC_GOOGLE_WILCO),y)
|
ifeq ($(CONFIG_EC_GOOGLE_WILCO),y)
|
||||||
|
|
||||||
ramstage-y += mailbox.c
|
ramstage-y += commands.c mailbox.c
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
52
src/ec/google/wilco/commands.c
Normal file
52
src/ec/google/wilco/commands.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the coreboot project.
|
||||||
|
*
|
||||||
|
* Copyright 2018 Google LLC
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <console/console.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "ec.h"
|
||||||
|
#include "commands.h"
|
||||||
|
|
||||||
|
int wilco_ec_get_info(enum get_ec_info_cmd type, char *info)
|
||||||
|
{
|
||||||
|
struct ec_response_get_ec_info rsp;
|
||||||
|
|
||||||
|
if (!info)
|
||||||
|
return -1;
|
||||||
|
if (wilco_ec_sendrecv(KB_EC_INFO, type, &rsp, sizeof(rsp)) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Copy returned string */
|
||||||
|
strncpy(info, rsp.data, sizeof(rsp.data));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wilco_ec_print_all_info(void)
|
||||||
|
{
|
||||||
|
char info[EC_INFO_MAX_SIZE];
|
||||||
|
|
||||||
|
if (!wilco_ec_get_info(GET_EC_LABEL, info))
|
||||||
|
printk(BIOS_INFO, "EC Label : %s\n", info);
|
||||||
|
|
||||||
|
if (!wilco_ec_get_info(GET_EC_SVN_REV, info))
|
||||||
|
printk(BIOS_INFO, "EC Revision : %s\n", info);
|
||||||
|
|
||||||
|
if (!wilco_ec_get_info(GET_EC_MODEL_NO, info))
|
||||||
|
printk(BIOS_INFO, "EC Model Num : %s\n", info);
|
||||||
|
|
||||||
|
if (!wilco_ec_get_info(GET_EC_BUILD_DATE, info))
|
||||||
|
printk(BIOS_INFO, "EC Build Date : %s\n", info);
|
||||||
|
}
|
77
src/ec/google/wilco/commands.h
Normal file
77
src/ec/google/wilco/commands.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the coreboot project.
|
||||||
|
*
|
||||||
|
* Copyright 2018 Google LLC
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EC_GOOGLE_WILCO_COMMANDS_H
|
||||||
|
#define EC_GOOGLE_WILCO_COMMANDS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
/* Retrieve information about the EC */
|
||||||
|
KB_EC_INFO = 0x38,
|
||||||
|
/* Set ACPI mode on or off */
|
||||||
|
KB_ACPI = 0x3a,
|
||||||
|
/* Manage the EC power button passthru to the host */
|
||||||
|
KB_POWER_BUTTON_TO_HOST = 0x3e,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum set_acpi_mode_cmd {
|
||||||
|
ACPI_OFF = 0,
|
||||||
|
ACPI_ON
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EC Information
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum get_ec_info_cmd {
|
||||||
|
GET_EC_LABEL = 0,
|
||||||
|
GET_EC_SVN_REV,
|
||||||
|
GET_EC_MODEL_NO,
|
||||||
|
GET_EC_BUILD_DATE
|
||||||
|
};
|
||||||
|
|
||||||
|
#define EC_INFO_MAX_SIZE 9
|
||||||
|
struct ec_response_get_ec_info {
|
||||||
|
char data[EC_INFO_MAX_SIZE]; /* ASCII NUL terminated string */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wilco_ec_get_info
|
||||||
|
*
|
||||||
|
* Read a specific information string from the EC and return it in
|
||||||
|
* the caller-provided buffer of at least EC_INFO_MAX_SIZE bytes.
|
||||||
|
*
|
||||||
|
* @cmd: Information to retrieve
|
||||||
|
* @info: Character array of EC_INFO_MAX_SIZE bytes
|
||||||
|
*
|
||||||
|
* Returns 0 if successful and resulting string is in 'info'
|
||||||
|
* Returns -1 if the EC command fails
|
||||||
|
*/
|
||||||
|
int wilco_ec_get_info(enum get_ec_info_cmd cmd, char *info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wilco_ec_print_all_info
|
||||||
|
*
|
||||||
|
* Retrieve and print all the information strings from the EC:
|
||||||
|
*
|
||||||
|
* GET_EC_LABEL
|
||||||
|
* GET_EC_SVN_REV
|
||||||
|
* GET_EC_MODEL_NO
|
||||||
|
* GET_EC_BUILD_DATE
|
||||||
|
*/
|
||||||
|
void wilco_ec_print_all_info(void);
|
||||||
|
|
||||||
|
#endif /* EC_GOOGLE_WILCO_COMMANDS_H */
|
Reference in New Issue
Block a user