1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Texas Instruments ICSSG Industrial Ethernet Peripheral (IEP) Driver
4 * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
8 #ifndef __NET_TI_ICSS_IEP_H
9 #define __NET_TI_ICSS_IEP_H
11 #include <linux/mutex.h>
12 #include <linux/ptp_clock_kernel.h>
13 #include <linux/regmap.h>
16 ICSS_IEP_GLOBAL_CFG_REG
,
17 ICSS_IEP_GLOBAL_STATUS_REG
,
19 ICSS_IEP_SLOW_COMPEN_REG
,
22 ICSS_IEP_CAPTURE_CFG_REG
,
23 ICSS_IEP_CAPTURE_STAT_REG
,
25 ICSS_IEP_CAP6_RISE_REG0
,
26 ICSS_IEP_CAP6_RISE_REG1
,
28 ICSS_IEP_CAP7_RISE_REG0
,
29 ICSS_IEP_CAP7_RISE_REG1
,
32 ICSS_IEP_CMP_STAT_REG
,
40 ICSS_IEP_SYNC_CTRL_REG
,
41 ICSS_IEP_SYNC0_STAT_REG
,
42 ICSS_IEP_SYNC1_STAT_REG
,
43 ICSS_IEP_SYNC_PWIDTH_REG
,
44 ICSS_IEP_SYNC0_PERIOD_REG
,
45 ICSS_IEP_SYNC1_DELAY_REG
,
46 ICSS_IEP_SYNC_START_REG
,
51 * struct icss_iep_plat_data - Plat data to handle SoC variants
52 * @config: Regmap configuration data
53 * @reg_offs: register offsets to capture offset differences across SoCs
54 * @flags: Flags to represent IEP properties
56 struct icss_iep_plat_data
{
57 const struct regmap_config
*config
;
58 u32 reg_offs
[ICSS_IEP_MAX_REGS
];
65 const struct icss_iep_plat_data
*plat_data
;
67 struct device_node
*client_np
;
68 unsigned long refclk_freq
;
69 int clk_tick_time
; /* one refclk tick time in ns */
70 struct ptp_clock_info ptp_info
;
71 struct ptp_clock
*ptp_clock
;
72 struct mutex ptp_clk_mutex
; /* PHC access serializer */
76 const struct icss_iep_clockops
*ops
;
84 struct work_struct work
;
87 extern const struct icss_iep_clockops prueth_iep_clockops
;
89 /* Firmware specific clock operations */
90 struct icss_iep_clockops
{
91 void (*settime
)(void *clockops_data
, u64 ns
);
92 void (*adjtime
)(void *clockops_data
, s64 delta
);
93 u64 (*gettime
)(void *clockops_data
, struct ptp_system_timestamp
*sts
);
94 int (*perout_enable
)(void *clockops_data
,
95 struct ptp_perout_request
*req
, int on
,
97 int (*extts_enable
)(void *clockops_data
, u32 index
, int on
);
100 struct icss_iep
*icss_iep_get(struct device_node
*np
);
101 struct icss_iep
*icss_iep_get_idx(struct device_node
*np
, int idx
);
102 void icss_iep_put(struct icss_iep
*iep
);
103 int icss_iep_init(struct icss_iep
*iep
, const struct icss_iep_clockops
*clkops
,
104 void *clockops_data
, u32 cycle_time_ns
);
105 int icss_iep_exit(struct icss_iep
*iep
);
106 int icss_iep_get_count_low(struct icss_iep
*iep
);
107 int icss_iep_get_count_hi(struct icss_iep
*iep
);
108 int icss_iep_get_ptp_clock_idx(struct icss_iep
*iep
);
109 void icss_iep_init_fw(struct icss_iep
*iep
);
110 void icss_iep_exit_fw(struct icss_iep
*iep
);
112 #endif /* __NET_TI_ICSS_IEP_H */