Software APIs
dt_clkmgr.h File Reference

Device Tables (DT) for IP clkmgr and top earlgrey. More...

#include "dt_api.h"
#include <stdint.h>
#include "sw/device/lib/base/bitfield.h"

Go to the source code of this file.

Data Structures

struct  dt_clkmgr_measurable_clk
 Description of a measurable clock. More...
 

Macros

#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4   1
 List of supported hardware features.
 
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2   1
 
#define OPENTITAN_CLKMGR_HAS_ENABLE_IO   1
 
#define OPENTITAN_CLKMGR_HAS_ENABLE_USB   1
 
#define OPENTITAN_CLKMGR_HAS_HINT_AES   1
 
#define OPENTITAN_CLKMGR_HAS_HINT_HMAC   1
 
#define OPENTITAN_CLKMGR_HAS_HINT_KMAC   1
 
#define OPENTITAN_CLKMGR_HAS_HINT_OTBN   1
 
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN   1
 
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO   1
 
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV2   1
 
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4   1
 
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN   1
 
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB   1
 
#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR   1
 
#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED   1
 
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN   1
 
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED   1
 
#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED   1
 
#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN   1
 
#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE   1
 
#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS   1
 

Typedefs

typedef enum dt_clkmgr dt_clkmgr_t
 List of instances.
 
typedef enum dt_clkmgr_reg_block dt_clkmgr_reg_block_t
 List of register blocks.
 
typedef enum dt_clkmgr_alert dt_clkmgr_alert_t
 List of Alerts.
 
typedef enum dt_clkmgr_clock dt_clkmgr_clock_t
 List of clock ports.
 
typedef enum dt_clkmgr_reset dt_clkmgr_reset_t
 List of reset ports.
 
typedef struct dt_clkmgr_measurable_clk dt_clkmgr_measurable_clk_t
 Description of a measurable clock.
 

Enumerations

enum  dt_clkmgr {
  kDtClkmgrAon = 0 ,
  kDtClkmgrFirst = 0 ,
  kDtClkmgrCount = 1
}
 List of instances. More...
 
enum  dt_clkmgr_reg_block {
  kDtClkmgrRegBlockCore = 0 ,
  kDtClkmgrRegBlockCount = 1
}
 List of register blocks. More...
 
enum  dt_clkmgr_alert {
  kDtClkmgrAlertRecovFault = 0 ,
  kDtClkmgrAlertFatalFault = 1 ,
  kDtClkmgrAlertCount = 2
}
 List of Alerts. More...
 
enum  dt_clkmgr_clock {
  kDtClkmgrClockClk = 0 ,
  kDtClkmgrClockMain = 1 ,
  kDtClkmgrClockIo = 2 ,
  kDtClkmgrClockUsb = 3 ,
  kDtClkmgrClockAon = 4 ,
  kDtClkmgrClockCount = 5
}
 List of clock ports. More...
 
enum  dt_clkmgr_reset {
  kDtClkmgrResetRst = 0 ,
  kDtClkmgrResetRoot = 1 ,
  kDtClkmgrResetMain = 2 ,
  kDtClkmgrResetIo = 3 ,
  kDtClkmgrResetUsb = 4 ,
  kDtClkmgrResetAon = 5 ,
  kDtClkmgrResetIoDiv2 = 6 ,
  kDtClkmgrResetIoDiv4 = 7 ,
  kDtClkmgrResetRootMain = 8 ,
  kDtClkmgrResetRootIo = 9 ,
  kDtClkmgrResetRootIoDiv2 = 10 ,
  kDtClkmgrResetRootIoDiv4 = 11 ,
  kDtClkmgrResetRootUsb = 12 ,
  kDtClkmgrResetCount = 13
}
 List of reset ports. More...
 

Functions

dt_clkmgr_t dt_clkmgr_from_instance_id (dt_instance_id_t inst_id)
 Get the clkmgr instance from an instance ID.
 
dt_instance_id_t dt_clkmgr_instance_id (dt_clkmgr_t dt)
 Get the instance ID of an instance.
 
uint32_t dt_clkmgr_reg_block (dt_clkmgr_t dt, dt_clkmgr_reg_block_t reg_block)
 Get the register base address of an instance.
 
