Merge tag 'net-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-block.git] / drivers / cdx / cdx.h
CommitLineData
2959ab24
NG
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
ce558a39 16 * @parent: Associated CDX Bus device
2959ab24
NG
17 * @vendor: Vendor ID for CDX device
18 * @device: Device ID for CDX device
fa10f413
AG
19 * @subsys_vendor: Sub vendor ID for CDX device
20 * @subsys_device: Sub device ID for CDX device
2959ab24
NG
21 * @bus_num: Bus number for this CDX device
22 * @dev_num: Device number for this device
23 * @res: array of MMIO region entries
24 * @res_count: number of valid MMIO regions
25 * @req_id: Requestor ID associated with CDX device
fa10f413
AG
26 * @class: Class of the CDX Device
27 * @revision: Revision of the CDX device
2959ab24
NG
28 */
29struct cdx_dev_params {
30 struct cdx_controller *cdx;
ce558a39 31 struct device *parent;
2959ab24
NG
32 u16 vendor;
33 u16 device;
fa10f413
AG
34 u16 subsys_vendor;
35 u16 subsys_device;
2959ab24
NG
36 u8 bus_num;
37 u8 dev_num;
38 struct resource res[MAX_CDX_DEV_RESOURCES];
39 u8 res_count;
40 u32 req_id;
fa10f413
AG
41 u32 class;
42 u8 revision;
2959ab24
NG
43};
44
45/**
46 * cdx_register_controller - Register a CDX controller and its ports
47 * on the CDX bus.
48 * @cdx: The CDX controller to register
49 *
50 * Return: -errno on failure, 0 on success.
51 */
52int cdx_register_controller(struct cdx_controller *cdx);
53
54/**
55 * cdx_unregister_controller - Unregister a CDX controller
56 * @cdx: The CDX controller to unregister
57 */
58void cdx_unregister_controller(struct cdx_controller *cdx);
59
60/**
61 * cdx_device_add - Add a CDX device. This function adds a CDX device
62 * on the CDX bus as per the device parameters provided
63 * by caller. It also creates and registers an associated
64 * Linux generic device.
65 * @dev_params: device parameters associated with the device to be created.
66 *
67 * Return: -errno on failure, 0 on success.
68 */
69int cdx_device_add(struct cdx_dev_params *dev_params);
70
ce558a39
AG
71/**
72 * cdx_bus_add - Add a CDX bus. This function adds a bus on the CDX bus
73 * subsystem. It creates a CDX device for the corresponding bus and
74 * also registers an associated Linux generic device.
75 * @cdx: Associated CDX controller
76 * @us_num: Bus number
77 *
78 * Return: associated Linux generic device pointer on success or NULL on failure.
79 */
80struct device *cdx_bus_add(struct cdx_controller *cdx, u8 bus_num);
81
2959ab24 82#endif /* _CDX_H_ */