From: Jan Dakinevich <jan.dakinevich@salutedevices.com>
To: Jan Dakinevich <jan.dakinevich@salutedevices.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Jerome Brunet <jbrunet@baylibre.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
<linux-amlogic@lists.infradead.org>, <linux-clk@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<alsa-devel@alsa-project.org>, <linux-sound@vger.kernel.org>,
<linux-gpio@vger.kernel.org>
Cc: <kernel@salutedevices.com>
Subject: [PATCH 02/25] clk: meson: axg: move reset controller's code to separate module
Date: Fri, 15 Mar 2024 02:21:38 +0300 [thread overview]
Message-ID: <20240314232201.2102178-3-jan.dakinevich@salutedevices.com> (raw)
In-Reply-To: <20240314232201.2102178-1-jan.dakinevich@salutedevices.com>
This code will by reused by A1 SoC.
Signed-off-by: Jan Dakinevich <jan.dakinevich@salutedevices.com>
---
drivers/clk/meson/Kconfig | 5 ++
drivers/clk/meson/Makefile | 1 +
drivers/clk/meson/axg-audio.c | 95 +----------------------
drivers/clk/meson/meson-audio-rstc.c | 109 +++++++++++++++++++++++++++
drivers/clk/meson/meson-audio-rstc.h | 12 +++
5 files changed, 130 insertions(+), 92 deletions(-)
create mode 100644 drivers/clk/meson/meson-audio-rstc.c
create mode 100644 drivers/clk/meson/meson-audio-rstc.h
diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig
index 29ffd14d267b..d6a2fa5f7e88 100644
--- a/drivers/clk/meson/Kconfig
+++ b/drivers/clk/meson/Kconfig
@@ -48,6 +48,10 @@ config COMMON_CLK_MESON_CPU_DYNDIV
tristate
select COMMON_CLK_MESON_REGMAP
+config COMMON_CLK_MESON_AUDIO_RSTC
+ tristate
+ select RESET_CONTROLLER
+
config COMMON_CLK_MESON8B
bool "Meson8 SoC Clock controller support"
depends on ARM
@@ -101,6 +105,7 @@ config COMMON_CLK_AXG_AUDIO
select COMMON_CLK_MESON_PHASE
select COMMON_CLK_MESON_SCLK_DIV
select COMMON_CLK_MESON_CLKC_UTILS
+ select COMMON_CLK_MESON_AUDIO_RSTC
select REGMAP_MMIO
help
Support for the audio clock controller on AmLogic A113D devices,
diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
index 9ee4b954c896..88d94921a4dc 100644
--- a/drivers/clk/meson/Makefile
+++ b/drivers/clk/meson/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_COMMON_CLK_MESON_PLL) += clk-pll.o
obj-$(CONFIG_COMMON_CLK_MESON_REGMAP) += clk-regmap.o
obj-$(CONFIG_COMMON_CLK_MESON_SCLK_DIV) += sclk-div.o
obj-$(CONFIG_COMMON_CLK_MESON_VID_PLL_DIV) += vid-pll-div.o
+obj-$(CONFIG_COMMON_CLK_MESON_AUDIO_RSTC) += meson-audio-rstc.o
# Amlogic Clock controllers
diff --git a/drivers/clk/meson/axg-audio.c b/drivers/clk/meson/axg-audio.c
index ac3482960903..990203a7ad5c 100644
--- a/drivers/clk/meson/axg-audio.c
+++ b/drivers/clk/meson/axg-audio.c
@@ -12,10 +12,10 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
-#include <linux/reset-controller.h>
#include <linux/slab.h>
#include "meson-clkc-utils.h"
+#include "meson-audio-rstc.h"
#include "axg-audio.h"
#include "clk-regmap.h"
#include "clk-phase.h"
@@ -1648,84 +1648,6 @@ static struct clk_regmap *const sm1_clk_regmaps[] = {
&sm1_sysclk_b_en,
};
-struct axg_audio_reset_data {
- struct reset_controller_dev rstc;
- struct regmap *map;
- unsigned int offset;
-};
-
-static void axg_audio_reset_reg_and_bit(struct axg_audio_reset_data *rst,
- unsigned long id,
- unsigned int *reg,
- unsigned int *bit)
-{
- unsigned int stride = regmap_get_reg_stride(rst->map);
-
- *reg = (id / (stride * BITS_PER_BYTE)) * stride;
- *reg += rst->offset;
- *bit = id % (stride * BITS_PER_BYTE);
-}
-
-static int axg_audio_reset_update(struct reset_controller_dev *rcdev,
- unsigned long id, bool assert)
-{
- struct axg_audio_reset_data *rst =
- container_of(rcdev, struct axg_audio_reset_data, rstc);
- unsigned int offset, bit;
-
- axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
-
- regmap_update_bits(rst->map, offset, BIT(bit),
- assert ? BIT(bit) : 0);
-
- return 0;
-}
-
-static int axg_audio_reset_status(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- struct axg_audio_reset_data *rst =
- container_of(rcdev, struct axg_audio_reset_data, rstc);
- unsigned int val, offset, bit;
-
- axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
-
- regmap_read(rst->map, offset, &val);
-
- return !!(val & BIT(bit));
-}
-
-static int axg_audio_reset_assert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return axg_audio_reset_update(rcdev, id, true);
-}
-
-static int axg_audio_reset_deassert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return axg_audio_reset_update(rcdev, id, false);
-}
-
-static int axg_audio_reset_toggle(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- int ret;
-
- ret = axg_audio_reset_assert(rcdev, id);
- if (ret)
- return ret;
-
- return axg_audio_reset_deassert(rcdev, id);
-}
-
-static const struct reset_control_ops axg_audio_rstc_ops = {
- .assert = axg_audio_reset_assert,
- .deassert = axg_audio_reset_deassert,
- .reset = axg_audio_reset_toggle,
- .status = axg_audio_reset_status,
-};
-
static const struct regmap_config axg_audio_regmap_cfg = {
.reg_bits = 32,
.val_bits = 32,
@@ -1745,7 +1667,6 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct audioclk_data *data;
- struct axg_audio_reset_data *rst;
struct regmap *map;
void __iomem *regs;
struct clk_hw *hw;
@@ -1807,18 +1728,8 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
if (!data->reset_num)
return 0;
- rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);
- if (!rst)
- return -ENOMEM;
-
- rst->map = map;
- rst->offset = data->reset_offset;
- rst->rstc.nr_resets = data->reset_num;
- rst->rstc.ops = &axg_audio_rstc_ops;
- rst->rstc.of_node = dev->of_node;
- rst->rstc.owner = THIS_MODULE;
-
- return devm_reset_controller_register(dev, &rst->rstc);
+ return meson_audio_rstc_register(dev, map, data->reset_offset,
+ data->reset_num);
}
static const struct audioclk_data axg_audioclk_data = {
diff --git a/drivers/clk/meson/meson-audio-rstc.c b/drivers/clk/meson/meson-audio-rstc.c
new file mode 100644
index 000000000000..2079d24c40f4
--- /dev/null
+++ b/drivers/clk/meson/meson-audio-rstc.c
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (c) 2018 BayLibre, SAS.
+ * Author: Jerome Brunet <jbrunet@baylibre.com>
+ */
+
+#include <linux/reset-controller.h>
+
+#include "meson-audio-rstc.h"
+
+struct meson_audio_reset_data {
+ struct reset_controller_dev rstc;
+ struct regmap *map;
+ unsigned int offset;
+};
+
+static void meson_audio_reset_reg_and_bit(struct meson_audio_reset_data *rst,
+ unsigned long id,
+ unsigned int *reg,
+ unsigned int *bit)
+{
+ unsigned int stride = regmap_get_reg_stride(rst->map);
+
+ *reg = (id / (stride * BITS_PER_BYTE)) * stride;
+ *reg += rst->offset;
+ *bit = id % (stride * BITS_PER_BYTE);
+}
+
+static int meson_audio_reset_update(struct reset_controller_dev *rcdev,
+ unsigned long id, bool assert)
+{
+ struct meson_audio_reset_data *rst =
+ container_of(rcdev, struct meson_audio_reset_data, rstc);
+ unsigned int offset, bit;
+
+ meson_audio_reset_reg_and_bit(rst, id, &offset, &bit);
+
+ regmap_update_bits(rst->map, offset, BIT(bit),
+ assert ? BIT(bit) : 0);
+
+ return 0;
+}
+
+static int meson_audio_reset_status(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct meson_audio_reset_data *rst =
+ container_of(rcdev, struct meson_audio_reset_data, rstc);
+ unsigned int val, offset, bit;
+
+ meson_audio_reset_reg_and_bit(rst, id, &offset, &bit);
+
+ regmap_read(rst->map, offset, &val);
+
+ return !!(val & BIT(bit));
+}
+
+static int meson_audio_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return meson_audio_reset_update(rcdev, id, true);
+}
+
+static int meson_audio_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return meson_audio_reset_update(rcdev, id, false);
+}
+
+static int meson_audio_reset_toggle(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ int ret;
+
+ ret = meson_audio_reset_assert(rcdev, id);
+ if (ret)
+ return ret;
+
+ return meson_audio_reset_deassert(rcdev, id);
+}
+
+static const struct reset_control_ops meson_audio_rstc_ops = {
+ .assert = meson_audio_reset_assert,
+ .deassert = meson_audio_reset_deassert,
+ .reset = meson_audio_reset_toggle,
+ .status = meson_audio_reset_status,
+};
+
+int meson_audio_rstc_register(struct device *dev, struct regmap *map,
+ unsigned int offset, unsigned int num)
+{
+ struct meson_audio_reset_data *rst;
+
+ rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);
+ if (!rst)
+ return -ENOMEM;
+
+ rst->map = map;
+ rst->offset = offset;
+ rst->rstc.nr_resets = num;
+ rst->rstc.ops = &meson_audio_rstc_ops;
+ rst->rstc.of_node = dev->of_node;
+ rst->rstc.owner = THIS_MODULE;
+
+ return devm_reset_controller_register(dev, &rst->rstc);
+}
+EXPORT_SYMBOL_GPL(meson_audio_rstc_register);
+
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/clk/meson/meson-audio-rstc.h b/drivers/clk/meson/meson-audio-rstc.h
new file mode 100644
index 000000000000..6b441549de03
--- /dev/null
+++ b/drivers/clk/meson/meson-audio-rstc.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+
+#ifndef __MESON_AUDIO_RSTC_H
+#define __MESON_AUDIO_RSTC_H
+
+#include <linux/device.h>
+#include <linux/regmap.h>
+
+int meson_audio_rstc_register(struct device *dev, struct regmap *map,
+ unsigned int offset, unsigned int num);
+
+#endif /* __MESON_AUDIO_RSTC_H */
--
2.34.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2024-03-14 23:23 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-14 23:21 [PATCH 00/25] Introduce support of audio for Amlogic A1 SoC family Jan Dakinevich
2024-03-14 23:21 ` [PATCH 01/25] clk: meson: a1: restrict an amount of 'hifi_pll' params Jan Dakinevich
2024-03-15 8:58 ` Jerome Brunet
2024-03-17 14:17 ` Jan Dakinevich
2024-03-18 10:17 ` Jerome Brunet
2024-03-18 22:35 ` Jan Dakinevich
2024-03-19 8:21 ` Jerome Brunet
2024-03-19 13:53 ` Dmitry Rokosov
2024-03-14 23:21 ` Jan Dakinevich [this message]
2024-03-14 23:21 ` [PATCH 03/25] dt-bindings: clock: meson: add A1 audio clock and reset controller bindings Jan Dakinevich
2024-03-15 9:56 ` Krzysztof Kozlowski
2024-03-14 23:21 ` [PATCH 04/25] clk: meson: a1: add the audio clock controller driver Jan Dakinevich
2024-03-15 9:20 ` Jerome Brunet
2024-03-19 1:47 ` Jan Dakinevich
2024-03-19 8:30 ` Jerome Brunet
2024-03-23 18:02 ` Jan Dakinevich
2024-03-26 15:26 ` Jerome Brunet
2024-03-26 18:44 ` Jan Dakinevich
2024-03-27 12:57 ` Jerome Brunet
2024-03-14 23:21 ` [PATCH 05/25] ASoC: meson: codec-glue: add support for capture stream Jan Dakinevich
2024-03-14 23:21 ` [PATCH 06/25] ASoC: meson: g12a-toacodec: fix "Lane Select" width Jan Dakinevich
2024-03-15 10:00 ` Jerome Brunet
2024-03-15 13:17 ` Dan Carpenter
2024-03-24 17:51 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 07/25] ASoC: meson: g12a-toacodec: rework the definition of bits Jan Dakinevich
2024-03-14 23:21 ` [PATCH 08/25] ASoC: dt-bindings: meson: g12a-toacodec: add support for A1 SoC family Jan Dakinevich
2024-03-15 9:58 ` Krzysztof Kozlowski
2024-03-17 14:29 ` Jan Dakinevich
2024-03-17 14:46 ` Krzysztof Kozlowski
2024-03-17 15:11 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 09/25] ASoC: " Jan Dakinevich
2024-03-15 13:33 ` Mark Brown
2024-03-17 15:19 ` Jan Dakinevich
2024-03-18 10:42 ` Jerome Brunet
2024-03-18 13:30 ` Mark Brown
2024-03-14 23:21 ` [PATCH 10/25] ASoC: meson: t9015: prepare to adding new platforms Jan Dakinevich
2024-03-14 23:21 ` [PATCH 11/25] ASoC: dt-bindings: meson: t9015: add support for A1 SoC family Jan Dakinevich
2024-03-17 19:03 ` Rob Herring
2024-03-17 23:39 ` Jan Dakinevich
2024-03-18 7:46 ` Krzysztof Kozlowski
2024-03-14 23:21 ` [PATCH 12/25] ASoC: " Jan Dakinevich
2024-03-15 13:36 ` Mark Brown
2024-03-17 16:27 ` Jan Dakinevich
2024-03-18 13:48 ` Mark Brown
2024-03-18 22:43 ` Jan Dakinevich
2024-03-18 10:46 ` Jerome Brunet
2024-03-19 0:17 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 13/25] ASoC: dt-bindings: meson: axg-pdm: document 'sysrate' property Jan Dakinevich
2024-03-15 10:00 ` Krzysztof Kozlowski
2024-03-15 10:22 ` Jerome Brunet
2024-03-17 15:52 ` Jan Dakinevich
2024-03-18 10:55 ` Jerome Brunet
2024-03-18 12:19 ` Jerome Brunet
2024-03-19 0:30 ` Jan Dakinevich
2024-03-19 0:35 ` Jan Dakinevich
2024-03-19 5:17 ` Krzysztof Kozlowski
2024-03-17 15:55 ` Jan Dakinevich
2024-03-17 16:27 ` Krzysztof Kozlowski
2024-03-17 16:35 ` Jan Dakinevich
2024-03-19 5:17 ` Krzysztof Kozlowski
2024-03-14 23:21 ` [PATCH 14/25] ASoC: meson: axg-pdm: introduce " Jan Dakinevich
2024-03-14 23:21 ` [PATCH 15/25] pinctrl/meson: fix typo in PDM's pin name Jan Dakinevich
2024-03-14 23:21 ` [PATCH 16/25] ASoC: dt-bindings: meson: meson-axg-audio-arb: claim support of A1 SoC family Jan Dakinevich
2024-03-17 19:10 ` Rob Herring
2024-03-14 23:21 ` [PATCH 17/25] ASoC: dt-bindings: meson: axg-fifo: " Jan Dakinevich
2024-03-17 19:13 ` Rob Herring
2024-03-14 23:21 ` [PATCH 18/25] ASoC: dt-bindings: meson: axg-pdm: " Jan Dakinevich
2024-03-17 19:14 ` Rob Herring
2024-03-14 23:21 ` [PATCH 19/25] ASoC: dt-bindings: meson: axg-sound-card: " Jan Dakinevich
2024-03-15 10:06 ` Jerome Brunet
2024-03-17 16:39 ` Jan Dakinevich
2024-03-14 23:21 ` [PATCH 20/25] ASoC: dt-bindings: meson: axg-tdm-formatters: " Jan Dakinevich
2024-03-17 19:16 ` Rob Herring
2024-03-14 23:21 ` [PATCH 21/25] ASoC: dt-bindings: meson: axg-tdm-iface: " Jan Dakinevich
2024-03-15 10:13 ` Jerome Brunet
2024-03-14 23:21 ` [PATCH 22/25] ASoC: dt-bindings: meson: introduce link-name optional property Jan Dakinevich
2024-03-17 19:45 ` Rob Herring
2024-03-18 7:27 ` Dmitry Rokosov
2024-03-14 23:21 ` [PATCH 23/25] ASoC: meson: implement link-name optional property in meson card utils Jan Dakinevich
2024-03-14 23:22 ` [PATCH 24/25] arm64: dts: meson: a1: add audio devices Jan Dakinevich
2024-03-14 23:22 ` [PATCH 25/25] arm64: dts: ad402: enable audio Jan Dakinevich
2024-03-15 10:01 ` [PATCH 00/25] Introduce support of audio for Amlogic A1 SoC family Jerome Brunet
2024-03-15 15:50 ` Rob Herring
2024-03-15 16:53 ` Neil Armstrong
2024-03-18 7:30 ` Dmitry Rokosov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240314232201.2102178-3-jan.dakinevich@salutedevices.com \
--to=jan.dakinevich@salutedevices.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jbrunet@baylibre.com \
--cc=kernel@salutedevices.com \
--cc=khilman@baylibre.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mturquette@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox