linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Dilip Kota <eswara.kota@linux.intel.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: robh@kernel.org, martin.blumenstingl@googlemail.com,
	cheol.yong.kim@intel.com, chuanhua.lei@linux.intel.com,
	qi-ming.wu@intel.com
Subject: Re: [PATCH v5 2/2] reset: intel: Add system reset controller driver
Date: Thu, 02 Jan 2020 12:43:11 +0100	[thread overview]
Message-ID: <fe55d2c00eda2d1b94e69fe2df05114ba88b5128.camel@pengutronix.de> (raw)
In-Reply-To: <decb025c9bd0ddc1da96801e57242bc8f5ce35d0.1576202050.git.eswara.kota@linux.intel.com>

On Mon, 2019-12-16 at 14:55 +0800, Dilip Kota wrote:
> Add driver for the reset controller present on Intel
> Gateway SoCs for performing reset management of the
> devices present on the SoC. Driver also registers a
> reset handler to peform the entire device reset.
> 
> Signed-off-by: Dilip Kota <eswara.kota@linux.intel.com>
> ---
> Changes on v5:
> 	Rebase patches on v5.5-rc1 kernel
> 
> Changes on v4:
> 	No Change
> 
> Changes on v3:
> 	Address review comments:
> 		Remove intel_reset_device() as not supported
> 	reset-intel-syscon.c renamed to reset-intel-gw.c
> 	Remove syscon and add regmap logic
> 	Add support to legacy xrx200 SoC
> 	Use bitfield helper functions for bit operations.
> 	Change config RESET_INTEL_SYSCON-> RESET_INTEL_GW
>  drivers/reset/Kconfig          |   9 ++
>  drivers/reset/Makefile         |   1 +
>  drivers/reset/reset-intel-gw.c | 262 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 272 insertions(+)
>  create mode 100644 drivers/reset/reset-intel-gw.c
> 
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index 3ad7817ce1f0..218571cda38d 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -64,6 +64,15 @@ config RESET_IMX7
>  	help
>  	  This enables the reset controller driver for i.MX7 SoCs.
>  
> +config RESET_INTEL_GW
> +	bool "Intel Reset Controller Driver"
> +	depends on OF
> +	select REGMAP_MMIO
> +	help
> +	  This enables the reset controller driver for Intel Gateway SoCs.
> +	  Say Y to control the reset signals provided by reset controller.
> +	  Otherwise, say N.
> +
>  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 cf60ce526064..a196d545b4b8 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -10,6 +10,7 @@ obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
>  obj-$(CONFIG_RESET_BRCMSTB) += reset-brcmstb.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_LANTIQ) += reset-lantiq.o
>  obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
>  obj-$(CONFIG_RESET_MESON) += reset-meson.o
> diff --git a/drivers/reset/reset-intel-gw.c b/drivers/reset/reset-intel-gw.c
> new file mode 100644
> index 000000000000..da285833cd22
> --- /dev/null
> +++ b/drivers/reset/reset-intel-gw.c
> @@ -0,0 +1,262 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2019 Intel Corporation.
> + * Lei Chuanhua <Chuanhua.lei@intel.com>
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/init.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/reboot.h>
> +#include <linux/regmap.h>
> +#include <linux/reset-controller.h>
> +
> +#define RCU_RST_STAT	0x0024
> +#define RCU_RST_REQ	0x0048
> +
> +#define REG_OFFSET	GENMASK(31, 16)
> +#define BIT_OFFSET	GENMASK(15, 8)
> +#define STAT_BIT_OFFSET	GENMASK(7, 0)
> +
> +#define to_reset_data(x)	container_of(x, struct intel_reset_data, rcdev)
> +
> +struct intel_reset_soc {
> +	bool legacy;
> +	u32 reset_cell_count;
> +};
> +
> +struct intel_reset_data {
> +	struct reset_controller_dev rcdev;
> +	struct notifier_block restart_nb;
> +	const struct intel_reset_soc *soc_data;
> +	struct regmap *regmap;
> +	struct device *dev;
> +	u32 reboot_id;
> +};
> +
> +static const struct regmap_config intel_rcu_regmap_config = {
> +	.name =		"intel-reset",
> +	.reg_bits =	32,
> +	.reg_stride =	4,
> +	.val_bits =	32,
> +	.fast_io =	true,
> +};
> +
> +/*
> + * Reset status register offset relative to
> + * the reset control register(X) is X + 4
> + */
> +static u32 id_to_reg_and_bit_offsets(struct intel_reset_data *data,
> +				     unsigned long id, u32 *rst_req,
> +				     u32 *req_bit, u32 *stat_bit)
> +{
> +	*rst_req = FIELD_GET(REG_OFFSET, id);
> +	*req_bit = FIELD_GET(BIT_OFFSET, id);
> +
> +	if (data->soc_data->legacy)
> +		*stat_bit = FIELD_GET(STAT_BIT_OFFSET, id);
> +	else
> +		*stat_bit = *req_bit;
> +
> +	if (data->soc_data->legacy && *rst_req == RCU_RST_REQ)
> +		return RCU_RST_STAT;
> +	else
> +		return *rst_req + 0x4;
> +}
> +
> +static int intel_set_clr_bits(struct intel_reset_data *data,
> +			      unsigned long id, bool set, u64 timeout)
> +{
> +	u32 rst_req, req_bit, rst_stat, stat_bit, val;
> +	int ret;
> +
> +	rst_stat = id_to_reg_and_bit_offsets(data, id, &rst_req,
> +					     &req_bit, &stat_bit);
> +
> +	val = set ? BIT(req_bit) : 0;
> +	ret = regmap_update_bits(data->regmap, rst_req,  BIT(req_bit), val);
> +	if (ret)
> +		return ret;
> +
> +	return regmap_read_poll_timeout(data->regmap, rst_stat, val,
> +					set == !!(val & BIT(stat_bit)),
> +					20, timeout);
> +}
> +
> +static int intel_assert_device(struct reset_controller_dev *rcdev,
> +			       unsigned long id)
> +{
> +	struct intel_reset_data *data = to_reset_data(rcdev);
> +	int ret;
> +
> +	ret = intel_set_clr_bits(data, id, true, 200);

timeout doesn't have to be a parameter to intel_set_clr_bits.

[...]
> +struct intel_reset_soc xrx200_data = {
> +	.legacy =		true,
> +	.reset_cell_count =	3,
> +};
> +
> +struct intel_reset_soc lgm_data = {
> +	.legacy =		false,
> +	.reset_cell_count =	2,
> +};

Please make these two static const, otherwise this looks fine to me.

regards
Philipp


  reply	other threads:[~2020-01-02 11:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16  6:55 [PATCH v5 1/2] dt-bindings: reset: Add YAML schemas for the Intel Reset controller Dilip Kota
2019-12-16  6:55 ` [PATCH v5 2/2] reset: intel: Add system reset controller driver Dilip Kota
2020-01-02 11:43   ` Philipp Zabel [this message]
2020-01-03  3:54     ` Dilip Kota

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=fe55d2c00eda2d1b94e69fe2df05114ba88b5128.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=cheol.yong.kim@intel.com \
    --cc=chuanhua.lei@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eswara.kota@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=qi-ming.wu@intel.com \
    --cc=robh@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).