Beispiel #1
0
Datei: ctc.c Projekt: dcobas/coht
int install_device(struct vmeio_device *dev, unsigned i)
{
	memset(dev, 0, sizeof(*dev));

	dev->lun = lun[i];
	dev->debug = DEBUG;

	/* configure mmapped I/O */
	if (base_address1_num && map(&dev->maps[0], base_address1[i],
						data_width1, am1, size1)) {
		printk(KERN_ERR PFX "could not map lun:%d, first space\n",
							dev->lun);
		goto out_map1;
	}

	if (base_address2_num && map(&dev->maps[1], base_address2[i],
						data_width2, am2, size2)) {
		printk(KERN_ERR PFX "could not map lun:%d, second space\n",
							dev->lun);
		goto out_map2;
	}

	/* configure interrupt handling */
	dev->vector  = vector[i];
	dev->level  = level;
	dev->isrc = isrc;
	dev->timeout = msecs_to_jiffies(TIMEOUT);
	dev->icnt = 0;
	init_waitqueue_head(&dev->queue);

	if (dev->level && dev->vector &&
		register_isr(dev, dev->vector, dev->level) < 0) {
			printk(KERN_ERR PFX "could not register isr "
				"for vector %d, level %d\n",
				dev->vector, dev->level);
			goto out_isr;
	}
	/* This will be eventually removed */
	register_int_source(dev, dev->maps[0].kernel_va, dev->isrc);

	return 0;

out_isr:
	vme_release_mapping(&dev->maps[1], 1);
out_map2:
	vme_release_mapping(&dev->maps[0], 1);
out_map1:
	return -ENODEV;

}
Beispiel #2
0
/*
 * Initialize ATM kernel
 * 
 * Performs any initialization required before things really get underway.
 * Called from ATM domain initialization or from first registration function 
 * which gets called.
 *
 * Arguments:
 *	none
 *
 * Returns:
 *	none
 *
 */
void
atm_initialize()
{
	/*
	 * Never called from interrupts, so no locking needed
	 */
	if (atm_init)
		return;
	atm_init = 1;

#ifndef __FreeBSD__
	/*
	 * Add ATM protocol family
	 */
	(void) protocol_family(&atmdomain, NULL, NULL);
#endif

	atm_intrq.ifq_maxlen = ATM_INTRQ_MAX;
#ifdef sgi
	atm_intr_index = register_isr(atm_intr);
#endif

	/*
	 * Initialize subsystems
	 */
	atm_aal5_init();

	/*
	 * Prime the timer
	 */
	(void) timeout(atm_timexp, (void *)0, hz/ATM_HZ);

	/*
	 * Start the compaction timer
	 */
	atm_timeout(&atm_compactimer, SPOOL_COMPACT, atm_compact);
}
Beispiel #3
0
//****************************************************************************
//
//! \brief  This function initialise the basic and application specific modules
//!         for a CC3200 platform
//!
//! \param  none
//!
//! \return 0 if application specific modules are loaded succesfully, -1 in case
//!         failure
//
//****************************************************************************
//ESSENTIAL
int platform_init(void)
{
        int retval = 0;
        struct cc_dma_cfg dma_config;
        struct platform_pm_ops lp3p0_pm_ops;
        struct cc_timer_setup timer_setup;
        tROMVersion* pRomVersion = (tROMVersion *)(ROM_VERSION_ADDR);
        u32 *spi_baud_rate;

        /* Disable clocks for modules that are not used on this platform */
        /* Initialize the PM framework */
        retval = cc_pm_framework_init();
        
        /* Get the SOC specific platform operations */
        lp3p0_get_pm_ops(&lp3p0_pm_ops);

        /* Register PM ops with framework */
        retval = cc_pm_platform_ops_register(&lp3p0_pm_ops);
        
        /* Register the power management ISR */
        register_isr(INT_PRCM, prcm_interrupt_handler, NULL);
        
        /* Register the timer ISR */
        register_isr(INT_TIMERA0A, timer_interrupt_handler, NULL);

        /* Initialize the platform specific services */
        timer_setup.enbl_irqc = osi_ExitCritical;
        timer_setup.dsbl_irqc = osi_EnterCritical;
        retval = cc_timer_module_init(&timer_setup);
        /* Initialize RTC services */
        retval = rtc_module_init();

        /* Initialize timer services */
        MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK|
                                                    PRCM_SLP_MODE_CLK);
        retval = hwt32_timer_init();
        
        /* Initialize the DMA module */
        MAP_PRCMPeripheralClkEnable(PRCM_UDMA, PRCM_RUN_MODE_CLK|
                                    PRCM_SLP_MODE_CLK);
        dma_config.ctl_table = dma_ctrl_table;
        retval = cc_dma_init(&dma_config);

        spi_baud_rate = &(((struct cc_spi_config*)(modules[0].hw_detail))->baud_rate);
        /* deciding the SPI baud rate depending upon PG version */
        if(pRomVersion->ucMinorVerNum == ROM_VER_PG1_21 )
		{
        	*spi_baud_rate = SPI_RATE_13M;
		}
		else if(pRomVersion->ucMinorVerNum == ROM_VER_PG1_32)
		{
			*spi_baud_rate = SPI_RATE_13M;
		}
		else if(pRomVersion->ucMinorVerNum >= ROM_VER_PG1_33)
		{
			*spi_baud_rate = SPI_RATE_20M;
		}

        /* Load the application specific modules */
