linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] reset: Add a Gemini reset controller
@ 2017-04-24 19:28 Linus Walleij
  2017-04-25  8:43 ` Philipp Zabel
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2017-04-24 19:28 UTC (permalink / raw)
  To: linux-arm-kernel

The Cortina Systems Gemini reset controller is a simple
32bit register with self-deasserting reset lines. It is
accessed using regmap over syscon.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/reset/Kconfig        |   7 +++
 drivers/reset/Makefile       |   1 +
 drivers/reset/reset-gemini.c | 112 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+)
 create mode 100644 drivers/reset/reset-gemini.c

diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index f4cdfe94b9ec..a82e1a78de25 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -27,6 +27,13 @@ config RESET_BERLIN
 	help
 	  This enables the reset controller driver for Marvell Berlin SoCs.
 
+config RESET_GEMINI
+	bool "Gemini Reset Driver" if COMPILE_TEST
+	default ARCH_GEMINI
+	select MFD_SYSCON
+	help
+	  This enables the reset controller driver for Cortina Systems Gemini.
+
 config RESET_LPC18XX
 	bool "LPC18xx/43xx Reset Driver" if COMPILE_TEST
 	default ARCH_LPC18XX
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 2cd3f6c45165..99e90ad18545 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_ARCH_STI) += sti/
 obj-$(CONFIG_ARCH_TEGRA) += tegra/
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_RESET_GEMINI) += reset-gemini.o
 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
diff --git a/drivers/reset/reset-gemini.c b/drivers/reset/reset-gemini.c
new file mode 100644
index 000000000000..481facbb2709
--- /dev/null
+++ b/drivers/reset/reset-gemini.c
@@ -0,0 +1,112 @@
+/*
+ * Cortina Gemini Reset controller driver
+ * Copyright (c) 2017 Linus Walleij <linus.walleij@linaro.org>
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+
+/**
+ * struct gemini_reset - gemini reset controller
+ * @map: regmap to access the containing system controller
+ * @dev: pointer back to device
+ * @rcdev: reset controller device
+ */
+struct gemini_reset {
+	struct regmap *map;
+	struct device *dev;
+	struct reset_controller_dev rcdev;
+};
+
+#define GEMINI_GLOBAL_SOFT_RESET 0x0c
+
+#define to_gemini_reset(p) \
+	container_of((p), struct gemini_reset, rcdev)
+
+/*
+ * This is a self-deasserting reset controller.
+ */
+static int gemini_reset(struct reset_controller_dev *rcdev,
+			unsigned long id)
+{
+	struct gemini_reset *gr = to_gemini_reset(rcdev);
+
+	/* Manual says to always set BIT 30 to 1 */
+	return regmap_write(gr->map,
+			    GEMINI_GLOBAL_SOFT_RESET,
+			    BIT(30) | BIT(id));
+}
+
+static int gemini_reset_status(struct reset_controller_dev *rcdev,
+			     unsigned long id)
+{
+	struct gemini_reset *gr = to_gemini_reset(rcdev);
+	u32 val;
+	int ret;
+
+	ret = regmap_read(gr->map, GEMINI_GLOBAL_SOFT_RESET, &val);
+	if (ret)
+		return ret;
+
+	return !!(val & BIT(id));
+}
+
+static const struct reset_control_ops gemini_reset_ops = {
+	.reset = gemini_reset,
+	.status = gemini_reset_status,
+};
+
+static int gemini_reset_probe(struct platform_device *pdev)
+{
+	struct gemini_reset *gr;
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *parent_np = np->parent;
+	int ret;
+
+	if (!parent_np) {
+		dev_err(dev, "missing parent node\n");
+		return -ENODEV;
+	}
+
+	gr = devm_kzalloc(dev, sizeof(*gr), GFP_KERNEL);
+	if (!gr)
+		return -ENOMEM;
+
+	gr->dev = dev;
+	gr->map = syscon_node_to_regmap(parent_np);
+	if (IS_ERR(gr->map)) {
+		dev_err(dev, "unable to get regmap");
+		return PTR_ERR(gr->map);
+	}
+	gr->rcdev.owner = THIS_MODULE;
+	gr->rcdev.nr_resets = 32;
+	gr->rcdev.ops = &gemini_reset_ops;
+	gr->rcdev.of_node = pdev->dev.of_node;
+
+	ret = devm_reset_controller_register(&pdev->dev, &gr->rcdev);
+	if (ret)
+		return ret;
+
+	dev_info(dev, "registered Gemini reset controller\n");
+	return 0;
+}
+
+static const struct of_device_id gemini_reset_dt_ids[] = {
+	{ .compatible = "cortina,gemini-reset", },
+	{ /* sentinel */ },
+};
+
+static struct platform_driver gemini_reset_driver = {
+	.probe	= gemini_reset_probe,
+	.driver = {
+		.name		= "gemini-reset",
+		.of_match_table	= gemini_reset_dt_ids,
+	},
+};
+builtin_platform_driver(gemini_reset_driver);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] reset: Add a Gemini reset controller
  2017-04-24 19:28 [PATCH 2/2] reset: Add a Gemini reset controller Linus Walleij
@ 2017-04-25  8:43 ` Philipp Zabel
  2017-05-07 19:23   ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Zabel @ 2017-04-25  8:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Linus,