dt_alert_id_t dt_clkmgr_alert_to_alert_id (dt_clkmgr_t dt, dt_clkmgr_alert_t alert)
 Get the alert ID of a clkmgr alert for a given instance.
 
dt_clkmgr_alert_t dt_clkmgr_alert_from_alert_id (dt_clkmgr_t dt, dt_alert_id_t alert)
 Convert a global alert ID to a local clkmgr alert type.
 
dt_clock_t dt_clkmgr_clock (dt_clkmgr_t dt, dt_clkmgr_clock_t clk)
 Get the clock signal connected to a clock port of an instance.
 
dt_reset_t dt_clkmgr_reset (dt_clkmgr_t dt, dt_clkmgr_reset_t rst)
 Get the reset signal connected to a reset port of an instance.
 
size_t dt_clkmgr_gateable_clock_count (dt_clkmgr_t dt)
 Get the number of software gateable clocks.
 
dt_instance_id_t dt_clkmgr_gateable_clock (dt_clkmgr_t dt, size_t idx)
 Get the instance ID of a gateable clock.
 
size_t dt_clkmgr_hintable_clock_count (dt_clkmgr_t dt)
 Get the number of software hintable clocks.
 
dt_instance_id_t dt_clkmgr_hintable_clock (dt_clkmgr_t dt, size_t idx)
 Get the instance ID of a hintable clock.
 
size_t dt_clkmgr_measurable_clock_count (dt_clkmgr_t dt)
 Get the number of measurable clocks.
 
dt_clkmgr_measurable_clk_t dt_clkmgr_measurable_clock (dt_clkmgr_t dt, size_t idx)
 Get the description of a measurable clock.
 

Detailed Description

Device Tables (DT) for IP clkmgr and top earlgrey.

This file contains the type definitions and global functions of the clkmgr.

Definition in file dt_clkmgr.h.


Data Structure Documentation

◆ dt_clkmgr_measurable_clk

struct dt_clkmgr_measurable_clk

Description of a measurable clock.

Definition at line 266 of file dt_clkmgr.h.

Data Fields
dt_clock_t clock Clock.
bitfield_field32_t meas_ctrl_en_en_field MEAS_CTRL_EN_EN bitfield.
uint32_t meas_ctrl_en_off MEAS_CTRL_EN register offset.
bitfield_field32_t meas_ctrl_shadowed_hi_field CTRL_SHADOWED_HI bitfield.
bitfield_field32_t meas_ctrl_shadowed_lo_field CTRL_SHADOWED_LO bitfield.
uint32_t meas_ctrl_shadowed_off CTRL_SHADOWED register offset.

Macro Definition Documentation

◆ OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS

#define OPENTITAN_CLKMGR_HAS_ALERT_HANDLER_CLOCK_STATUS   1

Definition at line 117 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_ENABLE_IO

#define OPENTITAN_CLKMGR_HAS_ENABLE_IO   1

Definition at line 98 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2

#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV2   1

Definition at line 97 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4

#define OPENTITAN_CLKMGR_HAS_ENABLE_IO_DIV4   1

List of supported hardware features.

Definition at line 96 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_ENABLE_USB

#define OPENTITAN_CLKMGR_HAS_ENABLE_USB   1

Definition at line 99 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_HINT_AES

#define OPENTITAN_CLKMGR_HAS_HINT_AES   1

Definition at line 100 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_HINT_HMAC

#define OPENTITAN_CLKMGR_HAS_HINT_HMAC   1

Definition at line 101 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_HINT_KMAC

#define OPENTITAN_CLKMGR_HAS_HINT_KMAC   1

Definition at line 102 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_HINT_OTBN

#define OPENTITAN_CLKMGR_HAS_HINT_OTBN   1

Definition at line 103 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_JITTER_ENABLE

#define OPENTITAN_CLKMGR_HAS_JITTER_ENABLE   1

Definition at line 116 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_JITTER_REGWEN

#define OPENTITAN_CLKMGR_HAS_JITTER_REGWEN   1

Definition at line 115 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED

#define OPENTITAN_CLKMGR_HAS_LC_EXTCLK_SPEED   1

Definition at line 111 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO

#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO   1

