coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mailbox.c File Reference
#include <arch/io.h>
#include <console/console.h>
#include <delay.h>
#include <ec/google/common/mec.h>
#include <string.h>
#include <timer.h>
#include <types.h>
#include "ec.h"
Include dependency graph for mailbox.c:

Go to the source code of this file.

Data Structures

struct  wilco_ec_request
 
struct  wilco_ec_response
 
struct  wilco_ec_message
 

Macros

#define EC_MAILBOX_ID   0x00f0
 
#define EC_MAILBOX_VERSION   0
 
#define EC_MAILBOX_START_COMMAND   0xda
 
#define EC_MAILBOX_PROTO_VERSION   3
 
#define EC_MAILBOX_DATA_SIZE   32
 
#define EC_MAILBOX_DATA_EXTRA   2
 
#define EC_MAILBOX_TIMEOUT_MS   MSECS_PER_SEC
 
#define EC_CMDR_DATA   BIT(0) /* Data ready for host to read */
 
#define EC_CMDR_PENDING   BIT(1) /* Write pending to EC */
 
#define EC_CMDR_BUSY   BIT(2) /* EC is busy processing a command */
 
#define EC_CMDR_CMD   BIT(3) /* Last host write was a command */
 

Functions

static bool wilco_ec_response_timed_out (void)
 
static uint8_t wilco_ec_checksum (void *data, size_t size)
 
static void wilco_ec_prepare (struct wilco_ec_message *msg, struct wilco_ec_request *rq)
 
static int wilco_ec_transfer (struct wilco_ec_message *msg)
 
int wilco_ec_mailbox (enum wilco_ec_msg_type type, uint8_t command, const void *request_data, size_t request_size, void *response_data, size_t response_size)
 wilco_ec_mailbox More...
 

Variables

struct wilco_ec_request __packed
 

Macro Definition Documentation

◆ EC_CMDR_BUSY

#define EC_CMDR_BUSY   BIT(2) /* EC is busy processing a command */

Definition at line 37 of file mailbox.c.

◆ EC_CMDR_CMD

#define EC_CMDR_CMD   BIT(3) /* Last host write was a command */

Definition at line 38 of file mailbox.c.

◆ EC_CMDR_DATA

#define EC_CMDR_DATA   BIT(0) /* Data ready for host to read */

Definition at line 35 of file mailbox.c.

◆ EC_CMDR_PENDING

#define EC_CMDR_PENDING   BIT(1) /* Write pending to EC */

Definition at line 36 of file mailbox.c.

◆ EC_MAILBOX_DATA_EXTRA

#define EC_MAILBOX_DATA_EXTRA   2

Definition at line 29 of file mailbox.c.

◆ EC_MAILBOX_DATA_SIZE

#define EC_MAILBOX_DATA_SIZE   32

Definition at line 26 of file mailbox.c.

◆ EC_MAILBOX_ID

#define EC_MAILBOX_ID   0x00f0

Definition at line 14 of file mailbox.c.

◆ EC_MAILBOX_PROTO_VERSION

#define EC_MAILBOX_PROTO_VERSION   3

Definition at line 23 of file mailbox.c.

◆ EC_MAILBOX_START_COMMAND

#define EC_MAILBOX_START_COMMAND   0xda

Definition at line 20 of file mailbox.c.

◆ EC_MAILBOX_TIMEOUT_MS

#define EC_MAILBOX_TIMEOUT_MS   MSECS_PER_SEC

Definition at line 32 of file mailbox.c.

◆ EC_MAILBOX_VERSION

#define EC_MAILBOX_VERSION   0

Definition at line 17 of file mailbox.c.

Function Documentation

◆ wilco_ec_checksum()

static uint8_t wilco_ec_checksum ( void data,
size_t  size 
)
static

Definition at line 93 of file mailbox.c.

References checksum().

Referenced by wilco_ec_prepare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wilco_ec_mailbox()

int wilco_ec_mailbox ( enum wilco_ec_msg_type  type,
uint8_t  command,
const void request_data,
size_t  request_size,
void response_data,
size_t  response_size 
)

wilco_ec_mailbox

Send a command request to the EC mailbox and receive the response.

@type: Mailbox message type, see enum above @command: Command to execute @request_data: Request data buffer @request_size: Number of bytes in request data buffer (max 32) @response_data: Response data buffer @response_size: Number of bytes in response data buffer (max 32)

Returns
number of bytes received, negative error code on failure

Definition at line 195 of file mailbox.c.

References BIOS_ERR, wilco_ec_message::command, wilco_ec_message::data, EC_MAILBOX_DATA_SIZE, memcpy(), printk, wilco_ec_message::request_size, wilco_ec_message::response_size, wilco_ec_message::result, type, and wilco_ec_transfer().

Referenced by die_notify(), wilco_ec_change_wake(), wilco_ec_get_board_id(), wilco_ec_power_off(), wilco_ec_radio_control(), wilco_ec_send(), wilco_ec_send_noargs(), wilco_ec_sendrecv(), wilco_ec_sendrecv_noargs(), wilco_ec_set_cpuid(), and wilco_ec_slp_en().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wilco_ec_prepare()

◆ wilco_ec_response_timed_out()

static bool wilco_ec_response_timed_out ( void  )
static

Definition at line 75 of file mailbox.c.

References BIOS_ERR, EC_CMDR_BUSY, EC_CMDR_PENDING, EC_MAILBOX_TIMEOUT_MS, inb(), mask, mdelay(), printk, stopwatch_expired(), and stopwatch_init_msecs_expire().

Referenced by wilco_ec_transfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wilco_ec_transfer()

Variable Documentation

◆ __packed