All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Marco Felsch <m.felsch@pengutronix.de>,
	p.zabel@pengutronix.de, robh+dt@kernel.org, krzk+dt@kernel.org
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH 2/2] reset: tps380x: Add TPS380x device driver supprt
Date: Thu, 26 May 2022 21:54:41 +0200	[thread overview]
Message-ID: <597de13b-28c8-3341-be11-da51e22304c3@linaro.org> (raw)
In-Reply-To: <20220525142019.3615253-2-m.felsch@pengutronix.de>

On 25/05/2022 16:20, Marco Felsch wrote:
> The TI TPS380x family [1] is a volatage supervisor with a dedicated
> manual reset (mr) line input and a reset output. The chip(s) have a
> build in reset delay, depending on the chip partnumber. This simple
> driver addresses this so the cosumer don't need to care about it.
> 
> [1] https://www.ti.com/product/TPS3801
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  drivers/reset/Kconfig         |   8 +++
>  drivers/reset/Makefile        |   1 +
>  drivers/reset/reset-tps380x.c | 130 ++++++++++++++++++++++++++++++++++
>  3 files changed, 139 insertions(+)
>  create mode 100644 drivers/reset/reset-tps380x.c
> 
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index e0fc80e041ea..e2eb616af812 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -256,6 +256,14 @@ config RESET_TI_SYSCON
>  	  you wish to use the reset framework for such memory-mapped devices,
>  	  say Y here. Otherwise, say N.
>  
> +config RESET_TI_TPS380X
> +	tristate "TI TPS380x Reset Driver"
> +	select GPIOLIB
> +	help
> +	  This enables the reset driver support for TI TPS380x devices. If
> +	  you wish to use the reset framework for such devices, say Y here.
> +	  Otherwise, say N.
> +
>  config RESET_TN48M_CPLD
>  	tristate "Delta Networks TN48M switch CPLD reset controller"
>  	depends on MFD_TN48M_CPLD || COMPILE_TEST
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index a80a9c4008a7..66399b92b1bb 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -33,6 +33,7 @@ obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o
>  obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
>  obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o
>  obj-$(CONFIG_RESET_TI_SYSCON) += reset-ti-syscon.o
> +obj-$(CONFIG_RESET_TI_TPS380X) += reset-tps380x.o
>  obj-$(CONFIG_RESET_TN48M_CPLD) += reset-tn48m.o
>  obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
>  obj-$(CONFIG_RESET_UNIPHIER_GLUE) += reset-uniphier-glue.o
> diff --git a/drivers/reset/reset-tps380x.c b/drivers/reset/reset-tps380x.c
> new file mode 100644
> index 000000000000..fd2c0929ae2d
> --- /dev/null
> +++ b/drivers/reset/reset-tps380x.c
> @@ -0,0 +1,130 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * TI TPS380x Supply Voltage Supervisor and Reset Controller Driver
> + *
> + * Copyright (C) 2022 Pengutronix, Marco Felsch <kernel@pengutronix.de>
> + *
> + * Based on Simple Reset Controller Driver
> + *
> + * Copyright (C) 2017 Pengutronix, Philipp Zabel <kernel@pengutronix.de>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/reset-controller.h>
> +
> +struct tps380x_reset {
> +	struct reset_controller_dev	rcdev;
> +	struct gpio_desc		*reset_gpio;
> +	unsigned int			reset_ms;
> +};
> +
> +struct tps380x_reset_devdata {
> +	unsigned int min_reset_ms;
> +	unsigned int typ_reset_ms;
> +	unsigned int max_reset_ms;
> +};
> +
> +static inline
> +struct tps380x_reset *to_tps380x_reset(struct reset_controller_dev *rcdev)
> +{
> +	return container_of(rcdev, struct tps380x_reset, rcdev);
> +}
> +
> +static int
> +tps380x_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
> +{
> +	struct tps380x_reset *tps380x = to_tps380x_reset(rcdev);
> +
> +	gpiod_set_value_cansleep(tps380x->reset_gpio, 1);
> +
> +	return 0;
> +}
> +
> +static int
> +tps380x_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
> +{
> +	struct tps380x_reset *tps380x = to_tps380x_reset(rcdev);
> +
> +	gpiod_set_value_cansleep(tps380x->reset_gpio, 0);
> +	msleep(tps380x->reset_ms);
> +
> +	return 0;
> +}
> +
> +const struct reset_control_ops reset_tps380x_ops = {

This looks static.


Best regards,
Krzysztof

  reply	other threads:[~2022-05-26 19:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 14:20 [PATCH 1/2] dt-bindings: reset: Add TPS380x documentation Marco Felsch
2022-05-25 14:20 ` [PATCH 2/2] reset: tps380x: Add TPS380x device driver supprt Marco Felsch
2022-05-26 19:54   ` Krzysztof Kozlowski [this message]
2022-05-30  7:00     ` Marco Felsch
2022-05-26 19:53 ` [PATCH 1/2] dt-bindings: reset: Add TPS380x documentation Krzysztof Kozlowski

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=597de13b-28c8-3341-be11-da51e22304c3@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.