TT-System-Firmware APIs 19.10.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
clock_control_tt_bh.c File Reference
Include dependency graph for clock_control_tt_bh.c:

Data Structures

struct  tt_bh_pll_cntl_wrapper_lock_fields
union  tt_bh_pll_cntl_wrapper_lock_reg
struct  tt_bh_pll_cntl_0_fields
union  tt_bh_pll_cntl_0_reg
struct  tt_bh_pll_cntl_1_fields
union  tt_bh_pll_cntl_1_reg
struct  tt_bh_pll_cntl_2_fields
union  tt_bh_pll_cntl_2_reg
struct  tt_bh_pll_cntl_3_fields
union  tt_bh_pll_cntl_3_reg
struct  tt_bh_pll_cntl_5_fields
union  tt_bh_pll_cntl_5_reg
struct  tt_bh_pll_use_postdiv_fields
union  tt_bh_pll_use_postdiv_reg
struct  tt_bh_pll_settings
struct  clock_control_tt_bh_config
struct  clock_control_tt_bh_data

Macros

#define DT_DRV_COMPAT   tenstorrent_bh_clock_control
#define PLL_LOCK_TIMEOUT_MS   400
#define PLL_CNTL_0_OFFSET   0x00
#define PLL_CNTL_1_OFFSET   0x04
#define PLL_CNTL_2_OFFSET   0x08
#define PLL_CNTL_3_OFFSET   0x0C
#define PLL_CNTL_4_OFFSET   0x10
#define PLL_CNTL_5_OFFSET   0x14
#define PLL_CNTL_6_OFFSET   0x18
#define PLL_USE_POSTDIV_OFFSET   0x1C
#define PLL_REFCLK_SEL_OFFSET   0x20
#define PLL_USE_FINE_DIVIDER_1_OFFSET   0x24
#define PLL_USE_FINE_DIVIDER_2_OFFSET   0x28
#define FINE_DUTYC_ADJUST_OFFSET   0x2C
#define CLK_COUNTER_EN_OFFSET   0x30
#define CLK_COUNTER_0_OFFSET   0x34
#define CLK_COUNTER_1_OFFSET   0x38
#define CLK_COUNTER_2_OFFSET   0x3C
#define CLK_COUNTER_3_OFFSET   0x40
#define CLK_COUNTER_4_OFFSET   0x44
#define CLK_COUNTER_5_OFFSET   0x48
#define CLK_COUNTER_6_OFFSET   0x4C
#define CLK_COUNTER_7_OFFSET   0x50
#define VCO_MIN_FREQ   1600
#define VCO_MAX_FREQ   5000
#define CLK_COUNTER_REFCLK_PERIOD   1000
#define PLL_CNTL_WRAPPER_PLL_LOCK_REG_ADDR   0x80020040
#define PLL_CNTL_WRAPPER_REFCLK_PERIOD_REG_ADDR   0x8002002C
#define CLOCK_CONTROL_TT_BH_INIT(_inst)

Functions

 LOG_MODULE_REGISTER (clock_control_tt_bh)
static uint32_t clock_control_tt_bh_read_reg (const struct clock_control_tt_bh_config *config, uint32_t offset)
static void clock_control_tt_bh_write_reg (const struct clock_control_tt_bh_config *config, uint32_t offset, uint32_t val)
static void clock_control_enable_clk_counters (const struct clock_control_tt_bh_config *config)
static void clock_control_tt_bh_config_vco (const struct clock_control_tt_bh_config *config, const struct tt_bh_pll_settings *settings)
static void clock_control_tt_bh_config_ext_postdivs (const struct clock_control_tt_bh_config *config, const struct tt_bh_pll_settings *settings)
static int clock_control_tt_bh_wait_lock (uint8_t inst)
static uint32_t clock_control_tt_bh_get_ext_postdiv (uint8_t postdiv_index, union tt_bh_pll_cntl_5_reg pll_cntl_5, union tt_bh_pll_use_postdiv_reg use_postdiv)
static uint32_t clock_control_tt_bh_calculate_fbdiv (uint32_t refclk_rate, uint32_t target_freq_mhz, union tt_bh_pll_cntl_1_reg pll_cntl_1, union tt_bh_pll_cntl_5_reg pll_cntl_5, union tt_bh_pll_use_postdiv_reg use_postdiv, uint8_t postdiv_index)
static uint32_t clock_control_tt_bh_get_freq (const struct clock_control_tt_bh_config *config, uint8_t postdiv_index)
static void clock_control_tt_bh_update (const struct clock_control_tt_bh_config *config, struct clock_control_tt_bh_data *data, const struct tt_bh_pll_settings *settings)
static int clock_control_tt_bh_enable (const struct device *dev, clock_control_subsys_t sys, uint8_t enable)
static int clock_control_tt_bh_on (const struct device *dev, clock_control_subsys_t sys)
static int clock_control_tt_bh_off (const struct device *dev, clock_control_subsys_t sys)
static int clock_control_tt_bh_async_on (const struct device *dev, clock_control_subsys_t sys, clock_control_cb_t cb, void *user_data)
static int clock_control_tt_bh_get_rate (const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)
static enum clock_control_status clock_control_tt_bh_get_status (const struct device *dev, clock_control_subsys_t sys)
static int clock_control_tt_bh_set_rate (const struct device *dev, clock_control_subsys_t sys, clock_control_subsys_rate_t rate)
static int clock_control_tt_bh_configure (const struct device *dev, clock_control_subsys_t sys, void *option)
static int clock_control_tt_bh_init (const struct device *dev)

