xref: /linux/drivers/cdx/controller/mcdi_functions.h (revision 07fdad3a93756b872da7b53647715c48d0f4a2d0)
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * Header file for MCDI FW interaction for CDX bus.
4  *
5  * Copyright (C) 2022-2023, Advanced Micro Devices, Inc.
6  */
7 
8 #ifndef CDX_MCDI_FUNCTIONS_H
9 #define CDX_MCDI_FUNCTIONS_H
10 
11 #include <linux/cdx/mcdi.h>
12 #include "mcdid.h"
13 #include "../cdx.h"
14 
15 /**
16  * cdx_mcdi_get_num_buses - Get the total number of buses on
17  *	the controller.
18  * @cdx: pointer to MCDI interface.
19  *
20  * Return: total number of buses available on the controller,
21  *	<0 on failure
22  */
23 int cdx_mcdi_get_num_buses(struct cdx_mcdi *cdx);
24 
25 /**
26  * cdx_mcdi_get_num_devs - Get the total number of devices on
27  *	a particular bus of the controller.
28  * @cdx: pointer to MCDI interface.
29  * @bus_num: Bus number.
30  *
31  * Return: total number of devices available on the bus, <0 on failure
32  */
33 int cdx_mcdi_get_num_devs(struct cdx_mcdi *cdx, int bus_num);
34 
35 /**
36  * cdx_mcdi_get_dev_config - Get configuration for a particular
37  *	bus_num:dev_num
38  * @cdx: pointer to MCDI interface.
39  * @bus_num: Bus number.
40  * @dev_num: Device number.
41  * @dev_params: Pointer to cdx_dev_params, this is populated by this
42  *	device with the configuration corresponding to the provided
43  *	bus_num:dev_num.
44  *
45  * Return: 0 total number of devices available on the bus, <0 on failure
46  */
47 int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
48 			    u8 bus_num, u8 dev_num,
49 			    struct cdx_dev_params *dev_params);
50 
51 /**
52  * cdx_mcdi_bus_enable - Enable CDX bus represented by bus_num
53  * @cdx: pointer to MCDI interface.
54  * @bus_num: Bus number.
55  *
56  * Return: 0 on success, <0 on failure
57  */
58 int cdx_mcdi_bus_enable(struct cdx_mcdi *cdx, u8 bus_num);
59 
60 /**
61  * cdx_mcdi_bus_disable - Disable CDX bus represented by bus_num
62  * @cdx: pointer to MCDI interface.
63  * @bus_num: Bus number.
64  *
65  * Return: 0 on success, <0 on failure
66  */
67 int cdx_mcdi_bus_disable(struct cdx_mcdi *cdx, u8 bus_num);
68 
69 /**
70  * cdx_mcdi_write_msi - Write MSI configuration for CDX device
71  * @cdx: pointer to MCDI interface.
72  * @bus_num: Bus number.
73  * @dev_num: Device number.
74  * @msi_vector: Device-relative MSI vector number.
75  *	Must be < MSI_COUNT reported for the device.
76  * @msi_address: MSI address to be used by the hardware. Typically, on ARM
77  *	systems this address is translated by the IOMMU (if enabled) and
78  *	it is the responsibility of the entity managing the IOMMU (APU kernel)
79  *	to supply the correct IOVA here.
80  * @msi_data: MSI data to be used by the hardware. On versal-net, only the
81  *	lower 16-bits are used, the remaining bits are ignored and should be
82  *	set to zero.
83  *
84  * Return: 0 on success, <0 on failure
85  */
86 int cdx_mcdi_write_msi(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num,
87 		       u32 msi_vector, u64 msi_address, u32 msi_data);
88 
89 /**
90  * cdx_mcdi_reset_device - Reset cdx device represented by bus_num:dev_num
91  * @cdx: pointer to MCDI interface.
92  * @bus_num: Bus number.
93  * @dev_num: Device number.
94  *
95  * Return: 0 on success, <0 on failure
96  */
97 int cdx_mcdi_reset_device(struct cdx_mcdi *cdx,
98 			  u8 bus_num, u8 dev_num);
99 
100 /**
101  * cdx_mcdi_bus_master_enable - Set/Reset bus mastering for cdx device
102  *				represented by bus_num:dev_num
103  * @cdx: pointer to MCDI interface.
104  * @bus_num: Bus number.
105  * @dev_num: Device number.
106  * @enable: Enable bus mastering if set, disable otherwise.
107  *
108  * Return: 0 on success, <0 on failure
109  */
110 int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num,
111 			       u8 dev_num, bool enable);
112 
113 /**
114  * cdx_mcdi_msi_enable - Enable/Disable MSIs for cdx device represented
115  *			 by bus_num:dev_num
116  * @cdx: pointer to MCDI interface.
117  * @bus_num: Bus number.
118  * @dev_num: Device number.
119  * @enable: Enable msi's if set, disable otherwise.
120  *
121  * Return: 0 on success, <0 on failure
122  */
123 int cdx_mcdi_msi_enable(struct cdx_mcdi *cdx, u8 bus_num,
124 			u8 dev_num, bool enable);
125 
126 #endif /* CDX_MCDI_FUNCTIONS_H */
127