Esempio n. 1
0
static void __exit sdp4430_soc_exit(void)
{
#if 0 //Ti patch
	regulator_put(av_switch_reg);
	cdc_tcxo_set_req_int(CDC_TCXO_CLK2, 0);
	cdc_tcxo_set_req_prio(CDC_TCXO_CLK2, CDC_TCXO_PRIO_REQINT);
#else
	cdc_tcxo_set_req_int(CDC_TCXO_CLK3, 0);
	cdc_tcxo_set_req_prio(CDC_TCXO_CLK3, CDC_TCXO_PRIO_REQINT);
#endif
	platform_device_unregister(sdp4430_snd_device);
	snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai));
}
Esempio n. 2
0
static int __init sdp4430_soc_init(void)
{
	int ret = 0;

	if (!machine_is_omap_4430sdp() &&
		!machine_is_omap_tabletblaze()) {
		pr_debug("Not SDP4430 or BlazeTablet\n");
		return -ENODEV;
	}
	printk(KERN_INFO "SDP4430 SoC init\n");

	sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
	if (!sdp4430_snd_device) {
		printk(KERN_ERR "Platform device allocation failed\n");
		return -ENOMEM;
	}

	snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));

	platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);

	ret = platform_device_add(sdp4430_snd_device);
	if (ret)
		goto plat_err;

	av_switch_reg = regulator_get(&sdp4430_snd_device->dev, "av-switch");
	if (IS_ERR(av_switch_reg)) {
		ret = PTR_ERR(av_switch_reg);
		printk(KERN_ERR "couldn't get AV Switch regulator %d\n",
			ret);
		goto reg_err;
	}

	/* Default mode is low-power, MCLK not required */
	twl6040_power_mode = 0;
	cdc_tcxo_set_req_int(CDC_TCXO_CLK2, 0);

	/*
	 * CDC CLK2 supplies TWL6040 MCLK, drive it from REQ2INT to
	 * have full control of MCLK gating
	 */
	cdc_tcxo_set_req_prio(CDC_TCXO_CLK2, CDC_TCXO_PRIO_REQINT);

	return ret;

reg_err:
	platform_device_del(sdp4430_snd_device);
plat_err:
	printk(KERN_ERR "Unable to add platform device\n");
	platform_device_put(sdp4430_snd_device);
	return ret;
}
Esempio n. 3
0
static int twl6040_shutdown(struct snd_pcm_substream *substream,
			struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai ? (dai->codec) : 0;
	struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);

	int idx;
	int cnt = 0;
	
	for( idx = 0 ; idx < TWL6040_MUTE_DATA_MAX ; idx++ )
	{
		if( s_mute_data[idx].dai == dai )
		{
			s_mute_data[idx].dai = 0;
			s_mute_data[idx].mute = 0;
		}

		if( s_mute_data[idx].dai )
			cnt++;
	}

	if( substream->stream == SNDRV_PCM_STREAM_CAPTURE )
		priv->ul_active--;
	if( substream->stream == SNDRV_PCM_STREAM_PLAYBACK )
		priv->dl_active--;
		
	if( cnt == 0 ) 
	{
		cdc_tcxo_set_req_prio(CDC_TCXO_CLK3, CDC_TCXO_PRIO_REQ);
		// FIXME : T_T 
		// TWL6040 DAC is going crazy. No way to recover. So, I decide to reset twl6040 here. (normal -> sleep -> normal)
		// reset twl6040
		if( codec->dapm->bias_level != SND_SOC_BIAS_OFF ){
			struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
			enum snd_soc_bias_level level = codec->dapm->bias_level;
			printk(KERN_ERR "twl6040_shutdown reset!! start\n");
			twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF);	// normal -> sleep
			msleep(5);	// more more...
			twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY);	// sleep -> normal			
			twl6040_set_bias_level(codec, level);
			printk(KERN_ERR "twl6040_shutdown reset!! end\n");
		}
	}

	return 0;
	
}
Esempio n. 4
0
static int __init cosmopolitan_soc_init(void)
{
	int ret;

	if (!machine_is_cosmopolitan()) {
		pr_debug("Not COSMOPOLITAN!\n");
		return -ENODEV;
	}
	printk(KERN_INFO "COSMOPOLITAN SoC init\n");

	sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
	if (!sdp4430_snd_device) {
		printk(KERN_ERR "Platform device allocation failed\n");
		return -ENOMEM;
	}

	snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));

	platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);

	ret = platform_device_add(sdp4430_snd_device);
	if (ret)
		goto plat_err;

	/* Default mode is low-power, MCLK not required */
	twl6040_power_mode = 0;
	cdc_tcxo_set_req_int(CDC_TCXO_CLK2, 0);

	/*
	 * CDC CLK2 supplies TWL6040 MCLK, drive it from REQ2INT to
	 * have full control of MCLK gating
	 */
	cdc_tcxo_set_req_prio(CDC_TCXO_CLK2, CDC_TCXO_PRIO_REQINT);

	return ret;