Variables

static const struct clock_control_driver_api clock_control_tt_bh_api

Macro Definition Documentation

◆ CLK_COUNTER_0_OFFSET

#define CLK_COUNTER_0_OFFSET   0x34

◆ CLK_COUNTER_1_OFFSET

#define CLK_COUNTER_1_OFFSET   0x38

◆ CLK_COUNTER_2_OFFSET

#define CLK_COUNTER_2_OFFSET   0x3C

◆ CLK_COUNTER_3_OFFSET

#define CLK_COUNTER_3_OFFSET   0x40

◆ CLK_COUNTER_4_OFFSET

#define CLK_COUNTER_4_OFFSET   0x44

◆ CLK_COUNTER_5_OFFSET

#define CLK_COUNTER_5_OFFSET   0x48

◆ CLK_COUNTER_6_OFFSET

#define CLK_COUNTER_6_OFFSET   0x4C

◆ CLK_COUNTER_7_OFFSET

#define CLK_COUNTER_7_OFFSET   0x50

◆ CLK_COUNTER_EN_OFFSET

#define CLK_COUNTER_EN_OFFSET   0x30

◆ CLK_COUNTER_REFCLK_PERIOD

#define CLK_COUNTER_REFCLK_PERIOD   1000

◆ CLOCK_CONTROL_TT_BH_INIT

