coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
sch5545_emi.c File Reference
#include <assert.h>
#include <arch/io.h>
#include <device/pnp.h>
#include <device/pnp_ops.h>
#include <superio/conf_mode.h>
#include <types.h>
#include "sch5545.h"
#include "sch5545_emi.h"
Include dependency graph for sch5545_emi.c:

Go to the source code of this file.

Functions

uint16_t sch5545_read_emi_bar (uint8_t sio_port)
 Reads and returns the base address of EMI from the SuperIO. More...
 
void sch5545_emi_init (uint8_t sio_port)
 One must call this function at every stage before using any of the EMI functions. More...
 
void sch5545_emi_ec2h_mailbox_clear (void)
 Reads the EC to Host mailbox register and then writes the same content to clear it. More...
 
void sch5545_emi_disable_interrupts (void)
 Writes the interrupt mask register with 0. More...
 
void sch5545_emi_h2ec_mbox_write (uint8_t mbox_message)
 Writes the Host to EC mailbox 8bit register with mbox_message. More...
 
uint8_t sch5545_emi_h2ec_mbox_read (void)
 Reads and returns the Host to EC mailbox 8bit register. More...
 
void sch5545_emi_ec2h_mbox_write (uint8_t mbox_message)
 Writes the EC to Host mailbox 8bit register with mbox_message. More...
 
uint8_t sch5545_emi_ec2h_mbox_read (void)
 Reads and returns the EC to Host mailbox 8bit register. More...
 
void sch5545_emi_set_int_mask (uint16_t mask)
 Sets the mask for all EC interrupts. More...
 
void sch5545_emi_set_int_mask_low (uint8_t mask)
 Sets the EC interrupt mask for LSB in the Interrupt Mask register. More...
 
void sch5545_emi_set_int_mask_high (uint8_t mask)
 Sets the EC interrupt mask for MSB in the Interrupt Mask register. More...
 
uint8_t sch5545_emi_get_int_mask_low (void)
 Returns LSB of Interrupt mask register. More...
 
uint8_t sch5545_emi_get_int_mask_high (void)
 Returns MSB of Interrupt mask register. More...
 
uint16_t sch5545_emi_get_int_mask (void)
 Returns the content of interrupt mask register. More...
 
void sch5545_emi_set_int_src_low (uint8_t int_src)
 Writes int_src bits to clear the desired interrupt source LSB. More...
 
void sch5545_emi_set_int_src_high (uint8_t int_src)
 Writes int_src bits to clear the desired interrupt source MSB. More...
 
uint8_t sch5545_emi_get_int_src_low (void)
 Returns LSB of interrupt source register. More...
 
uint8_t sch5545_emi_get_int_src_high (void)
 Returns MSB of interrupt source register. More...
 
uint16_t sch5545_emi_get_int_src (void)
 Returns the content of interrupt source register. More...
 
void sch5545_emi_set_int_src (uint16_t int_src)
 Writes int_src bits to clear the desired interrupt source bits. More...
 
void sch5545_emi_set_ec_addr (uint16_t addr)
 Sets the EC address registers with given addr for indirect access to Embedded Memory. More...
 
uint16_t sch5545_emi_read_ec_addr (void)
 Return the current EC address used for indirect access to Embedded Memory. More...
 
void sch5545_emi_ec_write8 (uint16_t addr, uint8_t data)
 Writes any byte of 4 bytes from the 32bit dword indicated by addr. More...
 
void sch5545_emi_ec_write16 (uint16_t addr, uint16_t data)
 Writes any word of 2 words from the 32bit dword indicated by addr. More...
 
void sch5545_emi_ec_write32 (uint16_t addr, uint32_t data)
 Writes dword of data at the desired address indicated by addr. More...
 
void sch5545_emi_ec_write32_bulk (uint16_t addr, const uint32_t *buffer, size_t len)
 Writes an array of dwords at the desired address indicated by addr. More...
 
uint8_t sch5545_emi_ec_read8 (uint16_t addr)
 Reads any byte of 4 bytes from the 32bit dword indicated by addr. More...
 
uint16_t sch5545_emi_ec_read16 (uint16_t addr)
 Reads any word of 2 words from the 32bit dword indicated by addr. More...
 
uint32_t sch5545_emi_ec_read32 (uint16_t addr)
 Reads dword of data at the desired address indicated by addr. More...
 