#define NUM_SOC_MODULES(modules) (sizeof(modules) / sizeof(struct soc_module))

        if(-1 == cc_modules_load(modules, NUM_SOC_MODULES(modules))) {
                /* Should modules be unloaded? */
                retval = -1;
        }
        
        return retval;
}
Beispiel #4
0
/* 
   This function should be called from centralized & RTOS specific initialization
   sequence. 

   Goal of this function is to extend information about SOC module to SW driver 
   enable it to initialize hardware through HAL. Driver could use private field 
   called 'hw_detail', if provisioned, to configure hardware. 

   Driver instance must enroll / register itself with PM / platfrom framework.

*/
i32 spi_driver_load(struct soc_module *spi_module)
{
        struct spi_rtos_driver *spi_rtos_drv_hndl;
        i32 ret_val;
        struct cc_spi_config *spi_config = 
                (struct cc_spi_config *)spi_module->hw_detail;
        cc_hndl hndl;
        struct cc_dma_chan_cfg chan_config;

        /* Reset the SPI driver structure once in the begining */
        if(!is_spidrv_reset) {
                reset_spi_rtosdrv();
                is_spidrv_reset = 1;
        }

        /* Initialize the SPI RTOS driver */
        spi_rtos_drv_hndl = check_spi_rtosdrv_inuse(spi_config->module_id);
        if(NULL == spi_rtos_drv_hndl) {
                /* Acquire a new rtos driver structure from the list */
                spi_rtos_drv_hndl = get_available_spi_rtosdrv();
                if(NULL == spi_rtos_drv_hndl) {
                        /* Something wrong - should have failed at spi_init */
                        goto exit1; /* Error */
                }
        } else {
                /* Module already in use. TBD?? */
                goto exit1;
        }

        /* Assign call back routines into spi_config structure for HAL  */
        spi_config->drv_rw_event_cb = drv_callback_ops_complete;
        spi_config->rtos_hndl = (void *)spi_rtos_drv_hndl;
        
        /* Initialize the SPI HAL */
        hndl = cc_spi_init(spi_config);
        if(NULL == hndl) {
                goto exit2; /* Error */
        }

        /* Derive other information from spi_haldrv.hw_module.priv_info */

        /* Initialize the module driver structure */
        spi_rtos_drv_hndl->device_id = spi_config->module_id;
        spi_rtos_drv_hndl->hal_driver.hw_module = NULL;
        spi_rtos_drv_hndl->hal_driver.clk_state = e_clk_cut_off;
        spi_rtos_drv_hndl->hal_driver.pm_state = e_pm_M0;
        spi_rtos_drv_hndl->hal_driver.rtos_drv = spi_rtos_drv_hndl;
        spi_rtos_drv_hndl->hal_driver.goto2pm_mode = spi_handle_pm_cmd;
        spi_rtos_drv_hndl->sync_obj = NULL;
        spi_rtos_drv_hndl->lock_obj = NULL;
        spi_rtos_drv_hndl->oper_mode = spi_config->oper_mode;

        /* Save HAL hndl in RTOS Driver structure */
        spi_rtos_drv_hndl->hal_handle = hndl;

        /* Setup the DMA based on the operation mode */
        chan_config.en_burst = false;
        chan_config.alt_cblk = false;
        chan_config.en_hwreq = false;
        chan_config.priority = false;
        spi_rtos_drv_hndl->rx_dma_hndl = 
                cc_dma_alloc(spi_config->dma_info.rx_dma_ch, 
                                map_moduleid_to_dmach(spi_config->module_id, 0));
        cc_dma_chan_config(spi_rtos_drv_hndl->rx_dma_hndl, &chan_config);

        spi_rtos_drv_hndl->tx_dma_hndl = 
                cc_dma_alloc(spi_config->dma_info.tx_dma_ch, 
                                map_moduleid_to_dmach(spi_config->module_id, 1));
        cc_dma_chan_config(spi_rtos_drv_hndl->tx_dma_hndl, &chan_config);

        /* Register with system INTC for irqvec_id */
        register_isr(spi_config->irqvec_id, 
                spi_interrupt_handler, 
                spi_rtos_drv_hndl->hal_handle);

        /* Register the module driver with the power management framework */
        ret_val = cc_module_drv_register(spi_module, 
                                       &spi_rtos_drv_hndl->hal_driver);
        if(ret_val < 0) {
                goto exit3; /* Error */
        }

        /* RTOS driver may need to do some more house-keeping ........  */

        return 0; /* Need to be RTOS specific */

exit3:
        cc_module_drv_unregister(&spi_rtos_drv_hndl->hal_driver);
exit2:
        cc_spi_deinit(hndl);
        free_spi_rtosdrv(spi_rtos_drv_hndl);
exit1:
        return -1;
}
Beispiel #5
0
/*
   This function should be called from centralized & RTOS specific
    initialization sequence.

   Goal of this function is to extend information about SOC module to SW driver
   enable it to initialize hardware through HAL. Driver could use private field
   called 'hw_detail', if provisioned, to configure hardware.

   Driver instance must enroll / register itself with PM / platfrom framework.

*/
i32 uart_driver_load(struct soc_module *uart_module)
{
        struct uart_rtos_driver *uart_rtos_drv_hndl;
        i32 ret_val;
        struct cc_uart_config *uart_config =
                (struct cc_uart_config *)uart_module->hw_detail;
        cc_hndl hndl;
        struct cc_dma_chan_cfg chan_config;

        /* Reset the UART driver structure once in the begining */
        reset_uart_rtosdrv();

        /* Initialize the UART RTOS driver */
        uart_rtos_drv_hndl = check_uart_rtosdrv_inuse(uart_config->module_id);
        if(NULL == uart_rtos_drv_hndl) {
                /* Acquire a new rtos driver structure from the list */
                uart_rtos_drv_hndl = get_available_uart_rtosdrv();
                if(NULL == uart_rtos_drv_hndl) {
                        /* Something wrong - should have failed at uart_init */
                        goto exit1; /* Error */
                }
        } else {
                /* Module already in use. TBD?? */
                goto exit1;
        }

        /* Assign call back routines into uart_config structure for HAL  */
        (uart_config->module_info).int_callback = uart_callback_from_hal;
        uart_config->rtos_hndl = (void *)uart_rtos_drv_hndl;

        /* Initialize the UART HAL */
        hndl = cc_uart_init(uart_config);
        if(NULL == hndl) {
                goto exit2; /* Error */
        }

        /* Initialize the module driver structure */
        uart_rtos_drv_hndl->device_id = uart_config->module_id;
        uart_rtos_drv_hndl->hal_driver.hw_module = NULL;
        uart_rtos_drv_hndl->hal_driver.clk_state = e_clk_cut_off;
        uart_rtos_drv_hndl->hal_driver.pm_state = e_pm_M0;
        uart_rtos_drv_hndl->hal_driver.rtos_drv = uart_rtos_drv_hndl;
        uart_rtos_drv_hndl->hal_driver.goto2pm_mode = uart_handle_pm_cmd;
        uart_rtos_drv_hndl->sync_obj = NULL;
        uart_rtos_drv_hndl->lock_obj = NULL;
        uart_rtos_drv_hndl->tx_oper_mode = uart_config->tx_transfer_mode;
        uart_rtos_drv_hndl->rx_oper_mode = uart_config->rx_transfer_mode;

        /* Save HAL hndl in RTOS Driver structure */
        uart_rtos_drv_hndl->hal_handle = hndl;

        /* Setup the DMA based on the operation mode */
        chan_config.en_burst = false;
        chan_config.alt_cblk = false;
        chan_config.en_hwreq = false;
        chan_config.priority = false;

        uart_rtos_drv_hndl->rx_dma_hndl =
                cc_dma_alloc(uart_config->dma_info.rx_dma_ch,
                             (DMA_USER_UART0_RX +
                              2*(uart_config->module_id - PRCM_UARTA0)));
        cc_dma_chan_config(uart_rtos_drv_hndl->rx_dma_hndl, &chan_config);

        uart_rtos_drv_hndl->tx_dma_hndl =
                cc_dma_alloc(uart_config->dma_info.tx_dma_ch,
                		     (DMA_USER_UART0_TX +
                		      2*(uart_config->module_id - PRCM_UARTA0)));
        cc_dma_chan_config(uart_rtos_drv_hndl->tx_dma_hndl, &chan_config);

        /* Register with system INTC for irqvec_id */
        register_isr(uart_config->irqvec_id,
                uart_interrupt_handler,
                uart_rtos_drv_hndl->hal_handle);

        /* Register the module driver with the power management framework */
        ret_val = cc_module_drv_register(uart_module,
                                       &uart_rtos_drv_hndl->hal_driver);
        if(ret_val < 0) {
                goto exit3; /* Error */
        }

        /* RTOS driver may need to do some more house-keeping ........  */

        return 0; /* Need to be RTOS specific */

exit3:
        cc_module_drv_unregister(&uart_rtos_drv_hndl->hal_driver);
exit2:
        cc_uart_deinit(hndl);
        free_uart_rtosdrv(uart_rtos_drv_hndl);
exit1:
        return -1;
}