thank you for the patch. A few comments and questions below:

On Mon, 2017-04-24 at 21:28 +0200, Linus Walleij wrote:
> The Cortina Systems Gemini reset controller is a simple
> 32bit register with self-deasserting reset lines. It is
> accessed using regmap over syscon.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/reset/Kconfig        |   7 +++
>  drivers/reset/Makefile       |   1 +
>  drivers/reset/reset-gemini.c | 112 +++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 120 insertions(+)
>  create mode 100644 drivers/reset/reset-gemini.c
> 
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index f4cdfe94b9ec..a82e1a78de25 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -27,6 +27,13 @@ config RESET_BERLIN
>  	help
>  	  This enables the reset controller driver for Marvell Berlin SoCs.
>  
> +config RESET_GEMINI
> +	bool "Gemini Reset Driver" if COMPILE_TEST
> +	default ARCH_GEMINI
> +	select MFD_SYSCON
> +	help
> +	  This enables the reset controller driver for Cortina Systems Gemini.
> +
>  config RESET_LPC18XX
>  	bool "LPC18xx/43xx Reset Driver" if COMPILE_TEST
>  	default ARCH_LPC18XX
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index 2cd3f6c45165..99e90ad18545 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -4,6 +4,7 @@ obj-$(CONFIG_ARCH_STI) += sti/
>  obj-$(CONFIG_ARCH_TEGRA) += tegra/
>  obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
>  obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
> +obj-$(CONFIG_RESET_GEMINI) += reset-gemini.o
>  obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
>  obj-$(CONFIG_RESET_MESON) += reset-meson.o
>  obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
> diff --git a/drivers/reset/reset-gemini.c b/drivers/reset/reset-gemini.c
> new file mode 100644
> index 000000000000..481facbb2709
> --- /dev/null
> +++ b/drivers/reset/reset-gemini.c
> @@ -0,0 +1,112 @@
> +/*
> + * Cortina Gemini Reset controller driver
> + * Copyright (c) 2017 Linus Walleij <linus.walleij@linaro.org>

No license statement, choice or oversight?

> + */
> +
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/regmap.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/reset-controller.h>
> +
> +/**
> + * struct gemini_reset - gemini reset controller
> + * @map: regmap to access the containing system controller
> + * @dev: pointer back to device
> + * @rcdev: reset controller device
> + */
> +struct gemini_reset {
> +	struct regmap *map;
> +	struct device *dev;

dev is unused, can be dropped.

> +	struct reset_controller_dev rcdev;
> +};
> +
> +#define GEMINI_GLOBAL_SOFT_RESET 0x0c
> +
> +#define to_gemini_reset(p) \
> +	container_of((p), struct gemini_reset, rcdev)
> +
> +/*
> + * This is a self-deasserting reset controller.
> + */
> +static int gemini_reset(struct reset_controller_dev *rcdev,
> +			unsigned long id)
> +{
> +	struct gemini_reset *gr = to_gemini_reset(rcdev);
> +
> +	/* Manual says to always set BIT 30 to 1 */
> +	return regmap_write(gr->map,
> +			    GEMINI_GLOBAL_SOFT_RESET,
> +			    BIT(30) | BIT(id));

BIT(30) is called CPU1 reset in the DT binding, maybe add a #define?

> +}
> +
> +static int gemini_reset_status(struct reset_controller_dev *rcdev,
> +			     unsigned long id)
> +{
> +	struct gemini_reset *gr = to_gemini_reset(rcdev);
> +	u32 val;
> +	int ret;
> +
> +	ret = regmap_read(gr->map, GEMINI_GLOBAL_SOFT_RESET, &val);
> +	if (ret)
> +		return ret;
> +
> +	return !!(val & BIT(id));
> +}
> +
> +static const struct reset_control_ops gemini_reset_ops = {
> +	.reset = gemini_reset,
> +	.status = gemini_reset_status,
> +};
> +
> +static int gemini_reset_probe(struct platform_device *pdev)
> +{
> +	struct gemini_reset *gr;
> +	struct device *dev = &pdev->dev;
> +	struct device_node *np = dev->of_node;
> +	struct device_node *parent_np = np->parent;
> +	int ret;
> +
> +	if (!parent_np) {

Is this even possible?

> +		dev_err(dev, "missing parent node\n");
> +		return -ENODEV;
> +	}
>+
> +	gr = devm_kzalloc(dev, sizeof(*gr), GFP_KERNEL);
> +	if (!gr)
> +		return -ENOMEM;
> +
> +	gr->dev = dev;

Can be dropped.

> +	gr->map = syscon_node_to_regmap(parent_np);
> +	if (IS_ERR(gr->map)) {
> +		dev_err(dev, "unable to get regmap");

It might be helpful to print the error code here.

> +		return PTR_ERR(gr->map);
> +	}
> +	gr->rcdev.owner = THIS_MODULE;
> +	gr->rcdev.nr_resets = 32;
> +	gr->rcdev.ops = &gemini_reset_ops;
> +	gr->rcdev.of_node = pdev->dev.of_node;
> +
> +	ret = devm_reset_controller_register(&pdev->dev, &gr->rcdev);
> +	if (ret)
> +		return ret;
> +
> +	dev_info(dev, "registered Gemini reset controller\n");

This is a bit verbose. I'd remove it and shorten the last part to:

	return devm_reset_controller_register(&pdev->dev, &gr->rcdev);

> +	return 0;
> +}
> +
> +static const struct of_device_id gemini_reset_dt_ids[] = {
> +	{ .compatible = "cortina,gemini-reset", },
> +	{ /* sentinel */ },
> +};
> +
> +static struct platform_driver gemini_reset_driver = {
> +	.probe	= gemini_reset_probe,
> +	.driver = {
> +		.name		= "gemini-reset",
> +		.of_match_table	= gemini_reset_dt_ids,
> +	},
> +};
> +builtin_platform_driver(gemini_reset_driver);