void sch5545_emi_ec_read32_bulk (uint16_t addr, uint32_t *buffer, size_t len)
 Reads a stream of dwords of size len to an array of dwords from the desired address indicated by addr. More...
 

Variables

static uint16_t emi_bar
 

Function Documentation

◆ sch5545_emi_disable_interrupts()

void sch5545_emi_disable_interrupts ( void  )

Writes the interrupt mask register with 0.

Definition at line 66 of file sch5545_emi.c.

References sch5545_emi_set_int_mask().

Referenced by bootblock_mainboard_early_init().

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

◆ sch5545_emi_ec2h_mailbox_clear()

void sch5545_emi_ec2h_mailbox_clear ( void  )

Reads the EC to Host mailbox register and then writes the same content to clear it.

Definition at line 61 of file sch5545_emi.c.

References sch5545_emi_ec2h_mbox_read(), and sch5545_emi_ec2h_mbox_write().

Referenced by ec_read_write_reg_timeout().

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

◆ sch5545_emi_ec2h_mbox_read()

uint8_t sch5545_emi_ec2h_mbox_read ( void  )

Reads and returns the EC to Host mailbox 8bit register.

Definition at line 86 of file sch5545_emi.c.

References emi_bar, inb(), and SCH5545_EMI_EC_TO_HOST_MAILBOX.

Referenced by ec_check_mbox_and_int_status(), ec_read_write_reg_timeout(), sch5545_emi_ec2h_mailbox_clear(), send_mbox_msg_simple(), and send_mbox_msg_with_int().

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

◆ sch5545_emi_ec2h_mbox_write()

void sch5545_emi_ec2h_mbox_write ( uint8_t  mbox_message)

Writes the EC to Host mailbox 8bit register with mbox_message.

Definition at line 81 of file sch5545_emi.c.

References emi_bar, outb(), and SCH5545_EMI_EC_TO_HOST_MAILBOX.

Referenced by sch5545_emi_ec2h_mailbox_clear().

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

◆ sch5545_emi_ec_read16()

uint16_t sch5545_emi_ec_read16 ( uint16_t  addr)

Reads any word of 2 words from the 32bit dword indicated by addr.

The addr must be aligned to 16bit access, because function programs the right access mode rounding the address to be read to 16 bit boundary.

Definition at line 194 of file sch5545_emi.c.

