Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1565455ybb; Fri, 29 Mar 2019 07:04:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyZGIC8qcrKFAso3N2+IUu44oZENmM7DBIyN+w6pPxAhzyxF8BZHJp/Wg0DD2TfCUL3W5e X-Received: by 2002:a63:2e87:: with SMTP id u129mr24428981pgu.321.1553868246906; Fri, 29 Mar 2019 07:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553868246; cv=none; d=google.com; s=arc-20160816; b=CKtZh2HTOL59qZe7YBRDTmPx0HXwwtnenSL5yFawAut8Nm3U0mxM7PC08BlrtxAlHK //pWua+eoQdwteQ7NeeTa0nPt8uhIR8S7SvpddW/8fncr2fapzFCmxfG4NMN4wUjwFtZ Q1TnB8EqKqvRp5GDDWE1B3khzGzwcrn7iH6mfEvJwqzr1MTWwyOzGG7r6+yK2U772sWm vnK4HeGczA8VJg+JUVx+ZSKDOhFRoRCJGqttsuPyxYMN7K5Evt+kZn6JY8J15bDJ8wsv jhMdJ6TVLlAlkmgCLx0YPg0oJJ1TZW3mmD9mGiONFBagEAL+3kwkLE2nKVVlbPzMD5VT Ie9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7hmY/yw5g+4uYrQoefetsK6comdJwRwmTHWjGjiqFog=; b=nTu38Y58/CDSNFL1b0WrVnTNcckZXkUNQVWDEAefLjZDh3Ru0v1noY6qVmGCc5hWqn kgjd4fCpjhOXQOV9BbGZTi2ahzaueMCq3noRT7b19CY255fttXaon1DdLZxJdc/4uLUS nzN1ELNF7kIbd2g/muymMdLDl1CMeXIrsRA86Ulvt3ZQr+OqUSNJA1qd8WB8o2wvxq2S 790I0fkqtxQ9VLwFBMmbKCqa0Gej0QsayF5cB1Qgj/QNNNgKLhHXxOsAW2LkvMd2leFl NQSimAK1fCFkEiDz7wqulyH0Pco4jjUh+I+wnSqDNXCQqot860e1QBMVHuwx9g1wbitc yp4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p11si1928888pgl.526.2019.03.29.07.03.50; Fri, 29 Mar 2019 07:04:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729754AbfC2OBP (ORCPT + 99 others); Fri, 29 Mar 2019 10:01:15 -0400 Received: from inva021.nxp.com ([92.121.34.21]:60148 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728720AbfC2OAY (ORCPT ); Fri, 29 Mar 2019 10:00:24 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 041062002E9; Fri, 29 Mar 2019 15:00:22 +0100 (CET) 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 EB71F200270; Fri, 29 Mar 2019 15:00:21 +0100 (CET) Received: from fsr-ub1864-101.ea.freescale.net (fsr-ub1864-101.ea.freescale.net [10.171.74.120]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 37BBE20606; Fri, 29 Mar 2019 15:00:21 +0100 (CET) From: laurentiu.tudor@nxp.com To: netdev@vger.kernel.org, madalin.bucur@nxp.com, roy.pledge@nxp.com, camelia.groza@nxp.com, leoyang.li@nxp.com Cc: davem@davemloft.net, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Laurentiu Tudor Subject: [PATCH 07/13] fsl/fman: backup and restore ICID registers Date: Fri, 29 Mar 2019 16:00:08 +0200 Message-Id: <20190329140014.8126-8-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190329140014.8126-1-laurentiu.tudor@nxp.com> References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 e80fedb27cee..ae833e215b74 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; }; -- 2.17.1