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

Go to the source code of this file.

Functions

static void read_bytes (u16 port, unsigned int length, u8 *dest, u8 *csum)
 
static u8 read_byte (u16 port)
 
static void write_bytes (u16 port, unsigned int length, u8 *msg, u8 *csum)
 
static u8 write_byte (u8 val, u16 port)
 
static int google_chromeec_status_check (u16 port, u8 mask, u8 cond)
 
static int google_chromeec_wait_ready (u16 port)
 
static int google_chromeec_command_version (void)
 
static int google_chromeec_command_v3 (struct chromeec_command *cec_command)
 
static int google_chromeec_command_v1 (struct chromeec_command *cec_command)
 
uint8_t google_chromeec_get_switches (void)
 
void google_chromeec_ioport_range (uint16_t *out_base, size_t *out_size)
 
int google_chromeec_command (struct chromeec_command *cec_command)
 Send a command to a CrOS EC. More...
 
static void lpc_ec_init (struct device *dev)
 
static void lpc_ec_read_resources (struct device *dev)
 
static void enable_dev (struct device *dev)
 
static int google_chromeec_data_ready (u16 port)
 
enum host_event_code google_chromeec_get_event (void)
 

Variables

static struct device_operations ops
 
static struct pnp_info pnp_dev_info []
 
struct chip_operations ec_google_chromeec_ops
 

Function Documentation

◆ enable_dev()

static void enable_dev ( struct device dev)
static

Definition at line 448 of file ec_lpc.c.

◆ google_chromeec_command()

int google_chromeec_command ( struct chromeec_command cec_command)

Send a command to a CrOS EC.

Parameters
cec_commandCrOS EC command to send
Returns
0 for success. Non-zero for error.

Definition at line 384 of file ec_lpc.c.

References ec_lpc_host_args::command_version, EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED, EC_HOST_CMD_FLAG_VERSION_3, google_chromeec_command_v1(), google_chromeec_command_v3(), and google_chromeec_command_version().

Here is the call graph for this function:

◆ google_chromeec_command_v1()

static int google_chromeec_command_v1 ( struct chromeec_command cec_command)
static

◆ google_chromeec_command_v3()

◆ google_chromeec_command_version()

static int google_chromeec_command_version ( void  )
static

Definition at line 148 of file ec_lpc.c.

References BIOS_ERR, EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED, EC_HOST_CMD_FLAG_VERSION_3, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_HOST_CMD_FLAGS, EC_MEMMAP_ID, id1, printk, and read_byte().

Referenced by google_chromeec_command().

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

◆ google_chromeec_data_ready()

static int google_chromeec_data_ready ( u16  port)
static

Definition at line 458 of file ec_lpc.c.

References EC_LPC_CMDR_DATA, and google_chromeec_status_check().

Here is the call graph for this function:

◆ google_chromeec_get_event()

enum host_event_code google_chromeec_get_event ( void  )

Definition at line 458 of file ec_lpc.c.

◆ google_chromeec_get_switches()

uint8_t google_chromeec_get_switches ( void  )

Definition at line 359 of file ec_lpc.c.

References EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SWITCHES, and read_byte().

Referenced by get_lid_switch(), and get_recovery_mode_switch().

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

◆ google_chromeec_ioport_range()

void google_chromeec_ioport_range ( uint16_t out_base,
size_t out_size 
)

Definition at line 364 of file ec_lpc.c.

References assert, base, CONFIG, EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION_SIZE, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE, MEC_EMI_BASE, and MEC_EMI_SIZE.

Referenced by bootblock_ec_init(), early_ec_init(), and lpc_ec_read_resources().

Here is the caller graph for this function:

◆ google_chromeec_status_check()

static int google_chromeec_status_check ( u16  port,
u8  mask,
u8  cond 
)
static

Definition at line 94 of file ec_lpc.c.

References mask, read_byte(), stopwatch_expired(), stopwatch_init_usecs_expire(), udelay(), and USECS_PER_SEC.

Referenced by google_chromeec_data_ready(), and google_chromeec_wait_ready().

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

◆ google_chromeec_wait_ready()

static int google_chromeec_wait_ready ( u16  port)
static

Definition at line 111 of file ec_lpc.c.

References EC_LPC_CMDR_BUSY, EC_LPC_CMDR_PENDING, and google_chromeec_status_check().

Referenced by google_chromeec_command_v1(), and google_chromeec_command_v3().

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

◆ lpc_ec_init()

static void lpc_ec_init ( struct device dev)
static

Definition at line 400 of file ec_lpc.c.

References device::enabled, and google_chromeec_init().

Here is the call graph for this function:

◆ lpc_ec_read_resources()

static void lpc_ec_read_resources ( struct device dev)
static

Definition at line 419 of file ec_lpc.c.

References resource::base, base, resource::flags, google_chromeec_ioport_range(), IORESOURCE_ASSIGNED, IORESOURCE_FIXED, IORESOURCE_IO, new_resource(), and resource::size.

Here is the call graph for this function:

◆ read_byte()

static u8 read_byte ( u16  port)
inlinestatic

Definition at line 48 of file ec_lpc.c.

References NULL, and read_bytes().

Referenced by google_chromeec_command_v1(), google_chromeec_command_v3(), google_chromeec_command_version(), google_chromeec_get_switches(), and google_chromeec_status_check().

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

◆ read_bytes()

static void read_bytes ( u16  port,
unsigned int  length,
u8 dest,
u8 csum 
)
static

Definition at line 24 of file ec_lpc.c.

References inb(), length, MEC_EMI_BASE, MEC_EMI_RANGE_END, MEC_EMI_RANGE_START, mec_io_bytes(), and MEC_IO_READ.

Referenced by google_chromeec_command_v1(), google_chromeec_command_v3(), and read_byte().

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

◆ write_byte()

static u8 write_byte ( u8  val,
u16  port 
)
inlinestatic

Definition at line 87 of file ec_lpc.c.

References NULL, val, and write_bytes().

Referenced by google_chromeec_command_v1(), and google_chromeec_command_v3().

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

◆ write_bytes()

static void write_bytes ( u16  port,
unsigned int  length,
u8 msg,
u8 csum 
)
static

Definition at line 63 of file ec_lpc.c.

References length, MEC_EMI_BASE, MEC_EMI_RANGE_END, MEC_EMI_RANGE_START, mec_io_bytes(), MEC_IO_WRITE, and outb().

Referenced by google_chromeec_command_v1(), google_chromeec_command_v3(), and write_byte().

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

Variable Documentation

◆ ec_google_chromeec_ops

struct chip_operations ec_google_chromeec_ops
Initial value:
= {
.enable_dev = enable_dev,
}
static void enable_dev(struct device *dev)
Definition: ec_lpc.c:448

Definition at line 448 of file ec_lpc.c.

◆ ops

struct device_operations ops
static
Initial value:
= {
.init = lpc_ec_init,
.read_resources = lpc_ec_read_resources,
.set_resources = noop_set_resources,
.scan_bus = scan_static_bus,
}
static void lpc_ec_read_resources(struct device *dev)
Definition: ec_lpc.c:419
static void lpc_ec_init(struct device *dev)
Definition: ec_lpc.c:400
static void noop_set_resources(struct device *dev)
Definition: device.h:74
void scan_static_bus(struct device *bus)
Definition: root_device.c:89

Definition at line 419 of file ec_lpc.c.

◆ pnp_dev_info

struct pnp_info pnp_dev_info[]
static
Initial value:
= {
{ NULL, 0, 0, 0, }
}
#define NULL
Definition: stddef.h:19

Definition at line 419 of file ec_lpc.c.