mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 03:10:52 +07:00
ptp: ptp_clockmatrix: update to support 4.8.7 firmware
With 4.8.7 firmware, adjtime can change delta instead of absolute time, which greately increases snap accuracy. PPS alignment doesn't have to be set for every single TOD change. Other minor changes includes: adding more debug logs, increasing snap accuracy for pre 4.8.7 firmware and supporting new tcs2bin format. Signed-off-by: Min Li <min.li.xe@renesas.com> Acked-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2a043e9cec
commit
7ea5fda2b1
@ -20,6 +20,10 @@
|
||||
#define HW_DPLL_1 (0x8b00)
|
||||
#define HW_DPLL_2 (0x8c00)
|
||||
#define HW_DPLL_3 (0x8d00)
|
||||
#define HW_DPLL_4 (0x8e00)
|
||||
#define HW_DPLL_5 (0x8f00)
|
||||
#define HW_DPLL_6 (0x9000)
|
||||
#define HW_DPLL_7 (0x9100)
|
||||
|
||||
#define HW_DPLL_TOD_SW_TRIG_ADDR__0 (0x080)
|
||||
#define HW_DPLL_TOD_CTRL_1 (0x089)
|
||||
@ -57,6 +61,43 @@
|
||||
#define SYNCTRL1_Q1_DIV_SYNC_TRIG BIT(1)
|
||||
#define SYNCTRL1_Q0_DIV_SYNC_TRIG BIT(0)
|
||||
|
||||
#define HW_Q8_CTRL_SPARE (0xa7d4)
|
||||
#define HW_Q11_CTRL_SPARE (0xa7ec)
|
||||
|
||||
/**
|
||||
* Select FOD5 as sync_trigger for Q8 divider.
|
||||
* Transition from logic zero to one
|
||||
* sets trigger to sync Q8 divider.
|
||||
*
|
||||
* Unused when FOD4 is driving Q8 divider (normal operation).
|
||||
*/
|
||||
#define Q9_TO_Q8_SYNC_TRIG BIT(1)
|
||||
|
||||
/**
|
||||
* Enable FOD5 as driver for clock and sync for Q8 divider.
|
||||
* Enable fanout buffer for FOD5.
|
||||
*
|
||||
* Unused when FOD4 is driving Q8 divider (normal operation).
|
||||
*/
|
||||
#define Q9_TO_Q8_FANOUT_AND_CLOCK_SYNC_ENABLE_MASK (BIT(0) | BIT(2))
|
||||
|
||||
/**
|
||||
* Select FOD6 as sync_trigger for Q11 divider.
|
||||
* Transition from logic zero to one
|
||||
* sets trigger to sync Q11 divider.
|
||||
*
|
||||
* Unused when FOD7 is driving Q11 divider (normal operation).
|
||||
*/
|
||||
#define Q10_TO_Q11_SYNC_TRIG BIT(1)
|
||||
|
||||
/**
|
||||
* Enable FOD6 as driver for clock and sync for Q11 divider.
|
||||
* Enable fanout buffer for FOD6.
|
||||
*
|
||||
* Unused when FOD7 is driving Q11 divider (normal operation).
|
||||
*/
|
||||
#define Q10_TO_Q11_FANOUT_AND_CLOCK_SYNC_ENABLE_MASK (BIT(0) | BIT(2))
|
||||
|
||||
#define RESET_CTRL 0xc000
|
||||
#define SM_RESET 0x0012
|
||||
#define SM_RESET_CMD 0x5A
|
||||
@ -191,6 +232,7 @@
|
||||
|
||||
#define DPLL_CTRL_0 0xc600
|
||||
#define DPLL_CTRL_DPLL_MANU_REF_CFG 0x0001
|
||||
#define DPLL_CTRL_COMBO_MASTER_CFG 0x003a
|
||||
|
||||
#define DPLL_CTRL_1 0xc63c
|
||||
|
||||
@ -646,6 +688,9 @@
|
||||
/* Bit definitions for the TOD_WRITE_CMD register */
|
||||
#define TOD_WRITE_SELECTION_SHIFT (0)
|
||||
#define TOD_WRITE_SELECTION_MASK (0xf)
|
||||
/* 4.8.7 */
|
||||
#define TOD_WRITE_TYPE_SHIFT (4)
|
||||
#define TOD_WRITE_TYPE_MASK (0x3)
|
||||
|
||||
/* Bit definitions for the TOD_READ_PRIMARY_SEL_CFG_0 register */
|
||||
#define RD_PWM_DECODER_INDEX_SHIFT (4)
|
||||
@ -658,4 +703,7 @@
|
||||
#define TOD_READ_TRIGGER_SHIFT (0)
|
||||
#define TOD_READ_TRIGGER_MASK (0xf)
|
||||
|
||||
/* Bit definitions for the DPLL_CTRL_COMBO_MASTER_CFG register */
|
||||
#define COMBO_MASTER_HOLD BIT(0)
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,32 +13,48 @@
|
||||
#include "idt8a340_reg.h"
|
||||
|
||||
#define FW_FILENAME "idtcm.bin"
|
||||
#define MAX_PHC_PLL 4
|
||||
#define MAX_TOD (4)
|
||||
#define MAX_PLL (8)
|
||||
|
||||
#define MAX_ABS_WRITE_PHASE_PICOSECONDS (107374182350LL)
|
||||
|
||||
#define PLL_MASK_ADDR (0xFFA5)
|
||||
#define DEFAULT_PLL_MASK (0x04)
|
||||
#define TOD_MASK_ADDR (0xFFA5)
|
||||
#define DEFAULT_TOD_MASK (0x04)
|
||||
|
||||
#define SET_U16_LSB(orig, val8) (orig = (0xff00 & (orig)) | (val8))
|
||||
#define SET_U16_MSB(orig, val8) (orig = (0x00ff & (orig)) | (val8 << 8))
|
||||
|
||||
#define OUTPUT_MASK_PLL0_ADDR (0xFFB0)
|
||||
#define OUTPUT_MASK_PLL1_ADDR (0xFFB2)
|
||||
#define OUTPUT_MASK_PLL2_ADDR (0xFFB4)
|
||||
#define OUTPUT_MASK_PLL3_ADDR (0xFFB6)
|
||||
#define TOD0_PTP_PLL_ADDR (0xFFA8)
|
||||
#define TOD1_PTP_PLL_ADDR (0xFFA9)
|
||||
#define TOD2_PTP_PLL_ADDR (0xFFAA)
|
||||
#define TOD3_PTP_PLL_ADDR (0xFFAB)
|
||||
|
||||
#define TOD0_OUT_ALIGN_MASK_ADDR (0xFFB0)
|
||||
#define TOD1_OUT_ALIGN_MASK_ADDR (0xFFB2)
|
||||
#define TOD2_OUT_ALIGN_MASK_ADDR (0xFFB4)
|
||||
#define TOD3_OUT_ALIGN_MASK_ADDR (0xFFB6)
|
||||
|
||||
#define DEFAULT_OUTPUT_MASK_PLL0 (0x003)
|
||||
#define DEFAULT_OUTPUT_MASK_PLL1 (0x00c)
|
||||
#define DEFAULT_OUTPUT_MASK_PLL2 (0x030)
|
||||
#define DEFAULT_OUTPUT_MASK_PLL3 (0x0c0)
|
||||
|
||||
#define DEFAULT_TOD0_PTP_PLL (0)
|
||||
#define DEFAULT_TOD1_PTP_PLL (1)
|
||||
#define DEFAULT_TOD2_PTP_PLL (2)
|
||||
#define DEFAULT_TOD3_PTP_PLL (3)
|
||||
|
||||
#define POST_SM_RESET_DELAY_MS (3000)
|
||||
#define PHASE_PULL_IN_THRESHOLD_NS (150000)
|
||||
#define TOD_WRITE_OVERHEAD_COUNT_MAX (5)
|
||||
#define PHASE_PULL_IN_THRESHOLD_NS_V487 (15000)
|
||||
#define TOD_WRITE_OVERHEAD_COUNT_MAX (2)
|
||||
#define TOD_BYTE_COUNT (11)
|
||||
#define WR_PHASE_SETUP_MS (5000)
|
||||
|
||||
#define OUTPUT_MODULE_FROM_INDEX(index) (OUTPUT_0 + (index) * 0x10)
|
||||
|
||||
#define PEROUT_ENABLE_OUTPUT_MASK (0xdeadbeef)
|
||||
|
||||
/* Values of DPLL_N.DPLL_MODE.PLL_MODE */
|
||||
enum pll_mode {
|
||||
PLL_MODE_MIN = 0,
|
||||
@ -48,7 +64,8 @@ enum pll_mode {
|
||||
PLL_MODE_GPIO_INC_DEC = 3,
|
||||
PLL_MODE_SYNTHESIS = 4,
|
||||
PLL_MODE_PHASE_MEASUREMENT = 5,
|
||||
PLL_MODE_MAX = PLL_MODE_PHASE_MEASUREMENT,
|
||||
PLL_MODE_DISABLED = 6,
|
||||
PLL_MODE_MAX = PLL_MODE_DISABLED,
|
||||
};
|
||||
|
||||
enum hw_tod_write_trig_sel {
|
||||
@ -63,6 +80,26 @@ enum hw_tod_write_trig_sel {
|
||||
WR_TRIG_SEL_MAX = HW_TOD_WR_TRIG_SEL_FOD_SYNC,
|
||||
};
|
||||
|
||||
/* 4.8.7 only */
|
||||
enum scsr_tod_write_trig_sel {
|
||||
SCSR_TOD_WR_TRIG_SEL_DISABLE = 0,
|
||||
SCSR_TOD_WR_TRIG_SEL_IMMEDIATE = 1,
|
||||
SCSR_TOD_WR_TRIG_SEL_REFCLK = 2,
|
||||
SCSR_TOD_WR_TRIG_SEL_PWMPPS = 3,
|
||||
SCSR_TOD_WR_TRIG_SEL_TODPPS = 4,
|
||||
SCSR_TOD_WR_TRIG_SEL_SYNCFOD = 5,
|
||||
SCSR_TOD_WR_TRIG_SEL_GPIO = 6,
|
||||
SCSR_TOD_WR_TRIG_SEL_MAX = SCSR_TOD_WR_TRIG_SEL_GPIO,
|
||||
};
|
||||
|
||||
/* 4.8.7 only */
|
||||
enum scsr_tod_write_type_sel {
|
||||
SCSR_TOD_WR_TYPE_SEL_ABSOLUTE = 0,
|
||||
SCSR_TOD_WR_TYPE_SEL_DELTA_PLUS = 1,
|
||||
SCSR_TOD_WR_TYPE_SEL_DELTA_MINUS = 2,
|
||||
SCSR_TOD_WR_TYPE_SEL_MAX = SCSR_TOD_WR_TYPE_SEL_DELTA_MINUS,
|
||||
};
|
||||
|
||||
struct idtcm;
|
||||
|
||||
struct idtcm_channel {
|
||||
@ -79,15 +116,17 @@ struct idtcm_channel {
|
||||
u16 tod_n;
|
||||
u16 hw_dpll_n;
|
||||
enum pll_mode pll_mode;
|
||||
u8 pll;
|
||||
u16 output_mask;
|
||||
int write_phase_ready;
|
||||
};
|
||||
|
||||
struct idtcm {
|
||||
struct idtcm_channel channel[MAX_PHC_PLL];
|
||||
struct idtcm_channel channel[MAX_TOD];
|
||||
struct i2c_client *client;
|
||||
u8 page_offset;
|
||||
u8 pll_mask;
|
||||
u8 tod_mask;
|
||||
char version[16];
|
||||
|
||||
/* Overhead calculation for adjtime */
|
||||
u8 calculate_overhead_flag;
|
||||
|
Loading…
Reference in New Issue
Block a user