brintos

brintos / linux-shallow public Read only

0
0
Text · 3.0 KiB · 0bdca01 Raw
113 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/* Texas Instruments ICSSG Industrial Ethernet Peripheral (IEP) Driver3 *4 * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/5 *6 */7 8#ifndef __NET_TI_ICSS_IEP_H9#define __NET_TI_ICSS_IEP_H10 11#include <linux/mutex.h>12#include <linux/ptp_clock_kernel.h>13#include <linux/regmap.h>14 15enum {16	ICSS_IEP_GLOBAL_CFG_REG,17	ICSS_IEP_GLOBAL_STATUS_REG,18	ICSS_IEP_COMPEN_REG,19	ICSS_IEP_SLOW_COMPEN_REG,20	ICSS_IEP_COUNT_REG0,21	ICSS_IEP_COUNT_REG1,22	ICSS_IEP_CAPTURE_CFG_REG,23	ICSS_IEP_CAPTURE_STAT_REG,24 25	ICSS_IEP_CAP6_RISE_REG0,26	ICSS_IEP_CAP6_RISE_REG1,27 28	ICSS_IEP_CAP7_RISE_REG0,29	ICSS_IEP_CAP7_RISE_REG1,30 31	ICSS_IEP_CMP_CFG_REG,32	ICSS_IEP_CMP_STAT_REG,33	ICSS_IEP_CMP0_REG0,34	ICSS_IEP_CMP0_REG1,35	ICSS_IEP_CMP1_REG0,36	ICSS_IEP_CMP1_REG1,37 38	ICSS_IEP_CMP8_REG0,39	ICSS_IEP_CMP8_REG1,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,47	ICSS_IEP_MAX_REGS,48};49 50/**51 * struct icss_iep_plat_data - Plat data to handle SoC variants52 * @config: Regmap configuration data53 * @reg_offs: register offsets to capture offset differences across SoCs54 * @flags: Flags to represent IEP properties55 */56struct icss_iep_plat_data {57	const struct regmap_config *config;58	u32 reg_offs[ICSS_IEP_MAX_REGS];59	u32 flags;60};61 62struct icss_iep {63	struct device *dev;64	void __iomem *base;65	const struct icss_iep_plat_data *plat_data;66	struct regmap *map;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 */73	u32 def_inc;74	s16 slow_cmp_inc;75	u32 slow_cmp_count;76	const struct icss_iep_clockops *ops;77	void *clockops_data;78	u32 cycle_time_ns;79	u32 perout_enabled;80	bool pps_enabled;81	int cap_cmp_irq;82	u64 period;83	u32 latch_enable;84	struct work_struct work;85};86 87extern const struct icss_iep_clockops prueth_iep_clockops;88 89/* Firmware specific clock operations */90struct 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,96			     u64 *cmp);97	int (*extts_enable)(void *clockops_data, u32 index, int on);98};99 100struct icss_iep *icss_iep_get(struct device_node *np);101struct icss_iep *icss_iep_get_idx(struct device_node *np, int idx);102void icss_iep_put(struct icss_iep *iep);103int icss_iep_init(struct icss_iep *iep, const struct icss_iep_clockops *clkops,104		  void *clockops_data, u32 cycle_time_ns);105int icss_iep_exit(struct icss_iep *iep);106int icss_iep_get_count_low(struct icss_iep *iep);107int icss_iep_get_count_hi(struct icss_iep *iep);108int icss_iep_get_ptp_clock_idx(struct icss_iep *iep);109void icss_iep_init_fw(struct icss_iep *iep);110void icss_iep_exit_fw(struct icss_iep *iep);111 112#endif /* __NET_TI_ICSS_IEP_H */113