31 "allocated from agtiapi_MemAlloc as simple malloc case" );
46 DELAY(MiliSeconds * 1000);
66 if( bus_dma_tag_create( bus_get_dma_tag(pmsc->
my_dev),
80 printf(
"agtiapi_typhAlloc: Can't create no-cache mem tag\n" );
86 BUS_DMA_WAITOK | BUS_DMA_ZERO | BUS_DMA_NOCACHE,
88 printf(
"agtiapi_typhAlloc: Cannot allocate cache mem %d\n",
100 for( ; wait < 20; wait++ ) {
106 printf(
"agtiapi_typhAlloc: cache mem won't load %d\n",
134 device_t devx = thisCardInst->
pPCIDev;
141 printf(
"agtiapi_InitResource: failed call to agtiapi_typhAlloc \n" );
145 AGTIAPI_PRINTK(
"agtiapi_InitResource: dma alloc MemSpan %p -- %p\n",
157 for (bar = 0; bar < PCI_NUMBER_BARS; bar++) {
158 if ((bar==1) || (bar==3))
160 thisCardInst->pciMemBaseRIDSpc[lBar] = PCIR_BAR(bar);
161 thisCardInst->pciMemBaseRscSpc[lBar] =
162 bus_alloc_resource_any( devx,
164 &(thisCardInst->pciMemBaseRIDSpc[lBar]),
166 AGTIAPI_PRINTK(
"agtiapi_InitResource: bus_alloc_resource_any rtn %p \n",
167 thisCardInst->pciMemBaseRscSpc[lBar] );
168 if ( thisCardInst->pciMemBaseRscSpc[lBar] !=
NULL ) {
169 thisCardInst->pciMemVirtAddrSpc[lBar] =
170 (caddr_t)rman_get_virtual(
171 thisCardInst->pciMemBaseRscSpc[lBar] );
172 thisCardInst->pciMemBaseSpc[lBar] =
173 bus_get_resource_start( devx, SYS_RES_MEMORY,
174 thisCardInst->pciMemBaseRIDSpc[lBar]);
175 thisCardInst->pciMemSizeSpc[lBar] =
176 bus_get_resource_count( devx, SYS_RES_MEMORY,
177 thisCardInst->pciMemBaseRIDSpc[lBar] );
179 "VirtAddr=%lx, len=%d\n", bar, lBar,
180 (
long unsigned int)thisCardInst->pciMemVirtAddrSpc[lBar],
181 thisCardInst->pciMemSizeSpc[lBar] );
184 thisCardInst->pciMemVirtAddrSpc[lBar] = 0;
185 thisCardInst->pciMemBaseSpc[lBar] = 0;
186 thisCardInst->pciMemSizeSpc[lBar] = 0;
190 thisCardInst->
pciMemVirtAddr = thisCardInst->pciMemVirtAddrSpc[0];
191 thisCardInst->
pciMemSize = thisCardInst->pciMemSizeSpc[0];
192 thisCardInst->
pciMemBase = thisCardInst->pciMemBaseSpc[0];
200 pci_get_function( devx );
206 ticksPerSec = tvtohz( &tv );
216 "pRscInfo->tiLoLevelResource.loLevelOption.usecsPerTick"
240 sizeof(thisCardInst->
tiDmaMem[0]) ) {
312 printf(
"RED ALARM: we need a BAR for TI_DMA_MEM_CHIP, ignoring!" );
315 printf(
"agtiapi_InitResource: Unknown required memory type %d "
335 (numVal + 1) * uSecPerTick;
338 numVal * uSecPerTick;
360 tdCachedMem[numVal].virtPtr,
403 tiDmaMem[thisCardInst->
dmaIndex].dmaVirtAddr,
446 tiSharedMem.tdSharedCachedMem1.totalLength,
458 AGTIAPI_PRINTK(
"agtiapi_InitResource: SharedMem cacheIndex=%d CACHED "
459 "vaddr %p / %p, length %d align 0x%x\n",
469 "Unknown required memory type ERROR!\n" );
495 U32 lTmpAlign, lTmpType, lTmpLen;
507 printf(
"agtiapi_ScopeDMARes: skip ZERO %d\n", numVal );
532 lAllMem += lTmpLen + lTmpAlign;
542 AGTIAPI_PRINTK(
"agtiapi_ScopeDMARes: Invalid cacheIndex %d ERROR\n",
548 printf(
"agtiapi_ScopeDMARes: Unknown required memory type %d "
570 lAllMem += lTmpLen + lTmpAlign;
576 printf(
"agtiapi_ScopeDMARes: Unknown required memory type ERROR!\n" );
581 pmsc->
typhn = lAllMem;
590 struct resource *tmpRsc =
NULL;
594 for (bar=0; bar < PCI_NUMBER_BARS; bar++) {
595 tmpRid = pCardInfo->pciMemBaseRIDSpc[bar];
596 tmpRsc = pCardInfo->pciMemBaseRscSpc[bar];
597 if (tmpRsc !=
NULL) {
598 bus_release_resource( dev, SYS_RES_MEMORY, tmpRid, tmpRsc );
625 vm_paddr_t *pDmaAddr,
635 alignOffset = Align - 1;
641 *VirtAlloc = malloc( MemSize + Align, M_PMC_MMAL, M_ZERO | M_NOWAIT );
642 *VirtAddr = (
void *)(((
U32_64)*VirtAlloc + alignOffset) & ~alignOffset);
649 *VirtAddr = (
void *)( ( (
U32_64)*VirtAlloc + alignOffset) & ~alignOffset );
650 if( *VirtAddr != *VirtAlloc )
651 residAlign = (
U64)*VirtAddr - (
U64)*VirtAlloc;
652 pmsc->
typhIdx += residAlign + MemSize;
656 vm_paddr_t *lPhysAligned =
657 (vm_paddr_t*)( ( (
U64)pDmaAddr + alignOffset ) & ~alignOffset );
658 if( lPhysAligned != pDmaAddr )
659 residAlign = (
U64)lPhysAligned - (
U64)pDmaAddr;
660 pmsc->
tyPhsIx += residAlign + MemSize;
760 u_int16_t agtiapi_vendor;
761 u_int16_t agtiapi_dev;
764 agtiapi_vendor = pci_get_vendor( dev );
765 agtiapi_dev = pci_get_device( dev );
778 AGTIAPI_PRINTK(
"agtiapi_ProbeCard: We've got PMC SAS, probe successful %p / %p\n",
779 thisCardInst->
pPCIDev, thisCardInst );
static void agtiapi_MemoryCB(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
static ag_card_info_t agCardInfoList[AGTIAPI_MAX_CARDS]
#define LOW_32_BITS(addr)
#define AGTIAPI_INITIATOR
#define HIGH_32_BITS(addr)
#define AGTIAPI_PRINTK(format, a...)
#define AGTIAPI_64BIT_ALIGN
static char const *const ag_card_names[]
ag_card_id_t ag_card_type[]
STATIC void agtiapi_DelayMSec(U32 MiliSeconds)
STATIC agBOOLEAN agtiapi_InitResource(ag_card_info_t *thisCardInst)
STATIC void agtiapi_ReleasePCIMem(ag_card_info_t *pCardInfo)
MALLOC_DEFINE(M_PMC_MMAL, "agtiapi_MemAlloc malloc", "allocated from agtiapi_MemAlloc as simple malloc case")
STATIC agBOOLEAN agtiapi_MemAlloc(ag_card_info_t *thisCardInst, void **VirtAlloc, vm_paddr_t *pDmaAddr, void **VirtAddr, U32 *pPhysAddrUp, U32 *pPhysAddrLow, U32 MemSize, U32 Type, U32 Align)
STATIC int agtiapi_ScopeDMARes(ag_card_info_t *thisCardInst)
STATIC void agtiapi_MemFree(ag_card_info_t *pCardInfo)
STATIC int agtiapi_ProbeCard(device_t dev, ag_card_info_t *thisCardInst, int thisCard)
STATIC agBOOLEAN agtiapi_typhAlloc(ag_card_info_t *thisCardInst)
void * tiCachedMem[AGTIAPI_CACHE_MEM_LIST_MAX]
ag_resource_info_t tiRscInfo
ag_dma_addr_t tiDmaMem[AGTIAPI_DMA_MEM_LIST_MAX]
tiTdSharedMem_t tiSharedMem
tiInitiatorResource_t tiInitiatorResource
tiLoLevelResource_t tiLoLevelResource
ag_card_info_t * pCardInfo
tiInitiatorOption_t initiatorOption
tiInitiatorMem_t initiatorMem
tiMem_t mem[MAX_LL_LAYER_MEM_DESCRIPTORS]
tiLoLevelOption_t loLevelOption
tiLoLevelMem_t loLevelMem
tiMem_t tdSharedCachedMem1
#define TI_CACHED_DMA_MEM