示例#1
0
int s3c_csis_clk_off(struct platform_device *pdev, struct clk **clk)
{
	struct clk *sclk_csis = NULL;
	struct s3c_platform_csis *pdata;
	int ret;

	pdata = to_csis_plat(&pdev->dev);

	/* sclk_csis */
	sclk_csis = clk_get(&pdev->dev, pdata->clk_name);
	if (IS_ERR(sclk_csis)) {
		dev_err(&pdev->dev, "failed to get csis clock source\n");
		return -EINVAL;
	}

	/* clock disable for csis */
	clk_disable(sclk_csis);

	/* power domain disable for mipi-csis */
	ret = s5pv210_pd_disable("csis_pd");
	if (ret < 0) {
		dev_err(&pdev->dev, "failed to enable csis power domain\n");
		return -EINVAL;
	}
	return 0;
}
示例#2
0
static void jpeg_clock_disable(void)
{
	/* clock disable */
	clk_disable(s3c_jpeg_clk);

	/* power domain disable */
	s5pv210_pd_disable("jpeg_pd");
}
示例#3
0
static int jpeg_suspend(struct platform_device *pdev, pm_message_t state)
{
	/* clock disable */
	clk_disable(jpeg_ctrl->clk);
#if defined(CONFIG_CPU_S5PV210)
	if (s5pv210_pd_disable("jpeg_pd") < 0) {
		jpeg_err("failed to disable jpeg power domain\n");
		return -EINVAL;
	}
#endif
	return 0;
}
示例#4
0
int s3cfb_clk_off(struct platform_device *pdev, struct clk **clk)
{
	int ret;

	clk_disable(*clk);
	clk_put(*clk);

	*clk = NULL;
	ret = s5pv210_pd_disable("fimd_pd");
	if (ret < 0)
		dev_err(&pdev->dev, "failed to disable fimd power domain\n");

	return 0;
}
示例#5
0
static int jpeg_release(struct inode *inode, struct file *file)
{
	atomic_dec(&jpeg_ctrl->in_use);

	jpeg_mem_free();

	clk_disable(jpeg_ctrl->clk);

#if defined(CONFIG_CPU_S5PV210)
	if (s5pv210_pd_disable("jpeg_pd") < 0) {
		jpeg_err("failed to disable jpeg power domain\n");
		return -EINVAL;
	}
#endif

#ifdef CONFIG_PM_RUNTIME
	pm_runtime_put_sync(jpeg_pm);
#endif

	return 0;
}
示例#6
0
int s5p_tv_clk_gate(bool on)
{
	if (on) {
#ifdef CONFIG_S5PV210_PM
		if (s5pv210_pd_enable("vp_pd") < 0) {
			printk(KERN_ERR "[Error]The power is not on for VP\n");
			goto err_pm;
		}
#endif
		clk_enable(s5ptv_status.vp_clk);
#ifdef CONFIG_S5PV210_PM
		if (s5pv210_pd_enable("mixer_pd") < 0) {
			printk(KERN_ERR "[Error]The power is not on for mixer\n");
			goto err_pm;
		}
#endif
		clk_enable(s5ptv_status.mixer_clk);
#ifdef CONFIG_S5PV210_PM
		if (s5pv210_pd_enable("tv_enc_pd") < 0) {
			printk(KERN_ERR "[Error]The power is not on for TV ENC\n");
			goto err_pm;
		}
#endif
		clk_enable(s5ptv_status.tvenc_clk);
#ifdef CONFIG_S5PV210_PM
		if (s5pv210_pd_enable("hdmi_pd") < 0) {
			printk(KERN_ERR "[Error]The power is not on for HDMI\n");
			goto err_pm;
		}
#endif
		clk_enable(s5ptv_status.hdmi_clk);

	} else {

		/* off */
		clk_disable(s5ptv_status.vp_clk);
#ifdef CONFIG_S5PV210_PM
		if (s5pv210_pd_disable("vp_pd") < 0) {
			printk(KERN_ERR "[Error]The power is not off for VP\n");
			goto err_pm;
		}
#endif
		clk_disable(s5ptv_status.mixer_clk);
#ifdef CONFIG_S5PV210_PM
		if (0 != s5pv210_pd_disable("mixer_pd")) {
			printk(KERN_ERR "[Error]The power is not off for mixer\n");
			goto err_pm;
		}
#endif
		clk_disable(s5ptv_status.tvenc_clk);
#ifdef CONFIG_S5PV210_PM
		if (s5pv210_pd_disable("tv_enc_pd") < 0) {
			printk(KERN_ERR "[Error]The power is not off for TV ENC\n");
			goto err_pm;
		}
#endif
		clk_disable(s5ptv_status.hdmi_clk);
#ifdef CONFIG_S5PV210_PM
		if (s5pv210_pd_disable("hdmi_pd") < 0) {
			printk(KERN_ERR "[Error]The power is not off for HDMI\n");
			goto err_pm;
		}
#endif
	}

	return 0;
#ifdef CONFIG_S5PV210_PM
err_pm:
	return -1;
#endif
}
示例#7
0
int mfc_power_off(void)
{
	return s5pv210_pd_disable(pm->pd_name);
}
示例#8
0
static int mfc_open(struct inode *inode, struct file *file)
{
	mfc_inst_ctx *mfc_ctx;
	int ret;
	//struct sched_param param = { .sched_priority = 1 };

#if	ENABLE_MONITORING_MFC_DD
	mfc_info("MFC mfc_open..\n");
#endif

	mutex_lock(&mfc_mutex);


	if (!mfc_is_running())
	{
#ifdef CONFIG_CPU_FREQ_S5PV210
		s5pv210_set_cpufreq_level(RESTRICT_TABLE);
#endif /* CONFIG_CPU_FREQ_S5PV210 */
#ifdef CONFIG_S5P_LPAUDIO
		s5p_set_lpaudio_lock(1);
#endif /* CONFIG_S5P_LPAUDIO */

		if (s5pv210_pd_enable("mfc_pd") < 0){
			printk(KERN_ERR "[Error]The power is not on for mfc\n");
			return -1;
		}
		clk_enable(mfc_clk);
#ifdef CONFIG_PM_PWR_GATING
		s5pc110_lock_power_domain(MFC_DOMAIN_LOCK_TOKEN);
#endif

		if (mfc_init_hw() != TRUE)
		{
#if	Frame_Base_Power_CTR_ON
			clk_disable(mfc_clk);
			if (s5pv210_pd_disable("mfc_pd") < 0) {
				printk(KERN_ERR "[Error]The power is not off for mfc\n");
				return -1;
			}
#endif
			ret =  -ENODEV;
			goto out_open;
		}
#if	Frame_Base_Power_CTR_ON
			clk_disable(mfc_clk);
			/*if (s5pv210_pd_disable("mfc_pd") < 0) {
				printk(KERN_ERR "[Error]The power is not off for mfc\n");
				return -1;
			}*/
#endif
	}

	mfc_ctx = (mfc_inst_ctx *)kmalloc(sizeof(mfc_inst_ctx), GFP_KERNEL);
	if (mfc_ctx == NULL)
	{
		mfc_err("MFCINST_MEMORY_ALLOC_FAIL\n");
		ret = -ENOMEM;
		goto out_open;
	}

	memset(mfc_ctx, 0, sizeof(mfc_inst_ctx));

	/* get the inst no allocating some part of memory among reserved memory */
	mfc_ctx->mem_inst_no = mfc_get_mem_inst_no();
	mfc_ctx->InstNo = -1;
	if (mfc_ctx->mem_inst_no < 0)
	{
		mfc_err("MFCINST_INST_NUM_EXCEEDED\n");
		kfree(mfc_ctx);
		ret = -EPERM;
		goto out_open;
	}

	if (mfc_set_state(mfc_ctx, MFCINST_STATE_OPENED) < 0)
	{
		mfc_err("MFCINST_ERR_STATE_INVALID\n");
		kfree(mfc_ctx);
		ret = -ENODEV;
		goto out_open;
	}

	/* Decoder only */
	mfc_ctx->extraDPB = MFC_MAX_EXTRA_DPB;
	mfc_ctx->FrameType = MFC_RET_FRAME_NOT_SET;

	file->private_data = (mfc_inst_ctx *)mfc_ctx;

	//sched_setscheduler(current, SCHED_FIFO, &param);

	ret = 0;

out_open:
	mutex_unlock(&mfc_mutex);

	if(ret != 0)
	{
		mfc_err("MFC_OEPN_FAIL..... ret(%d) \n", ret);
		return ret;
	}

#if	ENABLE_MONITORING_MFC_DD
		mfc_info("MFC_OEPN_OK..... ret(%d) \n", ret);
#endif


	return ret;
}
示例#9
0
static int mfc_resume(struct platform_device *pdev)
{
	int ret = 0;
	unsigned int mc_status;

#if	ENABLE_MONITORING_MFC_DD
	mfc_info("mfc_resume......#1\n");
#endif

	mutex_lock(&mfc_mutex);

	if (!mfc_is_running())
	{
#if	ENABLE_MONITORING_MFC_DD
	mfc_info("mfc_resume......#2-0\n");
#endif
		mutex_unlock(&mfc_mutex);
		return 0;
	}

#if	ENABLE_MONITORING_MFC_DD
	mfc_info("mfc_resume......#2-1\n");
#endif

#if	Frame_Base_Power_CTR_ON
	if (s5pv210_pd_enable("mfc_pd") < 0) {
		printk(KERN_ERR "[Error]The power is not on for mfc\n");
		return -1;
	}
	clk_enable(mfc_clk);
#endif
	/*
	 * 1. MFC reset
	 */
	do {
		mc_status = READL(MFC_MC_STATUS);
	} while(mc_status != 0);

	mfc_cmd_reset();

	WRITEL(mfc_port0_base_paddr, MFC_MC_DRAMBASE_ADDR_A);
	WRITEL(mfc_port1_base_paddr, MFC_MC_DRAMBASE_ADDR_B);
	WRITEL(1, MFC_NUM_MASTER);

	ret = mfc_set_wakeup();
	if(ret != MFCINST_RET_OK){
		mutex_unlock(&mfc_mutex);
		return ret;
	}

#if	Frame_Base_Power_CTR_ON
	clk_disable(mfc_clk);
	if (s5pv210_pd_disable("mfc_pd") < 0) {
		printk(KERN_ERR "[Error]The power is not off for mfc\n");
		return -1;
	}
#endif

	mutex_unlock(&mfc_mutex);

	return 0;
}
示例#10
0
static int mfc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
	int ret, ex_ret;
	mfc_inst_ctx *mfc_ctx = NULL;
	mfc_common_args in_param;

	mutex_lock(&mfc_mutex);
