From patchwork Fri Mar 6 13:03:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11423857 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C3A314E3 for ; Fri, 6 Mar 2020 13:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C70C2084E for ; Fri, 6 Mar 2020 13:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727186AbgCFNEE (ORCPT ); Fri, 6 Mar 2020 08:04:04 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:36166 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727174AbgCFNEE (ORCPT ); Fri, 6 Mar 2020 08:04:04 -0500 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id C07838030795; Fri, 6 Mar 2020 13:04:01 +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 9IZ3E-PxsihJ; Fri, 6 Mar 2020 16:03:56 +0300 (MSK) From: To: Sebastian Reichel , Rob Herring , Mark Rutland CC: Serge Semin , Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , , , Subject: [PATCH 2/4] dt-bindings: power: reset: Replace SYSCON reboot-mode legacy bindings with YAML-based one Date: Fri, 6 Mar 2020 16:03:39 +0300 In-Reply-To: <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru> References: <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Message-Id: <20200306130401.C07838030795@mail.baikalelectronics.ru> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Serge Semin Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces SYSCON reboot-mode legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible "syscon-reboot-mode" device and necessarily have an offset property to determine which register from the regmap is supposed to keep the mode on reboot. Signed-off-by: Serge Semin Signed-off-by: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle Acked-by: Sebastian Reichel Reviewed-by: Rob Herring --- .../power/reset/syscon-reboot-mode.txt | 35 ------------ .../power/reset/syscon-reboot-mode.yaml | 55 +++++++++++++++++++ 2 files changed, 55 insertions(+), 35 deletions(-) delete mode 100644 Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.txt create mode 100644 Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.txt b/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.txt deleted file mode 100644 index f7ce1d8af04a..000000000000 --- a/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.txt +++ /dev/null @@ -1,35 +0,0 @@ -SYSCON reboot mode driver - -This driver gets reboot mode magic value form reboot-mode driver -and stores it in a SYSCON mapped register. Then the bootloader -can read it and take different action according to the magic -value stored. - -This DT node should be represented as a sub-node of a "syscon", "simple-mfd" -node. - -Required properties: -- compatible: should be "syscon-reboot-mode" -- offset: offset in the register map for the storage register (in bytes) - -Optional property: -- mask: bits mask of the bits in the register to store the reboot mode magic value, - default set to 0xffffffff if missing. - -The rest of the properties should follow the generic reboot-mode description -found in reboot-mode.txt - -Example: - pmu: pmu@20004000 { - compatible = "rockchip,rk3066-pmu", "syscon", "simple-mfd"; - reg = <0x20004000 0x100>; - - reboot-mode { - compatible = "syscon-reboot-mode"; - offset = <0x40>; - mode-normal = ; - mode-recovery = ; - mode-bootloader = ; - mode-loader = ; - }; - }; diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml b/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml new file mode 100644 index 000000000000..e09bb07b1abb --- /dev/null +++ b/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/reset/syscon-reboot-mode.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Generic SYSCON reboot mode driver + +maintainers: + - Sebastian Reichel + +description: | + This driver gets reboot mode magic value from reboot-mode driver + and stores it in a SYSCON mapped register. Then the bootloader + can read it and take different action according to the magic + value stored. The SYSCON mapped register is retrieved from the + parental dt-node plus the offset. So the SYSCON reboot-mode node + should be represented as a sub-node of a "syscon", "simple-mfd" node. + +properties: + compatible: + const: syscon-reboot-mode + + mask: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Update only the register bits defined by the mask (32 bit). + + offset: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Offset in the register map for the mode register (in bytes). + +patternProperties: + "^mode-.+": + $ref: /schemas/types.yaml#/definitions/uint32 + description: Vendor-specific mode value written to the mode register. + +additionalProperties: false + +required: + - compatible + - offset + +examples: + - | + #include + + reboot-mode { + compatible = "syscon-reboot-mode"; + offset = <0x40>; + mode-normal = ; + mode-recovery = ; + mode-bootloader = ; + mode-loader = ; + }; +... From patchwork Fri Mar 6 13:03:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11423851 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EC15921 for ; Fri, 6 Mar 2020 13:04:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 49F8E208CD for ; Fri, 6 Mar 2020 13:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbgCFNEE (ORCPT ); Fri, 6 Mar 2020 08:04:04 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:36190 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgCFNEE (ORCPT ); Fri, 6 Mar 2020 08:04:04 -0500 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 1F4F0803079F; Fri, 6 Mar 2020 13:04:02 +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 dhEMg_zQDqYP; Fri, 6 Mar 2020 16:03:56 +0300 (MSK) From: To: Sebastian Reichel , Rob Herring , Mark Rutland CC: Serge Semin , Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , , , Subject: [PATCH 3/4] dt-bindings: power: reset: Add regmap support to the SYSCON reboot-mode bindings Date: Fri, 6 Mar 2020 16:03:40 +0300 In-Reply-To: <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru> References: <20200306130341.9585-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Message-Id: <20200306130402.1F4F0803079F@mail.baikalelectronics.ru> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Serge Semin Optional regmap property will be used to refer to a syscon-controller having a reboot tolerant register mapped. Signed-off-by: Serge Semin Signed-off-by: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle Acked-by: Sebastian Reichel --- .../bindings/power/reset/syscon-reboot-mode.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml b/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml index e09bb07b1abb..f47bf52ad983 100644 --- a/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml +++ b/Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml @@ -13,9 +13,8 @@ description: | This driver gets reboot mode magic value from reboot-mode driver and stores it in a SYSCON mapped register. Then the bootloader can read it and take different action according to the magic - value stored. The SYSCON mapped register is retrieved from the - parental dt-node plus the offset. So the SYSCON reboot-mode node - should be represented as a sub-node of a "syscon", "simple-mfd" node. + value stored. The SYSCON mapped register is retrieved either from + the parental dt-node or from a regmap phandle plus the offset. properties: compatible: @@ -29,6 +28,10 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 description: Offset in the register map for the mode register (in bytes). + regmap: + $ref: /schemas/types.yaml#/definitions/phandle + description: Phandle to the register map node. + patternProperties: "^mode-.+": $ref: /schemas/types.yaml#/definitions/uint32 From patchwork Fri Mar 6 13:03:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 11423853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BA5214E3 for ; Fri, 6 Mar 2020 13:04:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6672B2166E for ; Fri, 6 Mar 2020 13:04:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726898AbgCFNEI (ORCPT ); Fri, 6 Mar 2020 08:04:08 -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 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Message-Id: <20200306130407.136888030701@mail.baikalelectronics.ru> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Acked-by: Sebastian Reichel --- 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))