1 // SPDX-License-Identifier: GPL-2.0 !! 1 /* 2 // !! 2 * Phytec pcm030 driver for the PSC of the Freescale MPC52xx 3 // Phytec pcm030 driver for the PSC of the Fre !! 3 * configured as AC97 interface 4 // configured as AC97 interface !! 4 * 5 // !! 5 * Copyright 2008 Jon Smirl, Digispeaker 6 // Copyright 2008 Jon Smirl, Digispeaker !! 6 * Author: Jon Smirl <jonsmirl@gmail.com> 7 // Author: Jon Smirl <jonsmirl@gmail.com> !! 7 * >> 8 * This file is licensed under the terms of the GNU General Public License >> 9 * version 2. This program is licensed "as is" without any warranty of any >> 10 * kind, whether express or implied. >> 11 */ 8 12 9 #include <linux/init.h> 13 #include <linux/init.h> 10 #include <linux/module.h> 14 #include <linux/module.h> >> 15 #include <linux/interrupt.h> 11 #include <linux/device.h> 16 #include <linux/device.h> 12 #include <linux/of.h> !! 17 #include <linux/delay.h> 13 !! 18 #include <linux/of_device.h> >> 19 #include <linux/of_platform.h> >> 20 #include <linux/dma-mapping.h> >> 21 >> 22 #include <sound/core.h> >> 23 #include <sound/pcm.h> >> 24 #include <sound/pcm_params.h> >> 25 #include <sound/initval.h> 14 #include <sound/soc.h> 26 #include <sound/soc.h> >> 27 #include <sound/soc-of-simple.h> 15 28 16 #include "mpc5200_dma.h" 29 #include "mpc5200_dma.h" >> 30 #include "mpc5200_psc_ac97.h" >> 31 #include "../codecs/wm9712.h" 17 32 18 #define DRV_NAME "pcm030-audio-fabric" 33 #define DRV_NAME "pcm030-audio-fabric" 19 34 20 struct pcm030_audio_data { !! 35 static struct snd_soc_device device; 21 struct snd_soc_card *card; !! 36 static struct snd_soc_card card; 22 struct platform_device *codec_device; << 23 }; << 24 << 25 SND_SOC_DAILINK_DEFS(analog, << 26 DAILINK_COMP_ARRAY(COMP_CPU("mpc5200-p << 27 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712- << 28 DAILINK_COMP_ARRAY(COMP_EMPTY())); << 29 << 30 SND_SOC_DAILINK_DEFS(iec958, << 31 DAILINK_COMP_ARRAY(COMP_CPU("mpc5200-p << 32 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712- << 33 DAILINK_COMP_ARRAY(COMP_EMPTY())); << 34 37 35 static struct snd_soc_dai_link pcm030_fabric_d 38 static struct snd_soc_dai_link pcm030_fabric_dai[] = { 36 { 39 { 37 .name = "AC97.0", !! 40 .name = "AC97", 38 .stream_name = "AC97 Analog", 41 .stream_name = "AC97 Analog", 39 SND_SOC_DAILINK_REG(analog), !! 42 .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI], >> 43 .cpu_dai = &psc_ac97_dai[MPC5200_AC97_NORMAL], 40 }, 44 }, 41 { 45 { 42 .name = "AC97.1", !! 46 .name = "AC97", 43 .stream_name = "AC97 IEC958", 47 .stream_name = "AC97 IEC958", 44 SND_SOC_DAILINK_REG(iec958), !! 48 .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX], >> 49 .cpu_dai = &psc_ac97_dai[MPC5200_AC97_SPDIF], 45 }, 50 }, 46 }; 51 }; 47 52 48 static struct snd_soc_card pcm030_card = { !! 53 static __init int pcm030_fabric_init(void) 49 .name = "pcm030", << 50 .owner = THIS_MODULE, << 51 .dai_link = pcm030_fabric_dai, << 52 .num_links = ARRAY_SIZE(pcm030_fabric_ << 53 }; << 54 << 55 static int pcm030_fabric_probe(struct platform << 56 { 54 { 57 struct device_node *np = op->dev.of_no !! 55 struct platform_device *pdev; 58 struct device_node *platform_np; !! 56 int rc; 59 struct snd_soc_card *card = &pcm030_ca << 60 struct pcm030_audio_data *pdata; << 61 struct snd_soc_dai_link *dai_link; << 62 int ret; << 63 int i; << 64 57 65 if (!of_machine_is_compatible("phytec, !! 58 if (!machine_is_compatible("phytec,pcm030")) 66 return -ENODEV; 59 return -ENODEV; 67 60 68 pdata = devm_kzalloc(&op->dev, sizeof( !! 61 card.platform = &mpc5200_audio_dma_platform; 69 GFP_KERNEL); !! 62 card.name = "pcm030"; 70 if (!pdata) !! 63 card.dai_link = pcm030_fabric_dai; 71 return -ENOMEM; !! 64 card.num_links = ARRAY_SIZE(pcm030_fabric_dai); 72 !! 65 73 card->dev = &op->dev; !! 66 device.card = &card; 74 !! 67 device.codec_dev = &soc_codec_dev_wm9712; 75 pdata->card = card; !! 68 76 !! 69 pdev = platform_device_alloc("soc-audio", 1); 77 platform_np = of_parse_phandle(np, "as !! 70 if (!pdev) { 78 if (!platform_np) { !! 71 pr_err("pcm030_fabric_init: platform_device_alloc() failed\n"); 79 dev_err(&op->dev, "ac97 not re << 80 return -ENODEV; 72 return -ENODEV; 81 } 73 } 82 74 83 for_each_card_prelinks(card, i, dai_li !! 75 platform_set_drvdata(pdev, &device); 84 dai_link->platforms->of_node = !! 76 device.dev = &pdev->dev; 85 77 86 ret = request_module("snd-soc-wm9712") !! 78 rc = platform_device_add(pdev); 87 if (ret) !! 79 if (rc) { 88 dev_err(&op->dev, "request_mod !! 80 pr_err("pcm030_fabric_init: platform_device_add() failed\n"); 89 !! 81 return -ENODEV; 90 pdata->codec_device = platform_device_ << 91 if (!pdata->codec_device) << 92 dev_err(&op->dev, "platform_de << 93 << 94 ret = platform_device_add(pdata->codec << 95 if (ret) { << 96 dev_err(&op->dev, "platform_de << 97 platform_device_put(pdata->cod << 98 } << 99 << 100 ret = snd_soc_register_card(card); << 101 if (ret) { << 102 dev_err(&op->dev, "snd_soc_reg << 103 platform_device_unregister(pda << 104 } 82 } 105 !! 83 return 0; 106 platform_set_drvdata(op, pdata); << 107 return ret; << 108 << 109 } << 110 << 111 static void pcm030_fabric_remove(struct platfo << 112 { << 113 struct pcm030_audio_data *pdata = plat << 114 << 115 snd_soc_unregister_card(pdata->card); << 116 platform_device_unregister(pdata->code << 117 } 84 } 118 85 119 static const struct of_device_id pcm030_audio_ !! 86 module_init(pcm030_fabric_init); 120 { .compatible = "phytec,pcm030-audio-f << 121 {} << 122 }; << 123 MODULE_DEVICE_TABLE(of, pcm030_audio_match); << 124 << 125 static struct platform_driver pcm030_fabric_dr << 126 .probe = pcm030_fabric_probe, << 127 .remove = pcm030_fabric_remove << 128 .driver = { << 129 .name = DRV_NAME, << 130 .of_match_table = pcm030_au << 131 }, << 132 }; << 133 << 134 module_platform_driver(pcm030_fabric_driver); << 135 87 136 88 137 MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>" 89 MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); 138 MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 90 MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver"); 139 MODULE_LICENSE("GPL"); 91 MODULE_LICENSE("GPL"); 140 92 141 93
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.