cdx: add device attributes

Create sysfs entry for CDX devices.

Sysfs entries provided in each of the CDX device detected by
the CDX controller
 - vendor id
 - device id
 - remove
 - reset of the device.
 - driver override

Signed-off-by: Puneet Gupta <puneet.gupta@amd.com>
Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>
Signed-off-by: Tarak Reddy <tarak.reddy@amd.com>
Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
Tested-by: Nikhil Agarwal <nikhil.agarwal@amd.com>
Link: https://lore.kernel.org/r/20230313132636.31850-8-nipun.gupta@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Nipun Gupta
2023-03-13 18:56:36 +05:30
committed by Greg Kroah-Hartman
parent 2a226927d9
commit 48a6c7bced
6 changed files with 241 additions and 0 deletions

View File

@@ -21,8 +21,20 @@
/* Forward declaration for CDX controller */
struct cdx_controller;
enum {
CDX_DEV_RESET_CONF,
};
struct cdx_device_config {
u8 type;
};
typedef int (*cdx_scan_cb)(struct cdx_controller *cdx);
typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx,
u8 bus_num, u8 dev_num,
struct cdx_device_config *dev_config);
/**
* CDX_DEVICE_DRIVER_OVERRIDE - macro used to describe a CDX device with
* override_only flags.
@@ -39,9 +51,12 @@ typedef int (*cdx_scan_cb)(struct cdx_controller *cdx);
/**
* struct cdx_ops - Callbacks supported by CDX controller.
* @scan: scan the devices on the controller
* @dev_configure: configuration like reset, master_enable,
* msi_config etc for a CDX device
*/
struct cdx_ops {
cdx_scan_cb scan;
cdx_dev_configure_cb dev_configure;
};
/**
@@ -101,6 +116,8 @@ struct cdx_device {
* @probe: Function called when a device is added
* @remove: Function called when a device is removed
* @shutdown: Function called at shutdown time to quiesce the device
* @reset_prepare: Function called before is reset to notify driver
* @reset_done: Function called after reset is complete to notify driver
* @driver_managed_dma: Device driver doesn't use kernel DMA API for DMA.
* For most device drivers, no need to care about this flag
* as long as all DMAs are handled through the kernel DMA API.
@@ -115,6 +132,8 @@ struct cdx_driver {
int (*probe)(struct cdx_device *dev);
int (*remove)(struct cdx_device *dev);
void (*shutdown)(struct cdx_device *dev);
void (*reset_prepare)(struct cdx_device *dev);
void (*reset_done)(struct cdx_device *dev);
bool driver_managed_dma;
};
@@ -144,4 +163,12 @@ void cdx_driver_unregister(struct cdx_driver *cdx_driver);
extern struct bus_type cdx_bus_type;
/**
* cdx_dev_reset - Reset CDX device
* @dev: device pointer
*
* Return: 0 for success, -errno on failure
*/
int cdx_dev_reset(struct device *dev);
#endif /* _CDX_BUS_H_ */