xref: /linux/drivers/dpll/dpll_nl.c (revision ab475966455ce285c2c9978a3e3bfe97d75ff8d4)
1 // SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2 /* Do not edit directly, auto-generated from: */
3 /*	Documentation/netlink/specs/dpll.yaml */
4 /* YNL-GEN kernel source */
5 
6 #include <net/netlink.h>
7 #include <net/genetlink.h>
8 
9 #include "dpll_nl.h"
10 
11 #include <uapi/linux/dpll.h>
12 
13 /* Common nested types */
14 const struct nla_policy dpll_pin_parent_device_nl_policy[DPLL_A_PIN_PHASE_OFFSET + 1] = {
15 	[DPLL_A_PIN_PARENT_ID] = { .type = NLA_U32, },
16 	[DPLL_A_PIN_DIRECTION] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
17 	[DPLL_A_PIN_PRIO] = { .type = NLA_U32, },
18 	[DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3),
19 	[DPLL_A_PIN_PHASE_OFFSET] = { .type = NLA_S64, },
20 };
21 
22 const struct nla_policy dpll_pin_parent_pin_nl_policy[DPLL_A_PIN_STATE + 1] = {
23 	[DPLL_A_PIN_PARENT_ID] = { .type = NLA_U32, },
24 	[DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3),
25 };
26 
27 /* DPLL_CMD_DEVICE_ID_GET - do */
28 static const struct nla_policy dpll_device_id_get_nl_policy[DPLL_A_TYPE + 1] = {
29 	[DPLL_A_MODULE_NAME] = { .type = NLA_NUL_STRING, },
30 	[DPLL_A_CLOCK_ID] = { .type = NLA_U64, },
31 	[DPLL_A_TYPE] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
32 };
33 
34 /* DPLL_CMD_DEVICE_GET - do */
35 static const struct nla_policy dpll_device_get_nl_policy[DPLL_A_ID + 1] = {
36 	[DPLL_A_ID] = { .type = NLA_U32, },
37 };
38 
39 /* DPLL_CMD_DEVICE_SET - do */
40 static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_ID + 1] = {
41 	[DPLL_A_ID] = { .type = NLA_U32, },
42 };
43 
44 /* DPLL_CMD_PIN_ID_GET - do */
45 static const struct nla_policy dpll_pin_id_get_nl_policy[DPLL_A_PIN_TYPE + 1] = {
46 	[DPLL_A_PIN_MODULE_NAME] = { .type = NLA_NUL_STRING, },
47 	[DPLL_A_PIN_CLOCK_ID] = { .type = NLA_U64, },
48 	[DPLL_A_PIN_BOARD_LABEL] = { .type = NLA_NUL_STRING, },
49 	[DPLL_A_PIN_PANEL_LABEL] = { .type = NLA_NUL_STRING, },
50 	[DPLL_A_PIN_PACKAGE_LABEL] = { .type = NLA_NUL_STRING, },
51 	[DPLL_A_PIN_TYPE] = NLA_POLICY_RANGE(NLA_U32, 1, 5),
52 };
53 
54 /* DPLL_CMD_PIN_GET - do */
55 static const struct nla_policy dpll_pin_get_do_nl_policy[DPLL_A_PIN_ID + 1] = {
56 	[DPLL_A_PIN_ID] = { .type = NLA_U32, },
57 };
58 
59 /* DPLL_CMD_PIN_GET - dump */
60 static const struct nla_policy dpll_pin_get_dump_nl_policy[DPLL_A_PIN_ID + 1] = {
61 	[DPLL_A_PIN_ID] = { .type = NLA_U32, },
62 };
63 
64 /* DPLL_CMD_PIN_SET - do */
65 static const struct nla_policy dpll_pin_set_nl_policy[DPLL_A_PIN_PHASE_ADJUST + 1] = {
66 	[DPLL_A_PIN_ID] = { .type = NLA_U32, },
67 	[DPLL_A_PIN_FREQUENCY] = { .type = NLA_U64, },
68 	[DPLL_A_PIN_DIRECTION] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
69 	[DPLL_A_PIN_PRIO] = { .type = NLA_U32, },
70 	[DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3),
71 	[DPLL_A_PIN_PARENT_DEVICE] = NLA_POLICY_NESTED(dpll_pin_parent_device_nl_policy),
72 	[DPLL_A_PIN_PARENT_PIN] = NLA_POLICY_NESTED(dpll_pin_parent_pin_nl_policy),
73 	[DPLL_A_PIN_PHASE_ADJUST] = { .type = NLA_S32, },
74 };
75 
76 /* Ops table for dpll */
77 static const struct genl_split_ops dpll_nl_ops[] = {
78 	{
79 		.cmd		= DPLL_CMD_DEVICE_ID_GET,
80 		.pre_doit	= dpll_lock_doit,
81 		.doit		= dpll_nl_device_id_get_doit,
82 		.post_doit	= dpll_unlock_doit,
83 		.policy		= dpll_device_id_get_nl_policy,
84 		.maxattr	= DPLL_A_TYPE,
85 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
86 	},
87 	{
88 		.cmd		= DPLL_CMD_DEVICE_GET,
89 		.pre_doit	= dpll_pre_doit,
90 		.doit		= dpll_nl_device_get_doit,
91 		.post_doit	= dpll_post_doit,
92 		.policy		= dpll_device_get_nl_policy,
93 		.maxattr	= DPLL_A_ID,
94 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
95 	},
96 	{
97 		.cmd	= DPLL_CMD_DEVICE_GET,
98 		.start	= dpll_lock_dumpit,
99 		.dumpit	= dpll_nl_device_get_dumpit,
100 		.done	= dpll_unlock_dumpit,
101 		.flags	= GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
102 	},
103 	{
104 		.cmd		= DPLL_CMD_DEVICE_SET,
105 		.pre_doit	= dpll_pre_doit,
106 		.doit		= dpll_nl_device_set_doit,
107 		.post_doit	= dpll_post_doit,
108 		.policy		= dpll_device_set_nl_policy,
109 		.maxattr	= DPLL_A_ID,
110 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
111 	},
112 	{
113 		.cmd		= DPLL_CMD_PIN_ID_GET,
114 		.pre_doit	= dpll_lock_doit,
115 		.doit		= dpll_nl_pin_id_get_doit,
116 		.post_doit	= dpll_unlock_doit,
117 		.policy		= dpll_pin_id_get_nl_policy,
118 		.maxattr	= DPLL_A_PIN_TYPE,
119 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
120 	},
121 	{
122 		.cmd		= DPLL_CMD_PIN_GET,
123 		.pre_doit	= dpll_pin_pre_doit,
124 		.doit		= dpll_nl_pin_get_doit,
125 		.post_doit	= dpll_pin_post_doit,
126 		.policy		= dpll_pin_get_do_nl_policy,
127 		.maxattr	= DPLL_A_PIN_ID,
128 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
129 	},
130 	{
131 		.cmd		= DPLL_CMD_PIN_GET,
132 		.start		= dpll_lock_dumpit,
133 		.dumpit		= dpll_nl_pin_get_dumpit,
134 		.done		= dpll_unlock_dumpit,
135 		.policy		= dpll_pin_get_dump_nl_policy,
136 		.maxattr	= DPLL_A_PIN_ID,
137 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
138 	},
139 	{
140 		.cmd		= DPLL_CMD_PIN_SET,
141 		.pre_doit	= dpll_pin_pre_doit,
142 		.doit		= dpll_nl_pin_set_doit,
143 		.post_doit	= dpll_pin_post_doit,
144 		.policy		= dpll_pin_set_nl_policy,
145 		.maxattr	= DPLL_A_PIN_PHASE_ADJUST,
146 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
147 	},
148 };
149 
150 static const struct genl_multicast_group dpll_nl_mcgrps[] = {
151 	[DPLL_NLGRP_MONITOR] = { "monitor", },
152 };
153 
154 struct genl_family dpll_nl_family __ro_after_init = {
155 	.name		= DPLL_FAMILY_NAME,
156 	.version	= DPLL_FAMILY_VERSION,
157 	.netnsok	= true,
158 	.parallel_ops	= true,
159 	.module		= THIS_MODULE,
160 	.split_ops	= dpll_nl_ops,
161 	.n_split_ops	= ARRAY_SIZE(dpll_nl_ops),
162 	.mcgrps		= dpll_nl_mcgrps,
163 	.n_mcgrps	= ARRAY_SIZE(dpll_nl_mcgrps),
164 };
165