# /space/home/slher/rel/Beken/v6_4_5/macsw/plf/refip/src/driver/crm/v20/crm.c File Reference

Clock and Reset Module definitions. More...

`#include "crm.h"`
`#include "phy.h"`
`#include "dbg.h"`
`#include "reg_mac_core.h"`
`#include "reg_mdm_stat.h"`
`#include "reg_mdm_cfg.h"`
`#include "reg_karst_if.h"`
`#include <string.h>`

Go to the source code of this file.

## Data Structures
struct | crm_env_tag
| CRM driver context structure. More...
struct | clk_config
| Clock configuration structure. More...
struct | clk_config::mpif_config
| MAC-PHY interface configuration. More...
struct | clk_config::mac_config
| MAC configuration. More...
## Defines
#define | MDM_CONF_0_9 1
| This macro shall be set to one if the MDM is supporting confs 8 and 9 and to 0 otherwise.
#define | CRM_CLKCONF_UNDEFINED ((uint8_t)-1)
| Undefined value for the clock configuration.
#define | CLKOUT0 0x08
| Address of output0.
#define | CLKOUT1 0x0A
| Address of output1.
#define | CLKOUT2 0x0C
| Address of output2.
#define | CLKOUT3 0x0E
| Address of output3.
#define | CLKOUT4 0x10
| Address of output4.
#define | CLKOUT5 0x06
| Address of output5.
#define | CLKOUT6 0x12
| Address of output6.
#define | CLKOUTFB 0x14
| Address of feedback output.
#define | MMCM_REG1(mmcm, out)
| Address to configure clkreg1 reg for output `out` of mmcm `mmcm` note: use KARST_DYNCFGMMC_xxx defined assuming that FPGAA_DYNCFGMMC_xxx have the same values.
#define | MMCM_VCO_MULT(clk_ref_freq, vco_freq)
| Multiplier to apply to `clk_ref_freq` to get `vco_freq`.
#define | MMCM_VCO_DIV(vco_freq, target_freq)
| Divider to apply to `vco_freq` to get `target_freq`.
#define | MMCM_VCO_TO_NUM_DIV(vco_div) (((vco_div & 0x0FC0) >> 6) + (vco_div & 0x3F))
| Convert a VCO divider `vco_div` to its corresponding numeric value.
## Functions
static int | reg_poll (uint32_t reg, uint32_t val)
| Poll register until bits are set.
static void | udelay (uint32_t us)
| Active wait.
static void | crm_mmc_clk_set (uint32_t addr, uint16_t data)
| Configure one clock source.
static int | crm_clk_conf (uint8_t chan_type)
| Select clock configuration index.
void | crm_clk_set (uint8_t chan_type)
| Set the different clocks depending on the chosen channel bandwidth.
void | crm_init (void)
| Initial clock settings (e.g.
bool | crm_fe_160m (void)
| Indicate whether the RF front-end is configured at 160MHz or not.
uint8_t | crm_get_mac_freq (void)
| Return the frequency of the MAC core clock in case it would have been adjusted depending on the PHY properties.
uint32_t | crm_get_cpu_freq (void)
| Return the frequency of the CPU clock.
void | crm_mdm_reset (void)
| Reset the MODEM and the AGC.
## Variables
static struct crm_env_tag | crm_env
| CRM driver context.
static struct clk_config | clk_config [10]
| Table of all possible clock configurations.

## Detailed Description

Clock and Reset Module definitions.

Copyright (C) RivieraWaves 2018-2019

Definition in file crm.c.