18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Efika driver for the PSC of the Freescale MPC52xx
38c2ecf20Sopenharmony_ci * configured as AC97 interface
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2008 Jon Smirl, Digispeaker
68c2ecf20Sopenharmony_ci * Author: Jon Smirl <jonsmirl@gmail.com>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License
98c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any
108c2ecf20Sopenharmony_ci * kind, whether express or implied.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/init.h>
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
168c2ecf20Sopenharmony_ci#include <linux/device.h>
178c2ecf20Sopenharmony_ci#include <linux/delay.h>
188c2ecf20Sopenharmony_ci#include <linux/of_device.h>
198c2ecf20Sopenharmony_ci#include <linux/of_platform.h>
208c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#include <sound/core.h>
238c2ecf20Sopenharmony_ci#include <sound/pcm.h>
248c2ecf20Sopenharmony_ci#include <sound/pcm_params.h>
258c2ecf20Sopenharmony_ci#include <sound/initval.h>
268c2ecf20Sopenharmony_ci#include <sound/soc.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include "mpc5200_dma.h"
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define DRV_NAME "efika-audio-fabric"
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEFS(analog,
338c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("mpc5200-psc-ac97.0")),
348c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("stac9766-codec",
358c2ecf20Sopenharmony_ci				      "stac9766-hifi-analog")),
368c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_PLATFORM("mpc5200-pcm-audio")));
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEFS(iec958,
398c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("mpc5200-psc-ac97.1")),
408c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("stac9766-codec",
418c2ecf20Sopenharmony_ci				      "stac9766-hifi-IEC958")),
428c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_PLATFORM("mpc5200-pcm-audio")));
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistatic struct snd_soc_dai_link efika_fabric_dai[] = {
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	.name = "AC97",
478c2ecf20Sopenharmony_ci	.stream_name = "AC97 Analog",
488c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_REG(analog),
498c2ecf20Sopenharmony_ci},
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	.name = "AC97",
528c2ecf20Sopenharmony_ci	.stream_name = "AC97 IEC958",
538c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_REG(iec958),
548c2ecf20Sopenharmony_ci},
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistatic struct snd_soc_card card = {
588c2ecf20Sopenharmony_ci	.name = "Efika",
598c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
608c2ecf20Sopenharmony_ci	.dai_link = efika_fabric_dai,
618c2ecf20Sopenharmony_ci	.num_links = ARRAY_SIZE(efika_fabric_dai),
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic __init int efika_fabric_init(void)
658c2ecf20Sopenharmony_ci{
668c2ecf20Sopenharmony_ci	struct platform_device *pdev;
678c2ecf20Sopenharmony_ci	int rc;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	if (!of_machine_is_compatible("bplan,efika"))
708c2ecf20Sopenharmony_ci		return -ENODEV;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	pdev = platform_device_alloc("soc-audio", 1);
738c2ecf20Sopenharmony_ci	if (!pdev) {
748c2ecf20Sopenharmony_ci		pr_err("efika_fabric_init: platform_device_alloc() failed\n");
758c2ecf20Sopenharmony_ci		return -ENODEV;
768c2ecf20Sopenharmony_ci	}
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	platform_set_drvdata(pdev, &card);
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	rc = platform_device_add(pdev);
818c2ecf20Sopenharmony_ci	if (rc) {
828c2ecf20Sopenharmony_ci		pr_err("efika_fabric_init: platform_device_add() failed\n");
838c2ecf20Sopenharmony_ci		platform_device_put(pdev);
848c2ecf20Sopenharmony_ci		return -ENODEV;
858c2ecf20Sopenharmony_ci	}
868c2ecf20Sopenharmony_ci	return 0;
878c2ecf20Sopenharmony_ci}
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cimodule_init(efika_fabric_init);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ciMODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>");
938c2ecf20Sopenharmony_ciMODULE_DESCRIPTION(DRV_NAME ": mpc5200 Efika fabric driver");
948c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
958c2ecf20Sopenharmony_ci
96