Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6811042ybf; Fri, 6 Mar 2020 05:05:27 -0800 (PST) X-Google-Smtp-Source: ADFU+vtg6PIAZ3K4WPEOvUJEhfXRiC9nuOjVKK6RmeN/LxQfTvYhv/VGILoFqh7JJzoIor+zP/tY X-Received: by 2002:aca:f496:: with SMTP id s144mr2506486oih.71.1583499927105; Fri, 06 Mar 2020 05:05:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583499927; cv=none; d=google.com; s=arc-20160816; b=V1+vRocdegUfv3r42sPX/ljylux74beOf/eAHXrwykgZMF/qI+dFk/f6LphrgvxXO3 y4aB8Dcxlyt5r03B26Kjn2vL61R49ZAl5XUDixrF7K8YPSdx6+hG0IhgZObJCMI8bgzs e3Ob3FiVUBdj0V+huGggqyEmySG/mBskT98ZrGoFv8eFdUyhwzz1XI/4ShVf1I+YKj1e 7GvOZRr/CgLiKSNcrrroU/7GfheCtYtmihJBdupEmajCjtze+UZa93TytPeL3yNnmC5o JH5Mr1EB54VoP4eSBJSLmOkIsl0+Bwgnz1AcXaifE3804G8OWNZcIqLbhfKhC7Dh+2JQ ov8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=L3v+lN3NBgBznaGOJWctrcgvfJGppkw33Z0lEGR1pDc=; b=I72gPr9uu1/3rrXNDoRhgJ8hXfUnLWHwzS092I6BP53LLwgcePbReL7PSR+qA0cJ97 0lhe8fsCGRe4DWtdnNwTrgvtYl9/0zIXN34rqmiI/XFl9ppIeT+DZlXSgdctPYEWbLM8 cOkJv142mKZTZ6u9c/FuToa4kdhQFGqnX4FEEYw8ldGqzV+dB6HotBOAsoOE8/2V2X8w UkwG6maUwfe6KpSDqDXtZcvVQxNzUVhAk8NVVaBgfRw80wVpFtYUuKdwx07YcAmI2LpS 0bXxoeTJgYFqGy7Z07sd8yESuuGFl03GWlpR8lQoTA0dv6wpqqENlwpl4xKDb+pXQSnT cO4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si1387766otq.81.2020.03.06.05.05.05; Fri, 06 Mar 2020 05:05:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727268AbgCFNEJ (ORCPT + 99 others); Fri, 6 Mar 2020 08:04:09 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:36200 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727247AbgCFNEI (ORCPT ); Fri, 6 Mar 2020 08:04:08 -0500 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 136888030701; Fri, 6 Mar 2020 13:04:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eiDv7yP_oPEm; Fri, 6 Mar 2020 16:04:01 +0300 (MSK) From: To: Sebastian Reichel CC: Serge Semin , Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , , Subject: [PATCH 4/4] power: reset: syscon-reboot-mode: Add regmap dts-property support Date: Fri, 6 Mar 2020 16:03:41 +0300 In-Reply-To: <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru> References: <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Message-Id: <20200306130407.136888030701@mail.baikalelectronics.ru> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Serge Semin '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 Signed-off-by: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle --- 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