From patchwork Wed Feb 26 14:08:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 869204 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7927021D3C4 for ; Wed, 26 Feb 2025 14:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740578906; cv=none; b=dS5t11oCqkm1mCx3Ed/TtFX35SKow+RtGylmf8FqJe/fbtDVfnv9boiQRd2br8OZvc0WITqiw4cp1Pm6PoovA8AIvQPLJYxdG/3O5wxxK2Uldf/A50ioUZD68DkCMwBE8MUQ4QnNt7jgQKOmNHt5blAoReB2OgreD6gcNKRJfiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740578906; c=relaxed/simple; bh=P4n2TUurAZ0QjjR+H15n7mDXmaltx5kef1Mee5VWzEU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aWKqmRWQ1IJNwG0Ze6n1wd2Q9coYGjqIQbm0B8gUpbEqROqw8lIkk4+oDqjp0/jCdVvCXtNBFN3JPmXi18qGUsueaSLeuyWoyg0BZy6aNW5c0J0mtlYB3D06qqjxX7JM1EQDMfoRXH6R1DNAnlK2SK1lB9istxtrGarlUNkEIA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Tiix1jWe; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Tiix1jWe" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-abb9709b5b5so1242916766b.2 for ; Wed, 26 Feb 2025 06:08:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1740578903; x=1741183703; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ptWMUTZMUOXDkynnwEpEC1SXLl/PZJE3+R5Z2ydqVns=; b=Tiix1jWemSfLe80DOWkD8QDtI0y59joeUEOZygHzgOYX63vDp7Q3cBvRTExqrPlKi5 B8bKl29N+f27RouT0O14dYWmpP2Z8linkBw/j+WGO5AwrBm5eQYv3RRgK3nyejpSwJMc a3IWtYhjafz669eiv1ABEEkZfZhx0N1AMkLMdrDBZadkkLm6r0gFG9gz+qckY+Y5qidh cMAxU+cm4U/tjVyQuiqxq6sRSBV74EiHohH9SPQqz+mzpalwJ6JN9Hy7tZzjR6gSu0el 8cvQOHBSAcFWjeYsAZAHGfI2M7xjLz50rf/sAB3Ui/YIn5D4FhSXGI1+j/OsYlIpBXOW +9ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740578903; x=1741183703; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ptWMUTZMUOXDkynnwEpEC1SXLl/PZJE3+R5Z2ydqVns=; b=rIijr/nh+bkBON08B8n5awY/WWqysCV9CRLtl6zopxPaSBoIgxasOmfGeRTqncZVyy kB2V3UhIPFKgQ7TydB5eGMZ50mqxkqjjA8qhNQBtdI9o6kOu8Pt3xG0OxnR6zIlqQwE8 NRG7eUXDJBhL9IMUK/SddzRnFt5ABy2jJgmnYNuC3kzEySxaJsS0txT2TevTlql4aZtx zM9KVmslCd0sS6sXl8VJ++WyaB5O4GodIC1A8N7lcBJz+GHH2ROF1eozDhao3V2QF5xE NKiRrSKIO8H1fmXcBM3act+lDBgrHkeLbhFCKIqjeKSwGwr5sqBV0GodU0l8WwjnpSs4 34LA== X-Forwarded-Encrypted: i=1; AJvYcCV6iXdUUURu1EJRPd6GeI2sBM9eadDIRjI9neehP1U+Q41UWLtirhkKifynCBXTxkObZo95a96npA==@vger.kernel.org X-Gm-Message-State: AOJu0YzYobBmJVRihecunkeaGycUwGOVNalh6faV0i62EFzwko6Oormh gYI4ppj/w/KTALW9XPHj9F0XjJ1cR8XDkkQyJA72GwCP63lCR6ZxINl6pwLy9cM= X-Gm-Gg: ASbGncvMhYwkee8SMcZvJwLHeKKFUCW3EV+ev7GTVVoI2CRE55WuBqb/FWw+2xPbN5x U/KE+DrnHqgcRQ3t70vgE7UX9BGR2Yc8qppMcuhDyEZq+vctXDmBGTiijGnWsRksbEJ7F54PXbJ MateYY5Vf6Ow8OzfwyEsHEBq0fT/taBUpbNO+XX1NdXVoQJXGpqRBOhYqGiOFaGRhSyR1IAqXPP COs4MUGqzYm7k+5ID003yzFQohBERDemGre3nr4StzP6kuttAZqte0jYWnELbdwSUdA1Hxxdrrl CKn6YCY2vHvgqcrLV/Re6A0F4ax2GIpxPuI8OJdPwaWZEpEzaxVSsYcfkJtWhgWCYNx9u1wz8Yc 1lG+7jqlyoQ== X-Google-Smtp-Source: AGHT+IGalEUuTDwYDfunN57TQDxRb+0j8EpUzGDr7qDDi15A5nUiai0Xcy6PUoLEPI47zu9GGOn6VQ== X-Received: by 2002:a17:907:6d27:b0:ab7:e567:4fe8 with SMTP id a640c23a62f3a-abed0d60b6fmr922741866b.25.1740578902612; Wed, 26 Feb 2025 06:08:22 -0800 (PST) Received: from puffmais.c.googlers.com (30.171.91.34.bc.googleusercontent.com. [34.91.171.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abed20b6024sm330157566b.181.2025.02.26.06.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2025 06:08:22 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Wed, 26 Feb 2025 14:08:20 +0000 Subject: [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-syscon-reboot-reset-mode-v1-1-91c1b62166ae@linaro.org> References: <20250226-syscon-reboot-reset-mode-v1-0-91c1b62166ae@linaro.org> In-Reply-To: <20250226-syscon-reboot-reset-mode-v1-0-91c1b62166ae@linaro.org> To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Peter Griffin , Tudor Ambarus , Will McVicker , kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Draszik?= X-Mailer: b4 0.14.2 Add support for specifying different register/mask/value combinations for different types of reset. In particular, update the binding to allow platforms to specify the following reset modes: soft, warm, cold, hard. Linux can perform different types of reset using its reboot= kernel command line argument, and some platforms also wish to reset differently based on whether or not e.g. contents of RAM should be retained across the reboot. The new properties match the existing properties, just prefixed with one of the reset modes mentioned above. Signed-off-by: André Draszik --- .../bindings/power/reset/syscon-reboot.yaml | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml b/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml index 19d3093e6cd2f7e39d94c56636dc202a4427ffc3..a34b1c08b7e0f34574a0257e13c02fceac0243ae 100644 --- a/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml +++ b/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml @@ -18,6 +18,11 @@ description: |+ parental dt-node. So the SYSCON reboot node should be represented as a sub-node of a "syscon", "simple-mfd" node. Though the regmap property pointing to the system controller node is also supported. + This also supports specification of separate sets of register/mask/value + pairs for different types of reset: cold, hard, soft and warm, using + the respective properties with the respective reset type prefix. If prefixed + properties are not specified for a reset type, the non-prefixed properties + will be used for that reset type. properties: compatible: @@ -49,12 +54,41 @@ properties: priority: default: 192 +patternProperties: + "^(cold|hard|soft|warm)-(mask|offset|value)$": + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Optional alternative offset / mask / value combinations for specific + reboot modes. The mask is optional. + + "^(cold|hard|soft|warm)-reg$": + description: + Optional alternative base address and size for the reboot register for + specific reboot modes. + oneOf: - required: - offset - required: - reg +dependencies: + cold-mask: [ cold-value ] + cold-offset: [ cold-value ] + cold-reg: [ cold-value ] + + hard-mask: [ hard-value ] + hard-offset: [ hard-value ] + hard-reg: [ hard-value ] + + soft-mask: [ soft-value ] + soft-offset: [ soft-value ] + soft-reg: [ soft-value ] + + warm-mask: [ warm-value ] + warm-offset: [ warm-value ] + warm-reg: [ warm-value ] + required: - compatible @@ -70,6 +104,46 @@ allOf: required: - value + - if: + required: + - cold-value + then: + oneOf: + - required: + - cold-offset + - required: + - cold-reg + + - if: + required: + - hard-value + then: + oneOf: + - required: + - hard-offset + - required: + - hard-reg + + - if: + required: + - soft-value + then: + oneOf: + - required: + - soft-offset + - required: + - soft-reg + + - if: + required: + - warm-value + then: + oneOf: + - required: + - warm-offset + - required: + - warm-reg + examples: - | reboot { From patchwork Wed Feb 26 14:08:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 868835 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0D8221D3E7 for ; Wed, 26 Feb 2025 14:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740578907; cv=none; b=eBhYGrs/1lupW7rXcv4g48UtPoi7+3EAfEhz1s3004WrZIsywdakbIybrgO0HY86R+hnIil8ieS4NS7+Bu9DBHmrfpMuLiSkTuECmgURrQlkcx/YUAFcVDtHdgZeiBivBkBfe6kNnMHpDOxgPpkPvxZp/vjdv3c9lSjkau+YY1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740578907; c=relaxed/simple; bh=iNT0VqOrH9vAHA1UAijWCgNgr5GDEqXdheLf0A2HN9w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FFmfDoQj/4j/3rNVEUP/XEiVwebj9HXlV+limc6BDZPMokvVLQqQ1GVatcAQo6C054hfsr+UpSFIzsktrBjZ7MVNfyyn3WjdDUijdXfphTqSjCYfhGVzVZ090QTK8mSMIes0xS+A/X9s2voe4S/vCTPPiHQeW0q/xozBXDoNFLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OW7S127S; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OW7S127S" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4398c8c8b2cso69831335e9.2 for ; Wed, 26 Feb 2025 06:08:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1740578903; x=1741183703; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WxeFUEnPMpG6A3aZld5E/WFu7bcPUUeu7zfpRBo6A78=; b=OW7S127Sv2ogLD1vBLxNcb+XadepPo7LcPz0iLZlfIBrV84iBNBOmIZyZLGGhte3qU naRHm05Is229BOAVMMoGqAjVUk80VVuXbQGyhFPfqEjueS083LLUNNyBDSN1JbR71h27 gr7ihFyJPy+iBMM6FLD/E0TyNjTVEbMRgWKKAoCgVIH6XQAi52o6cGgkyA7HVhUwjCHL JbVfUZfv6B+qna3CFqKYaF9KKEZn6nit3Jq8MEfmxOBCOkH8o2NFIwqzqpQmkeP5AP/8 rED34ChY689awQG8i//qF92UK4NR0EMPNEmO+DFlDR1XOgjtUKACe40sM7xq6I4qDBuV 5Qwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740578903; x=1741183703; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WxeFUEnPMpG6A3aZld5E/WFu7bcPUUeu7zfpRBo6A78=; b=tMEsZGeApK+n2V8tnBjLcjpL+L1LT0utwt9i0OFy0Vf44+MuxksXsnf69UadRNbtXB DWoqCOf7kE5Ma6llVeGfzbLl5j8fCIrOKgWrAvLEtS00xu4K2LUCdY65gzDmvhy9Er24 sADJQgTCwtuE0CRot+FjowVQUbiTWP6gSUA9qCrTEAp5rsgErWp8qBnKIaOjO+P1ciek UfOKY8LPFqlkeJfPi7z5o76g6jDHVvrDzd7p9DiKZo8xoQKpEBgNxWHxOlmXZT2gdSdP 6iK/d5dT5QGGGJfgzh6f8q7nhOIculpFZvvn1brWo8mcyITpZJdNwny0dfj2v92i0fmf i8wA== X-Forwarded-Encrypted: i=1; AJvYcCXWdBRSCcbPfGwaelF09VaZXpszbrge5hovg0Q+dX2ept0poh93nr32q/mPqonRiH9qcLBpSdgD0A==@vger.kernel.org X-Gm-Message-State: AOJu0YxZKyepARTviHxFNp2WOtANdabhJAlZORHZU2hGtePWzf1dPm4w J2UXh/3eQbw3YwvUmUAVzXI2ZWzJvRRD4z1IyeQZoi/nZEn33RD2Ryc+fZwB08k= X-Gm-Gg: ASbGncs+IZKqpvhgKJFE61HUVLSU73UQ3LOnWp/rVtOH0xejpv/en61MmEBz7oqYqcY /sKikdw7IEFsCH0FCH1Qut0MGM2Cr+fA6DT56++lcqUTDaL7XQD3fMM5zmNAVEBIOf5ISESq/IG YHEn5rkpLg1kGmfhOWY4IkJ7YtQL794NcoXxmBZ8zXJ7tskkuEw0vKKsFdkh6L8reUwbl5B1rvt 9hb1F/cnM3WACCQ/xdila5GVKnrkZkGyHQTS5dxphu8tc/TwK7lGUT1spgSdx5IFHYOEzDrXLi/ Nv2/L3gPikOybrPp9uV8Yl5Gldua5auVPvUx+JBDXVIKmyF2XLj6nIQA3fixjlRf1fD7GVW1Kly cipsYKpW9qQ== X-Google-Smtp-Source: AGHT+IGv/eO4Q+853qoaaBSUt+F6k1tIspvcIuibPPRIZkfwO2bs2v7+pxNtqXYPmvOTuy5Yt55vgA== X-Received: by 2002:a05:600c:4753:b0:439:9a40:aa0b with SMTP id 5b1f17b1804b1-43ab0f6e6ccmr69618395e9.25.1740578903152; Wed, 26 Feb 2025 06:08:23 -0800 (PST) Received: from puffmais.c.googlers.com (30.171.91.34.bc.googleusercontent.com. [34.91.171.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abed20b6024sm330157566b.181.2025.02.26.06.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2025 06:08:22 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Wed, 26 Feb 2025 14:08:21 +0000 Subject: [PATCH 2/2] power: reset: syscon-reboot: support different reset modes Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250226-syscon-reboot-reset-mode-v1-2-91c1b62166ae@linaro.org> References: <20250226-syscon-reboot-reset-mode-v1-0-91c1b62166ae@linaro.org> In-Reply-To: <20250226-syscon-reboot-reset-mode-v1-0-91c1b62166ae@linaro.org> To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Peter Griffin , Tudor Ambarus , Will McVicker , kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Draszik?= X-Mailer: b4 0.14.2 Linux supports a couple different reset modes, but this driver here doesn't distinguish between them and issues the same syscon register write irrespective of the reset mode requested by the kernel. Update this driver to support most of Linux' reset modes: cold, hard, warm, and soft. The actions to take for these are taken from DT, and are all new optional properties. The property names match the existing properties supported but should be prefixed with the reset mode. This change is meant to be backwards compatible with existing DTs, and if Linux requests a reset mode that this driver doesn't support, or that the DT doesn't specify, the reset is triggered using the fallback / default entry. As an example why this is useful, other than properly supporting the Linux reboot= kernel command line option or sysfs entry, this change allows platforms to e.g. default to a more secure cold-reset, but also to do a warm-reset in case RAM contents needs to be retained across the reset. Signed-off-by: André Draszik --- drivers/power/reset/syscon-reboot.c | 88 ++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 11 deletions(-) diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c index d623d77e657e4c233d8ae88bb099bee13c48a9ef..1d3d8a3265ae8005c685b42d3e554bd8bb0047ea 100644 --- a/drivers/power/reset/syscon-reboot.c +++ b/drivers/power/reset/syscon-reboot.c @@ -14,11 +14,29 @@ #include #include -struct syscon_reboot_context { - struct regmap *map; +/* REBOOT_GPIO doesn't make sense for syscon-reboot */ +static const struct { + enum reboot_mode mode; + const char *prefix; +} prefix_map[] = { + { .mode = REBOOT_COLD, .prefix = "cold" }, + { .mode = REBOOT_WARM, .prefix = "warm" }, + { .mode = REBOOT_HARD, .prefix = "hard" }, + { .mode = REBOOT_SOFT, .prefix = "soft" }, +}; + +struct reboot_mode_bits { u32 offset; u32 value; u32 mask; + bool valid; +}; + +struct syscon_reboot_context { + struct regmap *map; + + struct reboot_mode_bits mode_bits[REBOOT_SOFT + 1]; + struct reboot_mode_bits catchall; struct notifier_block restart_handler; }; @@ -28,9 +46,16 @@ static int syscon_restart_handle(struct notifier_block *this, struct syscon_reboot_context *ctx = container_of(this, struct syscon_reboot_context, restart_handler); + const struct reboot_mode_bits *mode_bits; + + if (mode < ARRAY_SIZE(ctx->mode_bits) && ctx->mode_bits[mode].valid) + mode_bits = &ctx->mode_bits[mode]; + else + mode_bits = &ctx->catchall; /* Issue the reboot */ - regmap_update_bits(ctx->map, ctx->offset, ctx->mask, ctx->value); + regmap_update_bits(ctx->map, mode_bits->offset, mode_bits->mask, + mode_bits->value); mdelay(1000); @@ -45,6 +70,7 @@ static int syscon_reboot_probe(struct platform_device *pdev) int mask_err, value_err; int priority; int err; + char prop[32]; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) @@ -60,12 +86,52 @@ static int syscon_reboot_probe(struct platform_device *pdev) if (of_property_read_s32(pdev->dev.of_node, "priority", &priority)) priority = 192; - if (of_property_read_u32(pdev->dev.of_node, "offset", &ctx->offset)) - if (of_property_read_u32(pdev->dev.of_node, "reg", &ctx->offset)) + BUILD_BUG_ON(ARRAY_SIZE(prefix_map) != ARRAY_SIZE(ctx->mode_bits)); + BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_COLD); + BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_WARM); + BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_HARD); + BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_SOFT); + + for (int i = 0; i < ARRAY_SIZE(prefix_map); ++i) { + const char * const prefix = prefix_map[i].prefix; + struct reboot_mode_bits * const mode_bits = + &ctx->mode_bits[prefix_map[i].mode]; + + snprintf(prop, sizeof(prop), "%s-offset", prefix); + if (of_property_read_u32(pdev->dev.of_node, "offset", + &mode_bits->offset)) + continue; + + snprintf(prop, sizeof(prop), "%s-value", prefix); + if (of_property_read_u32(pdev->dev.of_node, prop, + &mode_bits->value)) { + /* don't support old binding here */ + dev_err(dev, "'%s-value' is mandatory\n", prefix); + continue; + } + + snprintf(prop, sizeof(prop), "%s-mask", prefix); + mask_err = of_property_read_u32(pdev->dev.of_node, prop, + &mode_bits->mask); + + if (mask_err) + /* support value without mask*/ + mode_bits->mask = 0xffffffff; + + mode_bits->valid = true; + } + + /* catch-all entry */ + if (of_property_read_u32(pdev->dev.of_node, "offset", + &ctx->catchall.offset)) + if (of_property_read_u32(pdev->dev.of_node, "reg", + &ctx->catchall.offset)) return -EINVAL; - 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); + value_err = of_property_read_u32(pdev->dev.of_node, "value", + &ctx->catchall.value); + mask_err = of_property_read_u32(pdev->dev.of_node, "mask", + &ctx->catchall.mask); if (value_err && mask_err) { dev_err(dev, "unable to read 'value' and 'mask'"); return -EINVAL; @@ -73,11 +139,11 @@ static int syscon_reboot_probe(struct platform_device *pdev) if (value_err) { /* support old binding */ - ctx->value = ctx->mask; - ctx->mask = 0xFFFFFFFF; + ctx->catchall.value = ctx->catchall.mask; + ctx->catchall.mask = 0xFFFFFFFF; } else if (mask_err) { - /* support value without mask*/ - ctx->mask = 0xFFFFFFFF; + /* support value without mask */ + ctx->catchall.mask = 0xFFFFFFFF; } ctx->restart_handler.notifier_call = syscon_restart_handle;