Beispiel #1
0
static int s3c_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai)
{
	int ret = 0;

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_RESUME:
			break;

	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		if (lpam_i2s.slave) {
			ret = s3c_snd_lrsync();
			if (ret)
				goto exit_err;
		}

		s3c_snd_txctrl(1);
		break;

	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
		s3c_snd_txctrl(0);
		break;

	default:
		ret = -EINVAL;
		break;
	}

exit_err:
	return ret;
}
Beispiel #2
0
static int s3c_pcmdev_trigger(struct snd_pcm_substream *substream,
				int cmd, struct snd_soc_dai *dai)
{
	int ret = 0;

	debug_msg("%s\n", __func__);

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		debug_msg("Pcm trigger start - %d\n", cmd);
		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
			s3c_snd_rxctrl(1);
		else
			s3c_snd_txctrl(1);
		break;
	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
		debug_msg("Pcm trigger stop - %d\n", cmd);
		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
			s3c_snd_rxctrl(0);
		else
			s3c_snd_txctrl(0);
		break;
	default:
		printk(KERN_ERR
			"Invalid pcm trigger cmd - %d\n", cmd);
		ret = -EINVAL;
		break;
	}

	return ret;
}
Beispiel #3
0
static int s3c_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
				struct snd_soc_dai *dai)
{
	int ret = 0;

	debug_msg("%s, stream:%d \n", __FUNCTION__, substream->stream);

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		if (s3c_i2s.slave) 
		{
			ret = s3c_snd_lrsync();
			if (ret)
				goto exit_err;
		}

		debug_msg("Start\n");
		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
			s3c_snd_rxctrl(1);
		else
			s3c_snd_txctrl(1);
		break;
	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
		debug_msg("Stop\n");
		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
			s3c_snd_rxctrl(0);
		else
			s3c_snd_txctrl(0);
		break;
	default:
		ret = -EINVAL;
		break;
	}


exit_err:
	return ret;
}
Beispiel #4
0
static int s3c_pcmdev_probe(struct platform_device *pdev,
			     struct snd_soc_dai *dai)
{
	int ret = 0;
	struct clk *cm, *cf;

	debug_msg("+++++++%s\n", __func__);

	s3c_pcmdev.regs = ioremap(S3C_PA_PCM, 0x100);
	if (s3c_pcmdev.regs == NULL)
		return -ENXIO;

	ret = request_irq(IRQ_S3C_PCM, s3c_pcmdev_irq, 0, "s3c-pcmdev", pdev);
	if (ret < 0) {
		printk(KERN_ERR
			"fail to claim pcmdev irq , ret = %d\n", ret);
		iounmap(s3c_pcmdev.regs);
		return -ENODEV;
	}


	s3c_pcmdev.pcm_clk = clk_get(&pdev->dev, "pcm");
	if (IS_ERR(s3c_pcmdev.pcm_clk)) {
		printk(KERN_ERR
			"failed to get clk(pcm1)\n");
		goto err_exit4;
	}
	s3c_pcmdev.clk_rate = clk_get_rate(s3c_pcmdev.pcm_clk);

	s3c_pcmdev.clk_src = clk_get(&pdev->dev, EXTCLK);
	if (IS_ERR(s3c_pcmdev.clk_src)) {
		printk(KERN_ERR
			"failed to get clk(%s)\n", EXTCLK);
		goto err_exit3;
	}

	cm = clk_get(NULL, EXTPRNT);
	if (IS_ERR(cm)) {
		printk(KERN_ERR
			"failed to get %s\n", EXTPRNT);
		goto err_exit2;
	}
/*	s3cdbg("Got Audio Bus Source Clock -> %s\n", EXTPRNT);*/

	if (clk_set_parent(s3c_pcmdev.clk_src, cm)) {
		printk(KERN_ERR
			"failed to set mOUTepll as parent of scklkaudio1\n");
		goto err_exit1;
	}

	cf = clk_get(NULL, "fout_epll");
	if (IS_ERR(cf)) {
		printk(KERN_ERR
			"failed to get fout_epll\n");
		goto err_exit1;
	}

	if (clk_set_parent(cm, cf)) {
		printk(KERN_ERR
			"failed to set FOUTepll as parent of MOUTepll\n");
		goto err_exit0;
	}
 /*	s3cdbg("Set fout_epll as parent of %s\n", EXTPRNT);*/