#define CLOCK_CONTROL_TT_BH_INIT ( _inst)
Value:
static struct clock_control_tt_bh_data clock_control_tt_bh_data_##_inst; \
\
static const struct clock_control_tt_bh_config clock_control_tt_bh_config_##_inst = { \
.inst = _inst, \
.refclk_rate = DT_PROP(DT_INST_CLOCKS_CTLR(_inst), clock_frequency), \
.base = DT_REG_ADDR(DT_DRV_INST(_inst)), \
.size = DT_REG_SIZE(DT_DRV_INST(_inst)), \
.init_settings = { \
.pll_cntl_1 = {.f.refdiv = DT_INST_PROP(_inst, refdiv), \
.f.postdiv = DT_INST_PROP(_inst, postdiv), \
.f.fbdiv = DT_INST_PROP(_inst, fbdiv)}, \
.pll_cntl_2 = {.f.ctrl_bus1 = DT_INST_PROP(_inst, ctrl_bus1)}, \
.pll_cntl_3 = {.f.ctrl_bus5 = DT_INST_PROP(_inst, ctrl_bus5)}, \
.pll_cntl_5 = {.f.postdiv0 = DT_INST_PROP_BY_IDX(_inst, post_divs, 0), \
.f.postdiv1 = DT_INST_PROP_BY_IDX(_inst, post_divs, 1), \
.f.postdiv2 = DT_INST_PROP_BY_IDX(_inst, post_divs, 2), \
.f.postdiv3 = DT_INST_PROP_BY_IDX(_inst, post_divs, 3)}, \
.use_postdiv = {.f.pll_use_postdiv0 = \
DT_INST_PROP_BY_IDX(_inst, use_post_divs, 0), \
.f.pll_use_postdiv1 = \
DT_INST_PROP_BY_IDX(_inst, use_post_divs, 1), \
.f.pll_use_postdiv2 = \
DT_INST_PROP_BY_IDX(_inst, use_post_divs, 2), \
.f.pll_use_postdiv3 = \
DT_INST_PROP_BY_IDX(_inst, use_post_divs, 3)}}}; \
\
DEVICE_DT_INST_DEFINE( \
_inst, clock_control_tt_bh_init, NULL, &clock_control_tt_bh_data_##_inst, \
&clock_control_tt_bh_config_##_inst, POST_KERNEL, 3, &clock_control_tt_bh_api);
#define NULL
Definition avs.c:45
static int clock_control_tt_bh_init(const struct device *dev)
Definition clock_control_tt_bh.c:570
static const struct clock_control_driver_api clock_control_tt_bh_api
Definition clock_control_tt_bh.c:630
#define DT_INST_CLOCKS_CTLR(inst)
#define DT_PROP(node_id, prop)
#define DT_DRV_INST(inst)
#define DT_INST_PROP_BY_IDX(inst, prop, idx)
#define DT_INST_PROP(inst, prop)
#define DT_REG_ADDR(node_id)
#define DT_REG_SIZE(node_id)
Definition clock_control_tt_bh.c:147
uint32_t refclk_rate
Definition clock_control_tt_bh.c:150
Definition clock_control_tt_bh.c:158

◆ DT_DRV_COMPAT

#define DT_DRV_COMPAT   tenstorrent_bh_clock_control

◆ FINE_DUTYC_ADJUST_OFFSET

#define FINE_DUTYC_ADJUST_OFFSET   0x2C

◆ PLL_CNTL_0_OFFSET

#define PLL_CNTL_0_OFFSET   0x00

◆ PLL_CNTL_1_OFFSET

#define PLL_CNTL_1_OFFSET   0x04

◆ PLL_CNTL_2_OFFSET

#define PLL_CNTL_2_OFFSET   0x08

◆ PLL_CNTL_3_OFFSET

#define PLL_CNTL_3_OFFSET   0x0C

◆ PLL_CNTL_4_OFFSET

#define PLL_CNTL_4_OFFSET   0x10

◆ PLL_CNTL_5_OFFSET

#define PLL_CNTL_5_OFFSET   0x14

◆ PLL_CNTL_6_OFFSET

#define PLL_CNTL_6_OFFSET   0x18

◆ PLL_CNTL_WRAPPER_PLL_LOCK_REG_ADDR

#define PLL_CNTL_WRAPPER_PLL_LOCK_REG_ADDR   0x80020040

◆ PLL_CNTL_WRAPPER_REFCLK_PERIOD_REG_ADDR

#define PLL_CNTL_WRAPPER_REFCLK_PERIOD_REG_ADDR   0x8002002C

◆ PLL_LOCK_TIMEOUT_MS

#define PLL_LOCK_TIMEOUT_MS   400

◆ PLL_REFCLK_SEL_OFFSET

#define PLL_REFCLK_SEL_OFFSET   0x20

◆ PLL_USE_FINE_DIVIDER_1_OFFSET

#define PLL_USE_FINE_DIVIDER_1_OFFSET   0x24

◆ PLL_USE_FINE_DIVIDER_2_OFFSET

#define PLL_USE_FINE_DIVIDER_2_OFFSET   0x28

◆ PLL_USE_POSTDIV_OFFSET

#define PLL_USE_POSTDIV_OFFSET   0x1C

◆ VCO_MAX_FREQ

#define VCO_MAX_FREQ   5000

◆ VCO_MIN_FREQ

#define VCO_MIN_FREQ   1600

Function Documentation

◆ clock_control_enable_clk_counters()

void clock_control_enable_clk_counters ( const struct clock_control_tt_bh_config * config)
static

◆ clock_control_tt_bh_async_on()

int clock_control_tt_bh_async_on ( const struct device * dev,
clock_control_subsys_t sys,
clock_control_cb_t cb,
void * user_data )
static

◆ clock_control_tt_bh_calculate_fbdiv()

uint32_t clock_control_tt_bh_calculate_fbdiv ( uint32_t refclk_rate,
uint32_t target_freq_mhz,
union tt_bh_pll_cntl_1_reg pll_cntl_1,
union tt_bh_pll_cntl_5_reg pll_cntl_5,
union tt_bh_pll_use_postdiv_reg use_postdiv,
uint8_t postdiv_index )
static

◆ clock_control_tt_bh_config_ext_postdivs()

void clock_control_tt_bh_config_ext_postdivs ( const struct clock_control_tt_bh_config * config,
const struct tt_bh_pll_settings * settings )
static

◆ clock_control_tt_bh_config_vco()

void clock_control_tt_bh_config_vco ( const struct clock_control_tt_bh_config * config,
const struct tt_bh_pll_settings * settings )
static

◆ clock_control_tt_bh_configure()

int clock_control_tt_bh_configure ( const struct device * dev,
clock_control_subsys_t sys,
void * option )
static

◆ clock_control_tt_bh_enable()

int clock_control_tt_bh_enable ( const struct device * dev,
clock_control_subsys_t sys,
uint8_t enable )
static

◆ clock_control_tt_bh_get_ext_postdiv()

uint32_t clock_control_tt_bh_get_ext_postdiv ( uint8_t postdiv_index,
union tt_bh_pll_cntl_5_reg pll_cntl_5,
union tt_bh_pll_use_postdiv_reg use_postdiv )
static

◆ clock_control_tt_bh_get_freq()

uint32_t clock_control_tt_bh_get_freq ( const struct clock_control_tt_bh_config * config,
uint8_t postdiv_index )
static

◆ clock_control_tt_bh_get_rate()

int clock_control_tt_bh_get_rate ( const struct device * dev,
clock_control_subsys_t sys,
uint32_t * rate )
static

◆ clock_control_tt_bh_get_status()

enum clock_control_status clock_control_tt_bh_get_status ( const struct device * dev,
clock_control_subsys_t sys )
static

◆ clock_control_tt_bh_init()

int clock_control_tt_bh_init ( const struct device * dev)
static

◆ clock_control_tt_bh_off()

int clock_control_tt_bh_off ( const struct device * dev,
clock_control_subsys_t sys )
static

◆ clock_control_tt_bh_on()

int clock_control_tt_bh_on ( const struct device * dev,
clock_control_subsys_t sys )
static

◆ clock_control_tt_bh_read_reg()

uint32_t clock_control_tt_bh_read_reg ( const struct clock_control_tt_bh_config * config,
uint32_t offset )
static

◆ clock_control_tt_bh_set_rate()

int clock_control_tt_bh_set_rate ( const struct device * dev,
clock_control_subsys_t sys,
clock_control_subsys_rate_t rate )
static

◆ clock_control_tt_bh_update()

void clock_control_tt_bh_update ( const struct clock_control_tt_bh_config * config,
struct clock_control_tt_bh_data * data,
const struct tt_bh_pll_settings * settings )
static

◆ clock_control_tt_bh_wait_lock()

int clock_control_tt_bh_wait_lock ( uint8_t inst)
static

◆ clock_control_tt_bh_write_reg()

void clock_control_tt_bh_write_reg ( const struct clock_control_tt_bh_config * config,
uint32_t offset,
uint32_t val )
static

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( clock_control_tt_bh )

Variable Documentation

◆ clock_control_tt_bh_api

const struct clock_control_driver_api clock_control_tt_bh_api
static
Initial value:
= {
static int clock_control_tt_bh_async_on(const struct device *dev, clock_control_subsys_t sys, clock_control_cb_t cb, void *user_data)
Definition clock_control_tt_bh.c:401
static int clock_control_tt_bh_on(const struct device *dev, clock_control_subsys_t sys)
Definition clock_control_tt_bh.c:391
static int clock_control_tt_bh_get_rate(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)
Definition clock_control_tt_bh.c:407
static int clock_control_tt_bh_set_rate(const struct device *dev, clock_control_subsys_t sys, clock_control_subsys_rate_t rate)
Definition clock_control_tt_bh.c:464
static int clock_control_tt_bh_off(const struct device *dev, clock_control_subsys_t sys)
Definition clock_control_tt_bh.c:396
static int clock_control_tt_bh_configure(const struct device *dev, clock_control_subsys_t sys, void *option)
Definition clock_control_tt_bh.c:534
static enum clock_control_status clock_control_tt_bh_get_status(const struct device *dev, clock_control_subsys_t sys)
Definition clock_control_tt_bh.c:458