plat_err:
	printk(KERN_ERR "Unable to add platform device\n");
	platform_device_put(sdp4430_snd_device);
	return ret;
}
Esempio n. 5
0
static int twl6040_set_dai_sysclk(struct snd_soc_dai *codec_dai,
		int clk_id, unsigned int freq, int dir)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
	u8 hppllctl, lppllctl;

	hppllctl = twl6040_read_reg_cache(codec, TWL6040_REG_HPPLLCTL);
	lppllctl = twl6040_read_reg_cache(codec, TWL6040_REG_LPPLLCTL);

	switch (clk_id) {
	case TWL6040_SYSCLK_SEL_LPPLL:
		switch (freq) {
		case 32768:
			/* headset dac and driver must be in low-power mode */
			headset_power_mode(codec, 0);

			/* clk32k input requires low-power pll */
			lppllctl |= TWL6040_LPLLENA;
			twl6040_write(codec, TWL6040_REG_LPPLLCTL, lppllctl);
			mdelay(5);
			lppllctl &= ~TWL6040_HPLLSEL;
			twl6040_write(codec, TWL6040_REG_LPPLLCTL, lppllctl);
			hppllctl &= ~TWL6040_HPLLENA;
			twl6040_write(codec, TWL6040_REG_HPPLLCTL, hppllctl);
			break;
		default:
			dev_err(codec->dev, "unknown mclk freq %d\n", freq);
			return -EINVAL;
		}

		/* lppll divider */
		switch (priv->sysclk) {
		case 17640000:
			lppllctl |= TWL6040_LPLLFIN;
			break;
		case 19200000:
			lppllctl &= ~TWL6040_LPLLFIN;
			break;
		default:
			/* sysclk not yet configured */
			lppllctl &= ~TWL6040_LPLLFIN;
			priv->sysclk = 19200000;
			break;
		}

		twl6040_write(codec, TWL6040_REG_LPPLLCTL, lppllctl);

		priv->pll = TWL6040_LPPLL_ID;
		priv->sysclk_constraints = &lp_constraints;

		cdc_tcxo_set_req_prio(CDC_TCXO_CLK3, CDC_TCXO_PRIO_REQINT);
		break;
	case TWL6040_SYSCLK_SEL_HPPLL:
		cdc_tcxo_set_req_prio(CDC_TCXO_CLK3, CDC_TCXO_PRIO_REQ);
		hppllctl &= ~TWL6040_MCLK_MSK;

		switch (freq) {
		case 12000000:
			/* mclk input, pll enabled */
			hppllctl |= TWL6040_MCLK_12000KHZ |
				    TWL6040_HPLLSQRBP |
				    TWL6040_HPLLENA;
			break;
		case 19200000:
			/* mclk input, pll disabled */
			hppllctl |= TWL6040_MCLK_19200KHZ |
				    TWL6040_HPLLSQRENA |
				    TWL6040_HPLLBP;
			break;
		case 26000000:
			/* mclk input, pll enabled */
			hppllctl |= TWL6040_MCLK_26000KHZ |
				    TWL6040_HPLLSQRBP |
				    TWL6040_HPLLENA;
			break;
		case 38400000:
			/* clk slicer, pll disabled */
			hppllctl |= TWL6040_MCLK_38400KHZ |
				    TWL6040_HPLLSQRENA |
				    TWL6040_HPLLBP;
			break;
		default:
			dev_err(codec->dev, "unknown mclk freq %d\n", freq);
			return -EINVAL;
		}

		/* headset dac and driver must be in high-performance mode */
		headset_power_mode(codec, 1);

		twl6040_write(codec, TWL6040_REG_HPPLLCTL, hppllctl);
		udelay(500);
		lppllctl |= TWL6040_HPLLSEL;
		twl6040_write(codec, TWL6040_REG_LPPLLCTL, lppllctl);
		lppllctl &= ~TWL6040_LPLLENA;
		twl6040_write(codec, TWL6040_REG_LPPLLCTL, lppllctl);

		/* high-performance pll can provide only 19.2 MHz */
		priv->pll = TWL6040_HPPLL_ID;
		priv->sysclk = 19200000;
		priv->sysclk_constraints = &hp_constraints;
		break;
	default:
		dev_err(codec->dev, "unknown clk_id %d\n", clk_id);
		return -EINVAL;
	}

	return 0;
}
static int __init sdp4430_soc_init(void)
{
	int ret;

	if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda() &&
		!machine_is_omap_tabletblaze()) {
		pr_debug("Not SDP4430, BlazeTablet or PandaBoard!\n");
		return -ENODEV;
	}
	printk(KERN_INFO "SDP4430 SoC init\n");
	if (machine_is_omap_4430sdp())
		snd_soc_sdp4430.name = "SDP4430";
	else if (machine_is_omap4_panda())
		snd_soc_sdp4430.name = "Panda";
	else if (machine_is_omap_tabletblaze())
		snd_soc_sdp4430.name = "Tablet44xx";

	sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
	if (!sdp4430_snd_device) {
		printk(KERN_ERR "Platform device allocation failed\n");
		return -ENOMEM;
	}

	ret = snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));
	if (ret < 0)
		goto err;
	platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);

	ret = platform_device_add(sdp4430_snd_device);
	if (ret)
		goto err_dev;

	twl6040_codec = snd_soc_card_get_codec(&snd_soc_sdp4430,
					"twl6040-codec");
	if(twl6040_codec <= 0) {
		printk(KERN_ERR "sdp4430: could not find `twl6040-codec`\n");
		ret = -ENODEV;
		goto err_dev;
	}

	/*av_switch_reg = regulator_get(&sdp4430_snd_device->dev, "av-switch");
	if (IS_ERR(av_switch_reg)) {
		ret = PTR_ERR(av_switch_reg);
		printk(KERN_ERR "couldn't get AV Switch regulator %d\n",
			ret);
		goto err_dev;
	}*/

	/* Default mode is low-power, MCLK not required */
	twl6040_power_mode = 0;
	cdc_tcxo_set_req_int(CDC_TCXO_CLK2, 0);

	/*
	 * CDC CLK2 supplies TWL6040 MCLK, drive it from REQ2INT to
	 * have full control of MCLK gating
	 */
	cdc_tcxo_set_req_prio(CDC_TCXO_CLK2, CDC_TCXO_PRIO_REQINT);

	return ret;

