coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cr50.c File Reference
#include <commonlib/endian.h>
#include <commonlib/helpers.h>
#include <console/console.h>
#include <delay.h>
#include <device/i2c_simple.h>
#include <drivers/tpm/cr50.h>
#include <endian.h>
#include <security/tpm/tis.h>
#include <string.h>
#include <types.h>
#include <timer.h>
#include "tpm.h"
Include dependency graph for cr50.c:

Go to the source code of this file.

Data Structures

struct  tpm_inf_dev
 

Macros

#define CR50_MAX_BUFSIZE   63
 
#define CR50_TIMEOUT_INIT_MS   30000 /* Very long timeout for TPM init */
 
#define CR50_TIMEOUT_LONG_MS   2000 /* Long timeout while waiting for TPM */
 
#define CR50_TIMEOUT_SHORT_MS   2 /* Short timeout during transactions */
 
#define CR50_TIMEOUT_NOIRQ_MS   20 /* Timeout for TPM ready without IRQ */
 
#define CR50_TIMEOUT_IRQ_MS   100 /* Timeout for TPM ready with IRQ */
 
#define CR50_DID_VID   0x00281ae0L
 
#define TI50_DID_VID   0x504a6666L
 

Functions

__weak int tis_plat_irq_status (void)
 
static int cr50_i2c_wait_tpm_ready (void)
 
static int cr50_i2c_read (uint8_t addr, uint8_t *buffer, size_t len)
 
static int cr50_i2c_write (uint8_t addr, const uint8_t *buffer, size_t len)
 
static int process_reset (void)
 
static int claim_locality (void)
 
static uint8_t cr50_i2c_tis_status (struct tpm_chip *chip)
 
static void cr50_i2c_tis_ready (struct tpm_chip *chip)
 
static int cr50_i2c_wait_burststs (struct tpm_chip *chip, uint8_t mask, size_t *burst, int *status)
 
static int cr50_i2c_tis_recv (struct tpm_chip *chip, uint8_t *buf, size_t buf_len)
 
static int cr50_i2c_tis_send (struct tpm_chip *chip, uint8_t *buf, size_t len)
 
static void cr50_vendor_init (struct tpm_chip *chip)
 
int tpm_vendor_probe (unsigned int bus, uint32_t addr)
 
static int cr50_i2c_probe (struct tpm_chip *chip, uint32_t *did_vid)
 
int tpm_vendor_init (struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr)
 
void tpm_vendor_cleanup (struct tpm_chip *chip)
 
enum cb_err tis_vendor_write (unsigned int addr, const void *buffer, size_t bytes)
 
enum cb_err tis_vendor_read (unsigned int addr, void *buffer, size_t bytes)
 

Variables

static struct tpm_inf_dev tpm_dev
 

Macro Definition Documentation

◆ CR50_DID_VID

#define CR50_DID_VID   0x00281ae0L

Definition at line 38 of file cr50.c.

◆ CR50_MAX_BUFSIZE

#define CR50_MAX_BUFSIZE   63

Definition at line 32 of file cr50.c.

◆ CR50_TIMEOUT_INIT_MS

#define CR50_TIMEOUT_INIT_MS   30000 /* Very long timeout for TPM init */

Definition at line 33 of file cr50.c.

◆ CR50_TIMEOUT_IRQ_MS

#define CR50_TIMEOUT_IRQ_MS   100 /* Timeout for TPM ready with IRQ */

Definition at line 37 of file cr50.c.

◆ CR50_TIMEOUT_LONG_MS

#define CR50_TIMEOUT_LONG_MS   2000 /* Long timeout while waiting for TPM */

Definition at line 34 of file cr50.c.

◆ CR50_TIMEOUT_NOIRQ_MS

#define CR50_TIMEOUT_NOIRQ_MS   20 /* Timeout for TPM ready without IRQ */

Definition at line 36 of file cr50.c.

◆ CR50_TIMEOUT_SHORT_MS

#define CR50_TIMEOUT_SHORT_MS   2 /* Short timeout during transactions */

Definition at line 35 of file cr50.c.

◆ TI50_DID_VID

#define TI50_DID_VID   0x504a6666L

Definition at line 39 of file cr50.c.

Function Documentation

◆ claim_locality()

static int claim_locality ( void  )
static

Definition at line 213 of file cr50.c.

References BIOS_INFO, cr50_i2c_read(), cr50_i2c_write(), mask, printk, TPM_ACCESS, TPM_ACCESS_ACTIVE_LOCALITY, TPM_ACCESS_REQUEST_USE, and TPM_ACCESS_VALID.

Referenced by tpm_vendor_init().

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

◆ cr50_i2c_probe()

static int cr50_i2c_probe ( struct tpm_chip chip,
uint32_t did_vid 
)
static

Definition at line 441 of file cr50.c.

References BIOS_ERR, BIOS_INFO, CR50_DID_VID, cr50_i2c_read(), mdelay(), printk, TI50_DID_VID, and TPM_DID_VID.

Referenced by tpm_vendor_init().

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

◆ cr50_i2c_read()

static int cr50_i2c_read ( uint8_t  addr,
uint8_t buffer,
size_t  len 
)
static

Definition at line 91 of file cr50.c.

References addr, tpm_inf_dev::addr, BIOS_ERR, buffer, tpm_inf_dev::bus, cr50_i2c_wait_tpm_ready(), i2c_read_raw(), i2c_write_raw(), printk, tis_plat_irq_status(), and tpm_dev.

