xref: /dpdk/drivers/raw/ifpga/base/ifpga_port.c (revision 9bf033217110c52ed0d7e9a380207da44d2fb4a5)
1473c88f9SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2473c88f9SBruce Richardson  * Copyright(c) 2010-2018 Intel Corporation
3473c88f9SBruce Richardson  */
4473c88f9SBruce Richardson 
5473c88f9SBruce Richardson #include "ifpga_feature_dev.h"
6473c88f9SBruce Richardson 
port_get_prop(struct ifpga_port_hw * port,struct feature_prop * prop)7473c88f9SBruce Richardson int port_get_prop(struct ifpga_port_hw *port, struct feature_prop *prop)
8473c88f9SBruce Richardson {
9473c88f9SBruce Richardson 	struct ifpga_feature *feature;
10473c88f9SBruce Richardson 
11473c88f9SBruce Richardson 	if (!port)
12473c88f9SBruce Richardson 		return -ENOENT;
13473c88f9SBruce Richardson 
14473c88f9SBruce Richardson 	feature = get_port_feature_by_id(port, prop->feature_id);
15473c88f9SBruce Richardson 
16473c88f9SBruce Richardson 	if (feature && feature->ops && feature->ops->get_prop)
17473c88f9SBruce Richardson 		return feature->ops->get_prop(feature, prop);
18473c88f9SBruce Richardson 
19473c88f9SBruce Richardson 	return -ENOENT;
20473c88f9SBruce Richardson }
21473c88f9SBruce Richardson 
port_set_prop(struct ifpga_port_hw * port,struct feature_prop * prop)22473c88f9SBruce Richardson int port_set_prop(struct ifpga_port_hw *port, struct feature_prop *prop)
23473c88f9SBruce Richardson {
24473c88f9SBruce Richardson 	struct ifpga_feature *feature;
25473c88f9SBruce Richardson 
26473c88f9SBruce Richardson 	if (!port)
27473c88f9SBruce Richardson 		return -ENOENT;
28473c88f9SBruce Richardson 
29473c88f9SBruce Richardson 	feature = get_port_feature_by_id(port, prop->feature_id);
30473c88f9SBruce Richardson 
31473c88f9SBruce Richardson 	if (feature && feature->ops && feature->ops->set_prop)
32473c88f9SBruce Richardson 		return feature->ops->set_prop(feature, prop);
33473c88f9SBruce Richardson 
34473c88f9SBruce Richardson 	return -ENOENT;
35473c88f9SBruce Richardson }
36473c88f9SBruce Richardson 
port_set_irq(struct ifpga_port_hw * port,u32 feature_id,void * irq_set)37473c88f9SBruce Richardson int port_set_irq(struct ifpga_port_hw *port, u32 feature_id, void *irq_set)
38473c88f9SBruce Richardson {
39473c88f9SBruce Richardson 	struct ifpga_feature *feature;
40473c88f9SBruce Richardson 
41473c88f9SBruce Richardson 	if (!port)
42473c88f9SBruce Richardson 		return -ENOENT;
43473c88f9SBruce Richardson 
44473c88f9SBruce Richardson 	feature = get_port_feature_by_id(port, feature_id);
45473c88f9SBruce Richardson 
46473c88f9SBruce Richardson 	if (feature && feature->ops && feature->ops->set_irq)
47473c88f9SBruce Richardson 		return feature->ops->set_irq(feature, irq_set);
48473c88f9SBruce Richardson 
49473c88f9SBruce Richardson 	return -ENOENT;
50473c88f9SBruce Richardson }
51473c88f9SBruce Richardson 
port_get_revision(struct ifpga_port_hw * port,u64 * revision)52473c88f9SBruce Richardson static int port_get_revision(struct ifpga_port_hw *port, u64 *revision)
53473c88f9SBruce Richardson {
54473c88f9SBruce Richardson 	struct feature_port_header *port_hdr
55473c88f9SBruce Richardson 		= get_port_feature_ioaddr_by_index(port,
56473c88f9SBruce Richardson 						   PORT_FEATURE_ID_HEADER);
57473c88f9SBruce Richardson 	struct feature_header header;
58473c88f9SBruce Richardson 
59473c88f9SBruce Richardson 	header.csr = readq(&port_hdr->header);
60473c88f9SBruce Richardson 
61473c88f9SBruce Richardson 	*revision = header.revision;
62473c88f9SBruce Richardson 
63473c88f9SBruce Richardson 	return 0;
64473c88f9SBruce Richardson }
65473c88f9SBruce Richardson 
port_get_portidx(struct ifpga_port_hw * port,u64 * idx)66473c88f9SBruce Richardson static int port_get_portidx(struct ifpga_port_hw *port, u64 *idx)
67473c88f9SBruce Richardson {
68473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
69473c88f9SBruce Richardson 	struct feature_port_capability capability;
70473c88f9SBruce Richardson 
71473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
72473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
73473c88f9SBruce Richardson 
74473c88f9SBruce Richardson 	capability.csr = readq(&port_hdr->capability);
75473c88f9SBruce Richardson 	*idx = capability.port_number;
76473c88f9SBruce Richardson 
77473c88f9SBruce Richardson 	return 0;
78473c88f9SBruce Richardson }
79473c88f9SBruce Richardson 
port_get_latency_tolerance(struct ifpga_port_hw * port,u64 * val)80473c88f9SBruce Richardson static int port_get_latency_tolerance(struct ifpga_port_hw *port, u64 *val)
81473c88f9SBruce Richardson {
82473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
83473c88f9SBruce Richardson 	struct feature_port_control control;
84473c88f9SBruce Richardson 
85473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
86473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
87473c88f9SBruce Richardson 
88473c88f9SBruce Richardson 	control.csr = readq(&port_hdr->control);
89473c88f9SBruce Richardson 	*val = control.latency_tolerance;
90473c88f9SBruce Richardson 
91473c88f9SBruce Richardson 	return 0;
92473c88f9SBruce Richardson }
93473c88f9SBruce Richardson 
port_get_ap1_event(struct ifpga_port_hw * port,u64 * val)94473c88f9SBruce Richardson static int port_get_ap1_event(struct ifpga_port_hw *port, u64 *val)
95473c88f9SBruce Richardson {
96473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
97473c88f9SBruce Richardson 	struct feature_port_status status;
98473c88f9SBruce Richardson 
99473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
100473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
101473c88f9SBruce Richardson 
102473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
103473c88f9SBruce Richardson 	status.csr = readq(&port_hdr->status);
104473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
105473c88f9SBruce Richardson 
106473c88f9SBruce Richardson 	*val = status.ap1_event;
107473c88f9SBruce Richardson 
108473c88f9SBruce Richardson 	return 0;
109473c88f9SBruce Richardson }
110473c88f9SBruce Richardson 
port_set_ap1_event(struct ifpga_port_hw * port,u64 val)111473c88f9SBruce Richardson static int port_set_ap1_event(struct ifpga_port_hw *port, u64 val)
112473c88f9SBruce Richardson {
113473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
114473c88f9SBruce Richardson 	struct feature_port_status status;
115473c88f9SBruce Richardson 
116473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
117473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
118473c88f9SBruce Richardson 
119473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
120473c88f9SBruce Richardson 	status.csr = readq(&port_hdr->status);
121473c88f9SBruce Richardson 	status.ap1_event = val;
122473c88f9SBruce Richardson 	writeq(status.csr, &port_hdr->status);
123473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
124473c88f9SBruce Richardson 
125473c88f9SBruce Richardson 	return 0;
126473c88f9SBruce Richardson }
127473c88f9SBruce Richardson 
port_get_ap2_event(struct ifpga_port_hw * port,u64 * val)128473c88f9SBruce Richardson static int port_get_ap2_event(struct ifpga_port_hw *port, u64 *val)
129473c88f9SBruce Richardson {
130473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
131473c88f9SBruce Richardson 	struct feature_port_status status;
132473c88f9SBruce Richardson 
133473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
134473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
135473c88f9SBruce Richardson 
136473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
137473c88f9SBruce Richardson 	status.csr = readq(&port_hdr->status);
138473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
139473c88f9SBruce Richardson 
140473c88f9SBruce Richardson 	*val = status.ap2_event;
141473c88f9SBruce Richardson 
142473c88f9SBruce Richardson 	return 0;
143473c88f9SBruce Richardson }
144473c88f9SBruce Richardson 
port_set_ap2_event(struct ifpga_port_hw * port,u64 val)145473c88f9SBruce Richardson static int port_set_ap2_event(struct ifpga_port_hw *port, u64 val)
146473c88f9SBruce Richardson {
147473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
148473c88f9SBruce Richardson 	struct feature_port_status status;
149473c88f9SBruce Richardson 
150473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
151473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
152473c88f9SBruce Richardson 
153473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
154473c88f9SBruce Richardson 	status.csr = readq(&port_hdr->status);
155473c88f9SBruce Richardson 	status.ap2_event = val;
156473c88f9SBruce Richardson 	writeq(status.csr, &port_hdr->status);
157473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
158473c88f9SBruce Richardson 
159473c88f9SBruce Richardson 	return 0;
160473c88f9SBruce Richardson }
161473c88f9SBruce Richardson 
port_get_power_state(struct ifpga_port_hw * port,u64 * val)162473c88f9SBruce Richardson static int port_get_power_state(struct ifpga_port_hw *port, u64 *val)
163473c88f9SBruce Richardson {
164473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
165473c88f9SBruce Richardson 	struct feature_port_status status;
166473c88f9SBruce Richardson 
167473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
168473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
169473c88f9SBruce Richardson 
170473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
171473c88f9SBruce Richardson 	status.csr = readq(&port_hdr->status);
172473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
173473c88f9SBruce Richardson 
174473c88f9SBruce Richardson 	*val = status.power_state;
175473c88f9SBruce Richardson 
176473c88f9SBruce Richardson 	return 0;
177473c88f9SBruce Richardson }
178473c88f9SBruce Richardson 
port_get_userclk_freqcmd(struct ifpga_port_hw * port,u64 * val)179473c88f9SBruce Richardson static int port_get_userclk_freqcmd(struct ifpga_port_hw *port, u64 *val)
180473c88f9SBruce Richardson {
181473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
182473c88f9SBruce Richardson 
183473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
184473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
185473c88f9SBruce Richardson 
186473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
187473c88f9SBruce Richardson 	*val = readq(&port_hdr->user_clk_freq_cmd0);
188473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
189473c88f9SBruce Richardson 
190473c88f9SBruce Richardson 	return 0;
191473c88f9SBruce Richardson }
192473c88f9SBruce Richardson 
port_set_userclk_freqcmd(struct ifpga_port_hw * port,u64 val)193473c88f9SBruce Richardson static int port_set_userclk_freqcmd(struct ifpga_port_hw *port, u64 val)
194473c88f9SBruce Richardson {
195473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
196473c88f9SBruce Richardson 
197473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
198473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
199473c88f9SBruce Richardson 
200473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
201473c88f9SBruce Richardson 	writeq(val, &port_hdr->user_clk_freq_cmd0);
202473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
203473c88f9SBruce Richardson 
204473c88f9SBruce Richardson 	return 0;
205473c88f9SBruce Richardson }
206473c88f9SBruce Richardson 
port_get_userclk_freqcntrcmd(struct ifpga_port_hw * port,u64 * val)207473c88f9SBruce Richardson static int port_get_userclk_freqcntrcmd(struct ifpga_port_hw *port, u64 *val)
208473c88f9SBruce Richardson {
209473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
210473c88f9SBruce Richardson 
211473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
212473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
213473c88f9SBruce Richardson 
214473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
215473c88f9SBruce Richardson 	*val = readq(&port_hdr->user_clk_freq_cmd1);
216473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
217473c88f9SBruce Richardson 
218473c88f9SBruce Richardson 	return 0;
219473c88f9SBruce Richardson }
220473c88f9SBruce Richardson 
port_set_userclk_freqcntrcmd(struct ifpga_port_hw * port,u64 val)221473c88f9SBruce Richardson static int port_set_userclk_freqcntrcmd(struct ifpga_port_hw *port, u64 val)
222473c88f9SBruce Richardson {
223473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
224473c88f9SBruce Richardson 
225473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
226473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
227473c88f9SBruce Richardson 
228473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
229473c88f9SBruce Richardson 	writeq(val, &port_hdr->user_clk_freq_cmd1);
230473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
231473c88f9SBruce Richardson 
232473c88f9SBruce Richardson 	return 0;
233473c88f9SBruce Richardson }
234473c88f9SBruce Richardson 
port_get_userclk_freqsts(struct ifpga_port_hw * port,u64 * val)235473c88f9SBruce Richardson static int port_get_userclk_freqsts(struct ifpga_port_hw *port, u64 *val)
236473c88f9SBruce Richardson {
237473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
238473c88f9SBruce Richardson 
239473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
240473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
241473c88f9SBruce Richardson 
242473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
243473c88f9SBruce Richardson 	*val = readq(&port_hdr->user_clk_freq_sts0);
244473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
245473c88f9SBruce Richardson 
246473c88f9SBruce Richardson 	return 0;
247473c88f9SBruce Richardson }
248473c88f9SBruce Richardson 
port_get_userclk_freqcntrsts(struct ifpga_port_hw * port,u64 * val)249473c88f9SBruce Richardson static int port_get_userclk_freqcntrsts(struct ifpga_port_hw *port, u64 *val)
250473c88f9SBruce Richardson {
251473c88f9SBruce Richardson 	struct feature_port_header *port_hdr;
252473c88f9SBruce Richardson 
253473c88f9SBruce Richardson 	port_hdr = get_port_feature_ioaddr_by_index(port,
254473c88f9SBruce Richardson 						    PORT_FEATURE_ID_HEADER);
255473c88f9SBruce Richardson 
256473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
257473c88f9SBruce Richardson 	*val = readq(&port_hdr->user_clk_freq_sts1);
258473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
259473c88f9SBruce Richardson 
260473c88f9SBruce Richardson 	return 0;
261473c88f9SBruce Richardson }
262473c88f9SBruce Richardson 
port_hdr_init(struct ifpga_feature * feature)263473c88f9SBruce Richardson static int port_hdr_init(struct ifpga_feature *feature)
264473c88f9SBruce Richardson {
265473c88f9SBruce Richardson 	struct ifpga_port_hw *port = feature->parent;
266473c88f9SBruce Richardson 
267473c88f9SBruce Richardson 	dev_info(NULL, "port hdr Init.\n");
268473c88f9SBruce Richardson 
269473c88f9SBruce Richardson 	fpga_port_reset(port);
270473c88f9SBruce Richardson 
271473c88f9SBruce Richardson 	return 0;
272473c88f9SBruce Richardson }
273473c88f9SBruce Richardson 
port_hdr_uinit(struct ifpga_feature * feature)274473c88f9SBruce Richardson static void port_hdr_uinit(struct ifpga_feature *feature)
275473c88f9SBruce Richardson {
276473c88f9SBruce Richardson 	UNUSED(feature);
277473c88f9SBruce Richardson 
278473c88f9SBruce Richardson 	dev_info(NULL, "port hdr uinit.\n");
279473c88f9SBruce Richardson }
280473c88f9SBruce Richardson 
port_hdr_get_prop(struct ifpga_feature * feature,struct feature_prop * prop)281473c88f9SBruce Richardson static int port_hdr_get_prop(struct ifpga_feature *feature,
282473c88f9SBruce Richardson 		struct feature_prop *prop)
283473c88f9SBruce Richardson {
284473c88f9SBruce Richardson 	struct ifpga_port_hw *port = feature->parent;
285473c88f9SBruce Richardson 
286473c88f9SBruce Richardson 	switch (prop->prop_id) {
287473c88f9SBruce Richardson 	case PORT_HDR_PROP_REVISION:
288473c88f9SBruce Richardson 		return port_get_revision(port, &prop->data);
289473c88f9SBruce Richardson 	case PORT_HDR_PROP_PORTIDX:
290473c88f9SBruce Richardson 		return port_get_portidx(port, &prop->data);
291473c88f9SBruce Richardson 	case PORT_HDR_PROP_LATENCY_TOLERANCE:
292473c88f9SBruce Richardson 		return port_get_latency_tolerance(port, &prop->data);
293473c88f9SBruce Richardson 	case PORT_HDR_PROP_AP1_EVENT:
294473c88f9SBruce Richardson 		return port_get_ap1_event(port, &prop->data);
295473c88f9SBruce Richardson 	case PORT_HDR_PROP_AP2_EVENT:
296473c88f9SBruce Richardson 		return port_get_ap2_event(port, &prop->data);
297473c88f9SBruce Richardson 	case PORT_HDR_PROP_POWER_STATE:
298473c88f9SBruce Richardson 		return port_get_power_state(port, &prop->data);
299473c88f9SBruce Richardson 	case PORT_HDR_PROP_USERCLK_FREQCMD:
300473c88f9SBruce Richardson 		return port_get_userclk_freqcmd(port, &prop->data);
301473c88f9SBruce Richardson 	case PORT_HDR_PROP_USERCLK_FREQCNTRCMD:
302473c88f9SBruce Richardson 		return port_get_userclk_freqcntrcmd(port, &prop->data);
303473c88f9SBruce Richardson 	case PORT_HDR_PROP_USERCLK_FREQSTS:
304473c88f9SBruce Richardson 		return port_get_userclk_freqsts(port, &prop->data);
305473c88f9SBruce Richardson 	case PORT_HDR_PROP_USERCLK_CNTRSTS:
306473c88f9SBruce Richardson 		return port_get_userclk_freqcntrsts(port, &prop->data);
307473c88f9SBruce Richardson 	}
308473c88f9SBruce Richardson 
309473c88f9SBruce Richardson 	return -ENOENT;
310473c88f9SBruce Richardson }
311473c88f9SBruce Richardson 
port_hdr_set_prop(struct ifpga_feature * feature,struct feature_prop * prop)312473c88f9SBruce Richardson static int port_hdr_set_prop(struct ifpga_feature *feature,
313473c88f9SBruce Richardson 		struct feature_prop *prop)
314473c88f9SBruce Richardson {
315473c88f9SBruce Richardson 	struct ifpga_port_hw *port = feature->parent;
316473c88f9SBruce Richardson 
317473c88f9SBruce Richardson 	switch (prop->prop_id) {
318473c88f9SBruce Richardson 	case PORT_HDR_PROP_AP1_EVENT:
319473c88f9SBruce Richardson 		return port_set_ap1_event(port, prop->data);
320473c88f9SBruce Richardson 	case PORT_HDR_PROP_AP2_EVENT:
321473c88f9SBruce Richardson 		return port_set_ap2_event(port, prop->data);
322473c88f9SBruce Richardson 	case PORT_HDR_PROP_USERCLK_FREQCMD:
323473c88f9SBruce Richardson 		return port_set_userclk_freqcmd(port, prop->data);
324473c88f9SBruce Richardson 	case PORT_HDR_PROP_USERCLK_FREQCNTRCMD:
325473c88f9SBruce Richardson 		return port_set_userclk_freqcntrcmd(port, prop->data);
326473c88f9SBruce Richardson 	}
327473c88f9SBruce Richardson 
328473c88f9SBruce Richardson 	return -ENOENT;
329473c88f9SBruce Richardson }
330473c88f9SBruce Richardson 
331473c88f9SBruce Richardson struct ifpga_feature_ops ifpga_rawdev_port_hdr_ops = {
332473c88f9SBruce Richardson 	.init = port_hdr_init,
333473c88f9SBruce Richardson 	.uinit = port_hdr_uinit,
334473c88f9SBruce Richardson 	.get_prop = port_hdr_get_prop,
335473c88f9SBruce Richardson 	.set_prop = port_hdr_set_prop,
336473c88f9SBruce Richardson };
337473c88f9SBruce Richardson 
port_stp_init(struct ifpga_feature * feature)338473c88f9SBruce Richardson static int port_stp_init(struct ifpga_feature *feature)
339473c88f9SBruce Richardson {
340473c88f9SBruce Richardson 	struct ifpga_port_hw *port = feature->parent;
341473c88f9SBruce Richardson 
342473c88f9SBruce Richardson 	dev_info(NULL, "port stp Init.\n");
343473c88f9SBruce Richardson 
344473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
345473c88f9SBruce Richardson 	port->stp_addr = feature->addr;
346473c88f9SBruce Richardson 	port->stp_size = feature->size;
347473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
348473c88f9SBruce Richardson 
349473c88f9SBruce Richardson 	return 0;
350473c88f9SBruce Richardson }
351473c88f9SBruce Richardson 
port_stp_uinit(struct ifpga_feature * feature)352473c88f9SBruce Richardson static void port_stp_uinit(struct ifpga_feature *feature)
353473c88f9SBruce Richardson {
354473c88f9SBruce Richardson 	UNUSED(feature);
355473c88f9SBruce Richardson 
356473c88f9SBruce Richardson 	dev_info(NULL, "port stp uinit.\n");
357473c88f9SBruce Richardson }
358473c88f9SBruce Richardson 
359473c88f9SBruce Richardson struct ifpga_feature_ops ifpga_rawdev_port_stp_ops = {
360473c88f9SBruce Richardson 	.init = port_stp_init,
361473c88f9SBruce Richardson 	.uinit = port_stp_uinit,
362473c88f9SBruce Richardson };
363473c88f9SBruce Richardson 
port_uint_init(struct ifpga_feature * feature)364473c88f9SBruce Richardson static int port_uint_init(struct ifpga_feature *feature)
365473c88f9SBruce Richardson {
366473c88f9SBruce Richardson 	struct ifpga_port_hw *port = feature->parent;
367473c88f9SBruce Richardson 
368473c88f9SBruce Richardson 	dev_info(NULL, "PORT UINT Init.\n");
369473c88f9SBruce Richardson 
370473c88f9SBruce Richardson 	spinlock_lock(&port->lock);
371473c88f9SBruce Richardson 	if (feature->ctx_num) {
372473c88f9SBruce Richardson 		port->capability |= FPGA_PORT_CAP_UAFU_IRQ;
373473c88f9SBruce Richardson 		port->num_uafu_irqs = feature->ctx_num;
374473c88f9SBruce Richardson 	}
375473c88f9SBruce Richardson 	spinlock_unlock(&port->lock);
376473c88f9SBruce Richardson 
377473c88f9SBruce Richardson 	return 0;
378473c88f9SBruce Richardson }
379473c88f9SBruce Richardson 
port_uint_uinit(struct ifpga_feature * feature)380473c88f9SBruce Richardson static void port_uint_uinit(struct ifpga_feature *feature)
381473c88f9SBruce Richardson {
382473c88f9SBruce Richardson 	UNUSED(feature);
383473c88f9SBruce Richardson 
384473c88f9SBruce Richardson 	dev_info(NULL, "PORT UINT UInit.\n");
385473c88f9SBruce Richardson }
386473c88f9SBruce Richardson 
port_uint_set_irq(struct ifpga_feature * feature,void * irq_set)387*9bf03321STianfei Zhang static int port_uint_set_irq(struct ifpga_feature *feature, void *irq_set)
388*9bf03321STianfei Zhang {
389*9bf03321STianfei Zhang 	struct fpga_uafu_irq_set *uafu_irq_set = irq_set;
390*9bf03321STianfei Zhang 	struct ifpga_port_hw *port = feature->parent;
391*9bf03321STianfei Zhang 	int ret;
392*9bf03321STianfei Zhang 
393*9bf03321STianfei Zhang 	if (!(port->capability & FPGA_PORT_CAP_UAFU_IRQ))
394*9bf03321STianfei Zhang 		return -ENODEV;
395*9bf03321STianfei Zhang 
396*9bf03321STianfei Zhang 	spinlock_lock(&port->lock);
397*9bf03321STianfei Zhang 	ret = fpga_msix_set_block(feature, uafu_irq_set->start,
398*9bf03321STianfei Zhang 				  uafu_irq_set->count, uafu_irq_set->evtfds);
399*9bf03321STianfei Zhang 	spinlock_unlock(&port->lock);
400*9bf03321STianfei Zhang 
401*9bf03321STianfei Zhang 	return ret;
402*9bf03321STianfei Zhang }
403*9bf03321STianfei Zhang 
404473c88f9SBruce Richardson struct ifpga_feature_ops ifpga_rawdev_port_uint_ops = {
405473c88f9SBruce Richardson 	.init = port_uint_init,
406473c88f9SBruce Richardson 	.uinit = port_uint_uinit,
407*9bf03321STianfei Zhang 	.set_irq = port_uint_set_irq,
408473c88f9SBruce Richardson };
409473c88f9SBruce Richardson 
port_afu_init(struct ifpga_feature * feature)410473c88f9SBruce Richardson static int port_afu_init(struct ifpga_feature *feature)
411473c88f9SBruce Richardson {
412473c88f9SBruce Richardson 	UNUSED(feature);
413473c88f9SBruce Richardson 
414473c88f9SBruce Richardson 	dev_info(NULL, "PORT AFU Init.\n");
415473c88f9SBruce Richardson 
416473c88f9SBruce Richardson 	return 0;
417473c88f9SBruce Richardson }
418473c88f9SBruce Richardson 
port_afu_uinit(struct ifpga_feature * feature)419473c88f9SBruce Richardson static void port_afu_uinit(struct ifpga_feature *feature)
420473c88f9SBruce Richardson {
421473c88f9SBruce Richardson 	UNUSED(feature);
422473c88f9SBruce Richardson 
423473c88f9SBruce Richardson 	dev_info(NULL, "PORT AFU UInit.\n");
424473c88f9SBruce Richardson }
425473c88f9SBruce Richardson 
426473c88f9SBruce Richardson struct ifpga_feature_ops ifpga_rawdev_port_afu_ops = {
427473c88f9SBruce Richardson 	.init = port_afu_init,
428473c88f9SBruce Richardson 	.uinit = port_afu_uinit,
429473c88f9SBruce Richardson };
430