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; } return ret; err_dev: snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai)); err: platform_device_put(sdp4430_snd_device); return ret; }
static int sdp4430_twl6040_init_hs(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; int ret; /* Add SDP4430 specific controls */ ret = snd_soc_add_controls(codec, sdp4430_controls, ARRAY_SIZE(sdp4430_controls)); if (ret) return ret; /* Add SDP4430 specific widgets */ ret = snd_soc_dapm_new_controls(codec->dapm, sdp4430_twl6040_dapm_widgets, ARRAY_SIZE(sdp4430_twl6040_dapm_widgets)); if (ret) return ret; /* Set up SDP4430 specific audio path audio_map */ snd_soc_dapm_add_routes(codec->dapm, audio_map, ARRAY_SIZE(audio_map)); /* SDP4430 connected pins */ snd_soc_dapm_enable_pin(codec->dapm, "Ext Mic"); snd_soc_dapm_enable_pin(codec->dapm, "Ext Spk"); snd_soc_dapm_enable_pin(codec->dapm, "AFML"); snd_soc_dapm_enable_pin(codec->dapm, "AFMR"); snd_soc_dapm_disable_pin(codec->dapm, "Headset Mic"); snd_soc_dapm_disable_pin(codec->dapm, "Headset Stereophone"); /* allow audio paths from the audio modem to run during suspend */ snd_soc_dapm_ignore_suspend(codec, "Ext Mic"); snd_soc_dapm_ignore_suspend(codec, "Ext Spk"); snd_soc_dapm_ignore_suspend(codec, "AFML"); snd_soc_dapm_ignore_suspend(codec, "AFMR"); snd_soc_dapm_ignore_suspend(codec, "Headset Mic"); snd_soc_dapm_ignore_suspend(codec, "Headset Stereophone"); ret = snd_soc_dapm_sync(codec->dapm); if (ret) return ret; /*Headset jack detection */ ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, &hs_jack); if (ret) return ret; ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), hs_jack_pins); if (machine_is_omap_4430sdp() || machine_is_omap_tabletblaze()) twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); else snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); /* wait 500 ms before switching of HS power */ rtd->pmdown_time = 500; return ret; }
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; }
static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct twl6040 *twl6040 = codec->control_data; struct snd_soc_dapm_context *dapm = &codec->dapm; int hsotrim, left_offset, right_offset, mode, ret; /* Add SDP4430 specific controls */ ret = snd_soc_add_controls(codec, sdp4430_controls, ARRAY_SIZE(sdp4430_controls)); if (ret) return ret; /* Add SDP4430 specific widgets */ ret = snd_soc_dapm_new_controls(dapm, sdp4430_twl6040_dapm_widgets, ARRAY_SIZE(sdp4430_twl6040_dapm_widgets)); if (ret) return ret; /* Set up SDP4430 specific audio path audio_map */ snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); /* SDP4430 connected pins */ snd_soc_dapm_enable_pin(dapm, "Ext Mic"); snd_soc_dapm_enable_pin(dapm, "Ext Spk"); snd_soc_dapm_enable_pin(dapm, "AFML"); snd_soc_dapm_enable_pin(dapm, "AFMR"); snd_soc_dapm_enable_pin(dapm, "Headset Mic"); snd_soc_dapm_enable_pin(dapm, "Headset Stereophone"); /* allow audio paths from the audio modem to run during suspend */ snd_soc_dapm_ignore_suspend(dapm, "Ext Mic"); snd_soc_dapm_ignore_suspend(dapm, "Ext Spk"); snd_soc_dapm_ignore_suspend(dapm, "AFML"); snd_soc_dapm_ignore_suspend(dapm, "AFMR"); snd_soc_dapm_ignore_suspend(dapm, "Headset Mic"); snd_soc_dapm_ignore_suspend(dapm, "Headset Stereophone"); snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 0"); snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 1"); snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 2"); ret = snd_soc_dapm_sync(dapm); if (ret) return ret; /* Headset jack detection */ ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, &hs_jack); if (ret) return ret; ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), hs_jack_pins); if (machine_is_omap_4430sdp() || machine_is_omap_tabletblaze() || machine_is_omap4_panda()) twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); else snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); /* DC offset cancellation computation */ hsotrim = snd_soc_read(codec, TWL6040_REG_HSOTRIM); right_offset = (hsotrim & TWL6040_HSRO) >> TWL6040_HSRO_OFFSET; left_offset = hsotrim & TWL6040_HSLO; if (twl6040_get_icrev(twl6040) < TWL6040_REV_1_3) /* For ES under ES_1.3 HS step is 2 mV */ mode = 2; else /* For ES_1.3 HS step is 1 mV */ mode = 1; abe_dsp_set_hs_offset(left_offset, right_offset, mode); /* don't wait before switching of HS power */ rtd->pmdown_time = 0; return ret; }
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; }
static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_card *card = codec->card; struct snd_soc_platform *platform = rtd->platform; struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_dapm_context *card_dapm = &card->dapm; struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); struct omap_abe_data *card_data = snd_soc_card_get_drvdata(card); u32 hsotrim, left_offset, right_offset, step_mV; int ret = 0; card_data->twl6040_codec = codec; /* Disable not connected paths if not used */ twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone"); twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk"); twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk"); twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out"); twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vibrator"); twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic"); twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic"); twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic"); twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In"); /* allow audio paths from the audio modem to run during suspend */ snd_soc_dapm_ignore_suspend(&card->dapm, "Ext Spk"); snd_soc_dapm_ignore_suspend(dapm, "AFML"); snd_soc_dapm_ignore_suspend(dapm, "AFMR"); snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic"); snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Stereophone"); snd_soc_dapm_ignore_suspend(&card->dapm, "Digital Mic 0"); snd_soc_dapm_ignore_suspend(&card->dapm, "Digital Mic 1"); snd_soc_dapm_ignore_suspend(&card->dapm, "Digital Mic 2"); card_dapm->stream_event = omap_abe_stream_event; /* DC offset cancellation computation only if ABE is enabled */ if (pdata->has_abe) { hsotrim = twl6040_get_trim_value(codec, TWL6040_TRIM_HSOTRIM); right_offset = TWL6040_HSF_TRIM_RIGHT(hsotrim); left_offset = TWL6040_HSF_TRIM_LEFT(hsotrim); step_mV = twl6040_get_hs_step_size(codec); omap_abe_dc_set_hs_offset(platform, left_offset, right_offset, step_mV); } /* Headset jack detection only if it is supported */ if (pdata->jack_detection) { ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, &hs_jack); if (ret) return ret; ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), hs_jack_pins); if (machine_is_omap_4430sdp() || machine_is_omap_tabletblaze() || machine_is_omap5_sevm() || machine_is_omap5_panda()) twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); else snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); } return ret; }
static int __init sdp4430_soc_init(void) { struct i2c_adapter *adapter; u8 gpoctl; 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; } /* enable tps6130x */ ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &gpoctl, TWL6040_REG_GPOCTL); if (ret) { printk(KERN_ERR "i2c read error\n"); goto i2c_err; } ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, gpoctl | TWL6040_GPO2, TWL6040_REG_GPOCTL); if (ret) { printk(KERN_ERR "i2c write error\n"); goto i2c_err; } adapter = i2c_get_adapter(TPS6130X_I2C_ADAPTER); if (!adapter) { printk(KERN_ERR "can't get i2c adapter\n"); ret = -ENODEV; goto adp_err; } tps6130x_client = i2c_new_device(adapter, &tps6130x_hwmon_info); if (!tps6130x_client) { printk(KERN_ERR "can't add i2c device\n"); ret = -ENODEV; goto tps_err; } /* Only configure the TPS6130x on SDP4430 */ if (machine_is_omap_4430sdp() || machine_is_omap_tabletblaze()) sdp4430_tps6130x_configure(); i2c_put_adapter(adapter); return ret; tps_err: i2c_put_adapter(adapter); adp_err: twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, gpoctl, TWL6040_REG_GPOCTL); i2c_err: regulator_put(av_switch_reg); err_dev: snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai)); err: platform_device_put(sdp4430_snd_device); return ret; }