Ejemplo n.º 1
0
STATUS sysScsiInit (VOID)
    {
#ifdef INCLUDE_AIC_7880

    AIC7880_INFO *aicResource;

    aicResource = &aic7880InfoTable;

    /* Create the SCSI controller */

    if ((pSysScsiCtrl = (SCSI_CTRL *) aic7880CtrlCreate 
        (aicResource->pciBus, aicResource->pciDevice, 
        SCSI_DEF_CTRL_BUS_ID)) == NULL)
        {
	logMsg ("Could not create SCSI controller\n", 
	         0, 0, 0, 0, 0, 0);
	return (ERROR);
	}
	
    /* connect the SCSI controller's interrupt service routine */
	
    if ((pciIntConnect (INUM_TO_IVEC (INT_NUM_GET (aicResource->irq)),
                        aic7880Intr, (int) pSysScsiCtrl)) == ERROR)
        {
        logMsg ("Failed to connect interrupt\n",
                 0, 0, 0, 0, 0, 0);
	return (ERROR);
        }

    sysIntEnablePIC((int) aicResource->irq) ;

#endif /* INCLUDE_AIC_7880 */

#ifdef  INCLUDE_TAPEFS
    tapeFsInit ();      /* initialize tape file system */
#endif /* INCLUDE_TAPEFS */

#ifdef INCLUDE_CDROMFS
    cdromFsInit ();     /* include CD-ROM file system */
#endif /* INCLUDE_CDROMFS */

    return (OK);
    }
