Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5701046imb; Thu, 7 Mar 2019 23:50:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzB8jOgRomyiF1rcMLaZ8f/Q05nUsDXHBNUzAZogs50fjfiQTJVpxPZVX0W6IT/N78jLeki X-Received: by 2002:a17:902:7613:: with SMTP id k19mr16958639pll.207.1552031446117; Thu, 07 Mar 2019 23:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552031446; cv=none; d=google.com; s=arc-20160816; b=nxJjkxVP7PYccX5T5wLWdvLM4MfIsZrc5YP3J7Y/+282qCGLVfHAdTzA9dV9Y5wAUz msMbJQTfhfoZOpye5aTbiYRhTQjcqtza+7hrJ60366UY9x2CsP/WGsnY1UIk+i4J79zS MfchfpZTTz/BWIfHnZlhENI7AbD7bXCYDiXF6Y/n8spQoFbYUM65QVlL1AvqarAt7a3q 8e4R9JMaXbcgDLy7jjsKsLiOPO52N5h0SvIwoSKCKp9XdZ2bdsWCJOBr5xzzMYyFjyzy eiPA/6GXrmhMLZZ/JueZVohIybAAW6sSXmRsN08PGxrI75HuPRQug3L3pJa+n/XrJpFY gQpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=ONNHJD/+jfQveyCt/dsQKfK+CH0M0KzhIx59yEChO4M=; b=FZzkOTWmtjETIT8BEr0+ErxK1VpEqNWTx5A6P67Zeh32yPYypwkUpuZZ86ZN2icoIN Mzto9Ex5YKDo4QATabuZPOWIvCpmA9r83lpoWm4UMz0XxNr06f9cYH9uUvYrkEiJhkhX n0xuVDjjLGqJ2aNZRkuhQ7qjUczOy2sNF3Hb48+VdyoL5PyHQ7AAYgZaWVZ0/zVVNyCa sOtMSBiq9MvinJNlGGN2kBPNfKZerwAo/+hreGIynnV+DUcSKfuafM119ulz2lFrY4yL ZGqFPGltO++JYou/sJHyoMhxm8JeGvqeXg87IJzgiTAP4hf7q1a5aI4WVp0Sqn0Z4UM9 hCng== 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 g98si6568664plb.11.2019.03.07.23.50.27; Thu, 07 Mar 2019 23:50:46 -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 S1726298AbfCHHto (ORCPT + 99 others); Fri, 8 Mar 2019 02:49:44 -0500 Received: from host-88-217-225-28.customer.m-online.net ([88.217.225.28]:41254 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725308AbfCHHto (ORCPT ); Fri, 8 Mar 2019 02:49:44 -0500 Received: from localhost.localdomain (unknown [10.2.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id B51C6203C6; Fri, 8 Mar 2019 07:49:41 +0000 (UTC) From: Martin Schiller To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, fkan@apm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Schiller Subject: [PATCH] power: reset: syscon-reboot: add a mask property Date: Fri, 8 Mar 2019 08:49:30 +0100 Message-Id: <20190308074930.15270-1-ms@dev.tdt.de> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make the syscon-reboot driver accept value and mask instead of just value. Prior to this patch, the property name for the value was 'mask'. If only the mask property is defined on a node, maintain compatibility by using it as the value. This patch is based on commit f2c199db477e ("power: reset: syscon-poweroff: add a mask property") and does the same change for the syscon-reboot driver. Signed-off-by: Martin Schiller --- .../devicetree/bindings/power/reset/syscon-reboot.txt | 11 +++++++++-- drivers/power/reset/syscon-reboot.c | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt b/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt index 11906316b43d..e23dea8344f8 100644 --- a/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt +++ b/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt @@ -3,13 +3,20 @@ Generic SYSCON mapped register reset driver This is a generic reset driver using syscon to map the reset register. The reset is generally performed with a write to the reset register defined by the register map pointed by syscon reference plus the offset -with the mask defined in the reboot node. +with the value and mask defined in the reboot node. Required properties: - compatible: should contain "syscon-reboot" - regmap: this is phandle to the register map node - offset: offset in the register map for the reboot register (in bytes) -- mask: the reset value written to the reboot register (32 bit access) +- value: the reset value written to the reboot register (32 bit access) + +Optional properties: +- mask: update only the register bits defined by the mask (32 bit) + +Legacy usage: +If a node doesn't contain a value property but contains a mask property, the +mask property is used as the value. Default will be little endian mode, 32 bit access only. diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c index 7d0d269a0837..5a6bb638c331 100644 --- a/drivers/power/reset/syscon-reboot.c +++ b/drivers/power/reset/syscon-reboot.c @@ -27,6 +27,7 @@ struct syscon_reboot_context { struct regmap *map; u32 offset; + u32 value; u32 mask; struct notifier_block restart_handler; }; @@ -39,7 +40,7 @@ static int syscon_restart_handle(struct notifier_block *this, restart_handler); /* Issue the reboot */ - regmap_write(ctx->map, ctx->offset, ctx->mask); + regmap_update_bits(ctx->map, ctx->offset, ctx->mask, ctx->value); mdelay(1000); @@ -51,6 +52,7 @@ static int syscon_reboot_probe(struct platform_device *pdev) { struct syscon_reboot_context *ctx; struct device *dev = &pdev->dev; + int mask_err, value_err; int err; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); @@ -64,8 +66,21 @@ static int syscon_reboot_probe(struct platform_device *pdev) if (of_property_read_u32(pdev->dev.of_node, "offset", &ctx->offset)) return -EINVAL; - if (of_property_read_u32(pdev->dev.of_node, "mask", &ctx->mask)) + value_err = of_property_read_u32(pdev->dev.of_node, "value", &ctx->value); + mask_err = of_property_read_u32(pdev->dev.of_node, "mask", &ctx->mask); + if (value_err && mask_err) { + dev_err(dev, "unable to read 'value' and 'mask'"); return -EINVAL; + } + + if (value_err) { + /* support old binding */ + ctx->value = ctx->mask; + ctx->mask = 0xFFFFFFFF; + } else if (mask_err) { + /* support value without mask*/ + ctx->mask = 0xFFFFFFFF; + } ctx->restart_handler.notifier_call = syscon_restart_handle; ctx->restart_handler.priority = 192; -- 2.11.0