mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <Sergey.Semin@baikalelectronics.ru>
To: Sebastian Reichel <sre@kernel.org>
Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>,
	Serge Semin <fancer.lancer@gmail.com>,
	Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Paul Burton <paulburton@kernel.org>,
	Ralf Baechle <ralf@linux-mips.org>, <linux-pm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH 4/4] power: reset: syscon-reboot-mode: Add regmap dts-property support
Date: Fri, 6 Mar 2020 16:03:41 +0300	[thread overview]
Message-ID: <20200306130407.136888030701@mail.baikalelectronics.ru> (raw)
In-Reply-To: <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru>

From: Serge Semin <Sergey.Semin@baikalelectronics.ru>

'Reboot-mode'-type of devices are supposed to work in conjunction with
'reboot'-type devices. In particular Baikal-T1 SoC provides a special
CCU_WDT_RCR register, which is preserved during any type of the CPU
reset (standard and caused by a watchdog one). Since both of them are
responsible for the system-wide operation and related with each other
it would be better to place them at the same place in the dt hierarchy.
In particular the best location would be the dt root node. Currently
'syscon-reboot' device node can be placed anywhere in a dtb as long as
the corresponding device is created at the system boot-up procedure.
While according to the corresponding bindings file 'system-boot-mode'
should be represented as a sub-node of a "syscon", "simple-mfd" node.
This isn't always suitable especially when the reboot-preserved
register is provided by some device, which we don't want to declared
as MFD. In this case it would be good to have the 'syscon-reboot-mode'
node accepting the 'regmap' property with a phandle reference to the
'syscon' dt-node, in the same way the 'syscon-reboot' driver does.
This is what this patch provides - it makes the driver to handle the
optional 'regmap' property. In case if one isn't provided the
previously implemented scheme is expected to be found in dtb.

Moreover seeing current dt-interface implementation of the
'syscon-reboot', 'syscon-poweroff' and 'syscon-reboot-mode' drivers,
they look more or less similar. All of them handle 'offset' and
'mask' dt-properties. While 'value' property is only acceptable
by the 'syscon-reboot' and 'syscon-poweroff' driver, the 'mode-*'
properties of 'syscon-reboot-mode' serve to the similar purpose.
The only strong difference between them is the ability to get the
syscon regmap from the 'regmap' property. By having this patch merged
we'll have that difference eliminated, so the interfaces would look
unified.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
 drivers/power/reset/syscon-reboot-mode.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/power/reset/syscon-reboot-mode.c b/drivers/power/reset/syscon-reboot-mode.c
index e0772c9f70f7..f8f8218ae3ee 100644
--- a/drivers/power/reset/syscon-reboot-mode.c
+++ b/drivers/power/reset/syscon-reboot-mode.c
@@ -40,6 +40,7 @@ static int syscon_reboot_mode_probe(struct platform_device *pdev)
 {
 	int ret;
 	struct syscon_reboot_mode *syscon_rbm;
+	struct regmap *map;
 
 	syscon_rbm = devm_kzalloc(&pdev->dev, sizeof(*syscon_rbm), GFP_KERNEL);
 	if (!syscon_rbm)
@@ -49,9 +50,13 @@ static int syscon_reboot_mode_probe(struct platform_device *pdev)
 	syscon_rbm->reboot.write = syscon_reboot_mode_write;
 	syscon_rbm->mask = 0xffffffff;
 
-	syscon_rbm->map = syscon_node_to_regmap(pdev->dev.parent->of_node);
-	if (IS_ERR(syscon_rbm->map))
-		return PTR_ERR(syscon_rbm->map);
+	map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "regmap");
+	if (IS_ERR(map)) {
+		map = syscon_node_to_regmap(pdev->dev.parent->of_node);
+		if (IS_ERR(map))
+			return PTR_ERR(map);
+	}
+	syscon_rbm->map = map;
 
 	if (of_property_read_u32(pdev->dev.of_node, "offset",
 	    &syscon_rbm->offset))
-- 
2.25.1


  parent reply	other threads:[~2020-03-06 13:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru>
2020-03-06 13:03 ` [PATCH 1/4] dt-bindings: syscon: Add syscon endian properties support Sergey.Semin
2020-03-12 21:11   ` Rob Herring
2020-03-13 12:26     ` Sergey Semin
2020-03-06 13:03 ` [PATCH 2/4] dt-bindings: power: reset: Replace SYSCON reboot-mode legacy bindings with YAML-based one Sergey.Semin
2020-03-06 19:56   ` Sebastian Reichel
     [not found]   ` <20200306200551.49C47803087C@mail.baikalelectronics.ru>
2020-03-11 20:47     ` Sergey Semin
2020-03-12 21:12   ` Rob Herring
2020-03-06 13:03 ` [PATCH 3/4] dt-bindings: power: reset: Add regmap support to the SYSCON reboot-mode bindings Sergey.Semin
2020-03-06 19:57   ` Sebastian Reichel
2020-03-12 21:14   ` Rob Herring
2020-03-13 13:02     ` Sergey Semin
2020-03-14 18:04       ` Sebastian Reichel
2020-03-18 23:14       ` Rob Herring
2020-03-31 19:50         ` Sergey Semin
2020-04-16 19:56           ` Sergey Semin
2020-04-16 21:28             ` Rob Herring
2020-04-17  7:45               ` Sergey Semin
2020-03-06 13:03 ` Sergey.Semin [this message]
2020-03-06 19:57   ` [PATCH 4/4] power: reset: syscon-reboot-mode: Add regmap dts-property support Sebastian Reichel

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=20200306130407.136888030701@mail.baikalelectronics.ru \
    --to=sergey.semin@baikalelectronics.ru \
    --cc=Alexey.Malahov@baikalelectronics.ru \
    --cc=fancer.lancer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=paulburton@kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=sre@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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

all inboxes | Powered by JetHome®