|
Packit |
534379 |
// Copyright(c) 2017, Intel Corporation
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
534379 |
// modification, are permitted provided that the following conditions are met:
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
534379 |
// this list of conditions and the following disclaimer.
|
|
Packit |
534379 |
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
534379 |
// this list of conditions and the following disclaimer in the documentation
|
|
Packit |
534379 |
// and/or other materials provided with the distribution.
|
|
Packit |
534379 |
// * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
534379 |
// may be used to endorse or promote products derived from this software
|
|
Packit |
534379 |
// without specific prior written permission.
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
534379 |
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
534379 |
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
534379 |
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
534379 |
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
534379 |
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
534379 |
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
534379 |
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
534379 |
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
534379 |
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
534379 |
// POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
534379 |
//****************************************************************************
|
|
Packit |
534379 |
// Arthur.Sheiman@Intel.com Created: 03-31-16
|
|
Packit |
534379 |
// Revised: 10-26-16 18:28
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
// User Clock header file
|
|
Packit |
534379 |
//
|
|
Packit |
534379 |
//****************************************************************************
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifndef USER_CLK_PGM_UCLK_H_
|
|
Packit |
534379 |
#define USER_CLK_PGM_UCLK_H_
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include <stdint.h>
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// .h include, defines
|
|
Packit |
534379 |
#include "user_clk_pgm_uclock_freq_template_D.h"
|
|
Packit |
534379 |
// Errors, decimal code
|
|
Packit |
534379 |
#include "user_clk_pgm_uclock_eror_messages_D.h"
|
|
Packit |
534379 |
// Private member variables and objects
|
|
Packit |
534379 |
#include "user_clk_pgm_uclock_freq_template_A.h"
|
|
Packit |
534379 |
#include "user_clk_pgm_uclock_eror_messages_A.h"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include "common_int.h"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// qph_user_clk.sv Equates
|
|
Packit |
534379 |
#if defined(DEF_BDX_P)
|
|
Packit |
534379 |
// BDX-P:
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_CMD_0 \
|
|
Packit |
534379 |
((uint64_t)0x0000000000000605LLU) // 0x03028 / 8 = 0x00605
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_CMD_1 \
|
|
Packit |
534379 |
((uint64_t)0x0000000000000606LLU) // 0x03030 / 8 = 0x00606
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_STS_0 \
|
|
Packit |
534379 |
((uint64_t)0x0000000000000607LLU) // 0x03038 / 8 = 0x00607
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_STS_1 \
|
|
Packit |
534379 |
((uint64_t)0x0000000000000608LLU) // 0x03040 / 8 = 0x00608
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#elif defined(DEF_SKX_P)
|
|
Packit |
534379 |
// SKX-P:
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_CMD_0 \
|
|
Packit |
534379 |
((uint64_t)0x000000000000000aLLU) // 0x00050 / 8 = 0x0060a
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_CMD_1 \
|
|
Packit |
534379 |
((uint64_t)0x000000000000000bLLU) // 0x00058 / 8 = 0x0060b
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_STS_0 \
|
|
Packit |
534379 |
((uint64_t)0x000000000000000cLLU) // 0x00060 / 8 = 0x0060c
|
|
Packit |
534379 |
#define QUCPU_UI64_PRT_UCLK_STS_1 \
|
|
Packit |
534379 |
((uint64_t)0x000000000000000dLLU) // 0x00068 / 8 = 0x0060d
|
|
Packit |
534379 |
#endif
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_AFU_MMIO_PRT_OFFSET_QW \
|
|
Packit |
534379 |
((uint64_t)0x0000000000000000LLU) // 0x00000 / 8 = 0x00000
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_SR1_b58 \
|
|
Packit |
534379 |
((uint64_t)0x0400000000000000LLU) // fPLL Select: 0=refclk0, 1=refclk1
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_PDN_b57 \
|
|
Packit |
534379 |
((uint64_t)0x0200000000000000LLU) // fPLL Powerdoen
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_PRS_b56 \
|
|
Packit |
534379 |
((uint64_t)0x0100000000000000LLU) // fPLL management reset
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_MRN_b52 \
|
|
Packit |
534379 |
((uint64_t)0x0010000000000000LLU) // mmmach machine reset_n
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_SEQ_b49t48 \
|
|
Packit |
534379 |
((uint64_t)0x0003000000000000LLU) // mmmach sequence
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_WRT_b44 \
|
|
Packit |
534379 |
((uint64_t)0x0000100000000000LLU) // mmmach write
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_ADR_b41t32 \
|
|
Packit |
534379 |
((uint64_t)0x000003ff00000000LLU) // mmmach MM address
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_DAT_b31t00 \
|
|
Packit |
534379 |
((uint64_t)0x00000000ffffffffLLU) // mmmach MM write data
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_0_AMM_b51t00 \
|
|
Packit |
534379 |
((uint64_t)0x000fffffffffffffLLU) // Avmm mmmach portion
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_ERR_b63 \
|
|
Packit |
534379 |
((uint64_t)0x8000000000000000LLU) // mmmach error
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_RCK_b62 \
|
|
Packit |
534379 |
((uint64_t)0x4000000000000000LLU) // 0=refclk0, 1=refclk1
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_BSY_b61 \
|
|
Packit |
534379 |
((uint64_t)0x2000000000000000LLU) // fPLL cal busy
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_LCK_b60 \
|
|
Packit |
534379 |
((uint64_t)0x1000000000000000LLU) // fPLL locked
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_SR1_b58 \
|
|
Packit |
534379 |
((uint64_t)0x0400000000000000LLU) // fPLL Select: 0=refclk0, 1=refclk1
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_PDN_b57 \
|
|
Packit |
534379 |
((uint64_t)0x0200000000000000LLU) // fPLL Powerdoen
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_PRS_b56 \
|
|
Packit |
534379 |
((uint64_t)0x0100000000000000LLU) // fPLL management reset
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_MRN_b52 \
|
|
Packit |
534379 |
((uint64_t)0x0010000000000000LLU) // mmmach machine reset_n
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_SEQ_b49t48 \
|
|
Packit |
534379 |
((uint64_t)0x0003000000000000LLU) // mmmach sequence
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_WRT_b44 \
|
|
Packit |
534379 |
((uint64_t)0x0000100000000000LLU) // mmmach write
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_ADR_b41t32 \
|
|
Packit |
534379 |
((uint64_t)0x000003ff00000000LLU) // mmmach MM address
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_0_DAT_b31t00 \
|
|
Packit |
534379 |
((uint64_t)0x00000000ffffffffLLU) // mmmach MM read data
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_CMD_1_MEA_b32 \
|
|
Packit |
534379 |
((uint64_t)0x0000000100000000LLU) // 1: measure user clock; 0: measure
|
|
Packit |
534379 |
// 2nd clock, div2
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_1_VER_b63t60 \
|
|
Packit |
534379 |
((uint64_t)0xf000000000000000LLU) // frequency in 10 kHz units
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_1_MEA_b32 \
|
|
Packit |
534379 |
((uint64_t)0x0000000100000000LLU) // 1: measure user clock; 0: measure
|
|
Packit |
534379 |
// 2nd clock, div2
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_1_FRQ_b16t00 \
|
|
Packit |
534379 |
((uint64_t)0x000000000001ffffLLU) // frequency in 10 kHz units
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_1_VER_version \
|
|
Packit |
534379 |
((uint64_t)0x03LLU) // Expected version number
|
|
Packit |
534379 |
#define QUCPU_UI64_STS_1_VER_version_legacy \
|
|
Packit |
534379 |
((uint64_t)0x01LLU) // Expected version number on legacy systems
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_AVMM_FPLL_IPI_200 ((uint64_t)0x200LLU) // IP identifer
|
|
Packit |
534379 |
#define QUCPU_UI64_AVMM_FPLL_IPI_200_IDI_RFDUAL \
|
|
Packit |
534379 |
((uint64_t)0x05LLU) // Expected ID, RF=100 MHz & RF=322.265625 MHz
|
|
Packit |
534379 |
#define QUCPU_UI64_AVMM_FPLL_IPI_200_IDI_RF100M \
|
|
Packit |
534379 |
((uint64_t)0x06LLU) // Expected ID, RF=100 MHz
|
|
Packit |
534379 |
#define QUCPU_UI64_AVMM_FPLL_IPI_200_IDI_RF322M \
|
|
Packit |
534379 |
((uint64_t)0x07LLU) // Expected ID, RF=322.265625 MHz
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#define QUCPU_UI64_AVMM_FPLL_GPR_280 ((uint64_t)0x280LLU)
|
|
Packit |
534379 |
#define QUCPU_UI64_AVMM_FPLL_GPR_280_PDN_b00 \
|
|
Packit |
534379 |
((uint64_t)0x0000000000000001LLU) // Powerdown when override set
|
|
Packit |
534379 |
#define QUCPU_UI64_AVMM_FPLL_GPR_280_ADM_b01 \
|
|
Packit |
534379 |
((uint64_t)0x0000000000000001LLU) // 1: Override listen to ADME; 0:
|
|
Packit |
534379 |
// listen to powerdown port
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// Bugs, decimal code
|
|
Packit |
534379 |
#define QUCPU_INT_UCLOCK_BUG_SLEEP_SHORT ((int)1) // Bug in fv_SleepShort
|
|
Packit |
534379 |
|
|
Packit |
534379 |
// Structures and Types
|
|
Packit |
534379 |
struct QUCPU_sInitz {
|
|
Packit |
534379 |
uint64_t u64i_Version; // Version of clock user
|
|
Packit |
534379 |
uint64_t u64i_PLL_ID; // PLL ID
|
|
Packit |
534379 |
uint64_t u64i_NumFrq_Intg_End; // Integer/exact fPLL indices [0 ..End]
|
|
Packit |
534379 |
uint64_t u64i_NumFrq_Frac_Beg; // Fractional fPLL indices [Beg..End]
|
|
Packit |
534379 |
uint64_t u64i_NumFrq_Frac_End;
|
|
Packit |
534379 |
uint64_t u64i_NumFrq; // Array frequency # of elements
|
|
Packit |
534379 |
uint64_t u64i_NumReg; // Array registers # of elements
|
|
Packit |
534379 |
uint64_t u64i_NumRck; // Array ref-clocks # of elements
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
struct QUCPU_sFreqs {
|
|
Packit |
534379 |
uint64_t u64i_Frq_ClkUsr; // Read user clock frequency (Hz)
|
|
Packit |
534379 |
uint64_t u64i_Frq_DivBy2; // Read user clock frequency (Hz) divided-by-2
|
|
Packit |
534379 |
// output
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
typedef struct QUCPU_sInitz QUCPU_tInitz;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
typedef struct QUCPU_sFreqs QUCPU_tFreqs;
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|
|
Packit |
534379 |
struct QUCPU_Uclock {
|
|
Packit |
534379 |
char sysfs_path[SYSFS_PATH_MAX]; // Port sysfs path
|
|
Packit |
534379 |
int i_Bug_First; // First bug
|
|
Packit |
534379 |
int i_Bug_Last; // Lasr bug
|
|
Packit |
534379 |
int i_InitzState; // Initialization state
|
|
Packit |
534379 |
QUCPU_tInitz tInitz_InitialParams; // Initialization parameters
|
|
Packit |
534379 |
uint64_t u64i_cmd_reg_0; // Command register 0
|
|
Packit |
534379 |
uint64_t u64i_cmd_reg_1; // Command register 1
|
|
Packit |
534379 |
uint64_t u64i_AVMM_seq; // Sequence ID
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_GetFreqs(QUCPU_tFreqs *ptFreqs_retFreqs);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_SetFreqs(uint64_t u64i_Refclk, uint64_t u64i_FrqInx);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_RunInitz(const char *sysfs_path);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int sysfs_read_file(const char *sysfs_path, const char *csr_path,
|
|
Packit |
534379 |
uint64_t *value);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int sysfs_write_file(const char *sysfs_path, const char *csr_path,
|
|
Packit |
534379 |
uint64_t value);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_WaitCalDone(void);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
void fv_BugLog(int i_BugID);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_AvmmReadModifyWrite(uint64_t u64i_AvmmAdr, uint64_t u64i_AvmmDat,
|
|
Packit |
534379 |
uint64_t u64i_AvmmMsk);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_AvmmReadModifyWriteVerify(uint64_t u64i_AvmmAdr, uint64_t u64i_AvmmDat,
|
|
Packit |
534379 |
uint64_t u64i_AvmmMsk);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
void fv_SleepShort(long int li_sleep_nanoseconds);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_AvmmWrite(uint64_t u64i_AvmmAdr, uint64_t u64i_WriteData);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
int fi_AvmmRead(uint64_t u64i_AvmmAdr, uint64_t *pu64i_ReadData);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
const char *fpac_GetErrMsg(int i_ErrMsgInx);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifdef __cplusplus
|
|
Packit |
534379 |
extern "C" {
|
|
Packit |
534379 |
#endif
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* @brief Get fpga user clock
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* @param sysfs_path port sysfs path
|
|
Packit |
534379 |
* @parm pointer to high user clock
|
|
Packit |
534379 |
* @parm pointer to low user clock
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* @return error code
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
fpga_result get_userclock(const char *sysfs_path, uint64_t *userclk_high,
|
|
Packit |
534379 |
uint64_t *userclk_low);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
/**
|
|
Packit |
534379 |
* @brief set fpga user clock
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* @param sysfs_path port sysfs path
|
|
Packit |
534379 |
* @parm high user clock
|
|
Packit |
534379 |
* @parm low user clock
|
|
Packit |
534379 |
*
|
|
Packit |
534379 |
* @return error code
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
fpga_result set_userclock(const char *sysfs_path, uint64_t userclk_high,
|
|
Packit |
534379 |
uint64_t userclk_low);
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#ifdef __cplusplus
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
#endif
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#endif // end USER_CLK_PGM_UCLK_H_
|