2024-05-20 07:29:40

by Shengjiu Wang

[permalink] [raw]
Subject: [PATCH v4 0/5] clk: imx: clk-audiomix: Improvement for audiomix

Some improvement for audiomix driver:
Add reset controller for EARC function
Add CLK_SET_RATE_PARENT flags for clocks
Corrent parent clock for earc_phy and audpll clocks.

changes in v4:
- use auxiliary device framework for reset controller driver.
- drop syscon and simple-mfd related changes in v3

changes in v3:
- separate reset driver to driver/reset/
- add binding doc for reset driver.
- modify imx8mp.dtsi accordingly

changes in v2:
- add more info in commit messages.

Shengjiu Wang (5):
dt-bindings: clock: imx8mp: Add #reset-cells property
clk: imx: clk-audiomix: Add reset controller
reset: imx-aux: Add i.MX auxiliary reset driver
clk: imx: clk-audiomix: Add CLK_SET_RATE_PARENT flags for clocks
clk: imx: clk-audiomix: Corrent parent clock for earc_phy and audpll

.../bindings/clock/imx8mp-audiomix.yaml | 3 +
drivers/clk/imx/Kconfig | 1 +
drivers/clk/imx/clk-imx8mp-audiomix.c | 84 ++++++-
drivers/reset/Kconfig | 8 +
drivers/reset/Makefile | 1 +
drivers/reset/reset-imx-aux.c | 217 ++++++++++++++++++
6 files changed, 308 insertions(+), 6 deletions(-)
create mode 100644 drivers/reset/reset-imx-aux.c

--
2.34.1



2024-05-20 07:29:56

by Shengjiu Wang

[permalink] [raw]
Subject: [PATCH v4 1/5] dt-bindings: clock: imx8mp: Add #reset-cells property

The Audio Block Control contains clock distribution and gating
controls, as well as reset handling to several of the AUDIOMIX
peripherals. Especially the reset controls for Enhanced Audio
Return Channel (EARC) PHY and Controller.

So make Audio Block Control a reset provider for EARC, which
is one of modules in this audio subsystem.

Signed-off-by: Shengjiu Wang <[email protected]>
Acked-by: Krzysztof Kozlowski <[email protected]>
---
Documentation/devicetree/bindings/clock/imx8mp-audiomix.yaml | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/clock/imx8mp-audiomix.yaml b/Documentation/devicetree/bindings/clock/imx8mp-audiomix.yaml
index 0a6dc1a6e122..6588a17a7d9a 100644
--- a/Documentation/devicetree/bindings/clock/imx8mp-audiomix.yaml
+++ b/Documentation/devicetree/bindings/clock/imx8mp-audiomix.yaml
@@ -44,6 +44,9 @@ properties:
ID in its "clocks" phandle cell. See include/dt-bindings/clock/imx8mp-clock.h
for the full list of i.MX8MP IMX8MP_CLK_AUDIOMIX_ clock IDs.

+ '#reset-cells':
+ const: 1
+
required:
- compatible
- reg
--
2.34.1


2024-05-20 07:29:55

by Shengjiu Wang

[permalink] [raw]
Subject: [PATCH v4 5/5] clk: imx: clk-audiomix: Corrent parent clock for earc_phy and audpll

According to Reference Manual of i.MX8MP
The parent clock of "earc_phy" is "sai_pll_out_div2",
The parent clock of "audpll" is "osc_24m".

Add CLK_GATE_PARENT() macro for usage of specifying parent clock.

Fixes: 6cd95f7b151c ("clk: imx: imx8mp: Add audiomix block control")
Signed-off-by: Shengjiu Wang <[email protected]>
---
drivers/clk/imx/clk-imx8mp-audiomix.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
index 3d15405cedb8..4ae0cf916d78 100644
--- a/drivers/clk/imx/clk-imx8mp-audiomix.c
+++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
@@ -155,6 +155,15 @@ static const struct clk_parent_data clk_imx8mp_audiomix_pll_bypass_sels[] = {
PDM_SEL, 2, 0 \
}