	s3c_pcmdev.clk_rate = clk_get_rate(s3c_pcmdev.clk_src);

	debug_msg("EXTclock rate=%d @..%d..\n", s3c_pcmdev.clk_rate, __LINE__);
	s3c_pcmdev.clk_rate = clk_get_rate(s3c_pcmdev.pcm_clk);
	debug_msg("PCMclock rate=%d @..%d..\n", s3c_pcmdev.clk_rate, __LINE__);
	clk_put(cf);
	clk_put(cm);
	s3c_snd_txctrl(0);
	s3c_snd_rxctrl(0);

	debug_msg("----------%s\n", __func__);
	return 0;
err_exit0:
	clk_put(cf);
err_exit1:
	clk_put(cm);
err_exit2:
	clk_put(s3c_pcmdev.clk_src);
err_exit3:
	clk_disable(s3c_pcmdev.pcm_clk);
	clk_put(s3c_pcmdev.pcm_clk);
err_exit4:
	free_irq(IRQ_S3C_PCM, pdev);
	iounmap(s3c_pcmdev.regs);

	return -ENODEV;
}
Beispiel #5
0
static int s3c_i2s_probe(struct platform_device *pdev,
			     struct snd_soc_dai *dai)
{
	int ret = 0;
	struct clk *cm, *cf;

	debug_msg("%s\n", __FUNCTION__);
	
	/* Configure the I2S pins in correct mode */
#ifndef CONFIG_SND_S3C64XX_I2S_BUS1
	s3c_gpio_cfgpin(S3C64XX_GPD(0),S3C64XX_GPD0_I2S0_CLK);
	s3c_gpio_cfgpin(S3C64XX_GPD(1),S3C64XX_GPD1_I2S0_CDCLK);
	s3c_gpio_cfgpin(S3C64XX_GPD(2),S3C64XX_GPD2_I2S0_LRCLK);
	
	s3c_gpio_cfgpin(S3C64XX_GPD(3),S3C64XX_GPD3_I2S0_DI);
	s3c_gpio_cfgpin(S3C64XX_GPD(4),S3C64XX_GPD4_I2S0_DO);

	/* pull-up-enable, pull-down-disable*/
	s3c_gpio_setpull(S3C64XX_GPD(0), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPD(1), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPD(2), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPD(3), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPD(4), S3C_GPIO_PULL_UP);
#else
	s3c_gpio_cfgpin(S3C64XX_GPE(0),S3C64XX_GPE0_I2S1_CLK);
	s3c_gpio_cfgpin(S3C64XX_GPE(1),S3C64XX_GPE1_I2S1_CDCLK);
	s3c_gpio_cfgpin(S3C64XX_GPE(2),S3C64XX_GPE2_I2S1_LRCLK);

	s3c_gpio_cfgpin(S3C64XX_GPE(3),S3C64XX_GPE3_I2S1_DI);
	s3c_gpio_cfgpin(S3C64XX_GPE(4),S3C64XX_GPE4_I2S1_DO);

	/* pull-up-enable, pull-down-disable*/
	s3c_gpio_setpull(S3C64XX_GPE(0), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPE(1), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPE(2), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPE(3), S3C_GPIO_PULL_UP);
	s3c_gpio_setpull(S3C64XX_GPE(4), S3C_GPIO_PULL_UP);
#endif

	s3c_i2s.regs = ioremap(S3C_IIS_PABASE, 0x100);
	if (s3c_i2s.regs == NULL)
		return -ENXIO;

	ret = request_irq(S3C_IISIRQ, s3c_iis_irq, 0, "s3c-i2s", pdev);
	if (ret < 0) {
		printk("fail to claim i2s irq , ret = %d\n", ret);
		iounmap(s3c_i2s.regs);
		return -ENODEV;
	}

	printk("pd name=%s\n", pdev->name);
	s3c_i2s.iis_clk = clk_get(&pdev->dev, PCLKCLK);
	if (IS_ERR(s3c_i2s.iis_clk)) {
		printk("failed to get clk(%s)\n", PCLKCLK);
		goto lb5;
	}
	clk_enable(s3c_i2s.iis_clk);
	s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.iis_clk);

	debug_msg("s3c_i2s.clk_rate1=%d\n",s3c_i2s.clk_rate);

