MLK-17674-2: CAAM SM : get base address from device tree

Remove hard coded value for base physical address.
Use device tree to get this value.

i.MX8 with seco is still not address since CAAM uses a private bus
to access secure memory

Signed-off-by: Silvano di Ninno <silvano.dininno@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
This commit is contained in:
Silvano di Ninno 2018-03-16 14:48:10 +01:00 committed by Leonard Crestez
parent de710d376a
commit cfcae64743
3 changed files with 20 additions and 4 deletions

View File

@ -305,6 +305,7 @@ static int caam_probe(struct platform_device *pdev)
};
struct device *dev;
struct device_node *nprop, *np;
struct resource res_regs;
struct caam_ctrl __iomem *ctrl;
struct caam_drv_private *ctrlpriv;
u32 comp_params;
@ -381,11 +382,25 @@ static int caam_probe(struct platform_device *pdev)
goto disable_clocks;
}
ctrlpriv->sm_base = of_iomap(np, 0);
/* Get CAAM SM registers base address from device tree */
ret = of_address_to_resource(np, 0, &res_regs);
if (ret) {
dev_err(dev, "failed to retrieve registers base from device tree\n");
ret = -ENODEV;
goto disable_clocks;
}
ctrlpriv->sm_phy = res_regs.start;
ctrlpriv->sm_base = devm_ioremap_resource(dev, &res_regs);
if (IS_ERR(ctrlpriv->sm_base)) {
ret = PTR_ERR(ctrlpriv->sm_base);
goto disable_clocks;
}
if (!of_machine_is_compatible("fsl,imx8mq") &&
!of_machine_is_compatible("fsl,imx8qm") &&
!of_machine_is_compatible("fsl,imx8qxp")) {
ctrlpriv->sm_size = 0x3fff;
ctrlpriv->sm_size = resource_size(&res_regs);
} else {
ctrlpriv->sm_size = PG_SIZE_64K;
}

View File

@ -92,6 +92,7 @@ struct caam_drv_private {
struct caam_queue_if __iomem *qi; /* QI control region */
struct caam_job_ring __iomem *jr[JOBR_MAX_COUNT]; /* JRs registers */
dma_addr_t __iomem *sm_base; /* Secure memory storage base */
phys_addr_t sm_phy; /* Secure memory storage physical */
u32 sm_size;
/*

View File

@ -1124,8 +1124,8 @@ int caam_sm_startup(struct platform_device *pdev)
lpagedesc[page].pg_phys = (u8 *)0x20800000 +
(smpriv->page_size * page);
} else {
/* FIXME: get base address from platform property... */
lpagedesc[page].pg_phys = (u8 *)0x00100000 +
lpagedesc[page].pg_phys =
(u8 *) ctrlpriv->sm_phy +
(smpriv->page_size * page);
}
lpagect++;