Definition at line 105 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV2

#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV2   1

Definition at line 106 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4

#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_IO_DIV4   1

Definition at line 107 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN

#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_MAIN   1

Definition at line 108 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR

#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_RECOV_ERR   1

Definition at line 110 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN

#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_REGWEN   1

Definition at line 104 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB

#define OPENTITAN_CLKMGR_HAS_MEAS_CTRL_USB   1

Definition at line 109 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED

#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_HIGH_SPEED   1

Definition at line 113 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED

#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_LOW_SPEED   1

Definition at line 114 of file dt_clkmgr.h.

◆ OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN

#define OPENTITAN_CLKMGR_HAS_SW_EXTCLK_REGWEN   1

Definition at line 112 of file dt_clkmgr.h.

Typedef Documentation

◆ dt_clkmgr_alert_t

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

◆ dt_clkmgr_clock_t

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

◆ dt_clkmgr_reg_block_t

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

◆ dt_clkmgr_reset_t

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumeration Type Documentation

◆ dt_clkmgr

enum dt_clkmgr

List of instances.

Enumerator
kDtClkmgrAon 

clkmgr_aon

Definition at line 27 of file dt_clkmgr.h.

◆ dt_clkmgr_alert

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

Enumerator
kDtClkmgrAlertRecovFault 

This recoverable alert is triggered when there are measurement errors.

kDtClkmgrAlertFatalFault 

This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.

Definition at line 51 of file dt_clkmgr.h.

◆ dt_clkmgr_clock

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtClkmgrClockClk 

Clock port clk_i.

kDtClkmgrClockMain 

Clock port clk_main_i.

kDtClkmgrClockIo 

Clock port clk_io_i.

kDtClkmgrClockUsb 

Clock port clk_usb_i.

kDtClkmgrClockAon 

Clock port clk_aon_i.

Definition at line 62 of file dt_clkmgr.h.

◆ dt_clkmgr_reg_block

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

Definition at line 38 of file dt_clkmgr.h.

◆ dt_clkmgr_reset

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtClkmgrResetRst 

Reset port rst_ni.

kDtClkmgrResetRoot 

Reset port rst_root_ni.

kDtClkmgrResetMain 

Reset port rst_main_ni.

kDtClkmgrResetIo 

Reset port rst_io_ni.

kDtClkmgrResetUsb 

Reset port rst_usb_ni.

kDtClkmgrResetAon 

Reset port rst_aon_ni.

kDtClkmgrResetIoDiv2 

Reset port rst_io_div2_ni.

kDtClkmgrResetIoDiv4 

Reset port rst_io_div4_ni.

kDtClkmgrResetRootMain 

Reset port rst_root_main_ni.

kDtClkmgrResetRootIo 

Reset port rst_root_io_ni.

kDtClkmgrResetRootIoDiv2 

Reset port rst_root_io_div2_ni.

kDtClkmgrResetRootIoDiv4 

Reset port rst_root_io_div4_ni.

kDtClkmgrResetRootUsb 

Reset port rst_root_usb_ni.

Definition at line 76 of file dt_clkmgr.h.

Function Documentation

◆ dt_clkmgr_alert_from_alert_id()

dt_clkmgr_alert_t dt_clkmgr_alert_from_alert_id ( dt_clkmgr_t dt,
dt_alert_id_t alert )

Convert a global alert ID to a local clkmgr alert type.

Parameters
dtInstance of clkmgr.
alertA global alert ID that belongs to this instance.
Returns
The clkmgr alert, or kDtClkmgrAlertCount.

Note: This function assumes that the global alert ID belongs to the instance of clkmgr passed in parameter. In other words, it must be the case that dt_clkmgr_instance_id(dt) == dt_alert_id_to_instance_id(alert). Otherwise, this function will return kDtClkmgrAlertCount.

Definition at line 163 of file dt_clkmgr.c.

◆ dt_clkmgr_alert_to_alert_id()

dt_alert_id_t dt_clkmgr_alert_to_alert_id ( dt_clkmgr_t dt,
dt_clkmgr_alert_t alert )

Get the alert ID of a clkmgr alert for a given instance.

Note: This function only makes sense if the instance is connected to the Alert Handler. For any instances where the instance is not connected, the return value is unspecified.

