From patchwork Mon Aug 7 07:39:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 9884577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 870EC602CC for ; Mon, 7 Aug 2017 07:40:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7948A28592 for ; Mon, 7 Aug 2017 07:40:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E189285C4; Mon, 7 Aug 2017 07:40:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF7C5285B7 for ; Mon, 7 Aug 2017 07:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=18w+aHeWGUZIoCGq/XBdI2XIU3EjSlapqXEmyvcWr2s=; b=jCBeXJu6ekcCdus2eQ8U1auR6C iZGAX96SxOwk8XLd1vUmi2/LpKbI1sidKnLQK4Kw2SAXCfy042RPTZaRMSRGnKdv8Gu4oAOysJ4Zo 2qzeNFPZsbd4xxNTB07vzgSVB55lxZ+1gGomXhXF8X0NthgQ0pCYrjVWNj10RGo45YWjj9Ffg0WFK xO7eD07pVnnP2ONiwDarkf/OxmCddUJVNgBFev/XyQ1ONqDRmcSyASnRHOViA+06wLdG2/cgq7/jm djatSZTtuHGRuF/J7NJzbdB3sReObRMWPUADVnhCfDk3X3HVUXyew4ajKwCwvG/glnPgMQxvc/H5Y ZPE83DLg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1deceB-0001Yp-8a; Mon, 07 Aug 2017 07:40:19 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1decdo-0000Hn-KC for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2017 07:39:59 +0000 Received: by mail-wm0-x241.google.com with SMTP id q189so55730wmd.0 for ; Mon, 07 Aug 2017 00:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=bXCrl2wul+AU/+ORD6a1F5GEz006yOJqmghNiDIlm/Y=; b=RZWjEPGqfEkFiDUul4sCsZi+XlzeF01A/sALnqJO6VmLBJeAkvgLunHIvTjo82QApJ cEOWq0st2QqYRa7j3lpEepVFfuEOsWeXCi8ZTc8zFrCqJVbvEqYzAOrXnTxmgfk2JByD E/sML9/LZXSFiYcEcy2HzDgeSPNgsx6kbmpWLUuQrwbDfAjCKSeqFbDuzpWVKi1PmVKw hz7k7nFvztKO5YD7FFwEZ+1kYKmLp/EPJj7Frk5z18JlnlHe+XO0CpZWxUHLnPwG0kpY C88WKOJIXfQoHG9J3BXmlbe3Fo3vAAhIa7UvjcZnx4EMXu5odynq4D4wnMT/wpdPV4R+ X1Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=bXCrl2wul+AU/+ORD6a1F5GEz006yOJqmghNiDIlm/Y=; b=KEObOz09C4HD6wTGHp6DQUie02V68He+Qj8b4w/Met8qPQHe21+KVoTgz9+5KruJgE 9yibGPiXdhaI0AeTrsrJFiB4zXzwCVElKwy8yBzAn/j5hyvByPw2piYIPB3Z9k8ddUme Q8vWyz6MrTeq3Bj7jwa498yvEY7ZiBGJFhoVrluPkWUUwKgqwJIA7oB1HHALDs1WE7Qo mkmGOhMfgh9c2UzhI8PM59IPNZSB5JoBDlyeQBPW9HYyOqlYvZ1oMxDVxvEiN0z8TJi5 rl78+uz6hi39UKkzemT1h4jHifDyWz+VatDRhh4XuLu1XCrcKBxtC7ifkoH244g/iZtr NuhQ== X-Gm-Message-State: AHYfb5jRf7WDpZsF08ICIRTMLeErosp1o2Db89M1FW+TeZKrIotCDQV1 fvM/gFTx3U32IUGm X-Received: by 10.28.154.211 with SMTP id c202mr14558wme.91.1502091574451; Mon, 07 Aug 2017 00:39:34 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 141sm8562673wmh.45.2017.08.07.00.39.33 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 07 Aug 2017 00:39:33 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH v2 2/6] edac: synopsys: Add platform specific structures for ddrc controller Date: Mon, 7 Aug 2017 09:39:24 +0200 Message-Id: <6c72eae7c1fbfd2b96d5dc1c7feb251bdbe3e591.1502091561.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <91fd6532076e4c905b5a228d852bba4941c54a28.1502091561.git.michal.simek@xilinx.com> References: <91fd6532076e4c905b5a228d852bba4941c54a28.1502091561.git.michal.simek@xilinx.com> In-Reply-To: <91fd6532076e4c905b5a228d852bba4941c54a28.1502091561.git.michal.simek@xilinx.com> References: <91fd6532076e4c905b5a228d852bba4941c54a28.1502091561.git.michal.simek@xilinx.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170807_003956_940100_B706FEC8 X-CRM114-Status: GOOD ( 19.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Naga Sureshkumar Relli , Borislav Petkov , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , Mauro Carvalho Chehab , 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-Virus-Scanned: ClamAV using ClamSMTP From: Naga Sureshkumar Relli Adds platform specific structures, so that we can add different IP support later using quirks. Signed-off-by: Naga Sureshkumar Relli Signed-off-by: Michal Simek --- Changes in v2: - Update commit message - Update patch subject - Update kernel-doc description for struct synps_platform_data - Change synps_platform_data pointer names and update code drivers/edac/synopsys_edac.c | 70 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c index 0c9c59e2b5a3..293380f884fe 100644 --- a/drivers/edac/synopsys_edac.c +++ b/drivers/edac/synopsys_edac.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "edac_module.h" @@ -95,6 +96,9 @@ #define SCRUB_MODE_MASK 0x7 #define SCRUB_MODE_SECDED 0x4 +/* DDR ECC Quirks */ +#define DDR_ECC_INTR_SUPPORT BIT(0) + /** * struct ecc_error_info - ECC error log information * @row: Row number @@ -130,6 +134,7 @@ struct synps_ecc_status { * @baseaddr: Base address of the DDR controller * @message: Buffer for framing the event specific info * @stat: ECC status information + * @p_data: Pointer to platform data * @ce_cnt: Correctable Error count * @ue_cnt: Uncorrectable Error count */ @@ -137,11 +142,29 @@ struct synps_edac_priv { void __iomem *baseaddr; char message[SYNPS_EDAC_MSG_SIZE]; struct synps_ecc_status stat; + const struct synps_platform_data *p_data; u32 ce_cnt; u32 ue_cnt; }; /** + * struct synps_platform_data - synps platform data structure + * @edac_geterror_info: function which returns the current ecc error info + * @edac_get_mtype: function which returns the memory type + * @edac_get_dtype: function which returns the DIMM type + * @edac_get_eccstate: function which returns the ecc enable/disable status + * @quirks: a bitfield of quirks + */ +struct synps_platform_data { + int (*edac_geterror_info)(void __iomem *base, + struct synps_ecc_status *p); + enum mem_type (*edac_get_mtype)(const void __iomem *base); + enum dev_type (*edac_get_dtype)(const void __iomem *base); + bool (*edac_get_eccstate)(void __iomem *base); + int quirks; +}; + +/** * synps_edac_geterror_info - Get the current ecc error info * @base: Pointer to the base address of the ddr memory controller * @p: Pointer to the synopsys ecc status structure @@ -242,7 +265,8 @@ static void synps_edac_check(struct mem_ctl_info *mci) struct synps_edac_priv *priv = mci->pvt_info; int status; - status = synps_edac_geterror_info(priv->baseaddr, &priv->stat); + status = priv->p_data->edac_geterror_info(priv->baseaddr, + &priv->stat); if (status) return; @@ -372,10 +396,12 @@ static int synps_edac_init_csrows(struct mem_ctl_info *mci) for (j = 0; j < csi->nr_channels; j++) { dimm = csi->channels[j]->dimm; dimm->edac_mode = EDAC_FLAG_SECDED; - dimm->mtype = synps_edac_get_mtype(priv->baseaddr); + dimm->mtype = priv->p_data->edac_get_mtype( + priv->baseaddr); dimm->nr_pages = (size >> PAGE_SHIFT) / csi->nr_channels; dimm->grain = SYNPS_EDAC_ERR_GRAIN; - dimm->dtype = synps_edac_get_dtype(priv->baseaddr); + dimm->dtype = priv->p_data->edac_get_dtype( + priv->baseaddr); } } @@ -423,6 +449,21 @@ static int synps_edac_mc_init(struct mem_ctl_info *mci, return status; } +static const struct synps_platform_data zynq_edac_def = { + .edac_geterror_info = synps_edac_geterror_info, + .edac_get_mtype = synps_edac_get_mtype, + .edac_get_dtype = synps_edac_get_dtype, + .edac_get_eccstate = synps_edac_get_eccstate, + .quirks = 0, +}; + +static const struct of_device_id synps_edac_match[] = { + { .compatible = "xlnx,zynq-ddrc-a05", .data = (void *)&zynq_edac_def }, + { /* end of table */ } +}; + +MODULE_DEVICE_TABLE(of, synps_edac_match); + /** * synps_edac_mc_probe - Check controller and bind driver * @pdev: Pointer to the platform_device struct @@ -440,13 +481,22 @@ static int synps_edac_mc_probe(struct platform_device *pdev) int rc; struct resource *res; void __iomem *baseaddr; + const struct of_device_id *match; + const struct synps_platform_data *p_data; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); baseaddr = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(baseaddr)) return PTR_ERR(baseaddr); - if (!synps_edac_get_eccstate(baseaddr)) { + match = of_match_node(synps_edac_match, pdev->dev.of_node); + if (!match && !match->data) { + dev_err(&pdev->dev, "of_match_node() failed\n"); + return -EINVAL; + } + + p_data = (struct synps_platform_data *)match->data; + if (!(p_data->edac_get_eccstate(baseaddr))) { edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n"); return -ENXIO; } @@ -468,6 +518,8 @@ static int synps_edac_mc_probe(struct platform_device *pdev) priv = mci->pvt_info; priv->baseaddr = baseaddr; + priv->p_data = match->data; + rc = synps_edac_mc_init(mci, pdev); if (rc) { edac_printk(KERN_ERR, EDAC_MC, @@ -486,7 +538,8 @@ static int synps_edac_mc_probe(struct platform_device *pdev) * Start capturing the correctable and uncorrectable errors. A write of * 0 starts the counters. */ - writel(0x0, baseaddr + ECC_CTRL_OFST); + if (!(priv->p_data->quirks & DDR_ECC_INTR_SUPPORT)) + writel(0x0, baseaddr + ECC_CTRL_OFST); return rc; free_edac_mc: @@ -511,13 +564,6 @@ static int synps_edac_mc_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id synps_edac_match[] = { - { .compatible = "xlnx,zynq-ddrc-a05", }, - { /* end of table */ } -}; - -MODULE_DEVICE_TABLE(of, synps_edac_match); - static struct platform_driver synps_edac_mc_driver = { .driver = { .name = "synopsys-edac",