+#define CLK_GATE_PARENT(gname, cname, pname) \
+ { \
+ gname"_cg", \
+ IMX8MP_CLK_AUDIOMIX_##cname, \
+ { .fw_name = pname, .name = pname }, NULL, 1, \
+ CLKEN0 + 4 * !!(IMX8MP_CLK_AUDIOMIX_##cname / 32), \
+ 1, IMX8MP_CLK_AUDIOMIX_##cname % 32 \
+ }
+
struct clk_imx8mp_audiomix_sel {
const char *name;
int clkid;
@@ -172,14 +181,14 @@ static struct clk_imx8mp_audiomix_sel sels[] = {
CLK_GATE("earc", EARC_IPG),
CLK_GATE("ocrama", OCRAMA_IPG),
CLK_GATE("aud2htx", AUD2HTX_IPG),
- CLK_GATE("earc_phy", EARC_PHY),
+ CLK_GATE_PARENT("earc_phy", EARC_PHY, "sai_pll_out_div2"),
CLK_GATE("sdma2", SDMA2_ROOT),
CLK_GATE("sdma3", SDMA3_ROOT),
CLK_GATE("spba2", SPBA2_ROOT),
CLK_GATE("dsp", DSP_ROOT),
CLK_GATE("dspdbg", DSPDBG_ROOT),
CLK_GATE("edma", EDMA_ROOT),
- CLK_GATE("audpll", AUDPLL_ROOT),
+ CLK_GATE_PARENT("audpll", AUDPLL_ROOT, "osc_24m"),
CLK_GATE("mu2", MU2_ROOT),
CLK_GATE("mu3", MU3_ROOT),
CLK_PDM,
--
2.34.1


2024-05-20 07:30:13

by Shengjiu Wang

[permalink] [raw]
Subject: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller

Audiomix block control can be a reset controller for
Enhanced Audio Return Channel (EARC), which is one of
modules in this audiomix subsystem.

The reset controller is supported by the auxiliary device
framework.

Signed-off-by: Shengjiu Wang <[email protected]>
---
drivers/clk/imx/Kconfig | 1 +
drivers/clk/imx/clk-imx8mp-audiomix.c | 61 +++++++++++++++++++++++++++
2 files changed, 62 insertions(+)

diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig
index 6da0fba68225..9edfb030bea9 100644
--- a/drivers/clk/imx/Kconfig
+++ b/drivers/clk/imx/Kconfig
@@ -81,6 +81,7 @@ config CLK_IMX8MP
tristate "IMX8MP CCM Clock Driver"
depends on ARCH_MXC || COMPILE_TEST
select MXC_CLK
+ select AUXILIARY_BUS
help
Build the driver for i.MX8MP CCM Clock Driver

diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
index b381d6f784c8..d2eaabe431cd 100644
--- a/drivers/clk/imx/clk-imx8mp-audiomix.c
+++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
@@ -5,6 +5,7 @@
* Copyright (C) 2022 Marek Vasut <[email protected]>
*/

+#include <linux/auxiliary_bus.h>
#include <linux/clk-provider.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -217,6 +218,62 @@ struct clk_imx8mp_audiomix_priv {
struct clk_hw_onecell_data clk_data;
};

+#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
+
+static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
+{
+ struct auxiliary_device *adev = _adev;
+
+ auxiliary_device_delete(adev);
+ auxiliary_device_uninit(adev);
+}
+
+static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
+{
+ struct auxiliary_device *adev = to_auxiliary_dev(dev);
+
+ kfree(adev);
+}
+
+static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
+ struct clk_imx8mp_audiomix_priv *priv)
+{
+ struct auxiliary_device *adev;
+ int ret;
+
+ adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+ if (!adev)
+ return -ENOMEM;
+
+ adev->name = "reset";
+ adev->dev.parent = dev;
+ adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
+
+ ret = auxiliary_device_init(adev);
+ if (ret) {
+ kfree(adev);
+ return ret;
+ }
+
+ ret = auxiliary_device_add(adev);
+ if (ret) {
+ auxiliary_device_uninit(adev);
+ kfree(adev);
+ return ret;
+ }
+
+ return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, adev);
+}
+
+#else /* !CONFIG_RESET_CONTROLLER */
+
+static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv)
+{
+ return 0;
+}
+
+#endif /* !CONFIG_RESET_CONTROLLER */
+
static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
{
struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev);
@@ -337,6 +394,10 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
if (ret)
goto err_clk_register;

+ ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
+ if (ret)
+ goto err_clk_register;
+
pm_runtime_put_sync(dev);
return 0;

--
2.34.1


2024-05-20 07:30:41

by Shengjiu Wang

[permalink] [raw]
Subject: [PATCH v4 3/5] reset: imx-aux: Add i.MX auxiliary reset driver

Add support for the resets on i.MX8MP Audio Block Control module.
The reset controller is created using the auxiliary device framework
and set up in the clock driver.

The EARC PHY software reset and EARC controller software
reset can be supported.

