coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
funitcfg.c File Reference
#include <console/console.h>
#include <soc/addressmap.h>
#include <soc/clock.h>
#include <soc/funitcfg.h>
#include <soc/nvidia/tegra/usb.h>
#include <soc/padconfig.h>
#include <string.h>
Include dependency graph for funitcfg.c:

Go to the source code of this file.

Data Structures

struct  clk_dev_control
 
struct  funit_cfg_data
 

Macros

#define CLK_SET_REGS(x)
 
#define FUNIT_DATA(funit_, loname_, clk_set_)
 
#define FUNIT_DATA_USB(funit_, clk_set_)
 

Enumerations

enum  {
  CLK_L_SET = 0 , CLK_H_SET = 1 , CLK_U_SET = 2 , CLK_V_SET = 3 ,
  CLK_W_SET = 4 , CLK_X_SET = 5 , CLK_Y_SET = 6
}
 

Functions

 _Static_assert (ARRAY_SIZE(funit_data)==FUNIT_INDEX_MAX, "funit_cfg_data array not filled out!")
 
static uint32_t get_clk_src_freq (uint32_t clk_src_freq_id)
 
static void configure_clock (const struct funit_cfg *const entry, const struct funit_cfg_data *const funit)
 
static int is_usb (uint32_t idx)
 
void soc_configure_funits (const struct funit_cfg *const entries, size_t num)
 
void __weak usb_setup_utmip (void *usb_base)
 

Variables

static const struct clk_dev_control clk_data_arr []
 
static const struct funit_cfg_data funit_data []
 

Macro Definition Documentation

◆ CLK_SET_REGS

#define CLK_SET_REGS (   x)
Value:
{ \
CLK_RST_REG(clk_enb_##x##_set), \
CLK_RST_REG(rst_dev_##x##_clr), \
}
int x
Definition: edid.c:994

Definition at line 34 of file funitcfg.c.

◆ FUNIT_DATA

#define FUNIT_DATA (   funit_,
  loname_,
  clk_set_ 
)
Value:
[FUNIT_INDEX(funit_)] = { \
.name = STRINGIFY(loname_), \
.ctlr_base = (void *)(uintptr_t)TEGRA_##funit_##_BASE, \
.clk_src_reg = CLK_RST_REG(clk_src_##loname_), \
.dev_control = &clk_data_arr[CLK_##clk_set_##_SET], \
.clk_enb_val = CLK_##clk_set_##_##funit_, \
}
#define STRINGIFY(x)
Definition: helpers.h:132
static const struct clk_dev_control clk_data_arr[]
Definition: funitcfg.c:40
@ FUNIT_INDEX
Definition: funitcfg.h:14
unsigned long uintptr_t
Definition: stdint.h:21
#define CLK_RST_REG(field_)
Definition: clk_rst.h:303

Definition at line 50 of file funitcfg.c.

◆ FUNIT_DATA_USB

#define FUNIT_DATA_USB (   funit_,
  clk_set_ 
)
Value:
[FUNIT_INDEX(funit_)] = { \
.name = STRINGIFY(funit_), \
.ctlr_base = (void *)(uintptr_t)TEGRA_##funit_##_BASE, \
.dev_control = &clk_data_arr[CLK_##clk_set_##_SET], \
.clk_enb_val = CLK_##clk_set_##_##funit_, \
}

Definition at line 59 of file funitcfg.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CLK_L_SET 
CLK_H_SET 
CLK_U_SET 
CLK_V_SET 
CLK_W_SET 
CLK_X_SET 
CLK_Y_SET 

Definition at line 24 of file funitcfg.c.

Function Documentation

◆ _Static_assert()

_Static_assert ( ARRAY_SIZE(funit_data = =FUNIT_INDEX_MAX,
"funit_cfg_data array not filled out!"   
)

◆ configure_clock()

static void configure_clock ( const struct funit_cfg *const  entry,
const struct funit_cfg_data *const  funit 
)
static

Definition at line 102 of file funitcfg.c.

References _clock_set_div(), funit_cfg::clk_dev_freq_khz, CLK_DIV_MASK, CLK_DIV_MASK_I2C, funit_cfg::clk_src_freq_id, funit_cfg::clk_src_id, funit_cfg_data::clk_src_reg, get_clk_div, get_clk_src_freq(), get_i2c_clk_div, funit_cfg_data::name, strlen(), and strncmp().

Referenced by soc_configure_funits().

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

◆ get_clk_src_freq()

static uint32_t get_clk_src_freq ( uint32_t  clk_src_freq_id)
inlinestatic

Definition at line 83 of file funitcfg.c.

References BIOS_SPEW, CLK_M, PLLP, printk, TEGRA_CLK_M_KHZ, and TEGRA_PLLP_KHZ.

Referenced by configure_clock().

Here is the caller graph for this function:

◆ is_usb()

static int is_usb ( uint32_t  idx)
inlinestatic

Definition at line 127 of file funitcfg.c.

Referenced by soc_configure_funits().

Here is the caller graph for this function:

◆ soc_configure_funits()

◆ usb_setup_utmip()

void __weak usb_setup_utmip ( void usb_base)

Definition at line 165 of file funitcfg.c.

References BIOS_ERR, and printk.

Referenced by soc_configure_funits().

Here is the caller graph for this function:

Variable Documentation

◆ clk_data_arr

const struct clk_dev_control clk_data_arr[]
static
Initial value:
= {
}
@ CLK_V_SET
Definition: funitcfg.c:28
@ CLK_Y_SET
Definition: funitcfg.c:31
@ CLK_W_SET
Definition: funitcfg.c:29
@ CLK_X_SET
Definition: funitcfg.c:30
@ CLK_H_SET
Definition: funitcfg.c:26
@ CLK_U_SET
Definition: funitcfg.c:27
@ CLK_L_SET
Definition: funitcfg.c:25
#define CLK_SET_REGS(x)
Definition: funitcfg.c:34
int y
Definition: edid.c:994

Definition at line 1 of file funitcfg.c.

◆ funit_data

const struct funit_cfg_data funit_data[]
static
Initial value:
= {
FUNIT_DATA(I2C1, i2c1, L),
FUNIT_DATA(I2C2, i2c2, H),
FUNIT_DATA(I2C3, i2c3, U),
FUNIT_DATA(I2C5, i2c5, H),
FUNIT_DATA(I2C6, i2c6, X),
FUNIT_DATA(SDMMC1, sdmmc1, L),
FUNIT_DATA(SDMMC4, sdmmc4, L),
FUNIT_DATA_USB(USBD, L),
FUNIT_DATA_USB(USB2, H),
FUNIT_DATA(QSPI, qspi, Y),
FUNIT_DATA(I2S1, i2s1, L),
}
#define FUNIT_DATA(funit_, loname_, clk_set_)
Definition: funitcfg.c:50
#define FUNIT_DATA_USB(funit_, clk_set_)
Definition: funitcfg.c:59
@ I2C5
Definition: i2c.h:55
@ I2C3
Definition: i2c.h:53
@ I2C2
Definition: i2c.h:52
@ I2C1
Definition: i2c.h:51
@ I2C6
Definition: i2c.h:56

Definition at line 1 of file funitcfg.c.

Referenced by soc_configure_funits().