xref: /linux/drivers/cdx/cdx.h (revision f9bff0e31881d03badf191d3b0005839391f5f2b)
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * Header file for the CDX Bus
4  *
5  * Copyright (C) 2022-2023, Advanced Micro Devices, Inc.
6  */
7 
8 #ifndef _CDX_H_
9 #define _CDX_H_
10 
11 #include <linux/cdx/cdx_bus.h>
12 
13 /**
14  * struct cdx_dev_params - CDX device parameters
15  * @cdx: CDX controller associated with the device
16  * @parent: Associated CDX controller
17  * @vendor: Vendor ID for CDX device
18  * @device: Device ID for CDX device
19  * @bus_num: Bus number for this CDX device
20  * @dev_num: Device number for this device
21  * @res: array of MMIO region entries
22  * @res_count: number of valid MMIO regions
23  * @req_id: Requestor ID associated with CDX device
24  */
25 struct cdx_dev_params {
26 	struct cdx_controller *cdx;
27 	u16 vendor;
28 	u16 device;
29 	u8 bus_num;
30 	u8 dev_num;
31 	struct resource res[MAX_CDX_DEV_RESOURCES];
32 	u8 res_count;
33 	u32 req_id;
34 };
35 
36 /**
37  * cdx_register_controller - Register a CDX controller and its ports
38  *		on the CDX bus.
39  * @cdx: The CDX controller to register
40  *
41  * Return: -errno on failure, 0 on success.
42  */
43 int cdx_register_controller(struct cdx_controller *cdx);
44 
45 /**
46  * cdx_unregister_controller - Unregister a CDX controller
47  * @cdx: The CDX controller to unregister
48  */
49 void cdx_unregister_controller(struct cdx_controller *cdx);
50 
51 /**
52  * cdx_device_add - Add a CDX device. This function adds a CDX device
53  *		on the CDX bus as per the device parameters provided
54  *		by caller. It also creates and registers an associated
55  *		Linux generic device.
56  * @dev_params: device parameters associated with the device to be created.
57  *
58  * Return: -errno on failure, 0 on success.
59  */
60 int cdx_device_add(struct cdx_dev_params *dev_params);
61 
62 #endif /* _CDX_H_ */
63