Signed-off-by: Shengjiu Wang <[email protected]>
---
drivers/reset/Kconfig | 8 ++
drivers/reset/Makefile | 1 +
drivers/reset/reset-imx-aux.c | 217 ++++++++++++++++++++++++++++++++++
3 files changed, 226 insertions(+)
create mode 100644 drivers/reset/reset-imx-aux.c

diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 7112f5932609..38fdf05b326b 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -91,6 +91,14 @@ config RESET_IMX7
help
This enables the reset controller driver for i.MX7 SoCs.

+config RESET_IMX_AUX
+ tristate "i.MX Auxiliary Reset Driver"
+ depends on CLK_IMX8MP
+ select AUXILIARY_BUS
+ default CLK_IMX8MP
+ help
+ This enables the auxiliary reset controller driver for i.MX.
+
config RESET_INTEL_GW
bool "Intel Reset Controller Driver"
depends on X86 || COMPILE_TEST
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index fd8b49fa46fc..f078da14c327 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_RESET_BRCMSTB_RESCAL) += reset-brcmstb-rescal.o
obj-$(CONFIG_RESET_GPIO) += reset-gpio.o
obj-$(CONFIG_RESET_HSDK) += reset-hsdk.o
obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
+obj-$(CONFIG_RESET_IMX_AUX) += reset-imx-aux.o
obj-$(CONFIG_RESET_INTEL_GW) += reset-intel-gw.o
obj-$(CONFIG_RESET_K210) += reset-k210.o
obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o
diff --git a/drivers/reset/reset-imx-aux.c b/drivers/reset/reset-imx-aux.c
new file mode 100644
index 000000000000..54a5e1e627ea
--- /dev/null
+++ b/drivers/reset/reset-imx-aux.c
@@ -0,0 +1,217 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2024 NXP
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+
+/*
+ * The reset does not support the feature and corresponding
+ * values are not valid
+ */
+#define ASSERT_NONE BIT(0)
+#define DEASSERT_NONE BIT(1)
+#define STATUS_NONE BIT(2)
+
+/* When set this function is activated by setting(vs clearing) this bit */
+#define ASSERT_SET BIT(3)
+#define DEASSERT_SET BIT(4)
+#define STATUS_SET BIT(5)
+
+/* The following are the inverse of the above and are added for consistency */
+#define ASSERT_CLEAR (0 << 3)
+#define DEASSERT_CLEAR (0 << 4)
+#define STATUS_CLEAR (0 << 5)
+
+/**
+ * struct imx_reset_ctrl - reset control structure
+ * @assert_offset: reset assert control register offset
+ * @assert_bit: reset assert bit in the reset assert control register
+ * @deassert_offset: reset deassert control register offset
+ * @deassert_bit: reset deassert bit in the reset deassert control register
+ * @status_offset: reset status register offset
+ * @status_bit: reset status bit in the reset status register
+ * @flags: reset flag indicating how the (de)assert and status are handled
+ */
+struct imx_reset_ctrl {
+ u32 assert_offset;
+ u32 assert_bit;
+ u32 deassert_offset;
+ u32 deassert_bit;
+ u32 status_offset;
+ u32 status_bit;
+ u32 flags;
+};
+
+struct imx_reset_data {
+ const struct imx_reset_ctrl *rst_ctrl;
+ size_t rst_ctrl_num;
+};
+
+struct imx_aux_reset_priv {
+ struct reset_controller_dev rcdev;
+ void __iomem *base;
+ const struct imx_reset_data *data;
+};
+
+static int imx_aux_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct imx_aux_reset_priv *priv = container_of(rcdev,
+ struct imx_aux_reset_priv, rcdev);
+ const struct imx_reset_data *data = priv->data;
+ void __iomem *reg_addr = priv->base;
+ const struct imx_reset_ctrl *ctrl;
+ unsigned int mask, value, reg;
+
+ if (id >= data->rst_ctrl_num)
+ return -EINVAL;
+
+ ctrl = &data->rst_ctrl[id];
+
+ /* assert not supported for this reset */
+ if (ctrl->flags & ASSERT_NONE)
+ return -EOPNOTSUPP;
+
+ mask = BIT(ctrl->assert_bit);
+ value = (ctrl->flags & ASSERT_SET) ? mask : 0x0;
+
+ reg = readl(reg_addr + ctrl->assert_offset);
+ writel(reg | value, reg_addr + ctrl->assert_offset);
+
+ return 0;
+}
+
+static int imx_aux_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct imx_aux_reset_priv *priv = container_of(rcdev,
+ struct imx_aux_reset_priv, rcdev);
+ const struct imx_reset_data *data = priv->data;
+ void __iomem *reg_addr = priv->base;
+ const struct imx_reset_ctrl *ctrl;
+ unsigned int mask, value, reg;
+
+ if (id >= data->rst_ctrl_num)
+ return -EINVAL;
+
+ ctrl = &data->rst_ctrl[id];
+
+ /* deassert not supported for this reset */
+ if (ctrl->flags & DEASSERT_NONE)
+ return -EOPNOTSUPP;
+
+ mask = BIT(ctrl->deassert_bit);
+ value = (ctrl->flags & DEASSERT_SET) ? mask : 0x0;
+
+ reg = readl(reg_addr + ctrl->deassert_offset);
+ writel(reg | value, reg_addr + ctrl->deassert_offset);
+
+ return 0;
+}
+
+static int imx_aux_reset_status(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct imx_aux_reset_priv *priv = container_of(rcdev,
+ struct imx_aux_reset_priv, rcdev);
+ const struct imx_reset_data *data = priv->data;
+ void __iomem *reg_addr = priv->base;
+ const struct imx_reset_ctrl *ctrl;
+ unsigned int reset_state;
+
+ if (id >= data->rst_ctrl_num)
+ return -EINVAL;
+
+ ctrl = &data->rst_ctrl[id];
+
+ /* status not supported for this reset */
+ if (ctrl->flags & STATUS_NONE)
+ return -EOPNOTSUPP;
+
+ reset_state = readl(reg_addr + ctrl->status_offset);
+
+ return !(reset_state & BIT(ctrl->status_bit)) ==
+ !(ctrl->flags & STATUS_SET);
+}
+
+static const struct reset_control_ops imx_aux_reset_ops = {
+ .assert = imx_aux_reset_assert,
+ .deassert = imx_aux_reset_deassert,
+ .status = imx_aux_reset_status,
+};
+
+static int imx_aux_reset_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ struct imx_reset_data *data = (struct imx_reset_data *)(id->driver_data);
+ struct imx_aux_reset_priv *priv;
+ struct device *dev = &adev->dev;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->rcdev.owner = THIS_MODULE;
+ priv->rcdev.nr_resets = data->rst_ctrl_num;
+ priv->rcdev.ops = &imx_aux_reset_ops;
+ priv->rcdev.of_node = dev->parent->of_node;
+ priv->rcdev.dev = dev;
+ priv->rcdev.of_reset_n_cells = 1;
+ priv->base = of_iomap(dev->parent->of_node, 0);
+ priv->data = data;
+
+ return devm_reset_controller_register(dev, &priv->rcdev);
+}
+
+#define EARC 0x200
+
+const struct imx_reset_ctrl imx8mp_audiomix_rst_ctrl[] = {
+ {
+ .assert_offset = EARC,
+ .assert_bit = 0,
+ .deassert_offset = EARC,
+ .deassert_bit = 0,
+ .flags = ASSERT_CLEAR | DEASSERT_SET | STATUS_NONE,
+ },
+ {
+ .assert_offset = EARC,
+ .assert_bit = 1,
+ .deassert_offset = EARC,
+ .deassert_bit = 1,
+ .flags = ASSERT_CLEAR | DEASSERT_SET | STATUS_NONE,
+ },
+};
+
+const struct imx_reset_data imx8mp_audiomix_rst_data = {
+ .rst_ctrl = imx8mp_audiomix_rst_ctrl,
+ .rst_ctrl_num = ARRAY_SIZE(imx8mp_audiomix_rst_ctrl),
+};
+
+static const struct auxiliary_device_id imx_aux_reset_ids[] = {
+ {
+ .name = "clk_imx8mp_audiomix.reset",
+ .driver_data = (kernel_ulong_t)&imx8mp_audiomix_rst_data,
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(auxiliary, imx_aux_reset_ids);
+
+static struct auxiliary_driver imx_aux_reset_driver = {
+ .probe = imx_aux_reset_probe,
+ .id_table = imx_aux_reset_ids,
+};
+
+module_auxiliary_driver(imx_aux_reset_driver);
+
+MODULE_AUTHOR("Shengjiu Wang <[email protected]>");
+MODULE_DESCRIPTION("Freescale i.MX auxiliary reset driver");
+MODULE_LICENSE("GPL");
--
2.34.1


2024-05-20 07:30:50

by Shengjiu Wang

[permalink] [raw]
Subject: [PATCH v4 4/5] clk: imx: clk-audiomix: Add CLK_SET_RATE_PARENT flags for clocks

Add CLK_SET_RATE_PARENT flags that when the device driver sets the
child clock rate, parent clock frequency can be refined accordingly.

Signed-off-by: Shengjiu Wang <[email protected]>
---
drivers/clk/imx/clk-imx8mp-audiomix.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
index d2eaabe431cd..3d15405cedb8 100644
--- a/drivers/clk/imx/clk-imx8mp-audiomix.c
+++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
@@ -326,12 +326,12 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(sels); i++) {
if (sels[i].num_parents == 1) {
hw = devm_clk_hw_register_gate_parent_data(dev,
- sels[i].name, &sels[i].parent, 0,
+ sels[i].name, &sels[i].parent, CLK_SET_RATE_PARENT,
base + sels[i].reg, sels[i].shift, 0, NULL);
} else {
hw = devm_clk_hw_register_mux_parent_data_table(dev,
sels[i].name, sels[i].parents,
- sels[i].num_parents, 0,
+ sels[i].num_parents, CLK_SET_RATE_PARENT,
base + sels[i].reg,
sels[i].shift, sels[i].width,
0, NULL, NULL);
@@ -374,7 +374,8 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
clk_hw_data->hws[IMX8MP_CLK_AUDIOMIX_SAI_PLL_BYPASS] = hw;

hw = devm_clk_hw_register_gate(dev, "sai_pll_out", "sai_pll_bypass",
- 0, base + SAI_PLL_GNRL_CTL, 13,
+ CLK_SET_RATE_PARENT,
+ base + SAI_PLL_GNRL_CTL, 13,
0, NULL);
if (IS_ERR(hw)) {
ret = PTR_ERR(hw);
@@ -383,7 +384,8 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
clk_hw_data->hws[IMX8MP_CLK_AUDIOMIX_SAI_PLL_OUT] = hw;

hw = devm_clk_hw_register_fixed_factor(dev, "sai_pll_out_div2",
- "sai_pll_out", 0, 1, 2);
+ "sai_pll_out",
+ CLK_SET_RATE_PARENT, 1, 2);
if (IS_ERR(hw)) {
ret = PTR_ERR(hw);
goto err_clk_register;
--
2.34.1


2024-05-20 10:30:22

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller

Hi Shengjiu,

kernel test robot noticed the following build warnings:

[auto build test WARNING on abelvesa/clk/imx]
[also build test WARNING on linus/master next-20240520]
[cannot apply to pza/reset/next shawnguo/for-next robh/for-next pza/imx-drm/next v6.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Shengjiu-Wang/dt-bindings-clock-imx8mp-Add-reset-cells-property/20240520-153230
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux.git clk/imx
patch link: https://lore.kernel.org/r/1716188963-16175-3-git-send-email-shengjiu.wang%40nxp.com
patch subject: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20240520/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240520/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/clk/imx/clk-imx8mp-audiomix.c: In function 'clk_imx8mp_audiomix_reset_adev_release':
drivers/clk/imx/clk-imx8mp-audiomix.c:235:9: error: implicit declaration of function 'kfree'; did you mean 'vfree'? [-Werror=implicit-function-declaration]
235 | kfree(adev);
| ^~~~~
| vfree
drivers/clk/imx/clk-imx8mp-audiomix.c: In function 'clk_imx8mp_audiomix_reset_controller_register':
drivers/clk/imx/clk-imx8mp-audiomix.c:244:16: error: implicit declaration of function 'kzalloc'; did you mean 'vzalloc'? [-Werror=implicit-function-declaration]
244 | adev = kzalloc(sizeof(*adev), GFP_KERNEL);
| ^~~~~~~
| vzalloc
>> drivers/clk/imx/clk-imx8mp-audiomix.c:244:14: warning: assignment to 'struct auxiliary_device *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
244 | adev = kzalloc(sizeof(*adev), GFP_KERNEL);
| ^
cc1: some warnings being treated as errors


vim +244 drivers/clk/imx/clk-imx8mp-audiomix.c

237
238 static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
239 struct clk_imx8mp_audiomix_priv *priv)
240 {
241 struct auxiliary_device *adev;
242 int ret;
243
> 244 adev = kzalloc(sizeof(*adev), GFP_KERNEL);
245 if (!adev)
246 return -ENOMEM;
247
248 adev->name = "reset";
249 adev->dev.parent = dev;
250 adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
251
252 ret = auxiliary_device_init(adev);
253 if (ret) {
254 kfree(adev);
255 return ret;
256 }
257
258 ret = auxiliary_device_add(adev);
259 if (ret) {
260 auxiliary_device_uninit(adev);
261 kfree(adev);
262 return ret;
263 }
264
265 return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, adev);
266 }
267

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-05-20 13:52:58

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller

Hi Shengjiu,

kernel test robot noticed the following build errors:

[auto build test ERROR on abelvesa/clk/imx]
[also build test ERROR on linus/master next-20240520]
[cannot apply to pza/reset/next shawnguo/for-next robh/for-next pza/imx-drm/next v6.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Shengjiu-Wang/dt-bindings-clock-imx8mp-Add-reset-cells-property/20240520-153230
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux.git clk/imx
patch link: https://lore.kernel.org/r/1716188963-16175-3-git-send-email-shengjiu.wang%40nxp.com
patch subject: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20240520/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240520/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/clk/imx/clk-imx8mp-audiomix.c: In function 'clk_imx8mp_audiomix_reset_adev_release':
>> drivers/clk/imx/clk-imx8mp-audiomix.c:235:9: error: implicit declaration of function 'kfree'; did you mean 'vfree'? [-Werror=implicit-function-declaration]
235 | kfree(adev);
| ^~~~~
| vfree
drivers/clk/imx/clk-imx8mp-audiomix.c: In function 'clk_imx8mp_audiomix_reset_controller_register':
>> drivers/clk/imx/clk-imx8mp-audiomix.c:244:16: error: implicit declaration of function 'kzalloc'; did you mean 'vzalloc'? [-Werror=implicit-function-declaration]
244 | adev = kzalloc(sizeof(*adev), GFP_KERNEL);
| ^~~~~~~
| vzalloc
drivers/clk/imx/clk-imx8mp-audiomix.c:244:14: warning: assignment to 'struct auxiliary_device *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
244 | adev = kzalloc(sizeof(*adev), GFP_KERNEL);
| ^
cc1: some warnings being treated as errors


vim +235 drivers/clk/imx/clk-imx8mp-audiomix.c

230
231 static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
232 {
233 struct auxiliary_device *adev = to_auxiliary_dev(dev);
234
> 235 kfree(adev);
236 }
237
238 static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
239 struct clk_imx8mp_audiomix_priv *priv)
240 {
241 struct auxiliary_device *adev;
242 int ret;
243
> 244 adev = kzalloc(sizeof(*adev), GFP_KERNEL);
245 if (!adev)
246 return -ENOMEM;
247
248 adev->name = "reset";
249 adev->dev.parent = dev;
250 adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
251
252 ret = auxiliary_device_init(adev);
253 if (ret) {
254 kfree(adev);
255 return ret;
256 }
257
258 ret = auxiliary_device_add(adev);
259 if (ret) {
260 auxiliary_device_uninit(adev);
261 kfree(adev);
262 return ret;
263 }
264
265 return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, adev);
266 }
267

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-05-20 15:45:15

by Frank Li

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller

On Mon, May 20, 2024 at 03:09:20PM +0800, Shengjiu Wang wrote:
> Audiomix block control can be a reset controller for
> Enhanced Audio Return Channel (EARC), which is one of
> modules in this audiomix subsystem.
>
> The reset controller is supported by the auxiliary device
> framework.
>
> Signed-off-by: Shengjiu Wang <[email protected]>
> ---
> drivers/clk/imx/Kconfig | 1 +
> drivers/clk/imx/clk-imx8mp-audiomix.c | 61 +++++++++++++++++++++++++++
> 2 files changed, 62 insertions(+)
>
> diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig
> index 6da0fba68225..9edfb030bea9 100644
> --- a/drivers/clk/imx/Kconfig
> +++ b/drivers/clk/imx/Kconfig
> @@ -81,6 +81,7 @@ config CLK_IMX8MP
> tristate "IMX8MP CCM Clock Driver"
> depends on ARCH_MXC || COMPILE_TEST
> select MXC_CLK
> + select AUXILIARY_BUS
> help
> Build the driver for i.MX8MP CCM Clock Driver
>
> diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
> index b381d6f784c8..d2eaabe431cd 100644
> --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
> +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
> @@ -5,6 +5,7 @@
> * Copyright (C) 2022 Marek Vasut <[email protected]>
> */
>
> +#include <linux/auxiliary_bus.h>
> #include <linux/clk-provider.h>
> #include <linux/device.h>
> #include <linux/io.h>
> @@ -217,6 +218,62 @@ struct clk_imx8mp_audiomix_priv {
> struct clk_hw_onecell_data clk_data;
> };
>
> +#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
> +
> +static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
> +{
> + struct auxiliary_device *adev = _adev;
> +
> + auxiliary_device_delete(adev);
> + auxiliary_device_uninit(adev);
> +}
> +
> +static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
> +{
> + struct auxiliary_device *adev = to_auxiliary_dev(dev);
> +
> + kfree(adev);
> +}
> +
> +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
> + struct clk_imx8mp_audiomix_priv *priv)
> +{
> + struct auxiliary_device *adev;
> + int ret;
> +
> + adev = kzalloc(sizeof(*adev), GFP_KERNEL);


You may use scoped free

struct auxiliary_device *adev __free(kfree) = kzalloc(sizeof(*adev), GFP_KERNEL);

> + if (!adev)
> + return -ENOMEM;
> +
> + adev->name = "reset";
> + adev->dev.parent = dev;
> + adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
> +
> + ret = auxiliary_device_init(adev);
> + if (ret) {
> + kfree(adev);
> + return ret;
> + }

if use scoped free,

if (ret)
return ret;

> +
> + ret = auxiliary_device_add(adev);
> + if (ret) {
> + auxiliary_device_uninit(adev);
> + kfree(adev);
> + return ret;

the same here.

> + }
> +
> + return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, adev);

if use scope free
return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, no_free_ptr(adev));

