summaryrefslogtreecommitdiff
path: root/drivers/cdx/cdx.h
blob: c436ac7ac86f8b9460cfc25ce09d6e621a65721b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* SPDX-License-Identifier: GPL-2.0
 *
 * Header file for the CDX Bus
 *
 * Copyright (C) 2022-2023, Advanced Micro Devices, Inc.
 */

#ifndef _CDX_H_
#define _CDX_H_

#include <linux/cdx/cdx_bus.h>

/**
 * struct cdx_dev_params - CDX device parameters
 * @cdx: CDX controller associated with the device
 * @parent: Associated CDX controller
 * @vendor: Vendor ID for CDX device
 * @device: Device ID for CDX device
 * @bus_num: Bus number for this CDX device
 * @dev_num: Device number for this device
 * @res: array of MMIO region entries
 * @res_count: number of valid MMIO regions
 * @req_id: Requestor ID associated with CDX device
 */
struct cdx_dev_params {
	struct cdx_controller *cdx;
	u16 vendor;
	u16 device;
	u8 bus_num;
	u8 dev_num;
	struct resource res[MAX_CDX_DEV_RESOURCES];
	u8 res_count;
	u32 req_id;
};

/**
 * cdx_register_controller - Register a CDX controller and its ports
 *		on the CDX bus.
 * @cdx: The CDX controller to register
 *
 * Return: -errno on failure, 0 on success.
 */
int cdx_register_controller(struct cdx_controller *cdx);

/**
 * cdx_unregister_controller - Unregister a CDX controller
 * @cdx: The CDX controller to unregister
 */
void cdx_unregister_controller(struct cdx_controller *cdx);

/**
 * cdx_device_add - Add a CDX device. This function adds a CDX device
 *		on the CDX bus as per the device parameters provided
 *		by caller. It also creates and registers an associated
 *		Linux generic device.
 * @dev_params: device parameters associated with the device to be created.
 *
 * Return: -errno on failure, 0 on success.
 */
int cdx_device_add(struct cdx_dev_params *dev_params);

#endif /* _CDX_H_ */