SRAM based reboot reason driver for HiKey
Subsystems (4)
cover SRAM based reboot reason driver for HiKey
Now that Andy's reboot reason core driver has landed, I wanted to resubmit a reworked version of my SRAM based reboot reason driver.
This allows the kernel to communicate to the bootloader what mode it should reboot to using some reserved memory.
Feedback would be very much appreciated!
thanks
-john
John Stultz (4):
drivers: sram: Have sram driver probe children nodes
dt-bindings: power: reset: Add document for sram-reboot-mode driver
power: reset: Add sram-reboot-mode driver
dts: hikey: Add hikey support for sram-reboot-mode
.../bindings/power/reset/sram-reboot-mode.txt | 35 ++++++++ arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 22 ++++- drivers/misc/sram.c | 3 + drivers/power/reset/Kconfig | 10 +++ drivers/power/reset/Makefile | 1 + drivers/power/reset/sram-reboot-mode.c | 95 ++++++++++++++++++++++ 6 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt create mode 100644 drivers/power/reset/sram-reboot-mode.c
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 1/4 drivers: sram: Have sram driver probe children nodes
In order to support sub-nodes with the sram driver, have the sram driver call of_probe_default_children().
This will allow for supportting sram based reboot reasons.
--- drivers/misc/sram.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/sram.c +3 -0
@@ -23,6 +23,7 @@#include <linux/io.h> #include <linux/list_sort.h> #include <linux/of_address.h> +#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/slab.h>
@@ -384,6 +385,8 @@ static int sram_probe(struct platform_device *pdev)platform_set_drvdata (pdev, sram); +of_platform_default_populate (pdev->dev.of_node, +NULL , &pdev->dev);dev_dbg (sram->dev,"SRAM pool: %zu KiB @ 0x%p\n" ,gen_pool_size (sram->pool) /1024 , sram->virt_base);
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 2/4 dt-bindings: power: reset: Add document for sram-reboot-mode driver
In reply to John StultzAdd device tree binding document for reboot-mode driver
--- .../bindings/power/reset/sram-reboot-mode.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt new file +35 -0
@@ -0,0 +1,35 @@ +SRAM reboot mode driver + +This driver get reboot mode magic value form reboot-mode driver +and stores it in a SRAM address. 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 "mmio-sram" node. + +Required properties: +- compatible: should be "sram-reboot-mode" +- reg: offset from the sram range where to store the magic value(in bytes) + +The rest of the properties should follow the generic reboot-mode discription +found in reboot-mode.txt + +Example: + + sram@5f01000 { + compatible = "mmio-sram"; + reg = <0x0 0x05f01000 0x0 0x00001000>; + ranges = <0x0 0x0 0x05f01000 0x00001000>; + + #address-cells = <1>; + #size-cells = <1>; + + reboot-mode@0 { + compatible = "sram-reboot-mode"; + reg = <0x0 0x4>; + + mode-normal = <0x77665501>; + mode-bootloader = <0x77665500>; + mode-recovery = <0x77665502>; + }; + };
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 3/4 power: reset: Add sram-reboot-mode driver
In reply to John StultzAdd sram-reboot-mode driver, which enables reboot modes to be specified from sram subnodes.
--- drivers/power/reset/Kconfig | 10 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/sram-reboot-mode.c | 95 ++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 drivers/power/reset/sram-reboot-mode.c
drivers/power/reset/Kconfig +10 -0
@@ -208,5 +208,15 @@ config SYSCON_REBOOT_MODE register, then the bootloader can read it to take different action according to the mode. +config SRAM_REBOOT_MODE + bool "Generic SRAM reboot mode driver" + select REBOOT_MODE + select SRAM + help + Say y here will enable reboot mode driver. This will + get reboot mode arguments and store it in an SRAM + address, then the bootloader can read it to take different + action according to the mode. + endif
drivers/power/reset/Makefile +1 -0
@@ -24,3 +24,4 @@ obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o +obj-$(CONFIG_SRAM_REBOOT_MODE) += sram-reboot-mode.o
drivers/power/reset/sram-reboot-mode.c new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
1.9.1
RFC PATCH 4/4 dts: hikey: Add hikey support for sram-reboot-mode
In reply to John StultzAdd support to hikey dts and defconfig for the
sram-reboot-mode driver.
The dts entries added here should really be generated by the UEFI firmware, and not be static in the dts, since one may be using different firmware on HiKey. But this patch provides an example of how the sram-reboot-mode entry would otherwise look.
--- arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +21 -1
@@ -29,6 +29,7 @@ * Reserve below regions from memory node: * * 0x05e0,0000 - 0x05ef,ffff: MCU firmware runtime using + * 0x05f0,1000 - 0x05f0,1fff: Reboot reason * 0x06df,f000 - 0x06df,ffff: Mailbox message data * 0x0740,f000 - 0x0740,ffff: MCU firmware section * 0x3e00,0000 - 0x3fff,ffff: OP-TEE
@@ -36,11 +37,30 @@ memory@0 { device_type = "memory"; reg = <0x00000000 0x00000000 0x00000000 0x05e00000>, - <0x00000000 0x05f00000 0x00000000 0x00eff000>, + <0x00000000 0x05f00000 0x00000000 0x00001000>, + <0x00000000 0x05f02000 0x00000000 0x00efd000>, <0x00000000 0x06e00000 0x00000000 0x0060f000>, <0x00000000 0x07410000 0x00000000 0x36bf0000>; }; + sram@5f01000 { + compatible = "mmio-sram"; + reg = <0x0 0x05f01000 0x0 0x00001000>; + ranges = <0x0 0x0 0x05f01000 0x00001000>; + + #address-cells = <1>; + #size-cells = <1>; + + reboot-mode@0 { + compatible = "sram-reboot-mode"; + reg = <0x0 0x4>; + + mode-normal = <0x77665501>; + mode-bootloader = <0x77665500>; + mode-recovery = <0x77665502>; + }; + }; + soc { spi0: spi@f7106000 { status = "ok";
Signature · 1 line
1.9.1
Re: [RFC][PATCH 3/4] power: reset: Add sram-reboot-mode driver
In reply to John StultzOn Wed 03 Aug 16:05 PDT 2016, John Stultz wrote:
[..]
Quoted 1 line
drivers/power/reset/sram-reboot-mode.c +0
-0
[..]
drivers/power/reset/sram-reboot-mode.c line 26
Quoted 4 lines
drivers/power/reset/sram-reboot-mode.c +4
-0+ +struct sram_reboot_mode { +struct reboot_mode_driver reboot; +void __iomem *reboot_reason_val_addr;
23 characters is...a lot of characters...
Quoted 24 lines
drivers/power/reset/sram-reboot-mode.c +24
-0+}; + +static int sram_reboot_mode_write (struct reboot_mode_driver *reboot, +unsigned int magic) +{ +struct sram_reboot_mode *sram_rbm; + + sram_rbm = container_of(reboot, struct sram_reboot_mode, reboot); + +writel (magic, sram_rbm->reboot_reason_val_addr); +return 0 ; +} + +static int sram_reboot_mode_probe (struct platform_device *pdev) +{ +struct sram_reboot_mode *sram_rbm; +struct resource *res; +int ret; + + sram_rbm =devm_kzalloc (&pdev->dev,sizeof (*sram_rbm),GFP_KERNEL ); +if (!sram_rbm) +return -ENOMEM ; + + sram_rbm->reboot.dev = &pdev->dev;
drivers/power/reset/sram-reboot-mode.c line 60
Quoted 10 lines
drivers/power/reset/sram-reboot-mode.c +10
-0+ sram_rbm->reboot.write = sram_reboot_mode_write; + +dev_set_drvdata (&pdev->dev, sram_rbm); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return PTR_ERR (res); + + sram_rbm->reboot_reason_val_addr =devm_ioremap (&pdev->dev, res->start, +resource_size (res));
Use devm_ioremap_resource() instead, it saves you the return value check on platform_get_resource() and is cleaner.
drivers/power/reset/sram-reboot-mode.c line 64
Quoted 4 lines
drivers/power/reset/sram-reboot-mode.c +4
-0+if (IS_ERR (sram_rbm->reboot_reason_val_addr)) +return PTR_ERR (sram_rbm->reboot_reason_val_addr); + + ret =reboot_mode_register (&sram_rbm->reboot);
I think you should take the time to throw in a devm_reboot_mode_register(), it would save you from the dev_set_drvdata() and you can drop the remove function.
drivers/power/reset/sram-reboot-mode.c line 70
Quoted 6 lines
drivers/power/reset/sram-reboot-mode.c +6
-0+if (ret) +dev_err (&pdev->dev,"can't register reboot mode\n" ); + +return ret; +} +
Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC][PATCH 3/4] power: reset: Add sram-reboot-mode driver
Quoted 11 lines · Bjorn Andersson
On Wed 03 Aug 16:05 PDT 2016, John Stultz wrote:
[..]
Quoted 1 line
drivers/power/reset/sram-reboot-mode.c +0
-0[..]
drivers/power/reset/sram-reboot-mode.c line 26
Quoted 4 lines
drivers/power/reset/sram-reboot-mode.c +4
-0+ +struct sram_reboot_mode { +struct reboot_mode_driver reboot; +void __iomem *reboot_reason_val_addr;23 characters is...a lot of characters...
Fair enough. Renamed to reason_addr.
Quoted 9 lines
drivers/power/reset/sram-reboot-mode.c line 60
Quoted 6 lines
drivers/power/reset/sram-reboot-mode.c +6
-0+ res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return PTR_ERR (res); + + sram_rbm->reboot_reason_val_addr =devm_ioremap (&pdev->dev, res->start, +resource_size (res));Use
devm_ioremap_resource()instead, it saves you the return value check onplatform_get_resource()and is cleaner.
Ok. Done.
Quoted 8 lines
drivers/power/reset/sram-reboot-mode.c line 64
Quoted 4 lines
drivers/power/reset/sram-reboot-mode.c +4
-0+if (IS_ERR (sram_rbm->reboot_reason_val_addr)) +return PTR_ERR (sram_rbm->reboot_reason_val_addr); + + ret =reboot_mode_register (&sram_rbm->reboot);I think you should take the time to throw in a
devm_reboot_mode_register(), it would save you from thedev_set_drvdata()and you can drop the remove function.
So I've only got a vague sense of what your suggesting here. Do you have a pointer to a good example?
thanks
-john
Re: [RFC][PATCH 3/4] power: reset: Add sram-reboot-mode driver
Quoted 6 lines · John Stultz
Quoted 4 lines · Bjorn Andersson
On Wed 03 Aug 16:05 PDT 2016, John Stultz wrote:
[..]
Quoted 1 line
drivers/power/reset/sram-reboot-mode.c +0
-0
[..]
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
+ ret =
reboot_mode_register(&sram_rbm->reboot);I think you should take the time to throw in a
devm_reboot_mode_register(), it would save you from thedev_set_drvdata()and you can drop the remove function.So I've only got a vague sense of what your suggesting here. Do you have a pointer to a good example?
https://patchwork.kernel.org/patch/9262691/
https://patchwork.kernel.org/patch/9262693/
Regards,
Bjorn
Rob Herring
maintainerRe: [RFC][PATCH 2/4] dt-bindings: power: reset: Add document for sram-reboot-mode driver
In reply to John StultzQuoted 27 lines · John Stultz
Add device tree binding document for reboot-mode driver
Cc Andy Yan <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Thierry Reding <[email protected]>Cc Heiko Stübner <[email protected]>Cc Caesar Wang <[email protected]>Cc Kees Cook <[email protected]>Cc Guodong Xu <[email protected]>Cc Haojian Zhuang <[email protected]>Cc Vishal Bhoj <[email protected]>Cc Bjorn Andersson <[email protected]>Cc Android Kernel Team <[email protected]>Signed-off-by John Stultz <[email protected]>--- .../bindings/power/reset/sram-reboot-mode.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txtDocumentation/devicetree/bindings/power/reset/sram-reboot-mode.txt new file +0
-0
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt new file +1
-0@@ -0,0 +1,35 @@ +SRAM reboot mode driver
Bindings don't describe drivers.
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt line 3
Quoted 2 lines
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt new file +2
-0+ +This driver get reboot mode magic value form reboot-mode driver
s/form/from/
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt line 6
Quoted 3 lines
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt new file +3
-0+and stores it in a SRAM address. Then the bootloader +can read it and take different action according to the magic +value stored.
Might say "on the next reboot" somewhere in here.
Quoted 32 lines
Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt new file +29
-0+ +This DT node should be represented as a sub-node of a "mmio-sram" node. + +Required properties: +- compatible: should be "sram-reboot-mode" +- reg: offset from the sram range where to store the magic value(in bytes) + +The rest of the properties should follow the generic reboot-mode discription +found in reboot-mode.txt + +Example: + + sram@5f01000 { + compatible = "mmio-sram"; + reg = <0x0 0x05f01000 0x0 0x00001000>; + ranges = <0x0 0x0 0x05f01000 0x00001000>; + + #address-cells = <1>; + #size-cells = <1>; + + reboot-mode@0 { + compatible = "sram-reboot-mode"; + reg = <0x0 0x4>; + + mode-normal = <0x77665501>; + mode-bootloader = <0x77665500>; + mode-recovery = <0x77665502>; + }; + };Signature · 1 line
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi John,
Quoted 8 lines · John Stultz
Now that Andy's reboot reason core driver has landed, I wanted to resubmit a reworked version of my SRAM based reboot reason driver.
This allows the kernel to communicate to the bootloader what mode it should reboot to using some reserved memory.
Feedback would be very much appreciated!
in my opinion the taken approach is wrong, and I've already explained why and how to rework your driver to shrink the change, please see
https://lkml.org/lkml/2016/1/27/133
In this case I think that a SRAM device node should just contain a plain description of partitions, compatible = "sram-reboot-mode" is clearly not a device on "SRAM bus", it is not a device at all, so please let's separate policy from mechanism
Because my proposed alternative approach separates policy from mechanism, it for instanse allows to avoid overlappings on SRAM areas, and still other drivers may serve as consumers of partitions on SRAM.
Please add me to Cc list when you send the next version of the driver.
With best wishes,
Vladimir
Quoted 33 lines
thanks
-johnCc Andy Yan <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Thierry Reding <[email protected]>Cc Heiko Stübner <[email protected]>Cc Caesar Wang <[email protected]>Cc Kees Cook <[email protected]>Cc Guodong Xu <[email protected]>Cc Haojian Zhuang <[email protected]>Cc Vishal Bhoj <[email protected]>Cc Bjorn Andersson <[email protected]>Cc Android Kernel Team <[email protected]>John Stultz (4):
drivers: sram: Have sram driver probe children nodes
dt-bindings: power: reset: Add document for sram-reboot-mode driver
power: reset: Add sram-reboot-mode driver
dts: hikey: Add hikey support for sram-reboot-mode.../bindings/power/reset/sram-reboot-mode.txt | 35 ++++++++ arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 22 ++++- drivers/misc/sram.c | 3 + drivers/power/reset/Kconfig | 10 +++ drivers/power/reset/Makefile | 1 + drivers/power/reset/sram-reboot-mode.c | 95 ++++++++++++++++++++++ 6 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/power/reset/sram-reboot-mode.txt create mode 100644 drivers/power/reset/sram-reboot-mode.c
Rob Herring
maintainerQuoted 14 lines · Vladimir Zapolskiy
Hi John,
Quoted 9 lines · John Stultz
Now that Andy's reboot reason core driver has landed, I wanted to resubmit a reworked version of my SRAM based reboot reason driver.
This allows the kernel to communicate to the bootloader what mode it should reboot to using some reserved memory.
Feedback would be very much appreciated!
Quoted 8 lines
in my opinion the taken approach is wrong, and I've already explained why and how to rework your driver to shrink the change, please see
https://lkml.org/lkml/2016/1/27/133In this case I think that a SRAM device node should just contain a plain description of partitions, compatible = "sram-reboot-mode" is clearly not a device on "SRAM bus", it is not a device at all, so please let's separate policy from mechanism
Having a 2nd node for the driver is still not a device on a bus. It adds unneeded complexity to the binding IMO.
The current approach also follows the model ramoops is using. Right now it's using reserved-memory, but that could easily be extended to SRAM region as well.
Quoted 3 lines
Because my proposed alternative approach separates policy from mechanism, it for instanse allows to avoid overlappings on SRAM areas, and still other drivers may serve as consumers of partitions on SRAM.
You could still have multiple consumers and having a compatible string doesn't necessarily imply a driver. Though multiple consumers without something arbitrating access sounds like broken design to me.
Rob
Quoted 32 lines · Rob Herring
Quoted 14 lines · Vladimir Zapolskiy
Hi John,
Quoted 9 lines · John Stultz
Now that Andy's reboot reason core driver has landed, I wanted to resubmit a reworked version of my SRAM based reboot reason driver.
This allows the kernel to communicate to the bootloader what mode it should reboot to using some reserved memory.
Feedback would be very much appreciated!
Quoted 8 lines
in my opinion the taken approach is wrong, and I've already explained why and how to rework your driver to shrink the change, please see
https://lkml.org/lkml/2016/1/27/133In this case I think that a SRAM device node should just contain a plain description of partitions, compatible = "sram-reboot-mode" is clearly not a device on "SRAM bus", it is not a device at all, so please let's separate policy from mechanism
Having a 2nd node for the driver is still not a device on a bus. It adds unneeded complexity to the binding IMO.
The current approach also follows the model ramoops is using. Right now it's using reserved-memory, but that could easily be extended to SRAM region as well.
Quoted 7 lines
Quoted 3 lines
Because my proposed alternative approach separates policy from mechanism, it for instanse allows to avoid overlappings on SRAM areas, and still other drivers may serve as consumers of partitions on SRAM.
You could still have multiple consumers and having a compatible string doesn't necessarily imply a driver. Though multiple consumers without something arbitrating access sounds like broken design to me.
So after running into some issues implementing the feedback that Bjorn suggested, I realized we were going to need to not only extend the sram driver to probe children, but we'd also have to make it a mfd so it wouldn't reserve the entire range and the reboot reason driver could map the memory.
That on top of the fact that we're already duplicating much of the syscon-reboot-mode driver to work on sram, I decided to just start over and use the syscon driver, which works fine here. All that is needed is just adding it to the dts.
I know that its not exactly correct usage of the syscon driver, but it starts to feel crazy almost completely duplicating the syscon driver just to have it named sram.
thanks
-john
Re: [RFC][PATCH 3/4] power: reset: Add sram-reboot-mode driver
In reply to John StultzQuoted 29 lines · John Stultz
Add sram-reboot-mode driver, which enables reboot modes to be specified from sram subnodes.
Cc Andy Yan <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Thierry Reding <[email protected]>Cc Heiko Stübner <[email protected]>Cc Caesar Wang <[email protected]>Cc Kees Cook <[email protected]>Cc Guodong Xu <[email protected]>Cc Haojian Zhuang <[email protected]>Cc Vishal Bhoj <[email protected]>Cc Bjorn Andersson <[email protected]>Cc Android Kernel Team <[email protected]>Signed-off-by John Stultz <[email protected]>--- drivers/power/reset/Kconfig | 10 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/sram-reboot-mode.c | 95 ++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 drivers/power/reset/sram-reboot-mode.cdrivers/power/reset/Kconfig +0
-0
drivers/power/reset/Kconfig config SYSCON_REBOOT_MODE · line 212
Quoted 5 lines
drivers/power/reset/Kconfig +2
-0@@ -208,5 +208,15 @@ config SYSCON_REBOOT_MODE register, then the bootloader can read it to take different action according to the mode. +config SRAM_REBOOT_MODE + bool "Generic SRAM reboot mode driver"
Since this is bool, can we dump the module.h and any MODULE_* tags from the driver, and register using a builtin variant?
Thanks,
Paul.
--
Quoted 46 lines
drivers/power/reset/Kconfig +8
-0+ select REBOOT_MODE + select SRAM + help + Say y here will enable reboot mode driver. This will + get reboot mode arguments and store it in an SRAM + address, then the bootloader can read it to take different + action according to the mode. + endifdrivers/power/reset/Makefile +1
-0@@ -24,3 +24,4 @@ obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o +obj-$(CONFIG_SRAM_REBOOT_MODE) += sram-reboot-mode.odrivers/power/reset/sram-reboot-mode.c new file +21
-0@@ -0,0 +1,95 @@ +/* +* Copyright (c) 2016, Linaro Limited +* Based on syscon-reboot-mode.c +* Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ +#include <linux/init.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/reboot.h> +#include <linux/regmap.h> +#include "reboot-mode.h" +
Hi Rob,
Quoted 20 lines · Rob Herring
Quoted 18 lines · Vladimir Zapolskiy
Hi John,
Quoted 9 lines · John Stultz
Now that Andy's reboot reason core driver has landed, I wanted to resubmit a reworked version of my SRAM based reboot reason driver.
This allows the kernel to communicate to the bootloader what mode it should reboot to using some reserved memory.
Feedback would be very much appreciated!
in my opinion the taken approach is wrong, and I've already explained why and how to rework your driver to shrink the change, please see
https://lkml.org/lkml/2016/1/27/133
Quoted 7 lines
Quoted 4 lines
In this case I think that a SRAM device node should just contain a plain description of partitions, compatible = "sram-reboot-mode" is clearly not a device on "SRAM bus", it is not a device at all, so please let's separate policy from mechanism
Having a 2nd node for the driver is still not a device on a bus. It adds unneeded complexity to the binding IMO.
What second node for the driver do you mean here? If you reference a reset/syscon driver then there should be only a property pointing to a partition on SRAM, similar case is found in CODA driver, see Documentation/devicetree/bindings/media/coda.txt and in my short term plans to do the same for lpc-eth driver.
And a node which describes an area on SRAM is generally needed in both cases, however note that with my approach techincally it is possible to specify the entire SRAM device as a target partition, sometimes it is sufficient but here it is not wanted, because there will be no control on offset/size of the particular data stored on SRAM. The essential part is the meaning of this added second node, either it is a reserved partition (= unified definition independently on consumers) or a description with a compatible property for some arbitrary device. Why zoo of compatibles under SRAM node should be accepted? Why SRAM should be converted to a bus type device? Should be the same done with e.g. MTD or NVMEM devices? IMHO clear separation between data proiders and data consumers should be preserved if possible, and here it appears to be a simpler solution for the given technical problem.
Quoted 4 lines
The current approach also follows the model ramoops is using. Right now it's using reserved-memory, but that could easily be extended to SRAM region as well.
Quoted 8 lines
Quoted 3 lines
Because my proposed alternative approach separates policy from mechanism, it for instanse allows to avoid overlappings on SRAM areas, and still other drivers may serve as consumers of partitions on SRAM.
You could still have multiple consumers and having a compatible string doesn't necessarily imply a driver. Though multiple consumers without something arbitrating access sounds like broken design to me.
Not in this case, the interface to SRAM partitions and/or SRAM as a whole deliberately assumes that a memory area is shared among all consumers in sense of a memory pool, data resides within the given area but it is not inter-shared among consumers.
--
With best wishes,
Vladimir
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html