int probe1()
{
    unsigned int pciBusNo, pciDevNo, pciFuncNo;
    unsigned char byte;
   /* int           i,j;*/
    UINT32 s_pBA0, s_pBA1;

    /* To ensure that taskDelay(1) is 1ms delay */
    sysClkRateSet(1000);
    if (pciConfigLibInit (PCI_MECHANISM_1, 0xCF8, 0xCFC, 0) != OK) {
	printf("PCI lib config error\n");
	return 1;
    }

    /****************************
     * Find SoundCard
     * Set  BaseAddr0, BaseAddr1
     ****************************/
    if(!(pciFindDevice(PCI_VENDOR_ID_CIRRUS,PCI_DEVICE_ID_CRYSTAL_CS4281,
		       0, &pciBusNo, &pciDevNo, &pciFuncNo)==OK)) {
	printf("\n CS4281 sound card NOT FOUND!!! \n");
	return 1;
    }

    printf("\n FOUND CS4281 sound card, configuring BA0,BA1... \n");    
    pciConfigOutLong( pciBusNo, pciDevNo, pciFuncNo,
		      PCI_CFG_BASE_ADDRESS_0, CS4281_pBA0);
    /*
    pciConfigOutLong( pciBusNo, pciDevNo, pciFuncNo,
		      PCI_CFG_BASE_ADDRESS_1, CS4281_pBA1);
    */
    pciConfigInLong( pciBusNo, pciDevNo, pciFuncNo,
		     PCI_CFG_BASE_ADDRESS_0, &s_pBA0);
    pciConfigInLong( pciBusNo, pciDevNo, pciFuncNo,
		     PCI_CFG_BASE_ADDRESS_1, &s_pBA1 );
    printf ("\npBusNo    pDeviceNo  pFuncNo  pBA0      pBA1\n\n");
    printf ("%.8x  %.8x  %.8x  %.8x  %.8x \n",
	    pciBusNo, pciDevNo, pciFuncNo, s_pBA0,s_pBA1); 


    

    /********************************
     * Config PCI Device Capability
     *     DMA Master
     *     MEM mapped
     ********************************/

    /* Set the INTA vector */
    pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo,
		    PCI_CFG_DEV_INT_LINE, &cs4281_irq);
    printf("\nFound CS4281 configured for IRQ %d\n", cs4281_irq);
    
    pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo,
		    PCI_CFG_DEV_INT_PIN, &byte);
    printf("\tINT_PIN=%.8x\n", byte);

    /* Enable the device's capabilities as specified
     * Bus Master Enable/ Mem Space Enable */
    pciConfigOutWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_COMMAND,
		     (unsigned short)0x0006);

    
    /***************************
     * BringUp Hardware 
     ***************************/
    /*Include Init Function Here*/
    cs4281_hw_init();

    /****************************
     * Allocate ADC_BUFFER
     * Allocate DAC_BUFFER
     *
     * Hook cs4281_interrupt
     *
     * Program CoDec
     ****************************/
    if((DAC_BUFFER=valloc(DAC_BUFFER_SIZE))==NULL) {
       printf("\n DAC_BUFFER valloc failed!\n");
       return 1;
       
    }
    memset( DAC_BUFFER, 0, DAC_BUFFER_SIZE );
    printf("\ndac=%x",DAC_BUFFER);
    /*for( i=0 ; i < DAC_BUFFER_SIZE  ; i++ )
        ((char *)DAC_BUFFER)[i]=0x7f;*/

    writel((UINT32)DAC_BUFFER+8,CS4281_pBA0 + BA0_DBA0);
    writel(DAC_BUFFER_SIZE-16, CS4281_pBA0 + BA0_DBC0);
    printf("\nbao=%x",readl(CS4281_pBA0 + BA0_DBA0));
    printf("\nbco=%x",readl(CS4281_pBA0 + BA0_DBC0));
    printf("\ncco=%x",readl(CS4281_pBA0 + BA0_DCC0));
    if((ADC_BUFFER=valloc(ADC_BUFFER_SIZE))==NULL) {
       printf("\n ADC_BUFFER valloc failed!\n");
       return 1;
    }
    printf("\nadc=%x",ADC_BUFFER);
    /*for( i=0 ; i < ADC_BUFFER_SIZE  ; i++ )
        ((char *)ADC_BUFFER)[i]=0x7f;*/

    writel((UINT32)ADC_BUFFER+8,CS4281_pBA0 + BA0_DBA1);
    writel(ADC_BUFFER_SIZE-16, CS4281_pBA0 + BA0_DBC1);
    
    /* connect interrupt */
    printf("\n Hook cs4281_interrupt to vector %d\n",
	   (INUM_TO_IVEC (cs4281_irq+INT_NUM_IRQ0)));
    pciIntConnect((INUM_TO_IVEC (cs4281_irq+INT_NUM_IRQ0)),
		(VOIDFUNCPTR)cs4281_interrupt, 0);
    sysIntEnablePIC(cs4281_irq);
    
    SEM_DMA_Playback = semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    SEM_MY_Playback = semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    SEM_DMA_Record = semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    SEM_Sample = semBCreate(SEM_Q_FIFO,SEM_EMPTY);

    CNT_DMA_Playback = CNT_DMA_Record = 0;
    
    /* program coDec */
    printf("\n Program CoDec (sample rate, DMA...)\n");
    prog_codec();


    /*********************************************
     *  start dac/adc, interrupt is comming...
     *********************************************/
    start_dac();
  	return 0;
}
Ejemplo n.º 3
0
int pci_int_connect(int intLine,
		    pci_isr_t isr,
		    void *isr_data)
{
#if !defined(NEGEV)
    extern int sysVectorIRQ0;
#endif

#if defined(NSX) || defined(GTO) || defined(METROCORE)
    int i;
#endif
  
    debugk(DK_PCI,
	   "pci_int_connect: intLine=%d, isr=%p, isr_data=%p\n",
	   intLine, (void *)isr, (void *)isr_data);

#if defined(NSX) || defined(METROCORE)
    /* all int lines */
    for (i = 0; i < 4; i++) {
        /* printk("pciIntConnect int line = %d\n", intLine + i); */
        if (pciIntConnect ((VOIDFUNCPTR *)
                     INUM_TO_IVEC(sysVectorIRQ0 + intLine + i),
                     (VOIDFUNCPTR) isr,
                     PTR_TO_INT(isr_data)) != OK) {
            return -1;
        }
    }
    return 0;
#endif

#if defined(GTO)
    for (i = 0; i < 4; i++) {
        /* PCI interrupts are connected at external interrupt
         * 0, 1, 2, and 3.
         */ 
        if (pciIntConnect ((VOIDFUNCPTR *)
                     INUM_TO_IVEC(sysVectorIRQ0 + i),
                     (VOIDFUNCPTR) isr,
                     PTR_TO_INT(isr_data)) != OK) {
            return -1;
        }

        if (intEnable(sysVectorIRQ0 + i) == ERROR) {
	    return -1;
        }
    }
    return 0;
#endif

#if !defined (NEGEV)
    if (pciIntConnect ((VOIDFUNCPTR *)
		       INUM_TO_IVEC(sysVectorIRQ0 + intLine),
		       (VOIDFUNCPTR) isr,
		       PTR_TO_INT(isr_data)) != OK) {
      return -1;
    }
#endif

#if (CPU_FAMILY != PPC) && !defined(IDTRP334) && \
    !defined(MBZ) && !defined(IDT438) && !defined(NSX) && !defined(ROBO_4704) \
    && !defined(ROBO_4702) && !defined(RAPTOR) && !defined(METROCORE) \
    && !defined(KEYSTONE)
    if (sysIntEnablePIC(intLine) == ERROR) {
	return -1;
    }
#endif
    
#if (CPU_FAMILY == PPC)
    if (intEnable(intLine) != OK) {
	return -1;
    }
#endif /* (CPU_FAMILY == PPC) */

    return 0;
}