static int aml_m8_audio_probe(struct platform_device *pdev) { //struct device_node *np = pdev->dev.of_node; struct snd_soc_card *card = &aml_snd_soc_card; struct aml_audio_private_data *p_aml_audio; int ret = 0; printk(KERN_DEBUG "enter %s\n", __func__); #ifdef CONFIG_USE_OF p_aml_audio = devm_kzalloc(&pdev->dev, sizeof(struct aml_audio_private_data), GFP_KERNEL); if (!p_aml_audio) { dev_err(&pdev->dev, "Can't allocate aml_audio_private_data\n"); ret = -ENOMEM; goto err; } card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, p_aml_audio); if (!(pdev->dev.of_node)) { dev_err(&pdev->dev, "Must be instantiated using device tree\n"); ret = -EINVAL; goto err; } ret = snd_soc_of_parse_card_name(card, "aml,sound_card"); if (ret) goto err; ret = of_property_read_string_index(pdev->dev.of_node, "aml,codec_dai", 0, &aml_codec_dai_link[0].codec_dai_name); if (ret) goto err; ret = snd_soc_of_parse_audio_routing(card, "aml,audio-routing"); if (ret) goto err; // aml_codec_dai_link[0].codec_of_node = of_parse_phandle( // pdev->dev.of_node, "aml,audio-codec", 0); ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err; } aml_m8_pinmux_init(card); return 0; #endif err: kfree(p_aml_audio); return ret; }
static int aml_m8_audio_probe(struct platform_device *pdev) { struct device_node *np; struct snd_soc_card *card = &aml_snd_soc_card; struct aml_audio_private_data *p_aml_audio; char tmp[NAME_SIZE]; int ret = 0; #ifdef CONFIG_USE_OF p_aml_audio = devm_kzalloc(&pdev->dev, sizeof(struct aml_audio_private_data), GFP_KERNEL); if (!p_aml_audio) { dev_err(&pdev->dev, "Can't allocate aml_audio_private_data\n"); ret = -ENOMEM; goto err; } card->dev = &pdev->dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, p_aml_audio); if (!(pdev->dev.of_node)) { dev_err(&pdev->dev, "Must be instantiated using device tree\n"); ret = -EINVAL; goto err; } ret = snd_soc_of_parse_card_name(card, "aml,sound_card"); if (ret) goto err; ret = of_property_read_string_index(pdev->dev.of_node, "aml,codec_dai", codec_info.codec_index, &aml_codec_dai_link[0].codec_dai_name); if (ret) goto err; printk("codec_name = %s\n", codec_info.name_bus); aml_codec_dai_link[0].codec_name = codec_info.name_bus; //ret = of_property_read_string_index(pdev->dev.of_node, "aml,codec_name", // 0, &aml_codec_dai_link[0].codec_name); //if (ret) // goto err; //aml_codec_dai_link[0].codec_of_node = of_parse_phandle( // pdev->dev.of_node, "aml,audio-codec", 0); snprintf(tmp, NAME_SIZE, "%s-%s", "aml,audio-routing", codec_info.name); ret = snd_soc_of_parse_audio_routing(card, tmp); if (ret) goto err; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); goto err; } aml_m8_pinmux_init(card); return 0; #endif err: kfree(p_aml_audio); return ret; }