static int __init at91sam9g20ek_init(void) { struct clk *pllb; int ret; if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) return -ENODEV; ret = atmel_ssc_set_audio(0); if (ret != 0) { pr_err("Failed to set SSC 0 for audio: %d\n", ret); return ret; } /* * Codec MCLK is supplied by PCK0 - set it up. */ mclk = clk_get(NULL, "pck0"); if (IS_ERR(mclk)) { printk(KERN_ERR "ASoC: Failed to get MCLK\n"); ret = PTR_ERR(mclk); goto err; } pllb = clk_get(NULL, "pllb"); if (IS_ERR(pllb)) { printk(KERN_ERR "ASoC: Failed to get PLLB\n"); ret = PTR_ERR(pllb); goto err_mclk; } ret = clk_set_parent(mclk, pllb); clk_put(pllb); if (ret != 0) { printk(KERN_ERR "ASoC: Failed to set MCLK parent\n"); goto err_mclk; } clk_set_rate(mclk, MCLK_RATE); at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); if (!at91sam9g20ek_snd_device) { printk(KERN_ERR "ASoC: Platform device allocation failed\n"); ret = -ENOMEM; goto err_mclk; } platform_set_drvdata(at91sam9g20ek_snd_device, &snd_soc_at91sam9g20ek); ret = platform_device_add(at91sam9g20ek_snd_device); if (ret) { printk(KERN_ERR "ASoC: Platform device allocation failed\n"); goto err_device_add; } return ret; err_device_add: platform_device_put(at91sam9g20ek_snd_device); err_mclk: clk_put(mclk); mclk = NULL; err: return ret; }
static int inline ek_have_2mmc(void) { return machine_is_at91sam9g20ek_2mmc() || (system_rev & HAVE_2MMC); }
static int __init at91sam9g20ek_init(void) { struct atmel_ssc_info *ssc_p = at91sam9g20ek_dai.cpu_dai->private_data; struct ssc_device *ssc = NULL; struct clk *pllb; int ret; if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) return -ENODEV; /* * Codec MCLK is supplied by PCK0 - set it up. */ mclk = clk_get(NULL, "pck0"); if (IS_ERR(mclk)) { printk(KERN_ERR "ASoC: Failed to get MCLK\n"); ret = PTR_ERR(mclk); goto err; } pllb = clk_get(NULL, "pllb"); if (IS_ERR(mclk)) { printk(KERN_ERR "ASoC: Failed to get PLLB\n"); ret = PTR_ERR(mclk); goto err_mclk; } ret = clk_set_parent(mclk, pllb); clk_put(pllb); if (ret != 0) { printk(KERN_ERR "ASoC: Failed to set MCLK parent\n"); goto err_mclk; } clk_set_rate(mclk, MCLK_RATE); /* * Request SSC device */ ssc = ssc_request(0); if (IS_ERR(ssc)) { printk(KERN_ERR "ASoC: Failed to request SSC 0\n"); ret = PTR_ERR(ssc); ssc = NULL; goto err_ssc; } ssc_p->ssc = ssc; at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); if (!at91sam9g20ek_snd_device) { printk(KERN_ERR "ASoC: Platform device allocation failed\n"); ret = -ENOMEM; } platform_set_drvdata(at91sam9g20ek_snd_device, &at91sam9g20ek_snd_devdata); at91sam9g20ek_snd_devdata.dev = &at91sam9g20ek_snd_device->dev; ret = platform_device_add(at91sam9g20ek_snd_device); if (ret) { printk(KERN_ERR "ASoC: Platform device allocation failed\n"); platform_device_put(at91sam9g20ek_snd_device); } return ret; err_ssc: ssc_free(ssc); ssc_p->ssc = NULL; err_mclk: clk_put(mclk); mclk = NULL; err: return ret; }
static int at91sam9g20ek_audio_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct device_node *codec_np, *cpu_np; struct snd_soc_card *card = &snd_soc_at91sam9g20ek; int ret; if (!np) { if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) return -ENODEV; } ret = atmel_ssc_set_audio(0); if (ret) { dev_err(&pdev->dev, "ssc channel is not valid\n"); return -EINVAL; } card->dev = &pdev->dev; /* Parse device node info */ if (np) { ret = snd_soc_of_parse_card_name(card, "atmel,model"); if (ret) goto err; ret = snd_soc_of_parse_audio_routing(card, "atmel,audio-routing"); if (ret) goto err; /* Parse codec info */ at91sam9g20ek_dai.codec_name = NULL; codec_np = of_parse_phandle(np, "atmel,audio-codec", 0); if (!codec_np) { dev_err(&pdev->dev, "codec info missing\n"); return -EINVAL; } at91sam9g20ek_dai.codec_of_node = codec_np; /* Parse dai and platform info */ at91sam9g20ek_dai.cpu_dai_name = NULL; at91sam9g20ek_dai.platform_name = NULL; cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0); if (!cpu_np) { dev_err(&pdev->dev, "dai and pcm info missing\n"); return -EINVAL; } at91sam9g20ek_dai.cpu_of_node = cpu_np; at91sam9g20ek_dai.platform_of_node = cpu_np; of_node_put(codec_np); of_node_put(cpu_np); } ret = snd_soc_register_card(card); if (ret) { printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n"); } return ret; err: atmel_ssc_put_audio(0); return ret; }