References addr, emi_bar, EMI_EC_16BIT_ACCESS, inw(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Here is the call graph for this function:

◆ sch5545_emi_ec_read32()

uint32_t sch5545_emi_ec_read32 ( uint16_t  addr)

Reads dword of data at the desired address indicated by addr.

The addr must be aligned to 32bit access, because function programs the right access mode rounding the address to be read to 32 bit boundary.

Definition at line 200 of file sch5545_emi.c.

References addr, emi_bar, EMI_EC_32BIT_ACCESS, inb(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Here is the call graph for this function:

◆ sch5545_emi_ec_read32_bulk()

void sch5545_emi_ec_read32_bulk ( uint16_t  addr,
uint32_t buffer,
size_t  len 
)

Reads a stream of dwords of size len to an array of dwords from the desired address indicated by addr.

The addr must be aligned to 32bit access, because function programs the right access mode rounding the start address to be read to 32 bit boundary. The address is autoincremented by each IO read operation automatically.

Definition at line 206 of file sch5545_emi.c.

References addr, buffer, emi_bar, EMI_EC_32BIT_AUTO_ACCESS, inl(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Here is the call graph for this function:

◆ sch5545_emi_ec_read8()

uint8_t sch5545_emi_ec_read8 ( uint16_t  addr)

Reads any byte of 4 bytes from the 32bit dword indicated by addr.

The function will automatically align to the matching 32bit dword.

Definition at line 188 of file sch5545_emi.c.

References addr, emi_bar, EMI_EC_8BIT_ACCESS, inb(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Referenced by ec_read_write_reg().

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

◆ sch5545_emi_ec_write16()

void sch5545_emi_ec_write16 ( uint16_t  addr,
uint16_t  data 
)

Writes any word of 2 words from the 32bit dword indicated by addr.

The addr must be aligned to 16bit access, because function programs the right access mode rounding the address to be written to 16 bit boundary.

Definition at line 166 of file sch5545_emi.c.

References addr, emi_bar, EMI_EC_16BIT_ACCESS, outw(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Referenced by ec_read_write_reg(), and ec_read_write_reg_timeout().

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

◆ sch5545_emi_ec_write32()

void sch5545_emi_ec_write32 ( uint16_t  addr,
uint32_t  data 
)

Writes dword of data at the desired address indicated by addr.

The addr must be aligned to 32bit access, because function programs the right access mode rounding the address to be written to 32 bit boundary.

Definition at line 172 of file sch5545_emi.c.

References addr, emi_bar, EMI_EC_32BIT_ACCESS, outl(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Referenced by ec_read_write_reg().

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

◆ sch5545_emi_ec_write32_bulk()

void sch5545_emi_ec_write32_bulk ( uint16_t  addr,
const uint32_t buffer,
size_t  len 
)

Writes an array of dwords at the desired address indicated by addr.

The addr must be aligned to 32bit access, because function programs the right access mode rounding the address to be written to 32 bit boundary. The address is autoincremented by each IO write operation automatically.

Definition at line 178 of file sch5545_emi.c.

References addr, buffer, emi_bar, EMI_EC_32BIT_AUTO_ACCESS, outl(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Referenced by sch5545_update_ec_firmware().

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

◆ sch5545_emi_ec_write8()

void sch5545_emi_ec_write8 ( uint16_t  addr,
uint8_t  data 
)

Writes any byte of 4 bytes from the 32bit dword indicated by addr.

The function will automatically align to the matching 32bit dword.

Definition at line 160 of file sch5545_emi.c.

References addr, emi_bar, EMI_EC_8BIT_ACCESS, outb(), SCH5545_EMI_EC_DATA, and sch5545_emi_set_ec_addr().

Here is the call graph for this function:

◆ sch5545_emi_get_int_mask()

uint16_t sch5545_emi_get_int_mask ( void  )

Returns the content of interrupt mask register.

Definition at line 116 of file sch5545_emi.c.

References emi_bar, inw(), and SCH5545_EMI_INT_MASK.

Here is the call graph for this function:

◆ sch5545_emi_get_int_mask_high()

uint8_t sch5545_emi_get_int_mask_high ( void  )

Returns MSB of Interrupt mask register.

Definition at line 111 of file sch5545_emi.c.

References emi_bar, inb(), and SCH5545_EMI_INT_MASK.

Referenced by mainboard_early_init().

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

◆ sch5545_emi_get_int_mask_low()

uint8_t sch5545_emi_get_int_mask_low ( void  )

Returns LSB of Interrupt mask register.

Definition at line 106 of file sch5545_emi.c.

References emi_bar, inb(), and SCH5545_EMI_INT_MASK.

Referenced by ec_read_write_reg().

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

◆ sch5545_emi_get_int_src()

uint16_t sch5545_emi_get_int_src ( void  )

Returns the content of interrupt source register.

Definition at line 140 of file sch5545_emi.c.

References emi_bar, inw(), and SCH5545_EMI_INT_SOURCE.

Here is the call graph for this function:

◆ sch5545_emi_get_int_src_high()

uint8_t sch5545_emi_get_int_src_high ( void  )

Returns MSB of interrupt source register.

Definition at line 136 of file sch5545_emi.c.

References emi_bar, inb(), and SCH5545_EMI_INT_SOURCE.

Here is the call graph for this function:

◆ sch5545_emi_get_int_src_low()

uint8_t sch5545_emi_get_int_src_low ( void  )

Returns LSB of interrupt source register.

Definition at line 131 of file sch5545_emi.c.

References emi_bar, inb(), and SCH5545_EMI_INT_SOURCE.

Referenced by ec_check_mbox_and_int_status(), send_mbox_msg_simple(), and send_mbox_msg_with_int().

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

◆ sch5545_emi_h2ec_mbox_read()

uint8_t sch5545_emi_h2ec_mbox_read ( void  )

Reads and returns the Host to EC mailbox 8bit register.

Definition at line 76 of file sch5545_emi.c.

References emi_bar, inb(), and SCH5545_EMI_HOST_TO_EC_MAILBOX.

Here is the call graph for this function:

◆ sch5545_emi_h2ec_mbox_write()

void sch5545_emi_h2ec_mbox_write ( uint8_t  mbox_message)

Writes the Host to EC mailbox 8bit register with mbox_message.

Definition at line 71 of file sch5545_emi.c.

References emi_bar, outb(), and SCH5545_EMI_HOST_TO_EC_MAILBOX.

Referenced by ec_read_write_reg_timeout(), send_mbox_msg_simple(), and send_mbox_msg_with_int().

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

◆ sch5545_emi_init()

void sch5545_emi_init ( uint8_t  sio_port)

One must call this function at every stage before using any of the EMI functions.

The base address of EMI interface must not be zero.

Definition at line 55 of file sch5545_emi.c.

References assert, emi_bar, and sch5545_read_emi_bar().

Referenced by bootblock_mainboard_early_init(), mainboard_early_init(), and sch5545_ec_hwm_init().

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

◆ sch5545_emi_read_ec_addr()

uint16_t sch5545_emi_read_ec_addr ( void  )

Return the current EC address used for indirect access to Embedded Memory.

Definition at line 155 of file sch5545_emi.c.

References emi_bar, inw(), and SCH5545_EMI_EC_ADDR.

Here is the call graph for this function:

◆ sch5545_emi_set_ec_addr()

void sch5545_emi_set_ec_addr ( uint16_t  addr)

Sets the EC address registers with given addr for indirect access to Embedded Memory.

Definition at line 150 of file sch5545_emi.c.

References addr, emi_bar, outw(), and SCH5545_EMI_EC_ADDR.

Referenced by ec_read_write_reg_timeout(), sch5545_emi_ec_read16(), sch5545_emi_ec_read32(), sch5545_emi_ec_read32_bulk(), sch5545_emi_ec_read8(), sch5545_emi_ec_write16(), sch5545_emi_ec_write32(), sch5545_emi_ec_write32_bulk(), and sch5545_emi_ec_write8().

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

◆ sch5545_emi_set_int_mask()

void sch5545_emi_set_int_mask ( uint16_t  mask)

Sets the mask for all EC interrupts.

Definition at line 91 of file sch5545_emi.c.

References emi_bar, mask, outw(), and SCH5545_EMI_INT_MASK.

Referenced by sch5545_emi_disable_interrupts().

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

◆ sch5545_emi_set_int_mask_high()

void sch5545_emi_set_int_mask_high ( uint8_t  mask)

Sets the EC interrupt mask for MSB in the Interrupt Mask register.

Definition at line 101 of file sch5545_emi.c.

References emi_bar, mask, outb(), and SCH5545_EMI_INT_MASK.

Here is the call graph for this function:

◆ sch5545_emi_set_int_mask_low()

void sch5545_emi_set_int_mask_low ( uint8_t  mask)

Sets the EC interrupt mask for LSB in the Interrupt Mask register.

Definition at line 96 of file sch5545_emi.c.

References emi_bar, mask, outb(), and SCH5545_EMI_INT_MASK.

Referenced by ec_read_write_reg().

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

◆ sch5545_emi_set_int_src()

void sch5545_emi_set_int_src ( uint16_t  int_src)

Writes int_src bits to clear the desired interrupt source bits.

Definition at line 145 of file sch5545_emi.c.

References emi_bar, outw(), and SCH5545_EMI_INT_SOURCE.

Referenced by ec_read_write_reg_timeout().

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

◆ sch5545_emi_set_int_src_high()

void sch5545_emi_set_int_src_high ( uint8_t  int_src)

Writes int_src bits to clear the desired interrupt source MSB.

Definition at line 126 of file sch5545_emi.c.

References emi_bar, outb(), and SCH5545_EMI_INT_SOURCE.

Here is the call graph for this function:

◆ sch5545_emi_set_int_src_low()

void sch5545_emi_set_int_src_low ( uint8_t  int_src)

Writes int_src bits to clear the desired interrupt source LSB.

Definition at line 121 of file sch5545_emi.c.

References emi_bar, outb(), and SCH5545_EMI_INT_SOURCE.

Referenced by ec_check_mbox_and_int_status(), and send_mbox_msg_with_int().

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

◆ sch5545_read_emi_bar()

uint16_t sch5545_read_emi_bar ( uint8_t  sio_port)

Reads and returns the base address of EMI from the SuperIO.

Definition at line 29 of file sch5545_emi.c.

References dev_find_slot_pnp(), PNP_DEV, pnp_enter_conf_mode_55(), pnp_exit_conf_mode_aa(), pnp_read_config(), pnp_set_logical_device(), SCH5545_BAR_EM_IF, and SCH5545_LDN_LPC.

Referenced by sch5545_ec_early_init(), and sch5545_emi_init().

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

Variable Documentation

◆ emi_bar