#ifdef USE_CLKAUDIO
	s3c_i2s.audio_bus = clk_get(NULL, EXTCLK);
	if (IS_ERR(s3c_i2s.audio_bus)) {
		printk("failed to get clk(%s)\n", EXTCLK);
		goto lb4;
	}

	cm = clk_get(NULL, "mout_epll");
	if (IS_ERR(cm)) {
		printk("failed to get mout_epll\n");
		goto lb3;
	}
	if(clk_set_parent(s3c_i2s.audio_bus, cm)){
		printk("failed to set MOUTepll as parent of CLKAUDIO0\n");
		goto lb2;
	}

	cf = clk_get(NULL, "fout_epll");
	if (IS_ERR(cf)) {
		printk("failed to get fout_epll\n");
		goto lb2;
	}
	clk_enable(cf);
	
	if(clk_set_parent(cm, cf)){
		printk("failed to set FOUTepll as parent of MOUTepll\n");
		goto lb1;
	}
	s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.audio_bus);
	clk_put(cf);
	clk_put(cm);
#endif

	debug_msg("s3c_i2s.clk_rate2=%d\n",s3c_i2s.clk_rate);

	writel(S3C_IISCON_I2SACTIVE | S3C_IISCON_SWRESET, s3c_i2s.regs + S3C_IISCON);

	s3c_snd_txctrl(0);
	s3c_snd_rxctrl(0);

	return 0;

#ifdef USE_CLKAUDIO
lb1:
	clk_put(cf);
lb2:
	clk_put(cm);
lb3:
	clk_put(s3c_i2s.audio_bus);
#endif
lb4:
	clk_disable(s3c_i2s.iis_clk);
	clk_put(s3c_i2s.iis_clk);
lb5:
	free_irq(S3C_IISIRQ, pdev);
	iounmap(s3c_i2s.regs);
	
	return -ENODEV;
}
Beispiel #6
0
static int s3c_i2s_probe(struct platform_device *pdev,
			     struct snd_soc_dai *dai)
{
	int ret = 0;
	struct clk *cf, *cm;

	/* Already called for one DAI */
	if(lpam_i2s.regs != NULL)
		return 0;

	lpam_clk_rate = &lpam_i2s.clk_rate;
	spin_lock_init(&lpam_pdata.lock);

	__lpinit();

	lpam_i2s.regs = ioremap(S3C_IIS_PABASE, 0x100);
	if (lpam_i2s.regs == NULL)
		return -ENXIO;

	ret = request_irq(S3C_IISIRQ, s3c_iis_irq, 0, "s3c-i2s", pdev);
	if (ret < 0) {
		printk("fail to claim i2s irq , ret = %d\n", ret);
		iounmap(lpam_i2s.regs);
		return -ENODEV;
	}

	lpam_i2s.iis_clk = clk_get(&pdev->dev, "iis");
	if (IS_ERR(lpam_i2s.iis_clk)) {
		printk("failed to get clk(iis)\n");
		goto lb4;
	}
	s3cdbg("Got Clock -> iis\n");
	clk_enable(lpam_i2s.iis_clk);
	lpam_i2s.clk_rate = clk_get_rate(lpam_i2s.iis_clk);

	/* To avoid switching between sources(LP vs NM mode),
	 * we use EXTPRNT as parent clock of audio-bus.
	 */
	lpam_i2s.audio_bus = clk_get(&pdev->dev, "audio-bus");
	if (IS_ERR(lpam_i2s.audio_bus)) {
		printk("failed to get clk(audio-bus)\n");
		goto lb3;
	}
	s3cdbg("Got Audio Bus Clock -> audio-bus\n");

	cm = clk_get(NULL, EXTPRNT);
	if (IS_ERR(cm)) {
		printk("failed to get %s\n", EXTPRNT);
		goto lb2;
	}
	s3cdbg("Got Audio Bus Source Clock -> %s\n", EXTPRNT);

	if(clk_set_parent(lpam_i2s.audio_bus, cm)){
		printk("failed to set %s as parent of audio-bus\n", EXTPRNT);
		goto lb1;
	}
	s3cdbg("Set %s as parent of audio-bus\n", EXTPRNT);

#if defined(CONFIG_MACH_SMDKC110)
	cf = clk_get(NULL, "fout_epll");
	if (IS_ERR(cf)) {
		printk("failed to get fout_epll\n");
		goto lb1;
	}
	s3cdbg("Got Clock -> fout_epll\n");

