18a7923dfSNipun Gupta /* SPDX-License-Identifier: GPL-2.0 28a7923dfSNipun Gupta * 38a7923dfSNipun Gupta * Header file for MCDI FW interaction for CDX bus. 48a7923dfSNipun Gupta * 58a7923dfSNipun Gupta * Copyright (C) 2022-2023, Advanced Micro Devices, Inc. 68a7923dfSNipun Gupta */ 78a7923dfSNipun Gupta 88a7923dfSNipun Gupta #ifndef CDX_MCDI_FUNCTIONS_H 98a7923dfSNipun Gupta #define CDX_MCDI_FUNCTIONS_H 108a7923dfSNipun Gupta 118a7923dfSNipun Gupta #include "mcdi.h" 128a7923dfSNipun Gupta #include "../cdx.h" 138a7923dfSNipun Gupta 148a7923dfSNipun Gupta /** 158a7923dfSNipun Gupta * cdx_mcdi_get_num_buses - Get the total number of buses on 168a7923dfSNipun Gupta * the controller. 178a7923dfSNipun Gupta * @cdx: pointer to MCDI interface. 188a7923dfSNipun Gupta * 198a7923dfSNipun Gupta * Return: total number of buses available on the controller, 208a7923dfSNipun Gupta * <0 on failure 218a7923dfSNipun Gupta */ 228a7923dfSNipun Gupta int cdx_mcdi_get_num_buses(struct cdx_mcdi *cdx); 238a7923dfSNipun Gupta 248a7923dfSNipun Gupta /** 258a7923dfSNipun Gupta * cdx_mcdi_get_num_devs - Get the total number of devices on 268a7923dfSNipun Gupta * a particular bus of the controller. 278a7923dfSNipun Gupta * @cdx: pointer to MCDI interface. 288a7923dfSNipun Gupta * @bus_num: Bus number. 298a7923dfSNipun Gupta * 308a7923dfSNipun Gupta * Return: total number of devices available on the bus, <0 on failure 318a7923dfSNipun Gupta */ 328a7923dfSNipun Gupta int cdx_mcdi_get_num_devs(struct cdx_mcdi *cdx, int bus_num); 338a7923dfSNipun Gupta 348a7923dfSNipun Gupta /** 358a7923dfSNipun Gupta * cdx_mcdi_get_dev_config - Get configuration for a particular 368a7923dfSNipun Gupta * bus_num:dev_num 378a7923dfSNipun Gupta * @cdx: pointer to MCDI interface. 388a7923dfSNipun Gupta * @bus_num: Bus number. 398a7923dfSNipun Gupta * @dev_num: Device number. 408a7923dfSNipun Gupta * @dev_params: Pointer to cdx_dev_params, this is populated by this 418a7923dfSNipun Gupta * device with the configuration corresponding to the provided 428a7923dfSNipun Gupta * bus_num:dev_num. 438a7923dfSNipun Gupta * 448a7923dfSNipun Gupta * Return: 0 total number of devices available on the bus, <0 on failure 458a7923dfSNipun Gupta */ 468a7923dfSNipun Gupta int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx, 478a7923dfSNipun Gupta u8 bus_num, u8 dev_num, 488a7923dfSNipun Gupta struct cdx_dev_params *dev_params); 498a7923dfSNipun Gupta 5048a6c7bcSNipun Gupta /** 51e3cfd49cSAbhijit Gangurde * cdx_mcdi_bus_enable - Enable CDX bus represented by bus_num 52e3cfd49cSAbhijit Gangurde * @cdx: pointer to MCDI interface. 53e3cfd49cSAbhijit Gangurde * @bus_num: Bus number. 54e3cfd49cSAbhijit Gangurde * 55e3cfd49cSAbhijit Gangurde * Return: 0 on success, <0 on failure 56e3cfd49cSAbhijit Gangurde */ 57e3cfd49cSAbhijit Gangurde int cdx_mcdi_bus_enable(struct cdx_mcdi *cdx, u8 bus_num); 58e3cfd49cSAbhijit Gangurde 59e3cfd49cSAbhijit Gangurde /** 60e3cfd49cSAbhijit Gangurde * cdx_mcdi_bus_disable - Disable CDX bus represented by bus_num 61e3cfd49cSAbhijit Gangurde * @cdx: pointer to MCDI interface. 62e3cfd49cSAbhijit Gangurde * @bus_num: Bus number. 63e3cfd49cSAbhijit Gangurde * 64e3cfd49cSAbhijit Gangurde * Return: 0 on success, <0 on failure 65e3cfd49cSAbhijit Gangurde */ 66e3cfd49cSAbhijit Gangurde int cdx_mcdi_bus_disable(struct cdx_mcdi *cdx, u8 bus_num); 67e3cfd49cSAbhijit Gangurde 68e3cfd49cSAbhijit Gangurde /** 69*0e439ba3SNipun Gupta * cdx_mcdi_write_msi - Write MSI configuration for CDX device 70*0e439ba3SNipun Gupta * @cdx: pointer to MCDI interface. 71*0e439ba3SNipun Gupta * @bus_num: Bus number. 72*0e439ba3SNipun Gupta * @dev_num: Device number. 73*0e439ba3SNipun Gupta * @msi_vector: Device-relative MSI vector number. 74*0e439ba3SNipun Gupta * Must be < MSI_COUNT reported for the device. 75*0e439ba3SNipun Gupta * @msi_address: MSI address to be used by the hardware. Typically, on ARM 76*0e439ba3SNipun Gupta * systems this address is translated by the IOMMU (if enabled) and 77*0e439ba3SNipun Gupta * it is the responsibility of the entity managing the IOMMU (APU kernel) 78*0e439ba3SNipun Gupta * to supply the correct IOVA here. 79*0e439ba3SNipun Gupta * @msi_data: MSI data to be used by the hardware. On versal-net, only the 80*0e439ba3SNipun Gupta * lower 16-bits are used, the remaining bits are ignored and should be 81*0e439ba3SNipun Gupta * set to zero. 82*0e439ba3SNipun Gupta * 83*0e439ba3SNipun Gupta * Return: 0 on success, <0 on failure 84*0e439ba3SNipun Gupta */ 85*0e439ba3SNipun Gupta int cdx_mcdi_write_msi(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num, 86*0e439ba3SNipun Gupta u32 msi_vector, u64 msi_address, u32 msi_data); 87*0e439ba3SNipun Gupta 88*0e439ba3SNipun Gupta /** 8948a6c7bcSNipun Gupta * cdx_mcdi_reset_device - Reset cdx device represented by bus_num:dev_num 9048a6c7bcSNipun Gupta * @cdx: pointer to MCDI interface. 9148a6c7bcSNipun Gupta * @bus_num: Bus number. 9248a6c7bcSNipun Gupta * @dev_num: Device number. 9348a6c7bcSNipun Gupta * 9448a6c7bcSNipun Gupta * Return: 0 on success, <0 on failure 9548a6c7bcSNipun Gupta */ 9648a6c7bcSNipun Gupta int cdx_mcdi_reset_device(struct cdx_mcdi *cdx, 9748a6c7bcSNipun Gupta u8 bus_num, u8 dev_num); 9848a6c7bcSNipun Gupta 99a941b784SNipun Gupta /** 100a941b784SNipun Gupta * cdx_mcdi_bus_master_enable - Set/Reset bus mastering for cdx device 101a941b784SNipun Gupta * represented by bus_num:dev_num 102a941b784SNipun Gupta * @cdx: pointer to MCDI interface. 103a941b784SNipun Gupta * @bus_num: Bus number. 104a941b784SNipun Gupta * @dev_num: Device number. 105a941b784SNipun Gupta * @enable: Enable bus mastering if set, disable otherwise. 106a941b784SNipun Gupta * 107a941b784SNipun Gupta * Return: 0 on success, <0 on failure 108a941b784SNipun Gupta */ 109a941b784SNipun Gupta int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num, 110a941b784SNipun Gupta u8 dev_num, bool enable); 111a941b784SNipun Gupta 112*0e439ba3SNipun Gupta /** 113*0e439ba3SNipun Gupta * cdx_mcdi_msi_enable - Enable/Disable MSIs for cdx device represented 114*0e439ba3SNipun Gupta * by bus_num:dev_num 115*0e439ba3SNipun Gupta * @cdx: pointer to MCDI interface. 116*0e439ba3SNipun Gupta * @bus_num: Bus number. 117*0e439ba3SNipun Gupta * @dev_num: Device number. 118*0e439ba3SNipun Gupta * @enable: Enable msi's if set, disable otherwise. 119*0e439ba3SNipun Gupta * 120*0e439ba3SNipun Gupta * Return: 0 on success, <0 on failure 121*0e439ba3SNipun Gupta */ 122*0e439ba3SNipun Gupta int cdx_mcdi_msi_enable(struct cdx_mcdi *cdx, u8 bus_num, 123*0e439ba3SNipun Gupta u8 dev_num, bool enable); 124*0e439ba3SNipun Gupta 1258a7923dfSNipun Gupta #endif /* CDX_MCDI_FUNCTIONS_H */ 126