> +}
> +
> +#else /* !CONFIG_RESET_CONTROLLER */
> +
> +static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv)
> +{
> + return 0;
> +}
> +
> +#endif /* !CONFIG_RESET_CONTROLLER */
> +
> static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
> {
> struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev);
> @@ -337,6 +394,10 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
> if (ret)
> goto err_clk_register;
>
> + ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
> + if (ret)
> + goto err_clk_register;
> +
> pm_runtime_put_sync(dev);
> return 0;
>
> --
> 2.34.1
>

2024-05-20 17:05:00

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller

Hi Shengjiu,

kernel test robot noticed the following build errors:

[auto build test ERROR on abelvesa/clk/imx]
[also build test ERROR on linus/master next-20240520]
[cannot apply to pza/reset/next shawnguo/for-next robh/for-next pza/imx-drm/next v6.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Shengjiu-Wang/dt-bindings-clock-imx8mp-Add-reset-cells-property/20240520-153230
base: https://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux.git clk/imx
patch link: https://lore.kernel.org/r/1716188963-16175-3-git-send-email-shengjiu.wang%40nxp.com
patch subject: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20240521/[email protected]/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project fa9b1be45088dce1e4b602d451f118128b94237b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240521/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/clk/imx/clk-imx8mp-audiomix.c:11:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/clk/imx/clk-imx8mp-audiomix.c:11:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/clk/imx/clk-imx8mp-audiomix.c:11:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
>> drivers/clk/imx/clk-imx8mp-audiomix.c:235:2: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
235 | kfree(adev);
| ^
drivers/clk/imx/clk-imx8mp-audiomix.c:235:2: note: did you mean 'vfree'?
include/linux/vmalloc.h:162:13: note: 'vfree' declared here
162 | extern void vfree(const void *addr);
| ^
>> drivers/clk/imx/clk-imx8mp-audiomix.c:244:9: error: call to undeclared function 'kzalloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
244 | adev = kzalloc(sizeof(*adev), GFP_KERNEL);
| ^
drivers/clk/imx/clk-imx8mp-audiomix.c:244:9: note: did you mean 'vzalloc'?
include/linux/vmalloc.h:142:14: note: 'vzalloc' declared here
142 | extern void *vzalloc(unsigned long size) __alloc_size(1);
| ^
>> drivers/clk/imx/clk-imx8mp-audiomix.c:244:7: error: incompatible integer to pointer conversion assigning to 'struct auxiliary_device *' from 'int' [-Wint-conversion]
244 | adev = kzalloc(sizeof(*adev), GFP_KERNEL);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/imx/clk-imx8mp-audiomix.c:254:3: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
254 | kfree(adev);
| ^
drivers/clk/imx/clk-imx8mp-audiomix.c:261:3: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
261 | kfree(adev);
| ^
6 warnings and 5 errors generated.


vim +/kfree +235 drivers/clk/imx/clk-imx8mp-audiomix.c

230
231 static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
232 {
233 struct auxiliary_device *adev = to_auxiliary_dev(dev);
234
> 235 kfree(adev);
236 }
237
238 static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
239 struct clk_imx8mp_audiomix_priv *priv)
240 {
241 struct auxiliary_device *adev;
242 int ret;
243
> 244 adev = kzalloc(sizeof(*adev), GFP_KERNEL);
245 if (!adev)
246 return -ENOMEM;
247
248 adev->name = "reset";
249 adev->dev.parent = dev;
250 adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
251
252 ret = auxiliary_device_init(adev);
253 if (ret) {
254 kfree(adev);
255 return ret;
256 }
257
258 ret = auxiliary_device_add(adev);
259 if (ret) {
260 auxiliary_device_uninit(adev);
261 kfree(adev);
262 return ret;
263 }
264
265 return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, adev);
266 }
267

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-05-22 02:07:00

