devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX
@ 2015-08-03 17:23 Alban Bedel
  2015-08-03 17:23 ` [PATCH 1/3] devicetree: Add bindings for the ATH79 reset controller Alban Bedel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alban Bedel @ 2015-08-03 17:23 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Ralf Baechle, devicetree, linux-kernel, linux-mips, Alban Bedel

Hi all,

this small serie add a trivial driver for the reset controller found
on the AR71XX/AR9XXX SoC. Of note is only the fact that the ATH79 board
support code use a custom API for this and ioremap the same memory area.
However this custom API is only used by board not supporting OF, so it
won't come into play for boards using OF. As such it should still be safe,
even if the double ioremap is a bit ugly.

Alban

Alban Bedel (3):
  devicetree: Add bindings for the ATH79 reset controller
  reset: Add a driver for the reset controller on the AR71XX/AR9XXX
  MIPS: ath79: Add the reset controller to the AR9132 dtsi

 .../devicetree/bindings/reset/ath79-reset.txt      |  20 ++++
 arch/mips/Kconfig                                  |   1 +
 arch/mips/boot/dts/qca/ar9132.dtsi                 |   8 ++
 drivers/reset/Makefile                             |   1 +
 drivers/reset/reset-ath79.c                        | 128 +++++++++++++++++++++
 5 files changed, 158 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/ath79-reset.txt
 create mode 100644 drivers/reset/reset-ath79.c

-- 
2.0.0

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

* [PATCH 1/3] devicetree: Add bindings for the ATH79 reset controller
  2015-08-03 17:23 [PATCH 0/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX Alban Bedel
@ 2015-08-03 17:23 ` Alban Bedel
  2015-08-03 17:23 ` [PATCH 2/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX Alban Bedel
  2015-08-03 17:23 ` [PATCH 3/3] MIPS: ath79: Add the reset controller to the AR9132 dtsi Alban Bedel
  2 siblings, 0 replies; 6+ messages in thread
From: Alban Bedel @ 2015-08-03 17:23 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Ralf Baechle, devicetree, linux-kernel, linux-mips, Alban Bedel

Signed-off-by: Alban Bedel <albeu@free.fr>
---
 .../devicetree/bindings/reset/ath79-reset.txt        | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/ath79-reset.txt

diff --git a/Documentation/devicetree/bindings/reset/ath79-reset.txt b/Documentation/devicetree/bindings/reset/ath79-reset.txt
new file mode 100644
index 0000000..4c56330
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/ath79-reset.txt
@@ -0,0 +1,20 @@
+Binding for Qualcomm Atheros AR7xxx/AR9XXX reset controller
+
+Please also refer to reset.txt in this directory for common reset
+controller binding usage.
+
+Required Properties:
+- compatible: has to be "qca,<soctype>-reset", "qca,ar7100-reset"
+              as fallback
+- reg: Base address and size of the controllers memory area
+- #reset-cells : Specifies the number of cells needed to encode reset
+                 line, should be 1
+
+Example:
+
+	reset-controller@1806001c {
+		compatible = "qca,ar9132-reset", "qca,ar7100-reset";
+		reg = <0x1806001c 0x4>;
+
+		#reset-cells = <1>;
+	};
-- 
2.0.0

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

