From patchwork Fri Oct 2 00:51:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loc Ho X-Patchwork-Id: 7312411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4161EBEEA4 for ; Fri, 2 Oct 2015 00:54:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D1FE207B6 for ; Fri, 2 Oct 2015 00:54:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E754207B1 for ; Fri, 2 Oct 2015 00:54:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhoaN-00081r-BK; Fri, 02 Oct 2015 00:52:31 +0000 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhoaJ-0007mO-2x for linux-arm-kernel@lists.infradead.org; Fri, 02 Oct 2015 00:52:28 +0000 Received: by pacfv12 with SMTP id fv12so91996203pac.2 for ; Thu, 01 Oct 2015 17:52:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=tvAs2f0ymQI18EolM53afni2qOw1E4c/0kmUDwzJnyc=; b=rebG4cSQwf3Zh9E/AyngRjIPSVAGloGaaNoNi5ooIZWdTh9nqIlJqMuAXeGgU+VUaV dK1iIyIU2zDP3YjQQblMtUEkFpmJ57oHgwV/+tYXUWpPg2Qf1GRwOB7eLDHzypZvoxMB lRkZbtSxmeDllb1EXkxNqiGHGfB5zsy+3frmw= 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; bh=tvAs2f0ymQI18EolM53afni2qOw1E4c/0kmUDwzJnyc=; b=BqY0N2ToLedEp9HRYm9Kh3/UC6ajgcR9XvVB4qiFTe7PWAQCSmPPXbIWxUBitUoeg7 K21Pu2poXBhn80jyTiNWac5/PnNXBYFgnttOgTUaQgtYO9ZZTiAIg3/7Td5DHMtVoqyw 55V2FcXvgfZeXtCszgKBxh5qxpntXO+SrWDJ93mbT77TqCmDgGu+3ShvALCMcNNqItcE Ewv4z3LzqaG6lGlNG+EcI8HjQSH+xDOSi4SKoOk1O7OYOW6ltDsf4+otIoHe4QPVAwR/ UDizR/sbesCxQ0J1OT8Bc8CU/NqqrqJgHU0s3JPqrYpJsI9F2x7NNiTwVJwkl6GQ9R5W uRUg== X-Gm-Message-State: ALoCoQn89RTQzPJrE0YzsMbewGdMXntFkySYjYilj5IS1osl5aFshwNs0gDjAqNh5Mb1us6FtaNW X-Received: by 10.66.163.228 with SMTP id yl4mr15977337pab.112.1443747125371; Thu, 01 Oct 2015 17:52:05 -0700 (PDT) Received: from localhost.localdomain ([198.137.200.11]) by smtp.gmail.com with ESMTPSA id pq1sm8954947pbb.91.2015.10.01.17.52.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 17:52:04 -0700 (PDT) From: Loc Ho To: dougthompson@xmission.com, bp@alien8.de, mchehab@osg.samsung.com, tomasz.nowicki@linaro.org, fu.wei@linaro.org Subject: [PATCH RFC] apei: xgene: Add ACPI APEI support for X-Gene Date: Thu, 1 Oct 2015 18:51:52 -0600 Message-Id: <1443747112-24814-1-git-send-email-lho@apm.com> X-Mailer: git-send-email 1.7.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151001_175227_212033_AE42BA8A X-CRM114-Status: GOOD ( 21.28 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jcm@redhat.com, patches@apm.com, Loc Ho , Tuan Phan , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 Add ACPI APEI support for X-Gene platform. This patch requires [1] to configiure and build. [1] http://marc.info/?l=linux-kernel&m=143955588312730&w=2 Signed-off-by: Tuan Phan Signed-off-by: Loc Ho --- drivers/edac/Kconfig | 7 +++ drivers/edac/Makefile | 2 + drivers/edac/xgene_apei.c | 120 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 0 deletions(-) create mode 100644 drivers/edac/xgene_apei.c diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index ef25000..f489852 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -390,4 +390,11 @@ config EDAC_XGENE Support for error detection and correction on the APM X-Gene family of SOCs. +config EDAC_XGENE_APEI + tristate "APM X-Gene SoC APEI" + depends on ACPI_APEI && (ARM64 || COMPILE_TEST) + help + APEI interface support for error detection and correction on the + APM X-Gene family of SOCs. + endif # EDAC diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile index dbf53e0..27dbae1 100644 --- a/drivers/edac/Makefile +++ b/drivers/edac/Makefile @@ -70,3 +70,5 @@ obj-$(CONFIG_EDAC_OCTEON_PCI) += octeon_edac-pci.o obj-$(CONFIG_EDAC_ALTERA_MC) += altera_edac.o obj-$(CONFIG_EDAC_SYNOPSYS) += synopsys_edac.o obj-$(CONFIG_EDAC_XGENE) += xgene_edac.o +obj-$(CONFIG_EDAC_XGENE_APEI) += xgene_apei.o + diff --git a/drivers/edac/xgene_apei.c b/drivers/edac/xgene_apei.c new file mode 100644 index 0000000..6ec416f --- /dev/null +++ b/drivers/edac/xgene_apei.c @@ -0,0 +1,120 @@ +/* + * AppliedMicro X-Gene APEI Driver + * + * Copyright (c) 2015, Applied Micro Circuits Corporation + * Author: Tuan Phan + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This driver provides the interrupt hook up with the UEFI FW for the X-Gene + * SoC processor under the following conditions: + * + * 1. No interrupt GPIO available or don't want to use one and no EL3 support + * 2. With EL3 support, but no mean to interrupt the Linux OS that an event + * has occurred. + * + */ +#include +#include +#include +#include + +#define AGENT_DB_STATUS_OFFSET 0x20 + +struct xgene_apei_dev { + void __iomem *csr_base; + struct device *dev; + u32 irq; + acpi_handle evt_handle; +}; + +static const struct acpi_device_id xgene_apei_acpi_match[] = { + { "APMC0D50", 0}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, xgene_apei_acpi_match); + +static irqreturn_t xgene_apei_irq_handler(int irq, void *data) +{ + struct xgene_apei_dev *ctx = (struct xgene_apei_dev *) data; + u32 val; + + /* Clear the interrupt */ + val = readl(ctx->csr_base + AGENT_DB_STATUS_OFFSET); + writel(val, ctx->csr_base + AGENT_DB_STATUS_OFFSET); + + /* Send error event */ + acpi_execute_simple_method(ctx->evt_handle, NULL, 0); + + return IRQ_HANDLED; +} + +static int xgene_apei_probe(struct platform_device *pdev) +{ + struct xgene_apei_dev *ctx; + struct resource *res; + acpi_handle evt_handle; + int rc; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->dev = &pdev->dev; + platform_set_drvdata(pdev, ctx); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ctx->csr_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(ctx->csr_base)) { + dev_err(&pdev->dev, "No CSR resource\n"); + return PTR_ERR(ctx->csr_base); + } + + ctx->irq = platform_get_irq(pdev, 0); + if (ctx->irq < 0) { + dev_err(&pdev->dev, "No IRQ resource\n"); + return ctx->irq; + } + + dev_dbg(&pdev->dev, "APM X-Gene APEI IRQ %d", ctx->irq); + + rc = devm_request_irq(&pdev->dev, ctx->irq, xgene_apei_irq_handler, 0, + dev_name(&pdev->dev), ctx); + if (rc) { + dev_err(&pdev->dev, "Could not request IRQ %d\n", ctx->irq); + return rc; + } + + if (!ACPI_SUCCESS(acpi_get_handle(ACPI_HANDLE(ctx->dev), "_EVT", + &evt_handle))) + return AE_BAD_PARAMETER; + + ctx->evt_handle = evt_handle; + + return rc; +} + +static struct platform_driver xgene_apei_driver = { + .probe = xgene_apei_probe, + .driver = { + .name = "xgene-apei", + .acpi_match_table = ACPI_PTR(xgene_apei_acpi_match), + }, +}; +module_platform_driver(xgene_apei_driver); + +MODULE_DESCRIPTION("APM X-Gene APEI driver"); +MODULE_AUTHOR("Tuan Phan "); +MODULE_LICENSE("GPL"); +MODULE_VERSION("0.1");