regards
Philipp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] reset: Add a Gemini reset controller
  2017-04-25  8:43 ` Philipp Zabel
@ 2017-05-07 19:23   ` Linus Walleij
  2017-05-08  7:01     ` Philipp Zabel
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2017-05-07 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 25, 2017 at 10:43 AM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> [Me]
>> +/*
>> + * Cortina Gemini Reset controller driver
>> + * Copyright (c) 2017 Linus Walleij <linus.walleij@linaro.org>
>
> No license statement, choice or oversight?

Choice. I'm one of those guys who think that the top-level COPYING file
in the kernel is by far enough of legalese. If you want, I can put in a license
of course.

>> +struct gemini_reset {
>> +     struct regmap *map;
>> +     struct device *dev;
>
> dev is unused, can be dropped.

OK

> BIT(30) is called CPU1 reset in the DT binding, maybe add a #define?

OK I have the new .h file that Rob asked for.

>> +static int gemini_reset_probe(struct platform_device *pdev)
>> +{
>> +     struct gemini_reset *gr;
>> +     struct device *dev = &pdev->dev;
>> +     struct device_node *np = dev->of_node;
>> +     struct device_node *parent_np = np->parent;
>> +     int ret;
>> +
>> +     if (!parent_np) {
>
> Is this even possible?

Goes away anyways when i fuse the syscon and reset controller
as Rob suggested.

>> +     if (IS_ERR(gr->map)) {
>> +             dev_err(dev, "unable to get regmap");
>
> It might be helpful to print the error code here.

OK.

>> +     ret = devm_reset_controller_register(&pdev->dev, &gr->rcdev);
>> +     if (ret)
>> +             return ret;
>> +
>> +     dev_info(dev, "registered Gemini reset controller\n");
>
> This is a bit verbose. I'd remove it and shorten the last part to:
>
>         return devm_reset_controller_register(&pdev->dev, &gr->rcdev);

It's always this thing whether to be in the camp that like drivers to announce
themselves or not, but I can do as you suggest if it's a strong preference.

The reason I want it is: deselect the driver from Kconfig, something stops
working. Compare the dmesg: they both look the same. You don't immediately
see that something is missing.

So some people think that it is time to go around in /sys, and then what
if it is a boot regression, like the system can't mount root without the
reset controller. (Yeah I know, the thing mounting root should select the
reset controller then, OK another bug we would have seen with this...)

And then all of a sudden there is a lot of debug time spent looking for this
fact that would be spotted in no time if the was a dev_info() about the
driver being probed.

But if you insist, I will remove it.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] reset: Add a Gemini reset controller
  2017-05-07 19:23   ` Linus Walleij