Referenced by claim_locality(), cr50_i2c_probe(), cr50_i2c_tis_recv(), cr50_i2c_tis_status(), cr50_i2c_wait_burststs(), and process_reset().

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

◆ cr50_i2c_tis_ready()

static void cr50_i2c_tis_ready ( struct tpm_chip chip)
static

Definition at line 255 of file cr50.c.

References buf, chip, cr50_i2c_write(), CR50_TIMEOUT_SHORT_MS, tpm_vendor_specific::locality, mdelay(), TPM_STS, TPM_STS_COMMAND_READY, and tpm_chip::vendor.

Referenced by cr50_i2c_tis_recv(), cr50_i2c_tis_send(), and cr50_vendor_init().

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

◆ cr50_i2c_tis_recv()

static int cr50_i2c_tis_recv ( struct tpm_chip chip,
uint8_t buf,
size_t  buf_len 
)
static

◆ cr50_i2c_tis_send()

static int cr50_i2c_tis_send ( struct tpm_chip chip,
uint8_t buf,
size_t  len 
)
static

◆ cr50_i2c_tis_status()

static uint8_t cr50_i2c_tis_status ( struct tpm_chip chip)
static

Definition at line 243 of file cr50.c.

References BIOS_ERR, buf, chip, cr50_i2c_read(), tpm_vendor_specific::locality, printk, TPM_STS, and tpm_chip::vendor.

Referenced by cr50_i2c_tis_recv(), cr50_i2c_tis_send(), and cr50_vendor_init().

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

◆ cr50_i2c_wait_burststs()

static int cr50_i2c_wait_burststs ( struct tpm_chip chip,
uint8_t  mask,
size_t burst,
int *  status 
)
static

Definition at line 264 of file cr50.c.

References BIOS_ERR, buf, chip, cr50_i2c_read(), CR50_MAX_BUFSIZE, CR50_TIMEOUT_LONG_MS, CR50_TIMEOUT_SHORT_MS, tpm_vendor_specific::locality, mask, mdelay(), printk, read_le16(), stopwatch_expired(), stopwatch_init_msecs_expire(), TPM_STS, and tpm_chip::vendor.

Referenced by cr50_i2c_tis_recv(), and cr50_i2c_tis_send().

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

◆ cr50_i2c_wait_tpm_ready()

static int cr50_i2c_wait_tpm_ready ( void  )
static

Definition at line 64 of file cr50.c.

References BIOS_ERR, CR50_TIMEOUT_IRQ_MS, printk, stopwatch_expired(), stopwatch_init_msecs_expire(), and tis_plat_irq_status().

Referenced by cr50_i2c_read(), and cr50_i2c_write().

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

◆ cr50_i2c_write()

static int cr50_i2c_write ( uint8_t  addr,
const uint8_t buffer,
size_t  len 
)
static

Definition at line 131 of file cr50.c.

References addr, tpm_inf_dev::addr, BIOS_ERR, tpm_inf_dev::buf, buffer, tpm_inf_dev::bus, cr50_i2c_wait_tpm_ready(), CR50_MAX_BUFSIZE, i2c_write_raw(), memcpy(), printk, tis_plat_irq_status(), and tpm_dev.

Referenced by claim_locality(), cr50_i2c_tis_ready(), and cr50_i2c_tis_send().

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

◆ cr50_vendor_init()

◆ process_reset()

static int process_reset ( void  )
static

Definition at line 162 of file cr50.c.

References BIOS_ERR, BIOS_INFO, cr50_i2c_read(), CR50_TIMEOUT_INIT_MS, mask, mdelay(), printk, stopwatch_duration_msecs(), stopwatch_expired(), stopwatch_init_msecs_expire(), TPM_ACCESS, TPM_ACCESS_ACTIVE_LOCALITY, and TPM_ACCESS_VALID.

Referenced by tpm_vendor_init().

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

◆ tis_plat_irq_status()

__weak int tis_plat_irq_status ( void  )

Definition at line 49 of file cr50.c.

References BIOS_WARNING, CR50_TIMEOUT_NOIRQ_MS, mdelay(), and printk.

Referenced by cr50_i2c_read(), cr50_i2c_wait_tpm_ready(), and cr50_i2c_write().

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

◆ tis_vendor_read()

enum cb_err tis_vendor_read ( unsigned int  addr,
void buffer,
size_t  bytes 
)

Definition at line 513 of file cr50.c.

Referenced by cr50_get_board_cfg().

Here is the caller graph for this function:

◆ tis_vendor_write()

enum cb_err tis_vendor_write ( unsigned int  addr,
const void buffer,
size_t  bytes 
)

Definition at line 513 of file cr50.c.

◆ tpm_vendor_cleanup()

void tpm_vendor_cleanup ( struct tpm_chip chip)

Definition at line 513 of file cr50.c.

Referenced by tis_close().

Here is the caller graph for this function:

◆ tpm_vendor_init()

int tpm_vendor_init ( struct tpm_chip chip,
unsigned int  bus,
uint32_t  dev_addr 
)

◆ tpm_vendor_probe()

int tpm_vendor_probe ( unsigned int  bus,
uint32_t  addr 
)

Definition at line 436 of file cr50.c.

Referenced by tis_init().

Here is the caller graph for this function:

Variable Documentation

◆ tpm_dev

struct tpm_inf_dev tpm_dev
static

Definition at line 1 of file cr50.c.

Referenced by cr50_i2c_read(), cr50_i2c_write(), and tpm_vendor_init().