From patchwork Wed Sep 28 18:17:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fu Wei Fu X-Patchwork-Id: 77093 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp578033qgf; Wed, 28 Sep 2016 11:20:08 -0700 (PDT) X-Received: by 10.66.149.138 with SMTP id ua10mr60102523pab.146.1475086807959; Wed, 28 Sep 2016 11:20:07 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c73si9634842pfc.116.2016.09.28.11.20.07 for ; Wed, 28 Sep 2016 11:20:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753312AbcI1SUH (ORCPT ); Wed, 28 Sep 2016 14:20:07 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:36650 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932221AbcI1SSt (ORCPT ); Wed, 28 Sep 2016 14:18:49 -0400 Received: by mail-pa0-f49.google.com with SMTP id qn7so19058097pac.3 for ; Wed, 28 Sep 2016 11:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Y7ngvuEy0yrkczHL2WrPKaYY0jiRBEHGfGXso5rV2I=; b=MFG+KqnjxlZBQuqV0RFIRYMXJO1FXzXH4sqeMb932QnLzzwge0EvgQ3h92AgsIuFCX 0ha4sV8LbegtCyV4e1EqC3LzJ8UDDCKWf5LekWKee/5BoXb0dkG4Xkq7jV9Wqu8AyLOh B9lK3oTX9soMSKAxnuRCAFdDo1IJTSwwiLJCM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Y7ngvuEy0yrkczHL2WrPKaYY0jiRBEHGfGXso5rV2I=; b=DHTRrD5olkT2BMxsZlsrnuJeuo7K0fmaTptUYOXIvrUblrF79vCD6zE3byRJjt6jdu Z6nRQ3PEpBKNQuBQdwOM+UZuP/mpTf70kG3iBbVA3KeNL0RQolQqMhgWzfYgz9FNGulR p3PWt05O0QVajZ6e5CUYDsNU8sNP7QGY1GBGJRVNqQV17ZWFKkURPdblBjetsviAPFEw rpwQI26tKz7rrBSct80A5KAs96RcQEjPX6Vj0O3ZwErRD0MTz1st8e96MvNUa6JkKnbr 4fGEEEzQGQTRriUvS78cOTnKsHOM638ENEa8wQ/n2VXZCRnKmF883udBKgrNt3G2jKMq /qtQ== X-Gm-Message-State: AA6/9RkpdfyfptlfupM5uxj0krpkrX1b/sTpmRG2kW6W6/piLQUqC6m4EI4BrXk5hm74NQq1 X-Received: by 10.66.87.199 with SMTP id ba7mr8535221pab.177.1475086728314; Wed, 28 Sep 2016 11:18:48 -0700 (PDT) Received: from Rei-Ayanami.localdomain.localdomain ([67.238.99.186]) by smtp.googlemail.com with ESMTPSA id ak3sm14226365pad.19.2016.09.28.11.18.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Sep 2016 11:18:47 -0700 (PDT) From: fu.wei@linaro.org To: rjw@rjwysocki.net, lenb@kernel.org, daniel.lezcano@linaro.org, tglx@linutronix.de, marc.zyngier@arm.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, hanjun.guo@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linaro-acpi@lists.linaro.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, rruigrok@codeaurora.org, harba@codeaurora.org, cov@codeaurora.org, timur@codeaurora.org, graeme.gregory@linaro.org, al.stone@linaro.org, jcm@redhat.com, wei@redhat.com, arnd@arndb.de, catalin.marinas@arm.com, will.deacon@arm.com, Suravee.Suthikulpanit@amd.com, leo.duran@amd.com, wim@iguana.be, linux@roeck-us.net, linux-watchdog@vger.kernel.org, tn@semihalf.com, christoffer.dall@linaro.org, julien.grall@arm.com, Fu Wei Subject: [PATCH v14 9/9] acpi/arm64: Add SBSA Generic Watchdog support in GTDT driver Date: Thu, 29 Sep 2016 02:17:17 +0800 Message-Id: <1475086637-1914-10-git-send-email-fu.wei@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475086637-1914-1-git-send-email-fu.wei@linaro.org> References: <1475086637-1914-1-git-send-email-fu.wei@linaro.org> MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Fu Wei This driver adds support for parsing SBSA Generic Watchdog timer in GTDT, parse all info in SBSA Generic Watchdog Structure in GTDT, and creating a platform device with that information. This allows the operating system to obtain device data from the resource of platform device. The platform device named "sbsa-gwdt" can be used by the ARM SBSA Generic Watchdog driver. Signed-off-by: Fu Wei Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/gtdt.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/watchdog/Kconfig | 1 + 2 files changed, 88 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/arm64/gtdt.c b/drivers/acpi/arm64/gtdt.c index b6021db..6d9fdd3 100644 --- a/drivers/acpi/arm64/gtdt.c +++ b/drivers/acpi/arm64/gtdt.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -220,3 +221,89 @@ int __init gtdt_arch_timer_mem_init(struct gt_block_data *data) return index; } + +/* + * Initialize a SBSA generic Watchdog platform device info from GTDT + */ +static int __init gtdt_import_sbsa_gwdt(struct acpi_gtdt_watchdog *wd, + int index) +{ + struct platform_device *pdev; + int irq = map_gt_gsi(wd->timer_interrupt, wd->timer_flags); + int no_irq = 1; + + /* + * According to SBSA specification the size of refresh and control + * frames of SBSA Generic Watchdog is SZ_4K(Offset 0x000 – 0xFFF). + */ + struct resource res[] = { + DEFINE_RES_MEM(wd->control_frame_address, SZ_4K), + DEFINE_RES_MEM(wd->refresh_frame_address, SZ_4K), + DEFINE_RES_IRQ(irq), + }; + + pr_debug("found a Watchdog (0x%llx/0x%llx gsi:%u flags:0x%x).\n", + wd->refresh_frame_address, wd->control_frame_address, + wd->timer_interrupt, wd->timer_flags); + + if (!(wd->refresh_frame_address && wd->control_frame_address)) { + pr_err(FW_BUG "failed to get the Watchdog base address.\n"); + return -EINVAL; + } + + if (!wd->timer_interrupt) + pr_warn(FW_BUG "failed to get the Watchdog interrupt.\n"); + else if (irq <= 0) + pr_warn("failed to map the Watchdog interrupt.\n"); + else + no_irq = 0; + + /* + * Add a platform device named "sbsa-gwdt" to match the platform driver. + * "sbsa-gwdt": SBSA(Server Base System Architecture) Generic Watchdog + * The platform driver (like drivers/watchdog/sbsa_gwdt.c)can get device + * info below by matching this name. + */ + pdev = platform_device_register_simple("sbsa-gwdt", index, res, + ARRAY_SIZE(res) - no_irq); + if (IS_ERR(pdev)) { + acpi_unregister_gsi(wd->timer_interrupt); + return PTR_ERR(pdev); + } + + return 0; +} + +static int __init gtdt_sbsa_gwdt_init(void) +{ + struct acpi_table_header *table; + void *platform_timer; + int index = 0; + int ret; + + if (acpi_disabled) + return 0; + + if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_GTDT, 0, &table))) + return -EINVAL; + + ret = acpi_gtdt_init(table); + if (ret <= 0) + return ret; + + for_each_platform_timer(platform_timer) { + if (!is_watchdog(platform_timer)) + continue; + ret = gtdt_import_sbsa_gwdt(platform_timer, index); + if (ret) + break; + index++; + } + + if (index) + pr_info("found %d SBSA generic Watchdog(s).\n", index); + + return ret; +} + +device_initcall(gtdt_sbsa_gwdt_init); diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 1bffe00..341964a 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -205,6 +205,7 @@ config ARM_SBSA_WATCHDOG tristate "ARM SBSA Generic Watchdog" depends on ARM64 depends on ARM_ARCH_TIMER + depends on ACPI_GTDT || !ACPI select WATCHDOG_CORE help ARM SBSA Generic Watchdog has two stage timeouts: