* [PATCH 0/4] Add restart commands for PM8150
@ 2020-07-31 21:14 Elliot Berman
2020-07-31 21:14 ` [PATCH 1/4] dt-bindings: power: reset: Convert reboot-mode to YAML Elliot Berman
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Elliot Berman @ 2020-07-31 21:14 UTC (permalink / raw)
To: Sebastian Reichel, Andy Yan, Bjorn Andersson
Cc: Elliot Berman, linux-pm, linux-arm-msm, Trilok Soni, Prasad Sodagudi
PM8150 uses reboot-mode framework to set magic values for bootloader to read
during next boot. dm-verity wants to use "dm-verity device corrupted" [1] as
the restart command, however the reboot-mode framework does not support spaces
in the command line as devicetree property names cannot have spaces. This
patch series adds two new optional array properties to reboot-mode framework:
reboot-mode-names and reboot-mode-magic. The arrays supply the commands and
magic values, respectively.
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-verity-target.c?h=v5.5#n255
Elliot Berman (4):
dt-bindings: power: reset: Convert reboot-mode to YAML
dt-bindings: power: reset: Add alternate reboot mode format
power: reset: Add support for reboot mode alternate properties
arm64: dts: qcom: pm8150: Add reboot magic
.../bindings/power/reset/reboot-mode.txt | 25 ---------
.../bindings/power/reset/reboot-mode.yaml | 64 ++++++++++++++++++++++
arch/arm64/boot/dts/qcom/pm8150.dtsi | 5 ++
drivers/power/reset/reboot-mode.c | 42 +++++++++++++-
4 files changed, 110 insertions(+), 26 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.txt
create mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] dt-bindings: power: reset: Convert reboot-mode to YAML
2020-07-31 21:14 [PATCH 0/4] Add restart commands for PM8150 Elliot Berman
@ 2020-07-31 21:14 ` Elliot Berman
2020-07-31 21:14 ` [PATCH 2/4] dt-bindings: power: reset: Add alternate reboot mode format Elliot Berman
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Elliot Berman @ 2020-07-31 21:14 UTC (permalink / raw)
To: Sebastian Reichel, Andy Yan, Bjorn Andersson
Cc: Elliot Berman, linux-pm, linux-arm-msm, Trilok Soni, Prasad Sodagudi
Convert reboot-mode bindings to YAML.
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
.../bindings/power/reset/reboot-mode.txt | 25 ------------
.../bindings/power/reset/reboot-mode.yaml | 47 ++++++++++++++++++++++
2 files changed, 47 insertions(+), 25 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.txt
create mode 100644 Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
diff --git a/Documentation/devicetree/bindings/power/reset/reboot-mode.txt b/Documentation/devicetree/bindings/power/reset/reboot-mode.txt
deleted file mode 100644
index de34f27..0000000
--- a/Documentation/devicetree/bindings/power/reset/reboot-mode.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-Generic reboot mode core map driver
-
-This driver get reboot mode arguments and call the write
-interface to store the magic value in special register
-or ram. Then the bootloader can read it and take different
-action according to the argument stored.
-
-All mode properties are vendor specific, it is a indication to tell
-the bootloader what to do when the system reboots, and should be named
-as mode-xxx = <magic> (xxx is mode name, magic should be a none-zero value).
-
-For example modes common on Android platform:
-- mode-normal: Normal reboot mode, system reboot with command "reboot".
-- mode-recovery: Android Recovery mode, it is a mode to format the device or update a new image.
-- mode-bootloader: Android fastboot mode, it's a mode to re-flash partitions on the Android based device.
-- mode-loader: A bootloader mode, it's a mode used to download image on Rockchip platform,
- usually used in development.
-
-Example:
- reboot-mode {
- mode-normal = <BOOT_NORMAL>;
- mode-recovery = <BOOT_RECOVERY>;
- mode-bootloader = <BOOT_FASTBOOT>;
- mode-loader = <BOOT_BL_DOWNLOAD>;
- }
diff --git a/Documentation/devicetree/bindings/power/reset/reboot-mode.yaml b/Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
new file mode 100644
index 0000000..a6c9102
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/reset/reboot-mode.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic reboot mode core map
+
+maintainers:
+ - Andy Yan <andy.yan@rock-chips.com>
+
+description: |
+ This driver get reboot mode arguments and call the write
+ interface to store the magic value in special register
+ or ram. Then the bootloader can read it and take different
+ action according to the argument stored.
+
+ All mode properties are vendor specific, it is a indication to tell
+ the bootloader what to do when the system reboots, and should be named
+ as mode-xxx = <magic> (xxx is mode name, magic should be a non-zero value).
+
+ For example, modes common Android platform are:
+ - normal: Normal reboot mode, system reboot with command "reboot".
+ - recovery: Android Recovery mode, it is a mode to format the device or update a new image.
+ - bootloader: Android fastboot mode, it's a mode to re-flash partitions on the Android based device.
+ - loader: A bootloader mode, it's a mode used to download image on Rockchip platform,
+ usually used in development.
+
+properties:
+ mode-normal:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ Default value to set on a reboot if no command was provided.
+
+patternProperties:
+ "^mode-.*$":
+ $ref: /schemas/types.yaml#/definitions/uint32
+
+examples:
+ - |
+ reboot-mode {
+ mode-normal = <0>;
+ mode-recovery = <1>;
+ mode-bootloader = <2>;
+ mode-loader = <3>;
+ };
+...
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] dt-bindings: power: reset: Add alternate reboot mode format
2020-07-31 21:14 [PATCH 0/4] Add restart commands for PM8150 Elliot Berman
2020-07-31 21:14 ` [PATCH 1/4] dt-bindings: power: reset: Convert reboot-mode to YAML Elliot Berman
@ 2020-07-31 21:14 ` Elliot Berman
2020-07-31 21:14 ` [PATCH 3/4] power: reset: Add support for reboot mode alternate properties Elliot Berman
2020-07-31 21:14 ` [PATCH 4/4] arm64: dts: qcom: pm8150: Add reboot magic Elliot Berman
3 siblings, 0 replies; 5+ messages in thread
From: Elliot Berman @ 2020-07-31 21:14 UTC (permalink / raw)
To: Sebastian Reichel, Andy Yan, Bjorn Andersson
Cc: Elliot Berman, linux-pm, linux-arm-msm, Trilok Soni, Prasad Sodagudi
Current reboot-mode device tree schema does not support reboot commands
with spaces in them [1]. Add an optional new node "reboot-mode-names"
and "reboot-mode-magic" which add an array of strings and u32s,
respectively which would permit any string in this framework.
[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-verity-target.c?h=v5.5#n255
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
.../devicetree/bindings/power/reset/reboot-mode.yaml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/Documentation/devicetree/bindings/power/reset/reboot-mode.yaml b/Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
index a6c9102..4ea6b33 100644
--- a/Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
+++ b/Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
@@ -19,6 +19,9 @@ description: |
the bootloader what to do when the system reboots, and should be named
as mode-xxx = <magic> (xxx is mode name, magic should be a non-zero value).
+ reboot-mode-magic and reboot-mode-names may be used in addition/instead of
+ mode-xxx style.
+
For example, modes common Android platform are:
- normal: Normal reboot mode, system reboot with command "reboot".
- recovery: Android Recovery mode, it is a mode to format the device or update a new image.
@@ -32,6 +35,14 @@ properties:
description: |
Default value to set on a reboot if no command was provided.
+ reboot-mode-names:
+ $ref: /schemas/types.yaml#/definitions/string-array
+ description: List of reboot commands, paired with reboot-mode-magic by index
+
+ reboot-mode-magic:
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ description: List of reboot magic, paired with reboot-mode-names by index
+
patternProperties:
"^mode-.*$":
$ref: /schemas/types.yaml#/definitions/uint32
@@ -44,4 +55,10 @@ examples:
mode-bootloader = <2>;
mode-loader = <3>;
};
+
+ - |
+ reboot-mode {
+ reboot-mode-names = "normal", "bootloader", "dm-verity device corrupted";
+ reboot-mode-magic = <0x0>, <0x1>, <0xf>;
+ };
...
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] power: reset: Add support for reboot mode alternate properties
2020-07-31 21:14 [PATCH 0/4] Add restart commands for PM8150 Elliot Berman
2020-07-31 21:14 ` [PATCH 1/4] dt-bindings: power: reset: Convert reboot-mode to YAML Elliot Berman
2020-07-31 21:14 ` [PATCH 2/4] dt-bindings: power: reset: Add alternate reboot mode format Elliot Berman
@ 2020-07-31 21:14 ` Elliot Berman
2020-07-31 21:14 ` [PATCH 4/4] arm64: dts: qcom: pm8150: Add reboot magic Elliot Berman
3 siblings, 0 replies; 5+ messages in thread
From: Elliot Berman @ 2020-07-31 21:14 UTC (permalink / raw)
To: Sebastian Reichel, Andy Yan, Bjorn Andersson
Cc: Elliot Berman, linux-pm, linux-arm-msm, Trilok Soni, Prasad Sodagudi
Reboot mode driver does not currently support reboot commands with
spaces in them [1]. Add an optional new node "reboot-mode-names" and
"reboot-mode-magic" which add an array of strings and u32s, respectively
which would permit any string in this framework.
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
drivers/power/reset/reboot-mode.c | 42 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index b4076b1..363734d 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -64,8 +64,9 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
struct mode_info *info;
struct property *prop;
struct device_node *np = reboot->dev->of_node;
+ const char *mode_name;
size_t len = strlen(PREFIX);
- int ret;
+ int ret, count, i;
INIT_LIST_HEAD(&reboot->head);
@@ -101,6 +102,45 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
list_add_tail(&info->list, &reboot->head);
}
+ count = of_property_count_u32_elems(np, "reboot-mode-magic");
+ for (i = 0; i < count; i++) {
+ info = devm_kzalloc(reboot->dev, sizeof(*info), GFP_KERNEL);
+ if (!info) {
+ ret = -ENOMEM;
+ goto error;
+ }
+
+ if (of_property_read_string_index(np, "reboot-mode-names", i,
+ &mode_name)) {
+ dev_err(reboot->dev, "unable to read reboot-mode-names[%d]\n",
+ i);
+ ret = -EINVAL;
+ goto error;
+ }
+ info->mode = kstrdup_const(mode_name, GFP_KERNEL);
+ if (!info->mode) {
+ ret = -ENOMEM;
+ goto error;
+ } else if (info->mode[0] == '\0') {
+ dev_err(reboot->dev, "invalid reboot-mode-names[%d]: too short!\n",
+ i);
+ kfree_const(info->mode);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ if (of_property_read_u32_index(np, "reboot-mode-magic", i,
+ &info->magic)) {
+ dev_err(reboot->dev, "unable to read reboot-mode-magic[%d]\n",
+ i);
+ kfree_const(info->mode);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ list_add_tail(&info->list, &reboot->head);
+ }
+
reboot->reboot_notifier.notifier_call = reboot_mode_notify;
register_reboot_notifier(&reboot->reboot_notifier);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] arm64: dts: qcom: pm8150: Add reboot magic
2020-07-31 21:14 [PATCH 0/4] Add restart commands for PM8150 Elliot Berman
` (2 preceding siblings ...)
2020-07-31 21:14 ` [PATCH 3/4] power: reset: Add support for reboot mode alternate properties Elliot Berman
@ 2020-07-31 21:14 ` Elliot Berman
3 siblings, 0 replies; 5+ messages in thread
From: Elliot Berman @ 2020-07-31 21:14 UTC (permalink / raw)
To: Sebastian Reichel, Andy Yan, Bjorn Andersson
Cc: Elliot Berman, linux-pm, linux-arm-msm, Trilok Soni, Prasad Sodagudi
Add reboot command magic values for pon device.
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
arch/arm64/boot/dts/qcom/pm8150.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/pm8150.dtsi b/arch/arm64/boot/dts/qcom/pm8150.dtsi
index 1b64069..afd6231 100644
--- a/arch/arm64/boot/dts/qcom/pm8150.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8150.dtsi
@@ -50,6 +50,11 @@
pon: power-on@800 {
compatible = "qcom,pm8916-pon";
reg = <0x0800>;
+
+ reboot-mode-names = "bootloader", "recovery",
+ "dm-verity device corrupted";
+ reboot-mode-magic = <0x1>, <0x2>, <0x4>;
+
pwrkey {
compatible = "qcom,pm8941-pwrkey";
interrupts = <0x0 0x8 0x0 IRQ_TYPE_EDGE_BOTH>;
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-31 21:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 21:14 [PATCH 0/4] Add restart commands for PM8150 Elliot Berman
2020-07-31 21:14 ` [PATCH 1/4] dt-bindings: power: reset: Convert reboot-mode to YAML Elliot Berman
2020-07-31 21:14 ` [PATCH 2/4] dt-bindings: power: reset: Add alternate reboot mode format Elliot Berman
2020-07-31 21:14 ` [PATCH 3/4] power: reset: Add support for reboot mode alternate properties Elliot Berman
2020-07-31 21:14 ` [PATCH 4/4] arm64: dts: qcom: pm8150: Add reboot magic Elliot Berman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).