/**
* @brief 	SD card io control function.
* @param 	dev[in]: Block device pointer.
* @param 	mode[in] : Mode.
* @param	cmd[in]: Command.
* @param	arg[in]: Argument.
* @return 	SUCCESS/ERROR_ID.
*/
static int gp_sdcard_ioctrl (struct block_device *dev, fmode_t mode, unsigned cmd, unsigned long arg)
{
	gpSDInfo_t *sd = dev->bd_disk->private_data;
	//unsigned short sys_apb = 810;
	int ret = 0;
	
	switch(cmd)
	{
		case SD_CLK_SET:
		{
			unsigned long sys_apb_clk = 0;
			struct clk *pclk;
			pclk = clk_get(NULL,"clk_sys_apb");
			if(pclk)
			{
				sys_apb_clk = clk_get_rate(pclk)/100000;	
				clk_put(pclk);
			}
			else
			{
				sys_apb_clk = 270;
			}
			ret = gpHalSDSetClk(sd->device_id, sys_apb_clk, (sd->speed>arg)?arg:sd->speed);
			break;
		}
		case SD_CLK_BUS:
			ret = gp_sdcard_setbus(sd,arg);
			break;
		default:
			ret = -ENOIOCTLCMD;
			break;
	}
	return ret;	
}
Exemple #2
0
/**
* @brief 	SD card io control function.
* @param 	dev[in]: Block device pointer.
* @param 	mode[in] : Mode.
* @param	cmd[in]: Command.
* @param	arg[in]: Argument.
* @return 	SUCCESS/ERROR_ID.
*/
static int gp_sdcard_ioctrl (struct block_device *dev, fmode_t mode, unsigned cmd, unsigned long arg)
{
	gpSDInfo_t *sd = dev->bd_disk->private_data;
	int ret = 0;

	switch(cmd)
	{
		case SD_CLK_SET:
		{
			unsigned long sys_apb_clk = 0;
			struct clk *pclk;
			pclk = clk_get(NULL,"clk_sys_apb");
			if(pclk)
			{
				sys_apb_clk = clk_get_rate(pclk)/100000;
				clk_put(pclk);
			}
			else
			{
				sys_apb_clk = 270;
			}
			ret = gpHalSDSetClk(sd->device_id, sys_apb_clk, (sd->speed>arg)?arg:sd->speed);
			break;
		}
		case SD_CLK_BUS:
			ret = gp_sdcard_setbus(sd,arg);
			break;
		case SD_APP_SET:
			if(sd->partition.activity)
			{
				/* ----- Enable app area ----- */
				if(arg==1)
				{
					struct hd_struct *part;
					part = gp_add_partition(sd->gd, GP_APP_MINOR, sd->partition.offset[MAX_SD_PART], sd->partition.capacity[MAX_SD_PART], ADDPART_FLAG_WHOLEDISK);
					if (IS_ERR(part))
						ret = -EIO;
				}
				/* ----- Disable app area ----- */
				else
					gp_delete_partition(sd->gd, GP_APP_MINOR);
			}
			else
				ret = -ENOIOCTLCMD;
			break;
		default:
			ret = -ENOIOCTLCMD;
			break;
	}
	return ret;
}