	if(clk_set_parent(cm, cf)){
		printk("failed to set fout_epll as parent of %s\n", EXTPRNT);
		clk_put(cf);
		goto lb1;
	}
	s3cdbg("Set fout_epll as parent of %s\n", EXTPRNT);
	clk_put(cf);
#endif
	clk_put(cm);

	clk_enable(lpam_i2s.audio_bus);
	lpam_i2s.clk_rate = clk_get_rate(lpam_i2s.audio_bus);

	init_i2s();

	s3c_snd_txctrl(0);

	return 0;

lb1:
	clk_put(cm);
lb2:
	clk_put(lpam_i2s.audio_bus);
lb3:
	clk_disable(lpam_i2s.iis_clk);
	clk_put(lpam_i2s.iis_clk);
lb4:
	free_irq(S3C_IISIRQ, pdev);
	iounmap(lpam_i2s.regs);

	return -ENODEV;
}
static int s3c_i2s_probe(struct platform_device *pdev,
	struct snd_soc_dai *dai)
{
	int ret = 0;
#if USE_CLKAUDIO
	struct clk *cm, *cf;
#endif

	debug_msg("%s\n", __FUNCTION__);

	s3c_i2s.regs = ioremap(S3C_IIS_PABASE, 0x100);

	/* Configure the I2S pins in correct mode */
	s3c_gpio_cfgpin(GPIO_I2S_LRCLK, S3C_GPIO_SFN(GPIO_I2S_LRCLK_AF)); 
	s3c_gpio_cfgpin(GPIO_I2S_CLK, S3C_GPIO_SFN(GPIO_I2S_CLK_AF)); 
	s3c_gpio_cfgpin(GPIO_I2S_DI, S3C_GPIO_SFN(GPIO_I2S_DI_AF));   
	s3c_gpio_cfgpin(GPIO_I2S_DO, S3C_GPIO_SFN(GPIO_I2S_DO_AF));

    /* pull-up-enable, pull-down-disable*/
	s3c_gpio_setpull(GPIO_I2S_CLK, S3C_GPIO_PULL_UP); 
	s3c_gpio_setpull(GPIO_I2S_LRCLK, S3C_GPIO_PULL_UP); 
	s3c_gpio_setpull(GPIO_I2S_DI, S3C_GPIO_PULL_UP); 
	s3c_gpio_setpull(GPIO_I2S_DO, S3C_GPIO_PULL_UP); 

	if (s3c_i2s.regs == NULL)
		return -ENXIO;

	ret = request_irq(S3C_IISIRQ, s3c_iis_irq, 0, "s3c-i2s", pdev);
	if (ret < 0) {
		printk("fail to claim i2s irq , ret = %d\n", ret);
		iounmap(s3c_i2s.regs);
		return -ENODEV;
	}

	s3c_i2s.iis_clk = clk_get(&pdev->dev, PCLKCLK);
	if (IS_ERR(s3c_i2s.iis_clk)) {
		printk("failed to get clk(%s)\n", PCLKCLK);
		goto lb5;
	}
	clk_enable(s3c_i2s.iis_clk);
	s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.iis_clk);

#if USE_CLKAUDIO
	s3c_i2s.audio_bus = clk_get(NULL, EXTCLK);
	if (IS_ERR(s3c_i2s.audio_bus)) {
		printk("failed to get clk(%s)\n", EXTCLK);
		goto lb4;
	}

	cm = clk_get(NULL, "mout_epll");
	if (IS_ERR(cm)) {
		printk("failed to get mout_epll\n");
		goto lb3;
	}
	if(clk_set_parent(s3c_i2s.audio_bus, cm)){
		printk("failed to set MOUTepll as parent of CLKAUDIO0\n");
		goto lb2;
	}

	cf = clk_get(NULL, "fout_epll");
	if (IS_ERR(cf)) {
		printk("failed to get fout_epll\n");
		goto lb2;
	}
	clk_enable(cf);
	if(clk_set_parent(cm, cf)){
		printk("failed to set FOUTepll as parent of MOUTepll\n");
		goto lb1;
	}
	s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.audio_bus);
	clk_put(cf);
	clk_put(cm);
#endif

