From 7069d8ecc61afe003a1cbe20a2a4c29c67dedeae Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Tue, 22 Oct 2019 14:03:49 +0200 Subject: [PATCH 49/94] WIP: ASoC: meson: add aiu bus support The AIU is audio playback subsystem of the legacy Amlogic SoC, such as the gxbb, gxl and gxm family. Blabla Signed-off-by: Jerome Brunet --- sound/soc/meson/Kconfig | 7 ++++ sound/soc/meson/Makefile | 2 ++ sound/soc/meson/aiu-bus.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 sound/soc/meson/aiu-bus.c diff --git a/sound/soc/meson/Kconfig b/sound/soc/meson/Kconfig index 4c1ced9..5b15077 100644 --- a/sound/soc/meson/Kconfig +++ b/sound/soc/meson/Kconfig @@ -2,6 +2,13 @@ menu "ASoC support for Amlogic platforms" depends on ARCH_MESON || COMPILE_TEST +config SND_MESON_AIU_BUS + tristate "Amlogic AIU bus support" + select REGMAP_MMIO + help + Select Y or M to add support for audio output interfaces + embedded in the Amlogic GX SoC families + config SND_MESON_AXG_FIFO tristate select REGMAP_MMIO diff --git a/sound/soc/meson/Makefile b/sound/soc/meson/Makefile index 5331c41..6c89ab3 100644 --- a/sound/soc/meson/Makefile +++ b/sound/soc/meson/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: (GPL-2.0 OR MIT) +snd-soc-meson-aiu-bus-objs := aiu-bus.o snd-soc-meson-axg-fifo-objs := axg-fifo.o snd-soc-meson-axg-frddr-objs := axg-frddr.o snd-soc-meson-axg-toddr-objs := axg-toddr.o @@ -16,6 +17,7 @@ snd-soc-meson-g12a-toacodec-objs := g12a-toacodec.o snd-soc-meson-g12a-tohdmitx-objs := g12a-tohdmitx.o snd-soc-meson-t9015-objs := t9015.o +obj-$(CONFIG_SND_MESON_AIU_BUS) += snd-soc-meson-aiu-bus.o obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o diff --git a/sound/soc/meson/aiu-bus.c b/sound/soc/meson/aiu-bus.c new file mode 100644 index 0000000..479c5e6 --- /dev/null +++ b/sound/soc/meson/aiu-bus.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2019 BayLibre, SAS. +// Author: Jerome Brunet + +#include +#include +#include +#include + +static const char * const aiu_bus_clk_names[] = { "top", "glue", }; + +static int aiu_bus_enable_pclks(struct device *dev) +{ + struct clk *clock; + int i, ret; + + for (i = 0; i < ARRAY_SIZE(aiu_bus_clk_names); i++) { + clock = devm_clk_get(dev, aiu_bus_clk_names[i]); + if (IS_ERR(clock)) { + if (PTR_ERR(clock) != -EPROBE_DEFER) + dev_err(dev, "Failed to get %s clock\n", + aiu_bus_clk_names[i]); + return PTR_ERR(clock); + } + + ret = clk_prepare_enable(clock); + if (ret) { + dev_err(dev, "Failed to enable %s clock\n", + aiu_bus_clk_names[i]); + return ret; + } + + ret = devm_add_action_or_reset(dev, + (void(*)(void *))clk_disable_unprepare, + clock); + if (ret) + return ret; + } + + return 0; +} + +static const struct of_device_id aiu_bus_of_match[] = { + { + .compatible = "amlogic,aiu-bus", + .data = NULL, + }, {} +}; +MODULE_DEVICE_TABLE(of, aiu_bus_of_match); + +static int aiu_bus_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int ret; + + /* Fire and forget bus pclks */ + ret = aiu_bus_enable_pclks(dev); + if (ret) + return ret; + + ret = device_reset(dev); + if (ret) { + dev_err(dev, "reset failed\n"); + return ret; + } + + return devm_of_platform_populate(dev); +} + +static struct platform_driver aiu_bus_pdrv = { + .probe = aiu_bus_probe, + .driver = { + .name = "meson-aiu-bus", + .of_match_table = aiu_bus_of_match, + }, +}; +module_platform_driver(aiu_bus_pdrv); + +MODULE_DESCRIPTION("Amlogic AIU bus driver"); +MODULE_AUTHOR("Jerome Brunet "); +MODULE_LICENSE("GPL v2"); -- 2.7.1