linux/include/linux/dpll.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 *  Copyright (c) 2023 Meta Platforms, Inc. and affiliates
 *  Copyright (c) 2023 Intel and affiliates
 */

#ifndef __DPLL_H__
#define __DPLL_H__

#include <uapi/linux/dpll.h>
#include <linux/device.h>
#include <linux/netlink.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>

struct dpll_device;
struct dpll_pin;

struct dpll_device_ops {};

struct dpll_pin_ops {};

struct dpll_pin_frequency {};

#define DPLL_PIN_FREQUENCY_RANGE(_min, _max)

#define DPLL_PIN_FREQUENCY(_val)
#define DPLL_PIN_FREQUENCY_1PPS
#define DPLL_PIN_FREQUENCY_10MHZ
#define DPLL_PIN_FREQUENCY_IRIG_B
#define DPLL_PIN_FREQUENCY_DCF77

struct dpll_pin_phase_adjust_range {};

struct dpll_pin_properties {};

#if IS_ENABLED(CONFIG_DPLL)
void dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin);
void dpll_netdev_pin_clear(struct net_device *dev);

size_t dpll_netdev_pin_handle_size(const struct net_device *dev);
int dpll_netdev_add_pin_handle(struct sk_buff *msg,
			       const struct net_device *dev);
#else
static inline void
dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin) { }
static inline void dpll_netdev_pin_clear(struct net_device *dev) { }

static inline size_t dpll_netdev_pin_handle_size(const struct net_device *dev)
{
	return 0;
}

static inline int
dpll_netdev_add_pin_handle(struct sk_buff *msg, const struct net_device *dev)
{
	return 0;
}
#endif

struct dpll_device *
dpll_device_get(u64 clock_id, u32 dev_driver_id, struct module *module);

void dpll_device_put(struct dpll_device *dpll);

int dpll_device_register(struct dpll_device *dpll, enum dpll_type type,
			 const struct dpll_device_ops *ops, void *priv);

void dpll_device_unregister(struct dpll_device *dpll,
			    const struct dpll_device_ops *ops, void *priv);

struct dpll_pin *
dpll_pin_get(u64 clock_id, u32 dev_driver_id, struct module *module,
	     const struct dpll_pin_properties *prop);

int dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
		      const struct dpll_pin_ops *ops, void *priv);

void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,
			 const struct dpll_pin_ops *ops, void *priv);

void dpll_pin_put(struct dpll_pin *pin);

int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
			     const struct dpll_pin_ops *ops, void *priv);

void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,
				const struct dpll_pin_ops *ops, void *priv);

int dpll_device_change_ntf(struct dpll_device *dpll);

int dpll_pin_change_ntf(struct dpll_pin *pin);

#endif