arm64: reboot driver missing dts entry and ACPI support for storm platform.
Subsystems (2)
PATCH 1/1 arm64: reboot driver missing dts entry and ACPI support for storm platform.
--- arch/arm64/boot/dts/apm-storm.dtsi | 5 ++ drivers/power/reset/Kconfig | 5 +- drivers/power/reset/xgene-reboot.c | 94 +++++++++++++++++++++++++++++++----- 3 files changed, 88 insertions(+), 16 deletions(-)
arch/arm64/boot/dts/apm-storm.dtsi +5 -0
@@ -112,5 +112,10 @@ interrupt-parent = <&gic>; interrupts = <0x0 0x4c 0x4>; }; + + reboot at 17000014 { + compatible = "apm,xgene-reboot"; + reg = <0x0 0x17000014 0x0 0x4>; + }; }; };
drivers/power/reset/Kconfig +2 -3
@@ -39,7 +39,7 @@ config POWER_RESET_RESTART config POWER_RESET_VEXPRESS bool "ARM Versatile Express power-off and reset driver" - depends on ARM || ARM64 + depends on (ARM || ARM64) && ARCH_VEXPRESS depends on POWER_RESET && VEXPRESS_CONFIG help Power off and reset support for the ARM Ltd. Versatile
@@ -47,7 +47,6 @@ config POWER_RESET_VEXPRESS config POWER_RESET_XGENE bool "APM SoC X-Gene reset driver" - depends on ARM64 - depends on POWER_RESET + default y if (ARM64 && ARCH_XGENE && POWER_RESET) help Reboot support for the APM SoC X-Gene Eval boards.
drivers/power/reset/xgene-reboot.c +81 -13
142 lines not on this page · raw message
Signature · 1 line
1.7.6.1
PATCH 1/1 arm64: reboot driver missing dts entry and ACPI support for storm platform.
Quoted 1 line · Feng Kan
Signed-off-by Feng Kan <[email protected]>
Please provide patch description. it's also clear that this patch does more than one change. One patch per change, one change per patch.
Add the DTS info in one (and you haven't posted a binding for that compatible string, you have to do that).
The ACPI junk should be split up in separate changes too.
drivers/power/reset/Kconfig config POWER_RESET_RESTART · line 45
Quoted 13 lines
drivers/power/reset/Kconfig +1
-1@@ -39,7 +39,7 @@ config POWER_RESET_RESTART config POWER_RESET_VEXPRESS bool "ARM Versatile Express power-off and reset driver" - depends on ARM || ARM64 + depends on (ARM || ARM64) && ARCH_VEXPRESS depends on POWER_RESET && VEXPRESS_CONFIG help Power off and reset support for the ARM Ltd. Versatile
This seems completely unrelated to the rest of this patch. It fixes a bug, but please do it in a separate patch.
drivers/power/reset/Kconfig config POWER_RESET_VEXPRESS · line 50
Quoted 7 lines
drivers/power/reset/Kconfig +1
-2@@ -47,7 +47,6 @@ config POWER_RESET_VEXPRESS config POWER_RESET_XGENE bool "APM SoC X-Gene reset driver" - depends on ARM64 - depends on POWER_RESET + default y if (ARM64 && ARCH_XGENE && POWER_RESET)
Ick, no, don't do these kind of default y if (compex statement).
Quoted 14 lines
drivers/power/reset/xgene-reboot.c +2
-0@@ -30,6 +30,8 @@#include <linux/platform_device.h> #include <linux/stat.h> #include <linux/slab.h> +#include <linux/acpi.h> +#include <linux/efi.h> #include <asm/system_misc.h> struct xgene_reboot_context {
drivers/power/reset/xgene-reboot.c struct xgene_reboot_context { · line 48
Quoted 8 lines
drivers/power/reset/xgene-reboot.c +1
-1@@ -40,7 +42,7 @@ struct xgene_reboot_context {static struct xgene_reboot_context *xgene_restart_ctx; -static void xgene_restart (char str,const char *cmd) +static void xgene_restart (enum reboot_mode reboot_mode,const char *cmd) {struct xgene_reboot_context *ctx = xgene_restart_ctx;unsigned long timeout;
Unrelated change (but relevant fix)
Quoted 26 lines
drivers/power/reset/xgene-reboot.c +22
-0@@ -56,48 +58,114 @@ static void xgene_restart(char str, const char *cmd)dev_emerg (&ctx->pdev->dev,"Unable to restart system\n" ); } +static int xgene_reboot_get_resource (struct platform_device *pdev,int index, +struct resource *res) +{ +struct resource *regs; +if (efi_enabled (EFI_BOOT )) { + regs =platform_get_resource (pdev,IORESOURCE_MEM , index); +if (regs ==NULL ) +return -ENODEV ; + *res = *regs; +return 0 ; + } +return of_address_to_resource (pdev->dev.of_node, index, res); +} + +static int xgene_reboot_get_u32_param (struct platform_device *pdev, +const char *of_name,char *acpi_name, +u32 *param) +{ +#ifdef CONFIG_ACPI +if (efi_enabled (EFI_BOOT )) { +unsigned long long value; +acpi_status status;
drivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 92
Quoted 10 lines
drivers/power/reset/xgene-reboot.c +10
-0+if (acpi_name ==NULL ) +return -ENODEV ; + status =acpi_evaluate_integer (ACPI_HANDLE (&pdev->dev), + acpi_name,NULL , &value); +if (ACPI_FAILURE (status)) +return -ENODEV ; + *param = value; + return 0; + } +#endif
Why ifdef here when there's none above? Are there stubs missing in the acpi framework?
Quoted 4 lines
drivers/power/reset/xgene-reboot.c +4
-0+if (of_name ==NULL ) +return -ENODEV ; +return of_property_read_u32 (pdev->dev.of_node, of_name, param); +}
drivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 106
Quoted 10 lines
drivers/power/reset/xgene-reboot.c +7
-0+static int xgene_reboot_probe (struct platform_device *pdev) {struct xgene_reboot_context *ctx; +struct resource res; +int rc; + +/* Skip the ACPI probe if booting via DTS */ +if (!efi_enabled (EFI_BOOT ) && !pdev->dev.of_node) + goto error;
The comment and the code say two different things.
Quoted 30 lines
drivers/power/reset/xgene-reboot.c +14
-7+ + rc =xgene_reboot_get_resource (pdev,0 , &res); +if (rc) { +dev_err (&pdev->dev,"no resource address\n" ); + goto error; + } ctx =devm_kzalloc (&pdev->dev,sizeof (*ctx),GFP_KERNEL );if (!ctx) {dev_err (&pdev->dev,"out of memory for context\n" ); -return -ENODEV ; + goto error; } - ctx->csr =of_iomap (pdev->dev.of_node,0 ); + ctx->csr =devm_ioremap (&pdev->dev, res.start,resource_size (&res));if (!ctx->csr) { -devm_kfree (&pdev->dev, ctx); -dev_err (&pdev->dev,"can not map resource\n" ); -return -ENODEV ; +dev_err (&pdev->dev,"can't map CSR resource\n" ); + rc = -ENOMEM ; + goto error; } -if (of_property_read_u32 (pdev->dev.of_node,"mask" , &ctx->mask)) - ctx->mask =0xFFFFFFFF ; + ctx->mask =0x1 ; + +dev_info (&pdev->dev,"X-Gene register reboot driver\n" );
drivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 138
Quoted 10 lines
drivers/power/reset/xgene-reboot.c +4
-1ctx->pdev = pdev; arm_pm_restart = xgene_restart; xgene_restart_ctx = ctx; -return 0 ; + +error: +if (ctx->csr) +devm_iounmap (&pdev->dev, ctx->csr);
With devm, you don't have to worry about freeing, that's the whole beauty of it.
drivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 140
Quoted 2 lines
drivers/power/reset/xgene-reboot.c +2
-0+devm_kfree (&pdev->dev, ctx); +return rc;
For the first test with goto error, you will be returning an inititalized value of rc. Did you compile this code before posting it?
Quoted 4 lines
drivers/power/reset/xgene-reboot.c +0
-1}static struct of_device_id xgene_reboot_of_match[] = { - { .compatible ="apm,xgene-reboot" },
drivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 153
Quoted 10 lines
drivers/power/reset/xgene-reboot.c +7
-0+ {.compatible = "apm,xgene-reboot"}, {} }; +#ifdef CONFIG_ACPI +static const struct acpi_device_id xgene_reset_acpi_ids[] = { + {"APMC0D00" ,0 }, + {} +}; +#endif
Do you have to ifdef this?
drivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 162
Quoted 12 lines
drivers/power/reset/xgene-reboot.c +6
-3+static struct platform_driver xgene_reboot_driver = { .probe = xgene_reboot_probe, .driver = { - .name ="xgene-reboot" , - .of_match_table = xgene_reboot_of_match, - }, + .name ="xgene-reboot" , + .of_match_table = xgene_reboot_of_match, +#ifdef CONFIG_ACPI + .acpi_match_table =ACPI_PTR (xgene_reset_acpi_ids), +#endif
And this? It'll make for really cluttered drivers if we need this everywhere.
drivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 170
Quoted 8 lines
drivers/power/reset/xgene-reboot.c +2
-0+ } };static int __init xgene_reboot_init (void ) {return platform_driver_register (&xgene_reboot_driver); } +
Gratuitous whitespace change.
-Olof
PATCH 1/1 arm64: reboot driver missing dts entry and ACPI support for storm platform.
In reply to Feng Kandrivers/power/reset/xgene-reboot.c static void xgene_restart(char str, const char *cmd) · line 90
Quoted 12 lines · Feng Kan
drivers/power/reset/xgene-reboot.c +12
-0+#ifdef CONFIG_ACPI +if (efi_enabled (EFI_BOOT )) { +unsigned long long value; +acpi_status status; +if (acpi_name ==NULL ) +return -ENODEV ; + status =acpi_evaluate_integer (ACPI_HANDLE (&pdev->dev), + acpi_name,NULL , &value); +if (ACPI_FAILURE (status)) +return -ENODEV ; + *param = value; +return 0 ;
The normal way to handle reboots in ACPI is to provide register address and value information in the FADT. The firmware should populate this at init time, and then you don't need this driver at all.
Signature · 1 line
Matthew Garrett | mjg59 at srcf.ucam.org