18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Generic TXx9 ACLC machine driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2009 Atsushi Nemoto
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Based on RBTX49xx patch from CELF patch archive.
88c2ecf20Sopenharmony_ci * (C) Copyright TOSHIBA CORPORATION 2004-2006
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * This is a very generic AC97 sound machine driver for boards which
118c2ecf20Sopenharmony_ci * have (AC97) audio at ACLC (e.g. RBTX49XX boards).
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
168c2ecf20Sopenharmony_ci#include <sound/core.h>
178c2ecf20Sopenharmony_ci#include <sound/pcm.h>
188c2ecf20Sopenharmony_ci#include <sound/soc.h>
198c2ecf20Sopenharmony_ci#include "txx9aclc.h"
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEFS(hifi,
228c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("txx9aclc-ac97")),
238c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("ac97-codec", "ac97-hifi")),
248c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_PLATFORM("txx9aclc-pcm-audio")));
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic struct snd_soc_dai_link txx9aclc_generic_dai = {
278c2ecf20Sopenharmony_ci	.name = "AC97",
288c2ecf20Sopenharmony_ci	.stream_name = "AC97 HiFi",
298c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_REG(hifi),
308c2ecf20Sopenharmony_ci};
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistatic struct snd_soc_card txx9aclc_generic_card = {
338c2ecf20Sopenharmony_ci	.name		= "Generic TXx9 ACLC Audio",
348c2ecf20Sopenharmony_ci	.owner		= THIS_MODULE,
358c2ecf20Sopenharmony_ci	.dai_link	= &txx9aclc_generic_dai,
368c2ecf20Sopenharmony_ci	.num_links	= 1,
378c2ecf20Sopenharmony_ci};
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistatic struct platform_device *soc_pdev;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistatic int __init txx9aclc_generic_probe(struct platform_device *pdev)
428c2ecf20Sopenharmony_ci{
438c2ecf20Sopenharmony_ci	int ret;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	soc_pdev = platform_device_alloc("soc-audio", -1);
468c2ecf20Sopenharmony_ci	if (!soc_pdev)
478c2ecf20Sopenharmony_ci		return -ENOMEM;
488c2ecf20Sopenharmony_ci	platform_set_drvdata(soc_pdev, &txx9aclc_generic_card);
498c2ecf20Sopenharmony_ci	ret = platform_device_add(soc_pdev);
508c2ecf20Sopenharmony_ci	if (ret) {
518c2ecf20Sopenharmony_ci		platform_device_put(soc_pdev);
528c2ecf20Sopenharmony_ci		return ret;
538c2ecf20Sopenharmony_ci	}
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	return 0;
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistatic int __exit txx9aclc_generic_remove(struct platform_device *pdev)
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	platform_device_unregister(soc_pdev);
618c2ecf20Sopenharmony_ci	return 0;
628c2ecf20Sopenharmony_ci}
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic struct platform_driver txx9aclc_generic_driver = {
658c2ecf20Sopenharmony_ci	.remove = __exit_p(txx9aclc_generic_remove),
668c2ecf20Sopenharmony_ci	.driver = {
678c2ecf20Sopenharmony_ci		.name = "txx9aclc-generic",
688c2ecf20Sopenharmony_ci	},
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic int __init txx9aclc_generic_init(void)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	return platform_driver_probe(&txx9aclc_generic_driver,
748c2ecf20Sopenharmony_ci				     txx9aclc_generic_probe);
758c2ecf20Sopenharmony_ci}
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistatic void __exit txx9aclc_generic_exit(void)
788c2ecf20Sopenharmony_ci{
798c2ecf20Sopenharmony_ci	platform_driver_unregister(&txx9aclc_generic_driver);
808c2ecf20Sopenharmony_ci}
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cimodule_init(txx9aclc_generic_init);
838c2ecf20Sopenharmony_cimodule_exit(txx9aclc_generic_exit);
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciMODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
868c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Generic TXx9 ACLC ALSA SoC audio driver");
878c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
888c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:txx9aclc-generic");
89