err_dev:
	snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai));
err:
	platform_device_put(sdp4430_snd_device);
	return ret;
}
Esempio n. 7
0
static int __init sdp4430_soc_init(void)
{
	u8 gpoctl;
	int ret;

//  Need Fix
//	if (!machine_is_p2() && !machine_is_lghdk() && !machine_is_iff() && !machine_is_u2) {
//		printk("Not Supported Sound Device\n");
//		return -ENODEV;
//	}
	printk(KERN_INFO "LG SoC init\n");
	if (machine_is_lghdk())
                snd_soc_sdp4430.name = "lghdk";
        else if(machine_is_p2())
                snd_soc_sdp4430.name = "p2";
        else if(machine_is_iff())
                snd_soc_sdp4430.name = "iff";
// Need Fix
	else
		snd_soc_sdp4430.name = "u2";

	sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
	if (!sdp4430_snd_device) {
		printk(KERN_ERR "Platform device allocation failed\n");
		return -ENOMEM;
	}

	ret = snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai));
	if (ret < 0)
		goto err;
	platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);

	ret = platform_device_add(sdp4430_snd_device);
	if (ret)
		goto err_dev;

	twl6040_codec = snd_soc_card_get_codec(&snd_soc_sdp4430,
					"twl6040-codec");
	if(twl6040_codec <= 0) {
		printk(KERN_ERR "sdp4430: could not find `twl6040-codec`\n");
		ret = -ENODEV;
		goto err_dev;
	}

#if 0 //Ti patch
	av_switch_reg = regulator_get(&sdp4430_snd_device->dev, "av-switch");
	if (IS_ERR(av_switch_reg)) {
		ret = PTR_ERR(av_switch_reg);
		printk(KERN_ERR "couldn't get AV Switch regulator %d\n",
			ret);
		goto err_dev;
	}

	/* Default mode is low-power, MCLK not required */
	twl6040_power_mode = 0;
	cdc_tcxo_set_req_int(CDC_TCXO_CLK2, 0);

	/*
	 * CDC CLK2 supplies TWL6040 MCLK, drive it from REQ2INT to
	 * have full control of MCLK gating
	 */
	cdc_tcxo_set_req_prio(CDC_TCXO_CLK2, CDC_TCXO_PRIO_REQINT);

	return ret;
#else //                                              

	/* Default mode is low-power, MCLK not required */
	twl6040_power_mode = 0;	//  Set Default mode is High-Performace power

	//                                                                                        
	//cdc_tcxo_set_req_int(CDC_TCXO_CLK3, 0);
	cdc_tcxo_set_req_int(CDC_TCXO_CLK3, 1);
	//                                                                                      

	/*
	 * CDC CLK2 supplies TWL6040 MCLK, drive it from REQ2INT to
	 * have full control of MCLK gating
	 */
	cdc_tcxo_set_req_prio(CDC_TCXO_CLK3, CDC_TCXO_PRIO_REQINT);

	return 0;
#endif

err_dev:
	snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai));
err:
	platform_device_put(sdp4430_snd_device);
	return ret;
}