From patchwork Fri Aug 4 12:00:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 9881175 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 E2BBE603F4 for ; Fri, 4 Aug 2017 12:25:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6E03289D1 for ; Fri, 4 Aug 2017 12:25:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A83D5289D3; Fri, 4 Aug 2017 12:25:32 +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=unavailable 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 2FEEB289DA for ; Fri, 4 Aug 2017 12:25:30 +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: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:In-Reply-To: References:List-Owner; bh=RQqajn65QyLZrIG/l9UWD6ZWxc3Ll0u12SWBjzQ9SVs=; b=oIZ mDyKmX/SpSrqMNhe9DJifmXP/DpXipyaFM38xkfpU/3os3+Mkxp+CovRtjZCzmAXOGzGHV314j/Tw YJ0oVcDShMOfQSAMr6lHKf/AVI8c2EvaCJ5m2tqRUzA7nbZivclDvrKAQZXdM/a5wISUKXKlS4VPm iAKQced8BhU/wAq5EIoFZn35+EiE6fVXjAeYQlf7P/3rbuVjHMDz0bRt+wToYDVyIzlnFqVNPlCq9 qb6wu85Tusr/hqN0S2o0upCueIyS/z6fbbB47WLTmi0Fkbg/tjxvm/15vLKVVS7C5CJhs13XI3x+m yXKtudNILup6wYSx4VWI3P5u4ND/weQ==; 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 1ddbfF-0002Vz-RA; Fri, 04 Aug 2017 12:25:13 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddbHg-0002Xb-0S for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2017 12:01:10 +0000 Received: by mail-wr0-x242.google.com with SMTP id 12so2853782wrb.4 for ; Fri, 04 Aug 2017 05:00:30 -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; bh=O004JLiy6da1EOahzlWlx1RtwxOsFpvvwTfFXmYRuDU=; b=QhE3wTzCwX1pbnee+qZLiutSfrQGAVe/Ph11XmoHG3mXbPIqYFEI77CMlM10+dMLG1 jGYq000UpWsqHrQZz2kmDODbL0MwXNg5zEw9HHbJlwG6NCGuFI4bp8a7WgPL85vlN/iV PvxSeijwirTZqmaioi1RpnLn1zMhLcD0599jlKuvPo6BIdrgYHN7N1E6EwKfcecQ5S7+ IgGBPov0mrtDHBibowhAqlfQH5Re2iFAYzIe4UsVG3LZtm57AArEmw94POQaNJ4oLuvl /pqOsZ2DkeAmiFIKHxhXt4zK83SF11Ku8RA1lPFaTc3tjVAHZqq/yU1h81CFdMk7YjF7 mIeg== 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; bh=O004JLiy6da1EOahzlWlx1RtwxOsFpvvwTfFXmYRuDU=; b=AqxBFrbhrk62jyKMGARwFI/VY23OY4FpHXKLiFrPBmZLUYbTcjEx/YDsMXBQP7ysgU sfrdI6dOeAMbl2BPfKbEpC7vtjkYqW3z7s38L/6lOHXqgqkxb677M2WT8Y1RU0Oz6Ikx oyYsb7RMRU+13QzZBsk4tCpFS7GAGmYr8lG78wpCNv7ZZ/d84bY1X03xXAgf9lJwvocl k9CnfkEYE9DGw9Djw5HcKbi81+HK+QBno8Hp4kmgFo+3lgjoXYSVNhMX04hOkIfAhTHP 4XlGvTCuwolslN+HG0PTET4KMejL6U3Dzek3EP2/DduHy9Jx+aCntry1s0i15hiXnaBb 7/Nw== X-Gm-Message-State: AIVw112wtVQUNpQ9ShjxAa483WVe7MwnDOh8kMGm/r4oypdYI9rjjo5z dej1m9V/H/0rD+a7 X-Received: by 10.223.167.73 with SMTP id e9mr1451205wrd.205.1501848029367; Fri, 04 Aug 2017 05:00:29 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id c34sm7021940wra.80.2017.08.04.05.00.28 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 04 Aug 2017 05:00:28 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH 1/5] edac: synopsys: Add platform specific structures ddrc controller Date: Fri, 4 Aug 2017 14:00:23 +0200 Message-Id: <60ff19f90adfd252cf296fe8988c614c4c3e43fd.1501848023.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170804_050053_091162_EEE2AC52 X-CRM114-Status: GOOD ( 16.99 ) 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 This patch 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 --- 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 1c01dec78ec3..65f3b04d5a87 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 + * @synps_edac_geterror_info: function pointer to synps edac error info + * @synps_edac_get_mtype: function pointer to synps edac mtype + * @synps_edac_get_dtype: function pointer to synps edac dtype + * @synps_edac_get_eccstate: function pointer to synps edac eccstate + * @quirks: to differentiate IPs + */ +struct synps_platform_data { + int (*synps_edac_geterror_info)(void __iomem *base, + struct synps_ecc_status *p); + enum mem_type (*synps_edac_get_mtype)(const void __iomem *base); + enum dev_type (*synps_edac_get_dtype)(const void __iomem *base); + bool (*synps_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->synps_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->synps_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->synps_edac_get_dtype( + priv->baseaddr); } } @@ -424,6 +450,21 @@ static int synps_edac_mc_init(struct mem_ctl_info *mci, return status; } +static const struct synps_platform_data zynq_edac_def = { + .synps_edac_geterror_info = synps_edac_geterror_info, + .synps_edac_get_mtype = synps_edac_get_mtype, + .synps_edac_get_dtype = synps_edac_get_dtype, + .synps_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 @@ -441,13 +482,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->synps_edac_get_eccstate(baseaddr))) { edac_printk(KERN_INFO, EDAC_MC, "ECC not enabled\n"); return -ENXIO; } @@ -469,6 +519,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, @@ -487,7 +539,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: @@ -512,13 +565,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",