Parameters
dtInstance of clkmgr.
alertA clkmgr alert.
Returns
The Alert Handler alert ID of the alert of this instance.

Definition at line 157 of file dt_clkmgr.c.

◆ dt_clkmgr_clock()

Get the clock signal connected to a clock port of an instance.

Parameters
dtInstance of clkmgr.
clkClock port.
Returns
Clock signal.

Definition at line 175 of file dt_clkmgr.c.

◆ dt_clkmgr_from_instance_id()

dt_clkmgr_t dt_clkmgr_from_instance_id ( dt_instance_id_t inst_id)

Get the clkmgr instance from an instance ID.

For example, dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3.

Parameters
inst_idInstance ID.
Returns
A clkmgr instance.

Note: This function only makes sense if the instance ID has device type clkmgr, otherwise the returned value is unspecified.

Definition at line 137 of file dt_clkmgr.c.

◆ dt_clkmgr_gateable_clock()

dt_instance_id_t dt_clkmgr_gateable_clock ( dt_clkmgr_t dt,
size_t idx )

Get the instance ID of a gateable clock.

The clocks are ordered as they appear in the registers.

Parameters
dtInstance of clkmgr.
idxIndex of the gateable clock, between 0 and dt_clkmgr_sw_clock_count(dt)-1.
Returns
Instance ID of the device whose clock is gateable.

Definition at line 198 of file dt_clkmgr.c.

◆ dt_clkmgr_gateable_clock_count()

size_t dt_clkmgr_gateable_clock_count ( dt_clkmgr_t dt)

Get the number of software gateable clocks.

Parameters
dtInstance of clkmgr.
Returns
Number of gateable clocks.

Definition at line 194 of file dt_clkmgr.c.

◆ dt_clkmgr_hintable_clock()

dt_instance_id_t dt_clkmgr_hintable_clock ( dt_clkmgr_t dt,
size_t idx )

Get the instance ID of a hintable clock.

The clocks sources are ordered as they appear in the registers.

Parameters
dtInstance of clkmgr.
idxIndex of the hintable clock, between 0 and dt_clkmgr_hint_clock_count(dt)-1.
Returns
Instance ID of the device whose clock is hintable.

Definition at line 206 of file dt_clkmgr.c.

◆ dt_clkmgr_hintable_clock_count()

size_t dt_clkmgr_hintable_clock_count ( dt_clkmgr_t dt)

Get the number of software hintable clocks.

Parameters
dtInstance of clkmgr.
Returns
Number of hintable clocks.

Definition at line 202 of file dt_clkmgr.c.

◆ dt_clkmgr_instance_id()

dt_instance_id_t dt_clkmgr_instance_id ( dt_clkmgr_t dt)

Get the instance ID of an instance.

Parameters
dtInstance of clkmgr.
Returns
The instance ID of that instance.

Definition at line 144 of file dt_clkmgr.c.

◆ dt_clkmgr_measurable_clock()

dt_clkmgr_measurable_clk_t dt_clkmgr_measurable_clock ( dt_clkmgr_t dt,
size_t idx )

Get the description of a measurable clock.

Parameters
dtInstance of clkmgr.
idxIndex of the measurable clock, between 0 and dt_clkmgr_measurable_clock_count(dt)-1.
Returns
Description of the measurable clock.

Definition at line 214 of file dt_clkmgr.c.

◆ dt_clkmgr_measurable_clock_count()

size_t dt_clkmgr_measurable_clock_count ( dt_clkmgr_t dt)

Get the number of measurable clocks.

Parameters
dtInstance of clkmgr.
Returns
Number of measurable clocks.

Definition at line 210 of file dt_clkmgr.c.

◆ dt_clkmgr_reg_block()

Get the register base address of an instance.

Parameters
dtInstance of clkmgr.
reg_blockThe register block requested.
Returns
The register base address of the requested block.

Definition at line 149 of file dt_clkmgr.c.

◆ dt_clkmgr_reset()

Get the reset signal connected to a reset port of an instance.

Parameters
dtInstance of clkmgr.
rstReset port.
Returns
Reset signal.

Definition at line 182 of file dt_clkmgr.c.