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 __init sdp4430_soc_init(void) { struct i2c_adapter *adapter; int ret; if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda()) { pr_debug("Not SDP4430 or PandaBoard!\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 err; adapter = i2c_get_adapter(1); if (!adapter) { printk(KERN_ERR "can't get i2c adapter\n"); return -ENODEV; } tps6130x_client = i2c_new_device(adapter, &tps6130x_hwmon_info); if (!tps6130x_client) { printk(KERN_ERR "can't add i2c device\n"); return -ENODEV; } /* Only configure the TPS6130x on SDP4430 */ if (machine_is_omap_4430sdp()) sdp4430_tps6130x_configure(); return 0; err: printk(KERN_ERR "Unable to add platform device\n"); platform_device_put(sdp4430_snd_device); return ret; }
static int __init omap4_hdmi_soc_init(void) { int ret; if (!(machine_is_omap_4430sdp() || machine_is_omap4_panda())) return -ENODEV; printk(KERN_INFO "OMAP4 HDMI audio SoC init\n"); if (machine_is_omap4_panda()) snd_soc_omap4_hdmi.name = "PandaHDMI"; omap4_hdmi_snd_device = platform_device_alloc("soc-audio", OMAP4_HDMI_SND_DEV_ID); if (!omap4_hdmi_snd_device) { printk(KERN_ERR "Platform device allocation failed\n"); return -ENOMEM; } platform_set_drvdata(omap4_hdmi_snd_device, &snd_soc_omap4_hdmi); ret = platform_device_add(omap4_hdmi_snd_device); if (ret) goto err; return 0; err: printk(KERN_ERR "Unable to add platform device\n"); platform_device_put(omap4_hdmi_snd_device); return ret; }
static int __init sdp4430_soc_init(void) { int ret; if (!machine_is_omap_4430sdp()) 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; } platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430); ret = platform_device_add(sdp4430_snd_device); if (ret) goto err; /* Codec starts in HP mode */ twl6040_power_mode = 1; return 0; err: printk(KERN_ERR "Unable to add platform device\n"); platform_device_put(sdp4430_snd_device); return ret; }
static int __init sdp4430_soc_init(void) { int ret; if (!machine_is_omap_4430sdp()) return -ENODEV; ; sdp4430_snd_device = platform_device_alloc("soc-audio", -1); if (!sdp4430_snd_device) { ; return -ENOMEM; } platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430); ret = platform_device_add(sdp4430_snd_device); if (ret) goto err; /* Codec starts in HP mode */ twl6040_power_mode = 1; return 0; err: ; 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; 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()) 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 __init sdp4430_soc_init(void) { int ret; if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda()) { pr_debug("Not SDP4430 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"; 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; twl6040_codec = snd_soc_card_get_codec(&snd_soc_sdp4430, "twl6040-codec"); return 0; 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 snd_soc_dapm_context *dapm = &codec->dapm; 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(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"); 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()) 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) { 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 __init sdp4430_soc_init(void) { int ret; if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda() && !machine_is_tuna()) { pr_debug("Not SDP4430, PandaBoard or Tuna!\n"); return -ENODEV; } printk(KERN_INFO "SDP4430 SoC init\n"); if (machine_is_tuna()) { ret = gpio_request(TUNA_MAIN_MIC_GPIO, "MAIN_MICBIAS_EN"); if (ret) goto mainmic_gpio_err; gpio_direction_output(TUNA_MAIN_MIC_GPIO, 0); ret = gpio_request(TUNA_SUB_MIC_GPIO, "SUB_MICBIAS_EN"); if (ret) goto submic_gpio_err; gpio_direction_output(TUNA_SUB_MIC_GPIO, 0); } 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_tuna()) snd_soc_sdp4430.name = "Tuna"; twl6040_clk32kreg = regulator_get(NULL, "twl6040_clk32k"); if (IS_ERR(twl6040_clk32kreg)) { ret = PTR_ERR(twl6040_clk32kreg); printk(KERN_ERR "failed to get CLK32K %d\n", ret); goto clk32kreg_err; } /* enable external 32kHz clock during TWL6040/McPDM probe */ ret = regulator_enable(twl6040_clk32kreg); if (ret) { printk(KERN_ERR "failed to enable TWL6040 CLK32K\n"); goto clk32kreg_ena_err; } sdp4430_snd_device = platform_device_alloc("soc-audio", -1); if (!sdp4430_snd_device) { printk(KERN_ERR "Platform device allocation failed\n"); ret = -ENOMEM; goto device_err; } 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; regulator_disable(twl6040_clk32kreg); twl6040_codec = snd_soc_card_get_codec(&snd_soc_sdp4430, "twl6040-codec"); return 0; err: printk(KERN_ERR "Unable to add platform device\n"); platform_device_put(sdp4430_snd_device); device_err: regulator_disable(twl6040_clk32kreg); clk32kreg_ena_err: regulator_put(twl6040_clk32kreg); clk32kreg_err: if (machine_is_tuna()) gpio_free(TUNA_SUB_MIC_GPIO); submic_gpio_err: if (machine_is_tuna()) gpio_free(TUNA_MAIN_MIC_GPIO); mainmic_gpio_err: 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 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 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; /* 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"); /* 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 */ 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 (pdata->jack_detection) twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); else snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); /* Only configure the TPS6130x on SDP4430 */ if (machine_is_omap_4430sdp()) { card_data->adapter = i2c_get_adapter(1); if (!card_data->adapter) { dev_err(card->dev, "can't get i2c adapter\n"); return -ENODEV; } card_data->tps6130x = i2c_new_device(card_data->adapter, &tps6130x_hwmon_info); if (!card_data->tps6130x) { dev_err(card->dev, "can't add i2c device\n"); i2c_put_adapter(card_data->adapter); return -ENODEV; } omap_abe_tps6130x_configure(card_data); } return ret; }
static __devinit int omap_abe_probe(struct platform_device *pdev) { struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev); struct snd_soc_card *card = &omap_abe_card; struct omap_abe_data *card_data; int ret; card->dev = &pdev->dev; if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda() && !machine_is_omap5_sevm()) return -ENODEV; pr_info("OMAP4/5 SoC init\n"); if (!pdata) { dev_err(&pdev->dev, "Missing pdata\n"); return -ENODEV; } if (pdata->card_name) { card->name = pdata->card_name; } else { dev_err(&pdev->dev, "Card name is not provided\n"); return -ENODEV; } if (!pdata->mclk_freq) { dev_err(&pdev->dev, "MCLK frequency missing\n"); return -ENODEV; } if (pdata->has_abe) { if (pdata->has_dmic) { card->dai_link = omap_abe_dai; card->num_links = ARRAY_SIZE(omap_abe_dai); } else { card->dai_link = omap_abe_no_dmic_dai; card->num_links = ARRAY_SIZE(omap_abe_no_dmic_dai); } } else if (pdata->has_dmic) { card->dai_link = twl6040_dmic_dai; card->num_links = ARRAY_SIZE(twl6040_dmic_dai); } else { card->dai_link = twl6040_only_dai; card->num_links = ARRAY_SIZE(twl6040_only_dai); } card_data = devm_kzalloc(&pdev->dev, sizeof(*card_data), GFP_KERNEL); if (card_data == NULL) return -ENOMEM; snd_soc_card_set_drvdata(card, card_data); /* * Dummy symbols to enforce loading of snd-soc-omap and snd-soc-mcpdm */ omap_pcm_dummy(); omap_mcpdm_dummy(); ret = snd_soc_register_card(card); if (ret) dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); return ret; }
static int __init sdp4430_soc_init(void) { struct i2c_adapter *adapter; int ret; if (!machine_is_omap_4430sdp()) { pr_debug("Not SDP4430!\n"); return -ENODEV; } pr_info("SDP4430 SoC init\n"); #ifdef CONFIG_SND_OMAP_SOC_HDMI snd_soc_register_dais(&null_dai, 1); #endif adapter = i2c_get_adapter(1); if (!adapter) { printk(KERN_ERR "can't get i2c adapter\n"); return -ENODEV; } tps61305_client = i2c_new_device(adapter, &tps61305_hwmon_info); if (!tps61305_client) { printk(KERN_ERR "can't add i2c device\n"); return -ENODEV; } sdp4430_tps61305_configure(); sdp4430_snd_device = platform_device_alloc("soc-audio", -1); if (!sdp4430_snd_device) { printk(KERN_ERR "Platform device allocation failed\n"); return -ENOMEM; } platform_set_drvdata(sdp4430_snd_device, &sdp4430_snd_devdata); sdp4430_snd_devdata.dev = &sdp4430_snd_device->dev; ret = platform_device_add(sdp4430_snd_device); if (ret) goto err; ret = snd_soc_dai_set_sysclk(sdp4430_dai[0].codec_dai, TWL6040_SYSCLK_SEL_HPPLL, 38400000, SND_SOC_CLOCK_IN); if (ret) { printk(KERN_ERR "can't set codec system clock\n"); goto err; } /* Codec starts in HP mode */ twl6040_power_mode = 1; pr_info("SDP4430 SoC init\n"); return 0; 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) { 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; }