linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Abel Vesa <abel.vesa@nxp.com>, Lee Jones <lee.jones@linaro.org>,
	Shawn Guo <shawnguo@kernel.org>, Peng Fan <peng.fan@nxp.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Sascha Hauer <kernel@pengutronix.de>,
	Anson Huang <anson.huang@nxp.com>,
	Leonard Crestez <leonard.crestez@nxp.com>,
	Jacky Bai <ping.bai@nxp.com>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	NXP Linux Team <linux-imx@nxp.com>,
	linux-arm-kernel@lists.infradead.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 12/13] reset: imx: Add audiomix reset controller support
Date: Thu, 23 Apr 2020 17:47:33 +0200	[thread overview]
Message-ID: <a32ab342e7e4928ec252815ab0023f81bb182b32.camel@pengutronix.de> (raw)
In-Reply-To: <1586937773-5836-13-git-send-email-abel.vesa@nxp.com>

Hi Abel,

On Wed, 2020-04-15 at 11:02 +0300, Abel Vesa wrote:
> The imx-mix MFD driver registers some devices, one of which, in case of
> audiomix, maps correctly to a reset controller type. This driver registers
> a reset controller for that. For now, only the EARC specific resets are added.
> 
> Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
> ---
>  drivers/reset/Kconfig              |   7 +++
>  drivers/reset/Makefile             |   1 +
>  drivers/reset/reset-imx-audiomix.c | 117 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 125 insertions(+)
>  create mode 100644 drivers/reset/reset-imx-audiomix.c
> 
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index d9efbfd..2f8d9b3 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -81,6 +81,13 @@ config RESET_INTEL_GW
>  	  Say Y to control the reset signals provided by reset controller.
>  	  Otherwise, say N.
>  
> +config RESET_IMX_AUDIOMIX
> +	bool "i.MX Audiomix Reset Driver" if COMPILE_TEST
> +	depends on HAS_IOMEM
> +	default ARCH_MXC
> +	help
> +	  This enables the audiomix reset controller driver for i.MX SoCs.
> +
>  config RESET_LANTIQ
>  	bool "Lantiq XWAY Reset Driver" if COMPILE_TEST
>  	default SOC_TYPE_XWAY
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index 249ed35..cf23d38 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -12,6 +12,7 @@ obj-$(CONFIG_RESET_BRCMSTB_RESCAL) += reset-brcmstb-rescal.o
>  obj-$(CONFIG_RESET_HSDK) += reset-hsdk.o
>  obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
>  obj-$(CONFIG_RESET_INTEL_GW) += reset-intel-gw.o
> +obj-$(CONFIG_RESET_IMX_AUDIOMIX) += reset-imx-audiomix.o
>  obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o
>  obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
>  obj-$(CONFIG_RESET_MESON) += reset-meson.o
> diff --git a/drivers/reset/reset-imx-audiomix.c b/drivers/reset/reset-imx-audiomix.c
> new file mode 100644
> index 00000000..9533e41
> --- /dev/null
> +++ b/drivers/reset/reset-imx-audiomix.c
> @@ -0,0 +1,117 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright 2019 NXP.
> + */
> +
> +#include <dt-bindings/reset/imx-audiomix-reset.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/platform_device.h>
> +#include <linux/reset-controller.h>
> +
> +#define IMX_AUDIOMIX_EARC_CTRL_REG	0x200
> +
> +#define IMX_AUDIOMIX_EARC_RESET_BIT	0x0
> +#define IMX_AUDIOMIX_EARC_PHY_RESET_BIT	0x1
> +
> +struct imx_audiomix_reset_data {
> +	void __iomem *base;
> +	struct reset_controller_dev rcdev;
> +	spinlock_t lock;
> +};
> +
> +static int imx_audiomix_reset_set(struct reset_controller_dev *rcdev,
> +			  unsigned long id, bool assert)
> +{
> +	struct imx_audiomix_reset_data *drvdata = container_of(rcdev,
> +			struct imx_audiomix_reset_data, rcdev);
> +	void __iomem *reg_addr = drvdata->base;
> +	unsigned long flags;
> +	unsigned int offset;
> +	u32 reg;
> +
> +	switch (id) {
> +	case IMX_AUDIOMIX_EARC_PHY_RESET:
> +		reg_addr += IMX_AUDIOMIX_EARC_CTRL_REG;
> +		offset = IMX_AUDIOMIX_EARC_PHY_RESET_BIT;
> +		break;
> +	case IMX_AUDIOMIX_EARC_RESET:
> +		reg_addr += IMX_AUDIOMIX_EARC_CTRL_REG;
> +		offset = IMX_AUDIOMIX_EARC_RESET_BIT;
> +		break;

This switch is not necessary. Since reg_addr is the same for both bits,
you can just set it directly, once. And since (IMX_AUDIOMIX_EARC_RESET
== IMX_AUDIOMIX_EARC_RESET_BIT) and (IMX_AUDIOMIX_EARC_PHY_RESET ==
IMX_AUDIOMIX_EARC_PHY_RESET_BIT), you can just use BIT(id) instead of
BIT(offset) below.

> +	default:
> +		return -EINVAL;

This is already catched by the core, which doesn't allow
(id >= rcdev->nr_resets).

> +	}
> +
> +	if (assert) {
> +		spin_lock_irqsave(&drvdata->lock, flags);
> +		reg = readl(reg_addr);
> +		writel(reg & ~BIT(offset), reg_addr);
> +		spin_unlock_irqrestore(&drvdata->lock, flags);
> +	} else {
> +		spin_lock_irqsave(&drvdata->lock, flags);
> +		reg = readl(reg_addr);
> +		writel(reg | BIT(offset), reg_addr);
> +		spin_unlock_irqrestore(&drvdata->lock, flags);
> +	}

regards
Philipp

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-04-23 15:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  8:02 [PATCH v3 00/13] Add generic MFD i.MX mix and audiomix support Abel Vesa
2020-04-15  8:02 ` [PATCH v3 01/13] mfd: Add i.MX generic mix support Abel Vesa
2020-04-17  8:07   ` Lee Jones
2020-04-22  9:18     ` Abel Vesa
2020-04-23 15:21       ` Aisheng Dong
2020-04-24  6:27         ` Lee Jones
2020-04-30 10:03           ` Abel Vesa
2020-04-30 10:22             ` Aisheng Dong
2020-04-30 11:13               ` Abel Vesa
2020-04-15  8:02 ` [PATCH v3 02/13] Documentation: mfd: Add DT bindings for i.MX Mix Abel Vesa
2020-04-16 11:11   ` Arnd Bergmann
2020-04-15  8:02 ` [PATCH v3 03/13] arm64: dts: imx8mp: Add AIPS 4 and 5 Abel Vesa
2020-04-15  8:02 ` [PATCH v3 04/13] arm64: dts: imx8mp: Add audiomix node Abel Vesa
2020-04-15  8:02 ` [PATCH v3 05/13] clk: imx: gate2: Allow single bit gating clock Abel Vesa
2020-04-22 18:35   ` Stephen Boyd
2020-04-29  2:00   ` Shawn Guo
2020-04-15  8:02 ` [PATCH v3 06/13] clk: imx: pll14xx: Add the device as argument when registering Abel Vesa
2020-04-29  2:00   ` Shawn Guo
2020-04-15  8:02 ` [PATCH v3 07/13] clk: imx: Add helpers for passing the device as argument Abel Vesa
2020-04-29  2:01   ` Shawn Guo
2020-04-15  8:02 ` [PATCH v3 08/13] dt-bindings: clocks: imx8mp: Add ids for audiomix clocks Abel Vesa
2020-04-29  2:16   ` Shawn Guo
2020-04-15  8:02 ` [PATCH v3 09/13] clk: imx: Add audiomix clock controller support Abel Vesa
2020-04-22 18:38   ` Stephen Boyd
2020-04-15  8:02 ` [PATCH v3 10/13] arm64: dts: imx8mp: Add audiomix clock controller node Abel Vesa
2020-04-15  8:02 ` [PATCH v3 11/13] dt-bindings: reset: imx8mp: Add ids for audiomix reset Abel Vesa
2020-04-16 11:10   ` Arnd Bergmann
2020-04-15  8:02 ` [PATCH v3 12/13] reset: imx: Add audiomix reset controller support Abel Vesa
2020-04-23 15:47   ` Philipp Zabel [this message]
2020-04-15  8:02 ` [PATCH v3 13/13] arm64: dts: imx8mp: Add audiomix reset controller node Abel Vesa

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=a32ab342e7e4928ec252815ab0023f81bb182b32.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=abel.vesa@nxp.com \
    --cc=anson.huang@nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=lee.jones@linaro.org \
    --cc=leonard.crestez@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=ping.bai@nxp.com \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).