From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/7] reset: Add reset controller API
Date: Wed, 16 Jan 2013 21:15:47 +0100 [thread overview]
Message-ID: <20130116201547.GW1906@pengutronix.de> (raw)
In-Reply-To: <1358352787-15441-3-git-send-email-p.zabel@pengutronix.de>
On Wed, Jan 16, 2013 at 05:13:02PM +0100, Philipp Zabel wrote:
> This adds a simple API for devices to request being reset
> by separate reset controller hardware and implements the
> reset signal device tree binding.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> drivers/Kconfig | 2 +
> drivers/Makefile | 2 +
> drivers/reset/Kconfig | 10 ++
> drivers/reset/Makefile | 2 +
> drivers/reset/core.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 257 insertions(+)
> create mode 100644 drivers/reset/Kconfig
> create mode 100644 drivers/reset/Makefile
> create mode 100644 drivers/reset/core.c
>
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index f5fb072..51f73ae 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -158,4 +158,6 @@ source "drivers/irqchip/Kconfig"
>
> source "drivers/ipack/Kconfig"
>
> +source "drivers/reset/Kconfig"
> +
> endmenu
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 346ecc5..870bf7e 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -42,6 +42,8 @@ ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
> obj-y += clocksource/
> endif
>
> +obj-$(CONFIG_RESET_CONTROLLER) += reset/
> +
> # tty/ comes before char/ so that the VT console is the boot-time
> # default.
> obj-y += tty/
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> new file mode 100644
> index 0000000..82dc89e
> --- /dev/null
> +++ b/drivers/reset/Kconfig
> @@ -0,0 +1,10 @@
> +menuconfig RESET_CONTROLLER
> + bool "Reset Controller Support"
> + help
> + Generic Reset Controller support.
> +
> + This framework is designed to abstract reset handling of devices
> + via GPIOs or SoC-internal reset controller modules.
> +
> + If unsure, say no.
> +
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> new file mode 100644
> index 0000000..9a7b6df
> --- /dev/null
> +++ b/drivers/reset/Makefile
> @@ -0,0 +1,2 @@
> +obj-$(CONFIG_RESET_CONTROLLER) += core.o
> +
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> new file mode 100644
> index 0000000..f0ed61b
> --- /dev/null
> +++ b/drivers/reset/core.c
> @@ -0,0 +1,241 @@
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/export.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/reset.h>
> +#include <linux/reset-controller.h>
> +#include <linux/slab.h>
> +
> +static DEFINE_MUTEX(reset_controller_list_mutex);
> +static LIST_HEAD(reset_controller_list);
> +
> +/**
> + * struct reset_control - a reset control
> + *
> + * @id: ID of the reset controller in the reset
> + * controller device
> + */
> +struct reset_control {
> + struct reset_controller_dev *rcdev;
> + unsigned int id;
> +};
> +
> +/**
> + * reset_controller_register - register a reset controller
> + *
> + * @ops: a pointer to struct reset_controller_ops callbacks
> + *
> + * Returns a struct reset_controller_dev or IS_ERR() condition
> + * containing errno.
The comment seems wrong.
> + */
> +int reset_controller_register(struct reset_controller_dev *rcdev)
> +{
> + mutex_lock(&reset_controller_list_mutex);
> + list_add(&rcdev->list, &reset_controller_list);
> + mutex_unlock(&reset_controller_list_mutex);
> +
> + return 0;
> +}
> +
> +/**
> + * reset_control_reset - reset the controlled device
> + * @rstc: reset controller
> + */
> +int reset_control_reset(struct reset_control *rstc)
> +{
> + if (rstc->rcdev->ops->reset)
> + return rstc->rcdev->ops->reset(rstc->id);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_reset);
> +
> +/**
> + * reset_control_assert - asserts the reset line
> + * @rstc: reset controller
> + */
> +int reset_control_assert(struct reset_control *rstc)
> +{
> + if (rstc->rcdev->ops->assert)
> + return rstc->rcdev->ops->assert(rstc->id);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_assert);
> +
> +/**
> + * reset_control_deassert - deasserts the reset line
> + * @rstc: reset controller
> + */
> +int reset_control_deassert(struct reset_control *rstc)
> +{
> + if (rstc->rcdev->ops->deassert)
> + return rstc->rcdev->ops->deassert(rstc->id);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_deassert);
> +
> +/**
> + * reset_control_is_asserted - deasserts the reset line
copy-paste from the function above?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
WARNING: multiple messages have this Message-ID (diff)
From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>,
Fabio Estevam
<fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
Mike Turquette
<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 2/7] reset: Add reset controller API
Date: Wed, 16 Jan 2013 21:15:47 +0100 [thread overview]
Message-ID: <20130116201547.GW1906@pengutronix.de> (raw)
In-Reply-To: <1358352787-15441-3-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
On Wed, Jan 16, 2013 at 05:13:02PM +0100, Philipp Zabel wrote:
> This adds a simple API for devices to request being reset
> by separate reset controller hardware and implements the
> reset signal device tree binding.
>
> Signed-off-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
> drivers/Kconfig | 2 +
> drivers/Makefile | 2 +
> drivers/reset/Kconfig | 10 ++
> drivers/reset/Makefile | 2 +
> drivers/reset/core.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 257 insertions(+)
> create mode 100644 drivers/reset/Kconfig
> create mode 100644 drivers/reset/Makefile
> create mode 100644 drivers/reset/core.c
>
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index f5fb072..51f73ae 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -158,4 +158,6 @@ source "drivers/irqchip/Kconfig"
>
> source "drivers/ipack/Kconfig"
>
> +source "drivers/reset/Kconfig"
> +
> endmenu
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 346ecc5..870bf7e 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -42,6 +42,8 @@ ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
> obj-y += clocksource/
> endif
>
> +obj-$(CONFIG_RESET_CONTROLLER) += reset/
> +
> # tty/ comes before char/ so that the VT console is the boot-time
> # default.
> obj-y += tty/
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> new file mode 100644
> index 0000000..82dc89e
> --- /dev/null
> +++ b/drivers/reset/Kconfig
> @@ -0,0 +1,10 @@
> +menuconfig RESET_CONTROLLER
> + bool "Reset Controller Support"
> + help
> + Generic Reset Controller support.
> +
> + This framework is designed to abstract reset handling of devices
> + via GPIOs or SoC-internal reset controller modules.
> +
> + If unsure, say no.
> +
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> new file mode 100644
> index 0000000..9a7b6df
> --- /dev/null
> +++ b/drivers/reset/Makefile
> @@ -0,0 +1,2 @@
> +obj-$(CONFIG_RESET_CONTROLLER) += core.o
> +
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> new file mode 100644
> index 0000000..f0ed61b
> --- /dev/null
> +++ b/drivers/reset/core.c
> @@ -0,0 +1,241 @@
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/export.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/reset.h>
> +#include <linux/reset-controller.h>
> +#include <linux/slab.h>
> +
> +static DEFINE_MUTEX(reset_controller_list_mutex);
> +static LIST_HEAD(reset_controller_list);
> +
> +/**
> + * struct reset_control - a reset control
> + *
> + * @id: ID of the reset controller in the reset
> + * controller device
> + */
> +struct reset_control {
> + struct reset_controller_dev *rcdev;
> + unsigned int id;
> +};
> +
> +/**
> + * reset_controller_register - register a reset controller
> + *
> + * @ops: a pointer to struct reset_controller_ops callbacks
> + *
> + * Returns a struct reset_controller_dev or IS_ERR() condition
> + * containing errno.
The comment seems wrong.
> + */
> +int reset_controller_register(struct reset_controller_dev *rcdev)
> +{
> + mutex_lock(&reset_controller_list_mutex);
> + list_add(&rcdev->list, &reset_controller_list);
> + mutex_unlock(&reset_controller_list_mutex);
> +
> + return 0;
> +}
> +
> +/**
> + * reset_control_reset - reset the controlled device
> + * @rstc: reset controller
> + */
> +int reset_control_reset(struct reset_control *rstc)
> +{
> + if (rstc->rcdev->ops->reset)
> + return rstc->rcdev->ops->reset(rstc->id);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_reset);
> +
> +/**
> + * reset_control_assert - asserts the reset line
> + * @rstc: reset controller
> + */
> +int reset_control_assert(struct reset_control *rstc)
> +{
> + if (rstc->rcdev->ops->assert)
> + return rstc->rcdev->ops->assert(rstc->id);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_assert);
> +
> +/**
> + * reset_control_deassert - deasserts the reset line
> + * @rstc: reset controller
> + */
> +int reset_control_deassert(struct reset_control *rstc)
> +{
> + if (rstc->rcdev->ops->deassert)
> + return rstc->rcdev->ops->deassert(rstc->id);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_deassert);
> +
> +/**
> + * reset_control_is_asserted - deasserts the reset line
copy-paste from the function above?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2013-01-16 20:15 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 16:13 [RFC PATCH 0/5] Reset controller API to reset IP modules on i.MX5 and i.MX6 Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-16 16:13 ` [PATCH 1/7] dt: describe base reset signal binding Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-16 22:06 ` Stephen Warren
2013-01-16 22:06 ` Stephen Warren
2013-01-16 16:13 ` [PATCH 2/7] reset: Add reset controller API Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-16 20:15 ` Sascha Hauer [this message]
2013-01-16 20:15 ` Sascha Hauer
2013-01-16 22:15 ` Stephen Warren
2013-01-16 22:15 ` Stephen Warren
2013-01-17 10:45 ` Philipp Zabel
2013-01-17 10:45 ` Philipp Zabel
2013-01-17 16:55 ` Stephen Warren
2013-01-17 16:55 ` Stephen Warren
2013-01-17 5:16 ` Shawn Guo
2013-01-17 5:16 ` Shawn Guo
2013-01-16 16:13 ` [PATCH 3/7] ARM i.MX6q: Add GPU, VPU, IPU, and OpenVG resets to System Reset Controller (SRC) Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-17 5:31 ` Shawn Guo
2013-01-17 5:31 ` Shawn Guo
2013-01-18 19:57 ` Matt Sealey
2013-01-18 19:57 ` Matt Sealey
2013-01-21 9:52 ` Philipp Zabel
2013-01-21 9:52 ` Philipp Zabel
2013-01-21 17:47 ` Matt Sealey
2013-01-21 17:47 ` Matt Sealey
2013-01-22 7:50 ` Shawn Guo
2013-01-22 7:50 ` Shawn Guo
2013-01-16 16:13 ` [PATCH 4/7] ARM i.MX6q: Link system reset controller (SRC) to IPU in DT Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-17 5:34 ` Shawn Guo
2013-01-17 5:34 ` Shawn Guo
2013-01-16 16:13 ` [PATCH 5/7] staging: drm/imx: Use SRC to reset IPU Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-16 16:13 ` [PATCH 6/7] ARM i.MX5: Add System Reset Controller (SRC) support for i.MX51 and i.MX53 Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-17 6:12 ` Shawn Guo
2013-01-17 6:12 ` Shawn Guo
2013-01-17 10:45 ` Philipp Zabel
2013-01-17 10:45 ` Philipp Zabel
2013-01-16 16:13 ` [PATCH 7/7] ARM i.MX5: Add system reset controller (SRC) to i.MX51 and i.MX53 device tree Philipp Zabel
2013-01-16 16:13 ` Philipp Zabel
2013-01-16 22:19 ` Stephen Warren
2013-01-16 22:19 ` Stephen Warren
2013-01-17 6:37 ` Shawn Guo
2013-01-17 6:37 ` Shawn Guo
2013-01-17 10:45 ` Philipp Zabel
2013-01-17 10:45 ` Philipp Zabel
2013-01-16 18:46 ` [RFC PATCH 0/5] Reset controller API to reset IP modules on i.MX5 and i.MX6 Marek Vasut
2013-01-16 18:46 ` Marek Vasut
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=20130116201547.GW1906@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.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.