Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Tsi140 PCI to VME window: (4 Items)
   
Tsi140 PCI to VME window  
Hi,
I am using QNX 6.6 and the Tsi140 PCI to VME bridge. I am trying to create a PCI to VME window in order to access VME 
cards. For this reason, I need the start and end addresses of a PCI memory block. How can I obtain these PCI addresses ?

Here is the code I wrote, which for some reason does not work:

BOOL qnx_pci_allocate_resource_memory(uint64 nSize, uint64 nAlign, uint64 *pPhysicalMemAddr, uint32 *pVirtualMemAddr)
{
	void *pAddr = 0;
	rsrc_request_t req;

	memset(&req, 0, sizeof(req));
	req.start = 0;
	req.align = nAlign;
	req.length = nSize;
	req.flags = RSRCDBMGR_FLAG_ALIGN | RSRCDBMGR_PCI_MEMORY;
	if (rsrcdbmgr_attach(&req, 1) == -1) return FALSE;

	pAddr = mmap_device_memory(0, nSize, PROT_READ | PROT_WRITE | PROT_NOCACHE, 0, req.start);
	if (!pAddr) return FALSE;

	*pPhysicalMemAddr = req.start;
	*pVirtualMemAddr = (uint32)pAddr;

	return TRUE;
}

Is rsrcdbmgr_attach the correct way to obtain an unused PCI memory block ? Is there anything wrong with the rest of the 
code ? I use mmap_device_memory in order to obtain a virtual memory pointer and be able to access the PCI memory block 
from my code.

Here is how I create a window to the 16M CR/CSR space - I pass as parameters the physical address of the PCI block 
obtained by  qnx_pci_allocate_resource_memory, and 0 for the VME address:

#define TSI148_REG_OTAT0    (TSI148_ADDR_CRG + 0x011C)  // Outbound translation attribute
#define TSI148_REG_OTSAU0   (TSI148_ADDR_CRG + 0x0100)  // Outbound translation starting address upper
#define TSI148_REG_OTSAL0   (TSI148_ADDR_CRG + 0x0104)  // Outbound translation starting address lower
#define TSI148_REG_OTEAU0   (TSI148_ADDR_CRG + 0x0108)  // Outbound translation ending address upper
#define TSI148_REG_OTEAL0   (TSI148_ADDR_CRG + 0x010C)  // Outbound translation ending address lower
#define TSI148_REG_OTOFU0   (TSI148_ADDR_CRG + 0x0110)  // Outbound translation offset upper
#define TSI148_REG_OTOFL0   (TSI148_ADDR_CRG + 0x0114)  // Outbound translation offset lower

void create_vme_master_window_crcsr(uint64 nPciAddress, uint64 nVmeAddress)
{
        uint64 nSize = 0x01000000;

	uint32 nPciStartAddrUpper = 0, nPciStartAddrLower = 0;
	uint64 nPciEndAddr = 0;
	uint32 nPciEndAddrUpper = 0, nPciEndAddrLower = 0;

	int64_t nOffset = 0;
	uint32 nOffsetUpper = 0, nOffsetLower = 0;

	nOffset = nVmeAddress - nPciAddress;
	nOffsetUpper = (uint32)(nOffset >> 32);
	nOffsetLower = (uint32)(nOffset & 0x00000000ffffffff);

	nPciStartAddrUpper = (uint32)(nPciAddress >> 32);
	nPciStartAddrLower = (uint32)(nPciAddress & 0x00000000ffffffff);

	nPciEndAddr = nPciAddress + nSize - 1;
	nPciEndAddrUpper = (uint32)(nPciEndAddr >> 32);
	nPciEndAddrLower = (uint32)(nPciEndAddr & 0x00000000ffffffff);

    *((uint32 *)(TSI148_REG_OTSAU0)) = htonl(nPciStartAddrUpper);
    *((uint32 *)(TSI148_REG_OTSAL0)) = htonl(nPciStartAddrLower);
    *((uint32 *)(TSI148_REG_OTEAU0)) = htonl(nPciEndAddrUpper);
    *((uint32 *)(TSI148_REG_OTEAL0)) = htonl(nPciEndAddrLower);
    *((uint32 *)(TSI148_REG_OTOFU0)) = htonl(nOffsetUpper);
    *((uint32 *)(TSI148_REG_OTOFL0)) = htonl(nOffsetLower);
    *((uint32 *)(TSI148_REG_OTAT0))  = htonl(0x80000045);
}

I would appreciate any help with the above code. Are you familiar with the Tsi148 chip ? Is there a QNX driver for it 
that I can use ?
Thanks in advance for your help.

Silva

Re: Tsi140 PCI to VME window  
I am using the Tsi148 chip - sorry for the typo
Re: Tsi140 PCI to VME window  
One last point - the Tsi148 chip is the newer version of the Tundra Universe II chip. The code for setting up PCI to VME
 windows should be the same for both chips.
Re: Tsi140 PCI to VME window  
I suspect You have to do some chip setting before reserving memory.
Try to use pci_attach()/pci_attach_device() instead . 
I've attached a driver I've wrote (derived from a linux one) for the tundra chip, 
maybe it can help: see universe_init() function for details.
By
M. Sangalli
Attachment: Compressed file tundra_universe.zip 19.51 KB