#if defined(CONFIG_SND_S3C_I2S_V50)
	writel(readl(s3c_i2s.regs + S3C_IISCON) | S3C_IISCON_SWRESET, s3c_i2s.regs + S3C_IISCON);
#else
	writel(S3C_IISCON_I2SACTIVE, s3c_i2s.regs + S3C_IISCON);
#endif


	s3c_snd_txctrl(0);
	s3c_snd_rxctrl(0);


	return 0;

#if USE_CLKAUDIO
lb1:
	clk_put(cf);
lb2:
	clk_put(cm);
lb3:
	clk_put(s3c_i2s.audio_bus);
lb4:
	clk_disable(s3c_i2s.iis_clk);
	clk_put(s3c_i2s.iis_clk);
#endif
lb5:
	free_irq(S3C_IISIRQ, pdev);
	iounmap(s3c_i2s.regs);
	
	return -ENODEV;
}
Beispiel #8
0
static int s3c_i2s_probe(struct platform_device *pdev,
			     struct snd_soc_dai *dai)
{
	int ret = 0;
	struct clk *cm, *cf;

	debug_msg("%s\n", __FUNCTION__);

  debug_msg("S3C_IIS_PABASE=0x%x ...\n",S3C_IIS_PABASE);
	s3c_i2s.regs = ioremap(S3C_IIS_PABASE, 0x100);
	if (s3c_i2s.regs == NULL)
	{
		debug_msg("%s ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", __FUNCTION__);
		return -ENXIO;
  }
  
	ret = request_irq(S3C_IISIRQ, s3c_iis_irq, 0, "s3c-i2s", pdev);
	if (ret < 0) {
		printk("fail to claim i2s irq , ret = %d\n", ret);
		iounmap(s3c_i2s.regs);
		return -ENODEV;
	}

	//s3c_i2s.iis_clk = clk_get(&pdev->dev, PCLKCLK);
	s3c_i2s.iis_clk = clk_get(&pdev->dev, "i2s_v32");
	//s3c_i2s.iis_clk = clk_get(&pdev->dev, "fout_epll");
	
	debug_msg("after clk_tet(\"i2s_v32\")...\n");
	if (IS_ERR(s3c_i2s.iis_clk)) {
		printk("failed to get clk(%s)\n", PCLKCLK);
		goto lb5;
	}
	clk_enable(s3c_i2s.iis_clk);
	s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.iis_clk);

  debug_msg("EXTCLK: %s__________________0\n",EXTCLK);
#ifdef USE_CLKAUDIO
	s3c_i2s.audio_bus = clk_get(NULL, EXTCLK);
 	debug_msg("EXTCLK: %s__________________1\n",EXTCLK);
	if (IS_ERR(s3c_i2s.audio_bus)) {
		printk("failed to get clk(%s)\n", EXTCLK);
		goto lb4;
	}

	cm = clk_get(NULL, "mout_epll");
	if (IS_ERR(cm)) {
		printk("failed to get mout_epll\n");
		goto lb3;
	}
	if(clk_set_parent(s3c_i2s.audio_bus, cm)){
		printk("failed to set MOUTepll as parent of CLKAUDIO0\n");
		goto lb2;
	}

	cf = clk_get(NULL, "fout_epll");
	if (IS_ERR(cf)) {
		printk("failed to get fout_epll\n");
		goto lb2;
	}
	clk_enable(cf);
	if(clk_set_parent(cm, cf)){
		printk("failed to set FOUTepll as parent of MOUTepll\n");
		goto lb1;
	}
	s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.audio_bus);
	clk_put(cf);
	clk_put(cm);
#endif

	writel(S3C_IISCON_I2SACTIVE | S3C_IISCON_SWRESET, s3c_i2s.regs + S3C_IISCON);

	s3c_snd_txctrl(0);
	s3c_snd_rxctrl(0);

	return 0;

#ifdef USE_CLKAUDIO
lb1:
	clk_put(cf);
lb2:
	clk_put(cm);
lb3:
	clk_put(s3c_i2s.audio_bus);
#endif
lb4:
	clk_disable(s3c_i2s.iis_clk);
	clk_put(s3c_i2s.iis_clk);
lb5:
	free_irq(S3C_IISIRQ, pdev);
	iounmap(s3c_i2s.regs);
	
	return -ENODEV;
}