coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
sifive.c File Reference
#include <device/mmio.h>
#include <boot/coreboot_tables.h>
#include <console/uart.h>
#include <types.h>
Include dependency graph for sifive.c:

Go to the source code of this file.

Data Structures

struct  sifive_uart_registers
 

Macros

#define TXDATA_FULL   BIT(31)
 
#define RXDATA_EMPTY   BIT(31)
 
#define TXCTRL_TXEN   BIT(0)
 
#define TXCTRL_NSTOP_SHIFT   1
 
#define TXCTRL_NSTOP(x)   (((x)-1) << TXCTRL_NSTOP_SHIFT)
 
#define TXCTRL_TXCNT_SHIFT   16
 
#define TXCTRL_TXCNT(x)   ((x) << TXCTRL_TXCNT_SHIFT)
 
#define RXCTRL_RXEN   BIT(0)
 
#define RXCTRL_RXCNT_SHIFT   16
 
#define RXCTRL_RXCNT(x)   ((x) << RXCTRL_RXCNT_SHIFT)
 
#define IP_TXWM   BIT(0)
 
#define IP_RXWM   BIT(1)
 

Functions

static void sifive_uart_init (struct sifive_uart_registers *regs, int div)
 
void uart_init (unsigned int idx)
 
static bool uart_can_tx (struct sifive_uart_registers *regs)
 
void uart_tx_byte (unsigned int idx, unsigned char data)
 
void uart_tx_flush (unsigned int idx)
 
unsigned char uart_rx_byte (unsigned int idx)
 
unsigned int uart_input_clock_divider (void)
 
void uart_fill_lb (void *data)
 

Variables

struct sifive_uart_registers __packed
 

Macro Definition Documentation

◆ IP_RXWM

#define IP_RXWM   BIT(1)

Definition at line 34 of file sifive.c.

◆ IP_TXWM

#define IP_TXWM   BIT(0)

Definition at line 33 of file sifive.c.

◆ RXCTRL_RXCNT

#define RXCTRL_RXCNT (   x)    ((x) << RXCTRL_RXCNT_SHIFT)

Definition at line 32 of file sifive.c.

◆ RXCTRL_RXCNT_SHIFT

#define RXCTRL_RXCNT_SHIFT   16

Definition at line 31 of file sifive.c.

◆ RXCTRL_RXEN

#define RXCTRL_RXEN   BIT(0)

Definition at line 30 of file sifive.c.

◆ RXDATA_EMPTY

#define RXDATA_EMPTY   BIT(31)

Definition at line 24 of file sifive.c.

◆ TXCTRL_NSTOP

#define TXCTRL_NSTOP (   x)    (((x)-1) << TXCTRL_NSTOP_SHIFT)

Definition at line 27 of file sifive.c.

◆ TXCTRL_NSTOP_SHIFT

#define TXCTRL_NSTOP_SHIFT   1

Definition at line 26 of file sifive.c.

◆ TXCTRL_TXCNT

#define TXCTRL_TXCNT (   x)    ((x) << TXCTRL_TXCNT_SHIFT)

Definition at line 29 of file sifive.c.

◆ TXCTRL_TXCNT_SHIFT

#define TXCTRL_TXCNT_SHIFT   16

Definition at line 28 of file sifive.c.

◆ TXCTRL_TXEN

#define TXCTRL_TXEN   BIT(0)

Definition at line 25 of file sifive.c.

◆ TXDATA_FULL

#define TXDATA_FULL   BIT(31)

Definition at line 23 of file sifive.c.

Function Documentation

◆ sifive_uart_init()

static void sifive_uart_init ( struct sifive_uart_registers regs,
int  div 
)
static

Definition at line 36 of file sifive.c.

References RXCTRL_RXCNT, RXCTRL_RXEN, TXCTRL_NSTOP, TXCTRL_TXCNT, TXCTRL_TXEN, and write32().

Referenced by uart_init().

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

◆ uart_can_tx()

static bool uart_can_tx ( struct sifive_uart_registers regs)
static

Definition at line 56 of file sifive.c.

References read32(), and TXDATA_FULL.

Referenced by uart_tx_byte().

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

◆ uart_fill_lb()

void uart_fill_lb ( void data)

Definition at line 103 of file sifive.c.

◆ uart_init()

void uart_init ( unsigned int  idx)

Definition at line 48 of file sifive.c.

References get_uart_baudrate(), sifive_uart_init(), uart_baudrate_divisor(), uart_input_clock_divider(), uart_platform_baseptr(), and uart_platform_refclk().

Here is the call graph for this function:

◆ uart_input_clock_divider()

unsigned int uart_input_clock_divider ( void  )

Definition at line 94 of file sifive.c.

Referenced by uart_init().

Here is the caller graph for this function:

◆ uart_rx_byte()

unsigned char uart_rx_byte ( unsigned int  idx)

Definition at line 82 of file sifive.c.

References read32(), sifive_uart_registers::rxdata, RXDATA_EMPTY, and uart_platform_baseptr().

Here is the call graph for this function:

◆ uart_tx_byte()

void uart_tx_byte ( unsigned int  idx,
unsigned char  data 
)

Definition at line 61 of file sifive.c.

References uart_can_tx(), uart_platform_baseptr(), and write32().

Here is the call graph for this function:

◆ uart_tx_flush()

void uart_tx_flush ( unsigned int  idx)

Definition at line 71 of file sifive.c.

References sifive_uart_registers::ip, IP_TXWM, read32(), and uart_platform_baseptr().

Here is the call graph for this function:

Variable Documentation

◆ __packed