* [PATCH 2/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX
  2015-08-03 17:23 [PATCH 0/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX Alban Bedel
  2015-08-03 17:23 ` [PATCH 1/3] devicetree: Add bindings for the ATH79 reset controller Alban Bedel
@ 2015-08-03 17:23 ` Alban Bedel
  2015-08-03 17:23 ` [PATCH 3/3] MIPS: ath79: Add the reset controller to the AR9132 dtsi Alban Bedel
  2 siblings, 0 replies; 6+ messages in thread
From: Alban Bedel @ 2015-08-03 17:23 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Ralf Baechle, devicetree, linux-kernel, linux-mips, Alban Bedel

The AR71XX/AR9XXX SoC have a simple reset controller with one bit per
reset line.

Signed-off-by: Alban Bedel <albeu@free.fr>
---
 arch/mips/Kconfig           |   1 +
 drivers/reset/Makefile      |   1 +
 drivers/reset/reset-ath79.c | 128 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/reset/reset-ath79.c

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index cee5f93..d896ffb 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -118,6 +118,7 @@ config ATH25
 
 config ATH79
 	bool "Atheros AR71XX/AR724X/AR913X based boards"
+	select ARCH_HAS_RESET_CONTROLLER
 	select ARCH_REQUIRE_GPIOLIB
 	select BOOT_RAW
 	select CEVT_R4K
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 157d421..f8db9b7 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_ARCH_BERLIN) += reset-berlin.o
 obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o
 obj-$(CONFIG_ARCH_STI) += sti/
+obj-$(CONFIG_ATH79) += reset-ath79.o
diff --git a/drivers/reset/reset-ath79.c b/drivers/reset/reset-ath79.c
new file mode 100644
index 0000000..d2d2904
--- /dev/null
+++ b/drivers/reset/reset-ath79.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2015 Alban Bedel <albeu@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+
+struct ath79_reset {
+	struct reset_controller_dev rcdev;
+	void __iomem *base;
+	spinlock_t lock;
+};
+
+static int ath79_reset_update(struct reset_controller_dev *rcdev,
+			unsigned long id, bool assert)
+{
+	struct ath79_reset *ath79_reset =
+		container_of(rcdev, struct ath79_reset, rcdev);
+	unsigned long flags;
+	u32 val;
+
+	spin_lock_irqsave(&ath79_reset->lock, flags);
+	val = readl(ath79_reset->base);
+	if (assert)
+		val |= BIT(id);
+	else
+		val &= ~BIT(id);
+	writel(val, ath79_reset->base);
+	spin_unlock_irqrestore(&ath79_reset->lock, flags);
+
+	return 0;
+}
+
+static int ath79_reset_assert(struct reset_controller_dev *rcdev,
+			unsigned long id)
+{
+	return ath79_reset_update(rcdev, id, true);
+}
+
+static int ath79_reset_deassert(struct reset_controller_dev *rcdev,
+				unsigned long id)
+{
+	return ath79_reset_update(rcdev, id, false);
+}
+
+static int ath79_reset_status(struct reset_controller_dev *rcdev,
+			unsigned long id)
+{
+	struct ath79_reset *ath79_reset =
+		container_of(rcdev, struct ath79_reset, rcdev);
+	u32 val;
+
+	val = readl(ath79_reset->base);
+
+	return !!(val & BIT(id));
+}
+
+static struct reset_control_ops ath79_reset_ops = {
+	.assert = ath79_reset_assert,
+	.deassert = ath79_reset_deassert,
+	.status = ath79_reset_status,
+};
+
+static int ath79_reset_probe(struct platform_device *pdev)
+{
+	struct ath79_reset *ath79_reset;
+	struct resource *res;
+
+	ath79_reset = devm_kzalloc(&pdev->dev,
+				sizeof(*ath79_reset), GFP_KERNEL);
+	if (!ath79_reset)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, ath79_reset);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	ath79_reset->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ath79_reset->base))
+		return PTR_ERR(ath79_reset->base);
+
+	ath79_reset->rcdev.ops = &ath79_reset_ops;
+	ath79_reset->rcdev.owner = THIS_MODULE;
+	ath79_reset->rcdev.of_node = pdev->dev.of_node;
+	ath79_reset->rcdev.of_reset_n_cells = 1;
+	ath79_reset->rcdev.nr_resets = 32;
+
+	return reset_controller_register(&ath79_reset->rcdev);
+}
+
+static int ath79_reset_remove(struct platform_device *pdev)
+{
+	struct ath79_reset *ath79_reset = platform_get_drvdata(pdev);
+
+	reset_controller_unregister(&ath79_reset->rcdev);
+
+	return 0;
+}
+
+static const struct of_device_id ath79_reset_dt_ids[] = {
+	{ .compatible = "qca,ar7100-reset", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, ath79_reset_dt_ids);
+
+static struct platform_driver ath79_reset_driver = {
+	.probe	= ath79_reset_probe,
+	.remove = ath79_reset_remove,
+	.driver = {
+		.name		= "ath79-reset",
+		.of_match_table	= ath79_reset_dt_ids,
+	},
+};
+module_platform_driver(ath79_reset_driver);
+
+MODULE_AUTHOR("Alban Bedel <albeu@free.fr>");
+MODULE_DESCRIPTION("AR71xx Reset Controller Driver");
+MODULE_LICENSE("GPL");
-- 
2.0.0

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

* [PATCH 3/3] MIPS: ath79: Add the reset controller to the AR9132 dtsi
  2015-08-03 17:23 [PATCH 0/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX Alban Bedel
  2015-08-03 17:23 ` [PATCH 1/3] devicetree: Add bindings for the ATH79 reset controller Alban Bedel
  2015-08-03 17:23 ` [PATCH 2/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX Alban Bedel
@ 2015-08-03 17:23 ` Alban Bedel
       [not found]   ` <1438622633-9407-4-git-send-email-albeu-GANU6spQydw@public.gmane.org>
  2 siblings, 1 reply; 6+ messages in thread
From: Alban Bedel @ 2015-08-03 17:23 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Ralf Baechle, devicetree, linux-kernel, linux-mips, Alban Bedel

Signed-off-by: Alban Bedel <albeu@free.fr>
---
 arch/mips/boot/dts/qca/ar9132.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/mips/boot/dts/qca/ar9132.dtsi b/arch/mips/boot/dts/qca/ar9132.dtsi
index 4759cff..fb7734e 100644
--- a/arch/mips/boot/dts/qca/ar9132.dtsi
+++ b/arch/mips/boot/dts/qca/ar9132.dtsi
@@ -115,6 +115,14 @@
 				interrupt-controller;
 				#interrupt-cells = <1>;
 			};
+
+			rst: reset-controller@1806001c {
+				compatible = "qca,ar9132-reset",
+						"qca,ar7100-reset";
+				reg = <0x1806001c 0x4>;
+
+				#reset-cells = <1>;
+			};
 		};
 
 		spi@1f000000 {
-- 
2.0.0

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

* Re: [PATCH 3/3] MIPS: ath79: Add the reset controller to the AR9132 dtsi
       [not found]   ` <1438622633-9407-4-git-send-email-albeu-GANU6spQydw@public.gmane.org>
@ 2015-08-03 18:23     ` Ralf Baechle
       [not found]       ` <20150803182336.GH2843-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Ralf Baechle @ 2015-08-03 18:23 UTC (permalink / raw)
  To: Alban Bedel
  Cc: Philipp Zabel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-mips-6z/3iImG2C8G8FEW9MqTrA

On Mon, Aug 03, 2015 at 07:23:53PM +0200, Alban Bedel wrote:

Acked-by: Ralf Baechle <ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>

Philipp,

Feel free to take this through the reset tree.  Or I can carry this in
the MIPS tree which is probably better for testing.  Just lemme know.

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 3/3] MIPS: ath79: Add the reset controller to the AR9132 dtsi
       [not found]       ` <20150803182336.GH2843-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>
@ 2015-08-04  8:47         ` Philipp Zabel
  0 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2015-08-04  8:47 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Alban Bedel, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-mips-6z/3iImG2C8G8FEW9MqTrA

Am Montag, den 03.08.2015, 20:23 +0200 schrieb Ralf Baechle:
> On Mon, Aug 03, 2015 at 07:23:53PM +0200, Alban Bedel wrote:
> 
> Acked-by: Ralf Baechle <ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>t
> 
> Philipp,
> 
> Feel free to take this through the reset tree.  Or I can carry this in
> the MIPS tree which is probably better for testing.  Just lemme know.
> 
>   Ralf

How about I put this on a branch for you to pull? That way I can already
resolve the (trivial) merge conflict in drivers/reset/Makefile

    git://git.pengutronix.de/git/pza/linux.git reset/ath79

regards
Philipp

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2015-08-04  8:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-03 17:23 [PATCH 0/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX Alban Bedel
2015-08-03 17:23 ` [PATCH 1/3] devicetree: Add bindings for the ATH79 reset controller Alban Bedel
2015-08-03 17:23 ` [PATCH 2/3] reset: Add a driver for the reset controller on the AR71XX/AR9XXX Alban Bedel
2015-08-03 17:23 ` [PATCH 3/3] MIPS: ath79: Add the reset controller to the AR9132 dtsi Alban Bedel
     [not found]   ` <1438622633-9407-4-git-send-email-albeu-GANU6spQydw@public.gmane.org>
2015-08-03 18:23     ` Ralf Baechle
     [not found]       ` <20150803182336.GH2843-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>
2015-08-04  8:47         ` Philipp Zabel

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