|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2023 Meta Platforms, Inc. and affiliates |
| 4 | + * Copyright (c) 2023 Intel and affiliates |
| 5 | + */ |
| 6 | + |
| 7 | +#ifndef __DPLL_H__ |
| 8 | +#define __DPLL_H__ |
| 9 | + |
| 10 | +#include <uapi/linux/dpll.h> |
| 11 | +#include <linux/device.h> |
| 12 | +#include <linux/netlink.h> |
| 13 | + |
| 14 | +struct dpll_device; |
| 15 | +struct dpll_pin; |
| 16 | + |
| 17 | +struct dpll_device_ops { |
| 18 | + int (*mode_get)(const struct dpll_device *dpll, void *dpll_priv, |
| 19 | + enum dpll_mode *mode, struct netlink_ext_ack *extack); |
| 20 | + int (*mode_set)(const struct dpll_device *dpll, void *dpll_priv, |
| 21 | + const enum dpll_mode mode, |
| 22 | + struct netlink_ext_ack *extack); |
| 23 | + bool (*mode_supported)(const struct dpll_device *dpll, void *dpll_priv, |
| 24 | + const enum dpll_mode mode, |
| 25 | + struct netlink_ext_ack *extack); |
| 26 | + int (*source_pin_idx_get)(const struct dpll_device *dpll, |
| 27 | + void *dpll_priv, |
| 28 | + u32 *pin_idx, |
| 29 | + struct netlink_ext_ack *extack); |
| 30 | + int (*lock_status_get)(const struct dpll_device *dpll, void *dpll_priv, |
| 31 | + enum dpll_lock_status *status, |
| 32 | + struct netlink_ext_ack *extack); |
| 33 | + int (*temp_get)(const struct dpll_device *dpll, void *dpll_priv, |
| 34 | + s32 *temp, struct netlink_ext_ack *extack); |
| 35 | + int (*phase_shift_get)(const struct dpll_device *dpll, void *dpll_priv, |
| 36 | + s32 *phase_shift, |
| 37 | + struct netlink_ext_ack *extack); |
| 38 | +}; |
| 39 | + |
| 40 | +struct dpll_pin_ops { |
| 41 | + int (*frequency_set)(const struct dpll_pin *pin, void *pin_priv, |
| 42 | + const struct dpll_device *dpll, void *dpll_priv, |
| 43 | + const u64 frequency, |
| 44 | + struct netlink_ext_ack *extack); |
| 45 | + int (*frequency_get)(const struct dpll_pin *pin, void *pin_priv, |
| 46 | + const struct dpll_device *dpll, void *dpll_priv, |
| 47 | + u64 *frequency, struct netlink_ext_ack *extack); |
| 48 | + int (*direction_set)(const struct dpll_pin *pin, void *pin_priv, |
| 49 | + const struct dpll_device *dpll, void *dpll_priv, |
| 50 | + const enum dpll_pin_direction direction, |
| 51 | + struct netlink_ext_ack *extack); |
| 52 | + int (*direction_get)(const struct dpll_pin *pin, void *pin_priv, |
| 53 | + const struct dpll_device *dpll, void *dpll_priv, |
| 54 | + enum dpll_pin_direction *direction, |
| 55 | + struct netlink_ext_ack *extack); |
| 56 | + int (*state_on_pin_get)(const struct dpll_pin *pin, void *pin_priv, |
| 57 | + const struct dpll_pin *parent_pin, |
| 58 | + void *parent_pin_priv, |
| 59 | + enum dpll_pin_state *state, |
| 60 | + struct netlink_ext_ack *extack); |
| 61 | + int (*state_on_dpll_get)(const struct dpll_pin *pin, void *pin_priv, |
| 62 | + const struct dpll_device *dpll, |
| 63 | + void *dpll_priv, enum dpll_pin_state *state, |
| 64 | + struct netlink_ext_ack *extack); |
| 65 | + int (*state_on_pin_set)(const struct dpll_pin *pin, void *pin_priv, |
| 66 | + const struct dpll_pin *parent_pin, |
| 67 | + void *parent_pin_priv, |
| 68 | + const enum dpll_pin_state state, |
| 69 | + struct netlink_ext_ack *extack); |
| 70 | + int (*state_on_dpll_set)(const struct dpll_pin *pin, void *pin_priv, |
| 71 | + const struct dpll_device *dpll, |
| 72 | + void *dpll_priv, |
| 73 | + const enum dpll_pin_state state, |
| 74 | + struct netlink_ext_ack *extack); |
| 75 | + int (*prio_get)(const struct dpll_pin *pin, void *pin_priv, |
| 76 | + const struct dpll_device *dpll, void *dpll_priv, |
| 77 | + u32 *prio, struct netlink_ext_ack *extack); |
| 78 | + int (*prio_set)(const struct dpll_pin *pin, void *pin_priv, |
| 79 | + const struct dpll_device *dpll, void *dpll_priv, |
| 80 | + const u32 prio, struct netlink_ext_ack *extack); |
| 81 | + int (*phase_adjust_get)(const struct dpll_pin *pin, void *pin_priv, |
| 82 | + const struct dpll_device *dpll, void *dpll_priv, |
| 83 | + s32 *phase_adjust, |
| 84 | + struct netlink_ext_ack *extack); |
| 85 | + int (*phase_adjust_set)(const struct dpll_pin *pin, void *pin_priv, |
| 86 | + const struct dpll_device *dpll, void *dpll_priv, |
| 87 | + const s32 phase_adjust, |
| 88 | + struct netlink_ext_ack *extack); |
| 89 | +}; |
| 90 | + |
| 91 | +struct dpll_pin_frequency { |
| 92 | + u64 min; |
| 93 | + u64 max; |
| 94 | +}; |
| 95 | + |
| 96 | +#define DPLL_PIN_FREQUENCY_RANGE(_min, _max) \ |
| 97 | + { \ |
| 98 | + .min = _min, \ |
| 99 | + .max = _max, \ |
| 100 | + } |
| 101 | + |
| 102 | +#define DPLL_PIN_FREQUENCY(_val) DPLL_PIN_FREQUENCY_RANGE(_val, _val) |
| 103 | +#define DPLL_PIN_FREQUENCY_1PPS \ |
| 104 | + DPLL_PIN_FREQUENCY(DPLL_PIN_FREQUENCY_1_HZ) |
| 105 | +#define DPLL_PIN_FREQUENCY_10MHZ \ |
| 106 | + DPLL_PIN_FREQUENCY(DPLL_PIN_FREQUENCY_10_MHZ) |
| 107 | +#define DPLL_PIN_FREQUENCY_IRIG_B \ |
| 108 | + DPLL_PIN_FREQUENCY(DPLL_PIN_FREQUENCY_10_KHZ) |
| 109 | +#define DPLL_PIN_FREQUENCY_DCF77 \ |
| 110 | + DPLL_PIN_FREQUENCY(DPLL_PIN_FREQUENCY_77_5_KHZ) |
| 111 | + |
| 112 | +struct dpll_pin_phase_adjust_range { |
| 113 | + s32 min; |
| 114 | + s32 max; |
| 115 | +}; |
| 116 | + |
| 117 | +struct dpll_pin_properties { |
| 118 | + const char *board_label; |
| 119 | + const char *panel_label; |
| 120 | + const char *package_label; |
| 121 | + enum dpll_pin_type type; |
| 122 | + unsigned long capabilities; |
| 123 | + u32 freq_supported_num; |
| 124 | + struct dpll_pin_frequency *freq_supported; |
| 125 | + struct dpll_pin_phase_adjust_range phase_range; |
| 126 | +}; |
| 127 | + |
| 128 | +struct dpll_device |
| 129 | +*dpll_device_get(u64 clock_id, u32 dev_driver_id, struct module *module); |
| 130 | + |
| 131 | +void dpll_device_put(struct dpll_device *dpll); |
| 132 | + |
| 133 | +int dpll_device_register(struct dpll_device *dpll, enum dpll_type type, |
| 134 | + const struct dpll_device_ops *ops, void *priv); |
| 135 | + |
| 136 | +void dpll_device_unregister(struct dpll_device *dpll, |
| 137 | + const struct dpll_device_ops *ops, void *priv); |
| 138 | + |
| 139 | +struct dpll_pin |
| 140 | +*dpll_pin_get(u64 clock_id, u32 dev_driver_id, struct module *module, |
| 141 | + const struct dpll_pin_properties *prop); |
| 142 | + |
| 143 | +int dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin, |
| 144 | + const struct dpll_pin_ops *ops, void *priv); |
| 145 | + |
| 146 | +void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin, |
| 147 | + const struct dpll_pin_ops *ops, void *priv); |
| 148 | + |
| 149 | +void dpll_pin_put(struct dpll_pin *pin); |
| 150 | + |
| 151 | +int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin, |
| 152 | + const struct dpll_pin_ops *ops, void *priv); |
| 153 | + |
| 154 | +void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin, |
| 155 | + const struct dpll_pin_ops *ops, void *priv); |
| 156 | + |
| 157 | +int dpll_device_change_ntf(struct dpll_device *dpll); |
| 158 | + |
| 159 | +int dpll_pin_change_ntf(struct dpll_pin *pin); |
| 160 | + |
| 161 | +#endif |
0 commit comments