#if	Frame_Base_Power_CTR_ON
	if (s5pv210_pd_enable("mfc_pd") < 0) {
		printk(KERN_ERR "[Error]The power is not on for mfc\n");
		return -1;
	}
	clk_enable(mfc_clk);
#endif

	ret = copy_from_user(&in_param, (mfc_common_args *)arg, sizeof(mfc_common_args));
	if (ret < 0)
	{
		mfc_err("Inparm copy error\n");
		ret = -EIO;
		in_param.ret_code = MFCINST_ERR_INVALID_PARAM;
		goto out_ioctl;
	}

	mfc_ctx = (mfc_inst_ctx *)file->private_data;
	mutex_unlock(&mfc_mutex);

	switch (cmd)
	{
		case IOCTL_MFC_ENC_INIT:
			mutex_lock(&mfc_mutex);

#if	ENABLE_MONITORING_MFC_DD
			mfc_info("IOCTL_MFC_ENC_INIT\n");
#endif
			if (mfc_set_state(mfc_ctx, MFCINST_STATE_ENC_INITIALIZE) < 0)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			/* MFC encode init */
			in_param.ret_code = mfc_init_encode(mfc_ctx, &(in_param.args));
			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_ENC_EXE:
			mutex_lock(&mfc_mutex);
#if	ENABLE_MONITORING_MFC_DD
			mfc_info("IOCTL_MFC_ENC_EXE\n");
#endif

			if (mfc_ctx->MfcState < MFCINST_STATE_ENC_INITIALIZE)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			if (mfc_set_state(mfc_ctx, MFCINST_STATE_ENC_EXE) < 0)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			in_param.ret_code = mfc_exe_encode(mfc_ctx, &(in_param.args));
			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_DEC_INIT:
			mutex_lock(&mfc_mutex);
#if	ENABLE_MONITORING_MFC_DD
			mfc_info("IOCTL_MFC_DEC_INIT\n");
#endif

			if (mfc_set_state(mfc_ctx, MFCINST_STATE_DEC_INITIALIZE) < 0)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			/* MFC decode init */
			in_param.ret_code = mfc_init_decode(mfc_ctx, &(in_param.args));
			if (in_param.ret_code < 0)
			{
                                mfc_err("MFC_DEC_INIT ERROR ............. ret(%d)\n",in_param.ret_code);
				ret = in_param.ret_code;
				mutex_unlock(&mfc_mutex);
				break;
			}

			if (in_param.args.dec_init.out_dpb_cnt <= 0)
			{
				mfc_err("MFC out_dpb_cnt error\n");
				mutex_unlock(&mfc_mutex);
				break;
			}

			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_DEC_EXE:
			mutex_lock(&mfc_mutex);
#if	ENABLE_MONITORING_MFC_DD
			mfc_debug_L0("IOCTL_MFC_DEC_EXE\n");
#endif
			if (mfc_ctx->MfcState < MFCINST_STATE_DEC_INITIALIZE)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			if (mfc_set_state(mfc_ctx, MFCINST_STATE_DEC_EXE) < 0)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			in_param.ret_code = mfc_exe_decode(mfc_ctx, &(in_param.args));
			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_GET_CONFIG:
			mutex_lock(&mfc_mutex);
#if	ENABLE_MONITORING_MFC_DD
			mfc_info("IOCTL_MFC_GET_CONFIG\n");
#endif
			if (mfc_ctx->MfcState < MFCINST_STATE_DEC_INITIALIZE)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			in_param.ret_code = mfc_get_config(mfc_ctx, &(in_param.args));
			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_SET_CONFIG:
			mutex_lock(&mfc_mutex);
#if	ENABLE_MONITORING_MFC_DD
			mfc_info("IOCTL_MFC_SET_CONFIG\n");
#endif
			in_param.ret_code = mfc_set_config(mfc_ctx, &(in_param.args));
			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_GET_IN_BUF:
			mutex_lock(&mfc_mutex);
#if	ENABLE_MONITORING_MFC_DD
			mfc_info("IOCTL_MFC_GET_IN_BUF\n");
#endif
			if (mfc_ctx->MfcState < MFCINST_STATE_OPENED)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			if (in_param.args.mem_alloc.buff_size <= 0)
			{
				mfc_err("MFCINST_ERR_INVALID_PARAM\n");
				in_param.ret_code = MFCINST_ERR_INVALID_PARAM;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			if ((is_dec_codec(in_param.args.mem_alloc.codec_type)) &&
				(in_param.args.mem_alloc.buff_size < (CPB_BUF_SIZE + DESC_BUF_SIZE)))
			{
				in_param.args.mem_alloc.buff_size = CPB_BUF_SIZE + DESC_BUF_SIZE;
			}

			/* Buffer manager should have 64KB alignment for MFC base addresses */
			in_param.args.mem_alloc.buff_size = ALIGN_TO_8KB(in_param.args.mem_alloc.buff_size);

			/* allocate stream buf for decoder & current YC buf for encoder */
			if (is_dec_codec(in_param.args.mem_alloc.codec_type))
			{
				in_param.ret_code = mfc_allocate_buffer(mfc_ctx, &in_param.args, 0);
			}
			else
			{
				in_param.ret_code = mfc_allocate_buffer(mfc_ctx, &in_param.args, 1);
			}

			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_FREE_BUF:
			mutex_lock(&mfc_mutex);
#if	ENABLE_MONITORING_MFC_DD
			mfc_info("IOCTL_MFC_FREE_BUF\n");
#endif

			if (mfc_ctx->MfcState < MFCINST_STATE_OPENED)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			in_param.ret_code = mfc_release_buffer((unsigned char *)in_param.args.mem_free.u_addr);
			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		case IOCTL_MFC_GET_PHYS_ADDR:
			mutex_lock(&mfc_mutex);
			mfc_debug("IOCTL_MFC_GET_PHYS_ADDR\n");

			if (mfc_ctx->MfcState < MFCINST_STATE_OPENED)
			{
				mfc_err("MFCINST_ERR_STATE_INVALID\n");
				in_param.ret_code = MFCINST_ERR_STATE_INVALID;
				ret = -EINVAL;
				mutex_unlock(&mfc_mutex);
				break;
			}

			in_param.ret_code = mfc_get_phys_addr(mfc_ctx, &(in_param.args));
			ret = in_param.ret_code;
			mutex_unlock(&mfc_mutex);
			break;

		default:
			mfc_err("Requested ioctl command is not defined. (ioctl cmd=0x%08x)\n", cmd);
			in_param.ret_code  = MFCINST_ERR_INVALID_PARAM;
			ret = -EINVAL;
	}

out_ioctl:
#if	Frame_Base_Power_CTR_ON
	clk_disable(mfc_clk);
	if (s5pv210_pd_disable("mfc_pd") < 0) {
		printk(KERN_ERR "[Error]The power is not off for mfc\n");
		return -1;
	}
#endif

	ex_ret = copy_to_user((mfc_common_args *)arg, &in_param, sizeof(mfc_common_args));
	if (ex_ret < 0)
	{
		mfc_err("Outparm copy to user error\n");
		ret = -EIO;
	}

	mfc_debug_L0("---------------IOCTL return = %d ---------------\n", ret);

	return ret;
}
示例#11
0
static int mfc_release(struct inode *inode, struct file *file)
{
	mfc_inst_ctx *mfc_ctx;
	int ret;

#if	ENABLE_MONITORING_MFC_DD
	mfc_info("MFC Release..\n");
#endif

	mutex_lock(&mfc_mutex);

#if	Frame_Base_Power_CTR_ON
	/*if (s5pv210_pd_enable("mfc_pd") < 0) {
		printk(KERN_ERR "[Error]The power is not on for mfc\n");
		return -1;
	}*/
	clk_enable(mfc_clk);
#endif

	mfc_ctx = (mfc_inst_ctx *)file->private_data;
	if (mfc_ctx == NULL)
	{
		mfc_err("MFCINST_ERR_INVALID_PARAM\n");
		ret = -EIO;
		goto out_release;
	}

	mfc_release_all_buffer(mfc_ctx->mem_inst_no);
	mfc_merge_fragment(mfc_ctx->mem_inst_no);

	mfc_return_mem_inst_no(mfc_ctx->mem_inst_no);

	/* In case of no instance, we should not release codec instance */
	if (mfc_ctx->InstNo >= 0)
		mfc_return_inst_no(mfc_ctx->InstNo, mfc_ctx->MfcCodecType);

	kfree(mfc_ctx);

	ret = 0;

out_release:


	if (!mfc_is_running())
	{
#ifdef CONFIG_CPU_FREQ_S5PV210
		s5pv210_set_cpufreq_level(NORMAL_TABLE);
#endif /* CONFIG_CPU_FREQ_S5PV210 */
#ifdef CONFIG_PM_PWR_GATING
		s5pc110_unlock_power_domain(MFC_DOMAIN_LOCK_TOKEN);
#endif
#ifdef CONFIG_S5P_LPAUDIO
		s5p_set_lpaudio_lock(0);
#endif /* CONFIG_S5P_LPAUDIO */
	}

	clk_disable(mfc_clk);
	if (s5pv210_pd_disable("mfc_pd") < 0) {
		printk(KERN_ERR "[Error]The power is not off for mfc\n");
		return -1;
	}

	mutex_unlock(&mfc_mutex);
	return ret;
}