Skip to content

Commit e95421d

Browse files
Vadim Fedorenkokubalewski
authored andcommitted
dpll: api header: Add DPLL framework base functions
DPLL framework is used to represent and configure DPLL devices in systems. Each device that has DPLL and can configure sources and outputs can use this framework. Netlink interface is used to provide configuration data and to receive notification messages about changes in the configuration or status of DPLL device. Inputs and outputs of the DPLL device are represented as special objects which could be dynamically added to and removed from DPLL device. Add kernel api header, make dpll subsystem available to device drivers. Add/update makefiles/Kconfig to allow compilation of dpll subsystem. v9->v10: - add phase-shift, pin-phase-adjust attributes Co-developed-by: Milena Olech <milena.olech@intel.com> Signed-off-by: Milena Olech <milena.olech@intel.com> Co-developed-by: Michal Michalik <michal.michalik@intel.com> Signed-off-by: Michal Michalik <michal.michalik@intel.com> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Co-developed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
1 parent 27bd586 commit e95421d

6 files changed

Lines changed: 188 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6307,6 +6307,14 @@ F: Documentation/networking/device_drivers/ethernet/freescale/dpaa2/switch-drive
63076307
F: drivers/net/ethernet/freescale/dpaa2/dpaa2-switch*
63086308
F: drivers/net/ethernet/freescale/dpaa2/dpsw*
63096309

6310+
DPLL CLOCK SUBSYSTEM
6311+
M: Vadim Fedorenko <vadfed@fb.com>
6312+
L: netdev@vger.kernel.org
6313+
S: Maintained
6314+
F: drivers/dpll/*
6315+
F: include/net/dpll.h
6316+
F: include/uapi/linux/dpll.h
6317+
63106318
DRBD DRIVER
63116319
M: Philipp Reisner <philipp.reisner@linbit.com>
63126320
M: Lars Ellenberg <lars.ellenberg@linbit.com>

drivers/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,6 @@ source "drivers/hte/Kconfig"
243243

244244
source "drivers/cdx/Kconfig"
245245

246+
source "drivers/dpll/Kconfig"
247+
246248
endmenu

drivers/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,4 @@ obj-$(CONFIG_PECI) += peci/
195195
obj-$(CONFIG_HTE) += hte/
196196
obj-$(CONFIG_DRM_ACCEL) += accel/
197197
obj-$(CONFIG_CDX_BUS) += cdx/
198+
obj-$(CONFIG_DPLL) += dpll/

drivers/dpll/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Generic DPLL drivers configuration
4+
#
5+
6+
config DPLL
7+
bool

drivers/dpll/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Makefile for DPLL drivers.
4+
#
5+
6+
obj-$(CONFIG_DPLL) += dpll.o
7+
dpll-y += dpll_core.o
8+
dpll-y += dpll_netlink.o
9+
dpll-y += dpll_nl.o

include/linux/dpll.h

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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

Comments
 (0)