/* SPDX-License-Identifier: GPL-2.0-or-later */


#ifndef LINUX_PPS_GEN_KERNEL_H
#define LINUX_PPS_GEN_KERNEL_H

#include <linux/pps_gen.h>
#include <linux/cdev.h>
#include <linux/device.h>



#define PPS_GEN_MAX_SOURCES	16		

struct pps_gen_device;


struct pps_gen_source_info {
	bool use_system_clock;

	int (*get_time)(struct pps_gen_device *pps_gen,
					struct timespec64 *time);
	int (*enable)(struct pps_gen_device *pps_gen, bool enable);


	struct module *owner;
	struct device *parent;			
};


struct pps_gen_device {
	const struct pps_gen_source_info *info;	
	bool enabled;				

	unsigned int event;
	unsigned int sequence;

	unsigned int last_ev;			
	wait_queue_head_t queue;		

	unsigned int id;			
	struct cdev cdev;
	struct device *dev;
	struct fasync_struct *async_queue;	
	spinlock_t lock;
};



extern const struct attribute_group *pps_gen_groups[];



extern struct pps_gen_device *pps_gen_register_source(
				const struct pps_gen_source_info *info);
extern void pps_gen_unregister_source(struct pps_gen_device *pps_gen);
extern void pps_gen_event(struct pps_gen_device *pps_gen,
				unsigned int event, void *data);

#endif 
