From patchwork Fri Nov 8 19:13:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Kan X-Patchwork-Id: 3159391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 85A7C9F461 for ; Fri, 8 Nov 2013 19:14:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CB4420119 for ; Fri, 8 Nov 2013 19:14:26 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 450FB200E1 for ; Fri, 8 Nov 2013 19:14:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VerVc-000388-Tq; Fri, 08 Nov 2013 19:14:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VerVa-0003W2-Da; Fri, 08 Nov 2013 19:14:18 +0000 Received: from [192.195.68.30] (helo=denmail01.apm.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VerVX-0003V1-HI for linux-arm-kernel@lists.infradead.org; Fri, 08 Nov 2013 19:14:16 +0000 Received: from amcc.com (svdclab154.amcc.com [10.66.12.74]) by denmail01.apm.com (8.13.8/8.13.8) with ESMTP id rA8JDcZM019202; Fri, 8 Nov 2013 12:13:39 -0700 Received: (from fkan@localhost) by amcc.com (8.13.8/8.12.2/Submit) id rA8JDaSj015344; Fri, 8 Nov 2013 11:13:36 -0800 From: Feng Kan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: reboot driver missing dts entry and ACPI support for storm platform. Date: Fri, 8 Nov 2013 11:13:30 -0800 Message-Id: <1383938010-15296-1-git-send-email-fkan@apm.com> X-Mailer: git-send-email 1.7.6.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131108_141415_673252_3E92A2A4 X-CRM114-Status: GOOD ( 17.24 ) X-Spam-Score: -1.1 (-) Cc: fkan@apm.com, ksankaran@apm.com, Catalin.Marinas@arm.com, lho@apm.com, jcm@redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Feng Kan --- 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(-) diff --git a/arch/arm64/boot/dts/apm-storm.dtsi b/arch/arm64/boot/dts/apm-storm.dtsi index bfdc578..4478bee 100644 --- a/arch/arm64/boot/dts/apm-storm.dtsi +++ b/arch/arm64/boot/dts/apm-storm.dtsi @@ -112,5 +112,10 @@ interrupt-parent = <&gic>; interrupts = <0x0 0x4c 0x4>; }; + + reboot@17000014 { + compatible = "apm,xgene-reboot"; + reg = <0x0 0x17000014 0x0 0x4>; + }; }; }; diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 9b3ea53..84883bc 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -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. diff --git a/drivers/power/reset/xgene-reboot.c b/drivers/power/reset/xgene-reboot.c index ecd55f8..856fed1 100644 --- a/drivers/power/reset/xgene-reboot.c +++ b/drivers/power/reset/xgene-reboot.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include struct xgene_reboot_context { @@ -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; @@ -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; + 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 + if (of_name == NULL) + return -ENODEV; + return of_property_read_u32(pdev->dev.of_node, of_name, param); +} + 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; + + 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"); ctx->pdev = pdev; arm_pm_restart = xgene_restart; xgene_restart_ctx = ctx; - return 0; + +error: + if (ctx->csr) + devm_iounmap(&pdev->dev, ctx->csr); + devm_kfree(&pdev->dev, ctx); + return rc; } static struct of_device_id xgene_reboot_of_match[] = { - { .compatible = "apm,xgene-reboot" }, + {.compatible = "apm,xgene-reboot"}, {} }; +#ifdef CONFIG_ACPI +static const struct acpi_device_id xgene_reset_acpi_ids[] = { + {"APMC0D00", 0}, + {} +}; +#endif + 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 + } }; static int __init xgene_reboot_init(void) { return platform_driver_register(&xgene_reboot_driver); } + device_initcall(xgene_reboot_init);