XilinxProcessorIPLib/drivers/aiengine/src/lib/ext/xaieio.c
void XAieIO_Init(void)
{
	struct metal_init_params init_param = METAL_INIT_DEFAULTS;
	int ret;

	if (IOInst.RefCnt) {
		IOInst.RefCnt++;
		return;
	}

	ret = metal_init(&init_param);
	if (ret) {
		XAieLib_print("failed to metal_init %d\n", ret);
		return;
	}

	ret = metal_device_open("platform", "xilinx-aiengine",
			&IOInst.device);
	if (ret) {
		XAieLib_print("failed to metal_device_open\n");
		return;
	}

	IOInst.io = metal_device_io_region(IOInst.device, 0);
	if (!IOInst.io) {
		XAieLib_print("failed to metal_device_io_region\n");
		return;
	}
	IOInst.io_base = metal_io_phys(IOInst.io, 0);
	IOInst.RefCnt++;

	ret = metal_device_open("platform", "f70a0000.aie-npi", &IOInst.npi);
	if (ret) {
		return;
	}

	IOInst.npi_io = metal_device_io_region(IOInst.npi, 0);
	if (!IOInst.npi_io) {
		return;
	}
	IOInst.npi_io_base = metal_io_phys(IOInst.npi_io, 0);
	XAieLib_print("AIE NPI space is mapped\n");
}
/*****************************************************************************/
/**
*
* This is the memory IO function to initialize the global IO instance
*
* @param	None.
*
* @return	None.
*
* @note		The global IO instance is a singleton and any further attempt
* to initialize just increments the reference count.
*
*******************************************************************************/
This is the memory IO function to initialize the global IO instance
This is the memory IO function to initialize the global IO instance
void XAieIO_Init(void)
{
	struct metal_init_params init_param = METAL_INIT_DEFAULTS;
	int ret;
	if (IOInst.RefCnt) {
		IOInst.RefCnt++;
		return;
	}
	ret = metal_init(&init_param);
	if (ret) {
		XAieLib_print("failed to metal_init %d\n", ret);
		return;
	}
	ret = metal_device_open("platform", "xilinx-aiengine",
			&IOInst.device);
	if (ret) {
		XAieLib_print("failed to metal_device_open\n");
		return;
	}
	IOInst.io = metal_device_io_region(IOInst.device, 0);
	if (!IOInst.io) {
		XAieLib_print("failed to metal_device_io_region\n");
		return;
	}
	IOInst.io_base = metal_io_phys(IOInst.io, 0);
	IOInst.RefCnt++;
	ret = metal_device_open("platform", "f70a0000.aie-npi", &IOInst.npi);
	if (ret) {
		return;
	}
	IOInst.npi_io = metal_device_io_region(IOInst.npi, 0);
	if (!IOInst.npi_io) {
		return;
	}
	IOInst.npi_io_base = metal_io_phys(IOInst.npi_io, 0);
	XAieLib_print("AIE NPI space is mapped\n");
}
void XAieIO_Init ( void ) { struct metal_init_params init_param = METAL_INIT_DEFAULTS ; int ret ; if ( IOInst . RefCnt ) { IOInst . RefCnt ++ ; return ; } ret = metal_init ( & init_param ) ; if ( ret ) { XAieLib_print ( " \n " , ret ) ; return ; } ret = metal_device_open ( " " , " " , & IOInst . device ) ; if ( ret ) { XAieLib_print ( " \n " ) ; return ; } IOInst . io = metal_device_io_region ( IOInst . device , 0 ) ; if ( ! IOInst . io ) { XAieLib_print ( " \n " ) ; return ; } IOInst . io_base = metal_io_phys ( IOInst . io , 0 ) ; IOInst . RefCnt ++ ; ret = metal_device_open ( " " , " " , & IOInst . npi ) ; if ( ret ) { return ; } IOInst . npi_io = metal_device_io_region ( IOInst . npi , 0 ) ; if ( ! IOInst . npi_io ) { return ; } IOInst . npi_io_base = metal_io_phys ( IOInst . npi_io , 0 ) ; XAieLib_print ( " \n " ) ; }
This is the memory IO function to initialize the global IO instance
This is the memory IO function to initialize the global IO instance