DEFINE_SPINLOCK(data_lock);
DEFINE_SPINLOCK(input_int_lock);
DEFINE_SPINLOCK(output_int_lock);
+DEFINE_SPINLOCK(asrc_clock_lock);
#define AICPA 0 /* Input Clock Divider A Offset */
#define AICDA 3 /* Input Clock Prescaler A Offset */
reg = __raw_readl(asrc_vrt_base_addr + ASRC_ASRCTR_REG);
if ((reg & 0x0E) == 0)
clk_enable(mxc_asrc_data->asrc_audio_clk);
-
reg |= (1 << (1 + index));
__raw_writel(reg, asrc_vrt_base_addr + ASRC_ASRCTR_REG);
err = -EFAULT;
break;
}
-
spin_lock_irqsave(&input_int_lock, lock_flags);
if (params->input_queue_empty == 0) {
err = -EFAULT;
{
int err = 0;
struct asrc_pair_params *pair_params;
+ unsigned long lock_flags;
+
+ spin_lock_irqsave(&asrc_clock_lock, lock_flags);
+ g_asrc_data->counter++;
+ clk_enable(mxc_asrc_data->asrc_core_clk);
+ spin_unlock_irqrestore(&asrc_clock_lock, lock_flags);
+
if (signal_pending(current))
return -EINTR;
pair_params = kzalloc(sizeof(struct asrc_pair_params), GFP_KERNEL);
static int mxc_asrc_close(struct inode *inode, struct file *file)
{
struct asrc_pair_params *pair_params;
+ unsigned long lock_flags;
pair_params = file->private_data;
+
if (pair_params->asrc_active == 1) {
dmaengine_terminate_all(pair_params->input_dma_channel);
dmaengine_terminate_all(pair_params->output_dma_channel);
mxc_free_dma_buf(pair_params);
asrc_release_pair(pair_params->index);
}
+
kfree(pair_params);
file->private_data = NULL;
+
+ spin_lock_irqsave(&asrc_clock_lock, lock_flags);
+ g_asrc_data->counter--;
+ if (g_asrc_data->counter == 0)
+ clk_disable(mxc_asrc_data->asrc_core_clk);
+ spin_unlock_irqrestore(&asrc_clock_lock, lock_flags);
return 0;
}
g_asrc_data->asrc_pair[0].overload_error = 0;
g_asrc_data->asrc_pair[1].overload_error = 0;
g_asrc_data->asrc_pair[2].overload_error = 0;
+ g_asrc_data->counter = 0;
asrc_major = register_chrdev(asrc_major, "mxc_asrc", &asrc_fops);
if (asrc_major < 0) {
mxc_asrc_data =
(struct imx_asrc_platform_data *)pdev->dev.platform_data;
+
clk_enable(mxc_asrc_data->asrc_core_clk);
switch (mxc_asrc_data->clk_map_ver) {
err = mxc_init_asrc();
if (err < 0)
goto err_out_class;
-
+ clk_disable(mxc_asrc_data->asrc_core_clk);
goto out;
err_out_class: