From patchwork Wed Oct 10 12:07:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 10634457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CBDB69B1 for ; Wed, 10 Oct 2018 12:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5AC729A8D for ; Wed, 10 Oct 2018 12:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9BE229DEF; Wed, 10 Oct 2018 12:14:04 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 5DF1A29A8D for ; Wed, 10 Oct 2018 12:14:04 +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=gdnyCheWWfoyXV5MRR5OiZU/d0jEqK2DZNYZzQRcw+k=; b=ANwnHvNPMl3eVMJKCrg8XBorr+ bEqBGB4xKouoYKroQ4gUw4UdZoRpJUD3/fsv5R+X/YMLSUaIBlmGK+GfLOWhUxbayjK1NLvoZvGLd JDt1DDK8gNfGDfog+CzGTK1hlScQvr9DBjisKo+5cU/1L7M78pEiQgNmEjH2wHuohCz8fNX41AJ1/ c9kX1wvUdAsaFRQLl8xd5W64pVVzX8FMmbp/sTmi9DX9ZadbVcwKE9PH0eo5SzR2a8666C+4nJDll of0jXwQq1oewCyQOP9QitrCVoFbEyyBb12ftzrX0ygOYQ7JYBjV5+I7jt05TG5EUEyhsY54pMBUm3 KouyMZhw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gADNI-0002MN-HK; Wed, 10 Oct 2018 12:14:00 +0000 Received: from inva021.nxp.com ([92.121.34.21]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gADHX-0006uZ-AD for linux-arm-kernel@lists.infradead.org; Wed, 10 Oct 2018 12:08:18 +0000 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3956D200153; Wed, 10 Oct 2018 14:07:53 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2CCF720009A; Wed, 10 Oct 2018 14:07:53 +0200 (CEST) Received: from fsr-ub1864-101.ea.freescale.net (fsr-ub1864-101.ea.freescale.net [10.171.82.46]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 74F9620604; Wed, 10 Oct 2018 14:07:52 +0200 (CEST) From: laurentiu.tudor@nxp.com To: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, arm@kernel.org Subject: [PATCH v3 09/22] fsl/fman: backup and restore ICID registers Date: Wed, 10 Oct 2018 15:07:24 +0300 Message-Id: <20181010120737.30300-7-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010120737.30300-1-laurentiu.tudor@nxp.com> References: <20181010120737.30300-1-laurentiu.tudor@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181010_050803_642182_14DA2478 X-CRM114-Status: GOOD ( 10.95 ) 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: arnd@arndb.de, bharat.bhushan@nxp.com, madalin.bucur@nxp.com, shawnguo@kernel.org, roy.pledge@nxp.com, leoyang.li@nxp.com, robin.murphy@arm.com, davem@davemloft.net, Laurentiu Tudor 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: Laurentiu Tudor During probing, FMAN is reset thus losing all its register settings. Backup port ICID registers before reset and restore them after, similarly to how it's done on powerpc / PAMU based platforms. This also has the side effect of disabling the old code path (liodn backup/restore handling) that obviously make no sense in the context of SMMU on ARMs. Signed-off-by: Laurentiu Tudor Acked-by: Madalin Bucur --- drivers/net/ethernet/freescale/fman/fman.c | 35 +++++++++++++++++++++- drivers/net/ethernet/freescale/fman/fman.h | 4 +++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c index c415ac67cb7b..8f9136892d98 100644 --- a/drivers/net/ethernet/freescale/fman/fman.c +++ b/drivers/net/ethernet/freescale/fman/fman.c @@ -629,6 +629,7 @@ static void set_port_order_restoration(struct fman_fpm_regs __iomem *fpm_rg, iowrite32be(tmp, &fpm_rg->fmfp_prc); } +#ifdef CONFIG_PPC static void set_port_liodn(struct fman *fman, u8 port_id, u32 liodn_base, u32 liodn_ofst) { @@ -646,6 +647,27 @@ static void set_port_liodn(struct fman *fman, u8 port_id, iowrite32be(tmp, &fman->dma_regs->fmdmplr[port_id / 2]); iowrite32be(liodn_ofst, &fman->bmi_regs->fmbm_spliodn[port_id - 1]); } +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64) +static void save_restore_port_icids(struct fman *fman, bool save) +{ + int port_idxes[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, + 0xd, 0xe, 0xf, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x10, 0x11, 0x30, 0x31 + }; + int idx, i; + + for (i = 0; i < ARRAY_SIZE(port_idxes); i++) { + idx = port_idxes[i]; + if (save) + fman->sp_icids[idx] = + ioread32be(&fman->bmi_regs->fmbm_spliodn[idx]); + else + iowrite32be(fman->sp_icids[idx], + &fman->bmi_regs->fmbm_spliodn[idx]); + } +} +#endif static void enable_rams_ecc(struct fman_fpm_regs __iomem *fpm_rg) { @@ -1914,7 +1936,10 @@ static int fman_reset(struct fman *fman) static int fman_init(struct fman *fman) { struct fman_cfg *cfg = NULL; - int err = 0, i, count; + int err = 0, count; +#ifdef CONFIG_PPC + int i; +#endif if (is_init_done(fman->cfg)) return -EINVAL; @@ -1934,6 +1959,7 @@ static int fman_init(struct fman *fman) memset_io((void __iomem *)(fman->base_addr + CGP_OFFSET), 0, fman->state->fm_port_num_of_cg); +#ifdef CONFIG_PPC /* Save LIODN info before FMan reset * Skipping non-existent port 0 (i = 1) */ @@ -1953,6 +1979,9 @@ static int fman_init(struct fman *fman) } fman->liodn_base[i] = liodn_base; } +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64) + save_restore_port_icids(fman, true); +#endif err = fman_reset(fman); if (err) @@ -2181,8 +2210,12 @@ int fman_set_port_params(struct fman *fman, if (err) goto return_err; +#ifdef CONFIG_PPC set_port_liodn(fman, port_id, fman->liodn_base[port_id], fman->liodn_offset[port_id]); +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64) + save_restore_port_icids(fman, false); +#endif if (fman->state->rev_info.major < 6) set_port_order_restoration(fman->fpm_regs, port_id); diff --git a/drivers/net/ethernet/freescale/fman/fman.h b/drivers/net/ethernet/freescale/fman/fman.h index 935c317fa696..19f20fa58053 100644 --- a/drivers/net/ethernet/freescale/fman/fman.h +++ b/drivers/net/ethernet/freescale/fman/fman.h @@ -346,8 +346,12 @@ struct fman { unsigned long fifo_offset; size_t fifo_size; +#ifdef CONFIG_PPC u32 liodn_base[64]; u32 liodn_offset[64]; +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64) + u32 sp_icids[64]; +#endif struct fman_dts_params dts_params; };