by Shengjiu Wang

[permalink] [raw]
Subject: Re: [PATCH v4 2/5] clk: imx: clk-audiomix: Add reset controller

On Mon, May 20, 2024 at 11:44 PM Frank Li <[email protected]> wrote:
>
> On Mon, May 20, 2024 at 03:09:20PM +0800, Shengjiu Wang wrote:
> > Audiomix block control can be a reset controller for
> > Enhanced Audio Return Channel (EARC), which is one of
> > modules in this audiomix subsystem.
> >
> > The reset controller is supported by the auxiliary device
> > framework.
> >
> > Signed-off-by: Shengjiu Wang <[email protected]>
> > ---
> > drivers/clk/imx/Kconfig | 1 +
> > drivers/clk/imx/clk-imx8mp-audiomix.c | 61 +++++++++++++++++++++++++++
> > 2 files changed, 62 insertions(+)
> >
> > diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig
> > index 6da0fba68225..9edfb030bea9 100644
> > --- a/drivers/clk/imx/Kconfig
> > +++ b/drivers/clk/imx/Kconfig
> > @@ -81,6 +81,7 @@ config CLK_IMX8MP
> > tristate "IMX8MP CCM Clock Driver"
> > depends on ARCH_MXC || COMPILE_TEST
> > select MXC_CLK
> > + select AUXILIARY_BUS
> > help
> > Build the driver for i.MX8MP CCM Clock Driver
> >
> > diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
> > index b381d6f784c8..d2eaabe431cd 100644
> > --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
> > +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
> > @@ -5,6 +5,7 @@
> > * Copyright (C) 2022 Marek Vasut <[email protected]>
> > */
> >
> > +#include <linux/auxiliary_bus.h>
> > #include <linux/clk-provider.h>
> > #include <linux/device.h>
> > #include <linux/io.h>
> > @@ -217,6 +218,62 @@ struct clk_imx8mp_audiomix_priv {
> > struct clk_hw_onecell_data clk_data;
> > };
> >
> > +#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
> > +
> > +static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
> > +{
> > + struct auxiliary_device *adev = _adev;
> > +
> > + auxiliary_device_delete(adev);
> > + auxiliary_device_uninit(adev);
> > +}
> > +
> > +static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
> > +{
> > + struct auxiliary_device *adev = to_auxiliary_dev(dev);
> > +
> > + kfree(adev);
> > +}
> > +
> > +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
> > + struct clk_imx8mp_audiomix_priv *priv)
> > +{
> > + struct auxiliary_device *adev;
> > + int ret;
> > +
> > + adev = kzalloc(sizeof(*adev), GFP_KERNEL);
>
>
> You may use scoped free
>
> struct auxiliary_device *adev __free(kfree) = kzalloc(sizeof(*adev), GFP_KERNEL);

Ok, will update the code

best regards
Shengjiu Wang
>
> > + if (!adev)
> > + return -ENOMEM;
> > +
> > + adev->name = "reset";
> > + adev->dev.parent = dev;
> > + adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
> > +
> > + ret = auxiliary_device_init(adev);
> > + if (ret) {
> > + kfree(adev);
> > + return ret;
> > + }
>
> if use scoped free,
>
> if (ret)
> return ret;
>
> > +
> > + ret = auxiliary_device_add(adev);
> > + if (ret) {
> > + auxiliary_device_uninit(adev);
> > + kfree(adev);
> > + return ret;
>
> the same here.
>
> > + }
> > +
> > + return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, adev);
>
> if use scope free
> return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, no_free_ptr(adev));
>
> > +}
> > +
> > +#else /* !CONFIG_RESET_CONTROLLER */
> > +
> > +static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv)
> > +{
> > + return 0;
> > +}
> > +
> > +#endif /* !CONFIG_RESET_CONTROLLER */
> > +
> > static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
> > {
> > struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev);
> > @@ -337,6 +394,10 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
> > if (ret)
> > goto err_clk_register;
> >
> > + ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
> > + if (ret)
> > + goto err_clk_register;
> > +
> > pm_runtime_put_sync(dev);
> > return 0;
> >
> > --
> > 2.34.1
> >