From ef2b0593c906a85ca59ed5957ae7a7361974349c Mon Sep 17 00:00:00 2001 From: Laurentiu Tudor Date: Tue, 6 Feb 2018 16:21:17 +0200 Subject: [PATCH] fsl/fman: backup and restore ICID registers 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(-) --- a/drivers/net/ethernet/freescale/fman/fman.c +++ b/drivers/net/ethernet/freescale/fman/fman.c @@ -634,6 +634,7 @@ static void set_port_order_restoration(s 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) { @@ -651,6 +652,27 @@ static void set_port_liodn(struct fman * 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) { @@ -1918,7 +1940,10 @@ _return: 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; @@ -1938,6 +1963,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) */ @@ -1957,6 +1983,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) @@ -2185,8 +2214,12 @@ int fman_set_port_params(struct fman *fm 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); --- a/drivers/net/ethernet/freescale/fman/fman.h +++ b/drivers/net/ethernet/freescale/fman/fman.h @@ -347,8 +347,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; };