* [PATCH 0/2] reset: meson: add audio arb controller
@ 2018-07-06 14:31 Jerome Brunet
2018-07-06 14:31 ` [PATCH 1/2] reset: meson: add dt-bindings for meson-axg audio arb Jerome Brunet
2018-07-06 14:31 ` [PATCH 2/2] reset: meson: add meson audio arb driver Jerome Brunet
0 siblings, 2 replies; 4+ messages in thread
From: Jerome Brunet @ 2018-07-06 14:31 UTC (permalink / raw)
To: Philipp Zabel, Kevin Hilman, Carlo Caione
Cc: Jerome Brunet, devicetree, linux-amlogic, linux-kernel
This patchset adds the audio ARB controller which is necessary to
enable or disable the DDR access for the FIFOs of the audio subsystem.
Jerome Brunet (2):
reset: meson: add dt-bindings for meson-axg audio arb
reset: meson: add meson audio arb driver
.../bindings/reset/amlogic,meson-axg-audio-arb.txt | 21 +++
drivers/reset/Kconfig | 7 +
drivers/reset/Makefile | 1 +
drivers/reset/reset-meson-audio-arb.c | 168 +++++++++++++++++++++
.../reset/amlogic,meson-axg-audio-arb.h | 17 +++
5 files changed, 214 insertions(+)
create mode 100644 Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt
create mode 100644 drivers/reset/reset-meson-audio-arb.c
create mode 100644 include/dt-bindings/reset/amlogic,meson-axg-audio-arb.h
--
2.14.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] reset: meson: add dt-bindings for meson-axg audio arb
2018-07-06 14:31 [PATCH 0/2] reset: meson: add audio arb controller Jerome Brunet
@ 2018-07-06 14:31 ` Jerome Brunet
2018-07-20 13:52 ` Rob Herring
2018-07-06 14:31 ` [PATCH 2/2] reset: meson: add meson audio arb driver Jerome Brunet
1 sibling, 1 reply; 4+ messages in thread
From: Jerome Brunet @ 2018-07-06 14:31 UTC (permalink / raw)
To: Philipp Zabel, Kevin Hilman, Carlo Caione
Cc: Jerome Brunet, devicetree, linux-amlogic, linux-kernel
Add dt-bindings for the audio memory arbitror found on Amlogic's
A113 based SoCs
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
.../bindings/reset/amlogic,meson-axg-audio-arb.txt | 21 +++++++++++++++++++++
.../dt-bindings/reset/amlogic,meson-axg-audio-arb.h | 17 +++++++++++++++++
2 files changed, 38 insertions(+)
create mode 100644 Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt
create mode 100644 include/dt-bindings/reset/amlogic,meson-axg-audio-arb.h
diff --git a/Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt b/Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt
new file mode 100644
index 000000000000..e29b3463f2e1
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt
@@ -0,0 +1,21 @@
+* Amlogic audio memory arbitror controller
+
+The Amlogic Audio ARB is a simple device which enables or
+disables the access of Audio FIFOs to DDR on AXG based SoC.
+
+Required properties:
+- compatible: 'amlogic,meson-axg-audio-arb'
+- reg: physical base address of the controller and length of memory
+ mapped region.
+- clocks: phandle to the fifo peripheral clock provided by the audio
+ clock controller.
+- #reset-cells: must be 1.
+
+Example on the A113 SoC:
+
+arb: reset-controller@280 {
+ compatible = "amlogic,meson-axg-audio-arb";
+ reg = <0x0 0x280 0x0 0x4>;
+ #reset-cells = <1>;
+ clocks = <&clkc_audio AUD_CLKID_DDR_ARB>;
+};
diff --git a/include/dt-bindings/reset/amlogic,meson-axg-audio-arb.h b/include/dt-bindings/reset/amlogic,meson-axg-audio-arb.h
new file mode 100644
index 000000000000..05c36367875c
--- /dev/null
+++ b/include/dt-bindings/reset/amlogic,meson-axg-audio-arb.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT)
+ *
+ * Copyright (c) 2018 Baylibre SAS.
+ * Author: Jerome Brunet <jbrunet@baylibre.com>
+ */
+
+#ifndef _DT_BINDINGS_AMLOGIC_MESON_AXG_AUDIO_ARB_H
+#define _DT_BINDINGS_AMLOGIC_MESON_AXG_AUDIO_ARB_H
+
+#define AXG_ARB_TODDR_A 0
+#define AXG_ARB_TODDR_B 1
+#define AXG_ARB_TODDR_C 2
+#define AXG_ARB_FRDDR_A 3
+#define AXG_ARB_FRDDR_B 4
+#define AXG_ARB_FRDDR_C 5
+
+#endif /* _DT_BINDINGS_AMLOGIC_MESON_AXG_AUDIO_ARB_H */
--
2.14.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] reset: meson: add meson audio arb driver
2018-07-06 14:31 [PATCH 0/2] reset: meson: add audio arb controller Jerome Brunet
2018-07-06 14:31 ` [PATCH 1/2] reset: meson: add dt-bindings for meson-axg audio arb Jerome Brunet
@ 2018-07-06 14:31 ` Jerome Brunet
1 sibling, 0 replies; 4+ messages in thread
From: Jerome Brunet @ 2018-07-06 14:31 UTC (permalink / raw)
To: Philipp Zabel, Kevin Hilman, Carlo Caione
Cc: Jerome Brunet, devicetree, linux-amlogic, linux-kernel
The Amlogic Audio ARB is a simple device which enables or
disables the access of Audio FIFOs to DDR on AXG based SoC.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/reset/Kconfig | 7 ++
drivers/reset/Makefile | 1 +
drivers/reset/reset-meson-audio-arb.c | 168 ++++++++++++++++++++++++++++++++++
3 files changed, 176 insertions(+)
create mode 100644 drivers/reset/reset-meson-audio-arb.c
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index c0b292be1b72..c62c915167c4 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -73,6 +73,13 @@ config RESET_MESON
help
This enables the reset driver for Amlogic Meson SoCs.
+config RESET_MESON_AUDIO_ARB
+ tristate "Meson Audio Memory Arbitror Reset Driver"
+ depends on ARCH_MESON || COMPILE_TEST
+ help
+ This enables the reset driver for Audio Memory Arbitror of
+ Amlogic's A113 based SoCs
+
config RESET_OXNAS
bool
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index c1261dcfe9ad..aca2240b48aa 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o
obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
obj-$(CONFIG_RESET_MESON) += reset-meson.o
+obj-$(CONFIG_RESET_MESON_AUDIO_ARB) += reset-meson-audio-arb.o
obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
obj-$(CONFIG_RESET_PISTACHIO) += reset-pistachio.o
obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
diff --git a/drivers/reset/reset-meson-audio-arb.c b/drivers/reset/reset-meson-audio-arb.c
new file mode 100644
index 000000000000..c3eec178972e
--- /dev/null
+++ b/drivers/reset/reset-meson-audio-arb.c
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+// Copyright (c) 2018 BayLibre, SAS.
+// Author: Jerome Brunet <jbrunet@baylibre.com>
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+
+#include <dt-bindings/reset/amlogic,meson-axg-audio-arb.h>
+
+struct meson_audio_arb_data {
+ struct reset_controller_dev rstc;
+ void __iomem *regs;
+ struct clk *clk;
+ const unsigned int *reset_bits;
+ spinlock_t lock;
+};
+
+#define ARB_GENERAL_BIT 31
+
+static const unsigned int axg_audio_arb_reset_bits[] = {
+ [AXG_ARB_TODDR_A] = 0,
+ [AXG_ARB_TODDR_B] = 1,
+ [AXG_ARB_TODDR_C] = 2,
+ [AXG_ARB_FRDDR_A] = 4,
+ [AXG_ARB_FRDDR_B] = 5,
+ [AXG_ARB_FRDDR_C] = 6,
+};
+
+static int meson_audio_arb_update(struct reset_controller_dev *rcdev,
+ unsigned long id, bool assert)
+{
+ u32 val;
+ struct meson_audio_arb_data *arb =
+ container_of(rcdev, struct meson_audio_arb_data, rstc);
+
+ spin_lock(&arb->lock);
+ val = readl(arb->regs);
+
+ if (assert)
+ val &= ~BIT(arb->reset_bits[id]);
+ else
+ val |= BIT(arb->reset_bits[id]);
+
+ writel(val, arb->regs);
+ spin_unlock(&arb->lock);
+
+ return 0;
+}
+
+static int meson_audio_arb_status(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ u32 val;
+ struct meson_audio_arb_data *arb =
+ container_of(rcdev, struct meson_audio_arb_data, rstc);
+
+ val = readl(arb->regs);
+
+ return !(val & BIT(arb->reset_bits[id]));
+}
+
+static int meson_audio_arb_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return meson_audio_arb_update(rcdev, id, true);
+}
+
+static int meson_audio_arb_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return meson_audio_arb_update(rcdev, id, false);
+}
+
+static const struct reset_control_ops meson_audio_arb_rstc_ops = {
+ .assert = meson_audio_arb_assert,
+ .deassert = meson_audio_arb_deassert,
+ .status = meson_audio_arb_status,
+};
+
+static const struct of_device_id meson_audio_arb_of_match[] = {
+ { .compatible = "amlogic,meson-axg-audio-arb", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, meson_audio_arb_of_match);
+
+static int meson_audio_arb_remove(struct platform_device *pdev)
+{
+ struct meson_audio_arb_data *arb = platform_get_drvdata(pdev);
+
+ /* Disable all access */
+ spin_lock(&arb->lock);
+ writel(0, arb->regs);
+ spin_unlock(&arb->lock);
+
+ clk_disable_unprepare(arb->clk);
+
+ return 0;
+}
+
+static int meson_audio_arb_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct meson_audio_arb_data *arb;
+ struct resource *res;
+ int ret;
+
+ arb = devm_kzalloc(dev, sizeof(*arb), GFP_KERNEL);
+ if (!arb)
+ return -ENOMEM;
+ platform_set_drvdata(pdev, arb);
+
+ arb->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(arb->clk)) {
+ if (PTR_ERR(arb->clk) != -EPROBE_DEFER)
+ dev_err(dev, "failed to get clock\n");
+ return PTR_ERR(arb->clk);
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ arb->regs = devm_ioremap_resource(dev, res);
+ if (IS_ERR(arb->regs))
+ return PTR_ERR(arb->regs);
+
+ spin_lock_init(&arb->lock);
+ arb->reset_bits = axg_audio_arb_reset_bits;
+ arb->rstc.nr_resets = ARRAY_SIZE(axg_audio_arb_reset_bits);
+ arb->rstc.ops = &meson_audio_arb_rstc_ops;
+ arb->rstc.of_node = dev->of_node;
+
+ /*
+ * Enable general :
+ * In the initial state, all memory interfaces are disabled
+ * and the general bit is on
+ */
+ ret = clk_prepare_enable(arb->clk);
+ if (ret) {
+ dev_err(dev, "failed to enable arb clock\n");
+ return ret;
+ }
+ writel(BIT(ARB_GENERAL_BIT), arb->regs);
+
+ /* Register reset controller */
+ ret = devm_reset_controller_register(dev, &arb->rstc);
+ if (ret) {
+ dev_err(dev, "failed to register arb reset controller\n");
+ meson_audio_arb_remove(pdev);
+ }
+
+ return ret;
+}
+
+static struct platform_driver meson_audio_arb_pdrv = {
+ .probe = meson_audio_arb_probe,
+ .remove = meson_audio_arb_remove,
+ .driver = {
+ .name = "meson-audio-arb-reset",
+ .of_match_table = meson_audio_arb_of_match,
+ },
+};
+module_platform_driver(meson_audio_arb_pdrv);
+
+MODULE_DESCRIPTION("Amlogic A113 Audio Memory Arbitror");
+MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
+MODULE_LICENSE("GPL v2");
--
2.14.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] reset: meson: add dt-bindings for meson-axg audio arb
2018-07-06 14:31 ` [PATCH 1/2] reset: meson: add dt-bindings for meson-axg audio arb Jerome Brunet
@ 2018-07-20 13:52 ` Rob Herring
0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2018-07-20 13:52 UTC (permalink / raw)
To: Jerome Brunet
Cc: Philipp Zabel, Kevin Hilman, Carlo Caione, devicetree,
linux-amlogic, linux-kernel
On Fri, Jul 06, 2018 at 04:31:21PM +0200, Jerome Brunet wrote:
> Add dt-bindings for the audio memory arbitror found on Amlogic's
> A113 based SoCs
s/arbitror/arbiter/
>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
> .../bindings/reset/amlogic,meson-axg-audio-arb.txt | 21 +++++++++++++++++++++
> .../dt-bindings/reset/amlogic,meson-axg-audio-arb.h | 17 +++++++++++++++++
> 2 files changed, 38 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt
> create mode 100644 include/dt-bindings/reset/amlogic,meson-axg-audio-arb.h
>
> diff --git a/Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt b/Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt
> new file mode 100644
> index 000000000000..e29b3463f2e1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/reset/amlogic,meson-axg-audio-arb.txt
> @@ -0,0 +1,21 @@
> +* Amlogic audio memory arbitror controller
s/arbitror/arbiter/
With that,
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-20 13:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 14:31 [PATCH 0/2] reset: meson: add audio arb controller Jerome Brunet
2018-07-06 14:31 ` [PATCH 1/2] reset: meson: add dt-bindings for meson-axg audio arb Jerome Brunet
2018-07-20 13:52 ` Rob Herring
2018-07-06 14:31 ` [PATCH 2/2] reset: meson: add meson audio arb driver Jerome Brunet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).