コード例 #1
0
/**
* @brief 	SD driver initial function.
* @return 	SUCCESS/ERROR_ID.
*/
static int __init gp_sdcard_init(void)
{
	int i;
	/* ----- Get registered. ----- */
	sd_major = register_blkdev(sd_major, "sdcard");
	if (sd_major <= 0) 
	{
		DERROR(KERN_WARNING "SD card : unable to get major number\n");
		return -EBUSY;
	}
	/* ----- Allocate the device array, and initialize each one. ----- */
	sd_info = kmalloc(SD_NUM*sizeof (gpSDInfo_t), GFP_KERNEL);
	if (sd_info == NULL)
		goto out_unregister;
	/* ----- Initial SD information ----- */
	for(i=0; i<SD_NUM; i++)
	{
		gpSDInfo_t *sd = &sd_info[i];
		/* ----- Clear memory ----- */
		memset (sd, 0, sizeof (gpSDInfo_t));
		sd->device_id = i;
		/* ----- Initial spinlock ----- */
		spin_lock_init(&sd->lock);
		spin_lock_init(&sd->hal_lock);
		/* ----- Initial work queue ----- */
		INIT_WORK(&sd->init, gp_sdcard_work_init);
		INIT_WORK(&sd->uninit, gp_sdcard_work_uninit);
		if(i==0)
		{
			/* ----- request IO function ----- */
			sd->sd_func = gp_board_get_config("sd0",gp_board_sd_t);
			/* ----- Initial dma module ----- */
			sd->dma_param.module = SD0;
		}
		else
		{
			/* ----- request IO function ----- */
			sd->sd_func = gp_board_get_config("sd1",gp_board_sd_t);
			/* ----- Initial dma module ----- */
			sd->dma_param.module = SD1;
		}
		/* ----- Init timer ----- */
		init_timer(&sd->timer);
		sd->timer.data = (unsigned long) sd;
		sd->timer.function = gp_sdcard_timer_fn;
		sd->timer.expires = jiffies + SD_CD_POLL;
		add_timer(&sd->timer);
	}
	gp_sdio_init();
	return 0;
out_unregister:
	unregister_blkdev(sd_major, "sdcard");
	return -ENOMEM;
}
コード例 #2
0
ファイル: gp_sd_module.c プロジェクト: go2ev-devteam/GPCV
/**
* @brief 	SD driver initial function.
* @return 	SUCCESS/ERROR_ID.
*/
static int __init gp_sdcard_init(void)
{
	int i;
	/* ----- Get registered. ----- */
	sd_major = register_blkdev(sd_major, "sdcard");
	if (sd_major <= 0)
	{
		DERROR(KERN_WARNING "SD card : unable to get major number\n");
		return -EBUSY;
	}
	/* ----- Allocate the device array, and initialize each one. ----- */
	sd_info = kmalloc(SD_NUM*sizeof (gpSDInfo_t), GFP_KERNEL);
	if (sd_info == NULL)
		goto out_unregister;
	/* ----- Initial SD information ----- */
	for(i = 0; i < SD_NUM; i++)
	{
		char tag[4] = "sd0";
		gpSDInfo_t *sd = &sd_info[i];
		/* ----- Clear memory ----- */
		memset (sd, 0, sizeof (gpSDInfo_t));
		sd->device_id = i;
		/* ----- Initial spinlock ----- */
		spin_lock_init(&sd->lock);
		spin_lock_init(&sd->hal_lock);
		/* ----- Initial work queue ----- */
		INIT_WORK(&sd->init, gp_sdcard_work_init);
		INIT_WORK(&sd->uninit, gp_sdcard_work_uninit);
		/* ----- request IO function ----- */
		tag[2] = '0'+ i;
		sd->sd_func = gp_board_get_config( tag, gp_board_sd_t );
		if ( sd->sd_func == NULL ) {
            DEBUG("NO SD%d found in board config\n",i);
            continue;
        }
		/* ----- Initial dma module ----- */
		sd->dma_param.module = SD0+i;
		/* ----- Register get serial number function to board config ----- */
		sd->sd_func->get_sn = gp_sdcard_get_sn;
		/* ------Register gadget used function to board config ------*/
		sd->sd_func->read_cmd = gp_sdcard_readcmd;
		sd->sd_func->write_cmd = gp_sdcard_writecmd;
		sd->sd_func->dma_enable = gp_sdcard_dma_en;
		sd->sd_func->dma_finish = gp_sdcard_dma_finish;
		sd->sd_func->dma_stop = gp_sdcard_dma_stop;
		sd->sd_func->transfer_stop = gp_sdcard_stop;
		sd->sd_func->WaitDataComplete = gpHalSDWaitDataComplete;

		//gp_sdcard_carduninit(sd);						// Clock will disable when booting
        /* ----- Set Power Off Default ----- */
        sd->sd_func->set_power(0);
		/* ----- Init timer ----- */
		init_timer(&sd->timer);
		sd->timer.data = (unsigned long) sd;

		sd->timer.function = gp_sdcard_timer_fn;
		sd->timer.expires = jiffies + SD_CD_POLL;

		add_timer(&sd->timer);
	}

	gp_sdio_init();

	platform_device_register(&gp_sd_device);
	platform_driver_register(&gp_sd_driver);

	return 0;
out_unregister:
	unregister_blkdev(sd_major, "sdcard");
	return -ENOMEM;
}