@ 2017-05-08  7:01     ` Philipp Zabel
  0 siblings, 0 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-05-08  7:01 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Linus,

On Sun, 2017-05-07 at 21:23 +0200, Linus Walleij wrote:
> On Tue, Apr 25, 2017 at 10:43 AM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> > [Me]
> >> +/*
> >> + * Cortina Gemini Reset controller driver
> >> + * Copyright (c) 2017 Linus Walleij <linus.walleij@linaro.org>
> >
> > No license statement, choice or oversight?
> 
> Choice. I'm one of those guys who think that the top-level COPYING file
> in the kernel is by far enough of legalese. If you want, I can put in a license
> of course.

Yes, please do. The implicit statement made by the Signed-off-by tag
refers to the "license indicated in the file", unfortunately.

[...]
> >> +     ret = devm_reset_controller_register(&pdev->dev, &gr->rcdev);
> >> +     if (ret)
> >> +             return ret;
> >> +
> >> +     dev_info(dev, "registered Gemini reset controller\n");
> >
> > This is a bit verbose. I'd remove it and shorten the last part to:
> >
> >         return devm_reset_controller_register(&pdev->dev, &gr->rcdev);
> 
> It's always this thing whether to be in the camp that like drivers to announce
> themselves or not, but I can do as you suggest if it's a strong preference.
> 
> The reason I want it is: deselect the driver from Kconfig, something stops
> working. Compare the dmesg: they both look the same. You don't immediately
> see that something is missing.
> 
> So some people think that it is time to go around in /sys, and then what
> if it is a boot regression, like the system can't mount root without the
> reset controller. (Yeah I know, the thing mounting root should select the
> reset controller then, OK another bug we would have seen with this...)
> 
> And then all of a sudden there is a lot of debug time spent looking for this
> fact that would be spotted in no time if the was a dev_info() about the
> driver being probed.
> 
> But if you insist, I will remove it.

I don't insist.
I am in the camp of people who don't particularly like to see driver
announcements, but that preference only extends to machines I use.

regards
Philipp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] reset: Add a Gemini reset controller
@ 2017-05-24  8:19 Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2017-05-24  8:19 UTC (permalink / raw)
  To: linux-arm-kernel

The Cortina Systems Gemini reset controller is a simple
32bit register with self-deasserting reset lines. It is
accessed using regmap over syscon.

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Philipp: please merge this into the reset subsystem once
you're happy with it. Sorry for the back-and-forth. I will
deal with the ARM SoC DTS landing orthogonally.

ChangeLog v3->v4:
- Provide macros in a separate patch.
- Add Philipp's ACK.
ChangeLog v2->v3:
- Use the syscon node to probe the driver.
- Sebastian: when you're happy with this please ACK it so I
  can merge it through ARM SoC. This is needed because of
  the mess of #include <dt-bindings/*> from the DT bindings
  that is then used all over the DTS files.
ChangeLog v1->v2:
- Add an explicit GPL license statement.
- Move the reset controller to be identical to the sycon
  node, no need to a separate child node for this.
- Drop unneeded struct device *dev pointer from state
  container.
- Print error code on missing regmap.
- Use #define from the <dt-bindings/*> to indicate that we
  always set the CPU1 reset line to 1 when writing the
  resets.
---
 drivers/reset/Kconfig        |   7 +++
 drivers/reset/Makefile       |   1 +
 drivers/reset/reset-gemini.c | 110 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/reset/reset-gemini.c

diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index d21c07ccc94e..361c5515fd48 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -34,6 +34,13 @@ config RESET_BERLIN
 	help
 	  This enables the reset controller driver for Marvell Berlin SoCs.
 
+config RESET_GEMINI
+	bool "Gemini Reset Driver" if COMPILE_TEST
+	default ARCH_GEMINI
+	select MFD_SYSCON
+	help
+	  This enables the reset controller driver for Cortina Systems Gemini.
+
 config RESET_IMX7
 	bool "i.MX7 Reset Driver" if COMPILE_TEST
 	default SOC_IMX7D
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 02a74db94339..c711594ebcc0 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
 obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_RESET_GEMINI) += reset-gemini.o
 obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
diff --git a/drivers/reset/reset-gemini.c b/drivers/reset/reset-gemini.c
new file mode 100644
index 000000000000..a2478997c75b
--- /dev/null
+++ b/drivers/reset/reset-gemini.c
@@ -0,0 +1,110 @@
+/*
+ * Cortina Gemini Reset controller driver
+ * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+#include <dt-bindings/reset/cortina,gemini-reset.h>
+
+/**
+ * struct gemini_reset - gemini reset controller
+ * @map: regmap to access the containing system controller
+ * @rcdev: reset controller device
+ */
+struct gemini_reset {
+	struct regmap *map;
+	struct reset_controller_dev rcdev;
+};
+
+#define GEMINI_GLOBAL_SOFT_RESET 0x0c
+
+#define to_gemini_reset(p) \
+	container_of((p), struct gemini_reset, rcdev)
+
+/*
+ * This is a self-deasserting reset controller.
+ */
+static int gemini_reset(struct reset_controller_dev *rcdev,
+			unsigned long id)
+{
+	struct gemini_reset *gr = to_gemini_reset(rcdev);
+
+	/* Manual says to always set BIT 30 (CPU1) to 1 */
+	return regmap_write(gr->map,
+			    GEMINI_GLOBAL_SOFT_RESET,
+			    BIT(GEMINI_RESET_CPU1) | BIT(id));
+}
+
+static int gemini_reset_status(struct reset_controller_dev *rcdev,
+			     unsigned long id)
+{
+	struct gemini_reset *gr = to_gemini_reset(rcdev);
+	u32 val;
+	int ret;
+
+	ret = regmap_read(gr->map, GEMINI_GLOBAL_SOFT_RESET, &val);
+	if (ret)
+		return ret;
+
+	return !!(val & BIT(id));
+}
+
+static const struct reset_control_ops gemini_reset_ops = {
+	.reset = gemini_reset,
+	.status = gemini_reset_status,
+};
+
+static int gemini_reset_probe(struct platform_device *pdev)
+{
+	struct gemini_reset *gr;
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	int ret;
+
+	gr = devm_kzalloc(dev, sizeof(*gr), GFP_KERNEL);
+	if (!gr)
+		return -ENOMEM;
+
+	gr->map = syscon_node_to_regmap(np);
+	if (IS_ERR(gr->map)) {
+		ret = PTR_ERR(gr->map);
+		dev_err(dev, "unable to get regmap (%d)", ret);
+		return ret;
+	}
+	gr->rcdev.owner = THIS_MODULE;
+	gr->rcdev.nr_resets = 32;
+	gr->rcdev.ops = &gemini_reset_ops;
+	gr->rcdev.of_node = pdev->dev.of_node;
+
+	ret = devm_reset_controller_register(&pdev->dev, &gr->rcdev);
+	if (ret)
+		return ret;
+
+	dev_info(dev, "registered Gemini reset controller\n");
+	return 0;
+}
+
+static const struct of_device_id gemini_reset_dt_ids[] = {
+	{ .compatible = "cortina,gemini-syscon", },
+	{ /* sentinel */ },
+};
+
+static struct platform_driver gemini_reset_driver = {
+	.probe	= gemini_reset_probe,
+	.driver = {
+		.name		= "gemini-reset",
+		.of_match_table	= gemini_reset_dt_ids,
+		.suppress_bind_attrs = true,
+	},
+};
+builtin_platform_driver(gemini_reset_driver);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-24  8:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-24 19:28 [PATCH 2/2] reset: Add a Gemini reset controller Linus Walleij
2017-04-25  8:43 ` Philipp Zabel
2017-05-07 19:23   ` Linus Walleij
2017-05-08  7:01     ` Philipp Zabel
  -- strict thread matches above, loose matches on Subject: below --
2017-05-24  8:19 Linus Walleij

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).