From c559ba052a6f73e921e37a988eb48a40a4ea0947 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Wed, 22 Jul 2026 02:15:57 +0300 Subject: [PATCH] soc: fsl: guts: add a global structure to hold state Add the fsl_soc_guts structure in order to pass information like base addresses, endianness etc between the init time and the runtime operations (RCW override) which will get added in future patches. There is no point in mapping and unmapping the DCFG CCSR space every time we need to make a read, just map it once and keep its reference in this new global structure. Signed-off-by: Ioana Ciornei Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20260721231603.67865-4-vladimir.oltean@nxp.com [chleroy: fixed typo on 'structure' in commit message] Signed-off-by: Christophe Leroy (CS GROUP) --- drivers/soc/fsl/guts.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index b97eb80cea95..bb65b62ed805 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -106,6 +106,11 @@ static const struct fsl_soc_die_attr fsl_soc_die[] = { { }, }; +static struct fsl_soc_guts { + struct ccsr_guts __iomem *dcfg_ccsr; + bool little_endian; +} soc; + static const struct fsl_soc_die_attr *fsl_soc_die_match( u32 svr, const struct fsl_soc_die_attr *matches) { @@ -187,9 +192,7 @@ static int __init fsl_guts_init(void) const struct fsl_soc_die_attr *soc_die; const struct fsl_soc_data *soc_data; const struct of_device_id *match; - struct ccsr_guts __iomem *regs; struct device_node *np; - bool little_endian; u64 soc_uid = 0; u32 svr; int ret; @@ -199,24 +202,25 @@ static int __init fsl_guts_init(void) return 0; soc_data = match->data; - regs = of_iomap(np, DCFG_CCSR); - if (!regs) { + soc.dcfg_ccsr = of_iomap(np, DCFG_CCSR); + if (!soc.dcfg_ccsr) { of_node_put(np); return -ENOMEM; } - little_endian = of_property_read_bool(np, "little-endian"); - if (little_endian) - svr = ioread32(®s->svr); + soc.little_endian = of_property_read_bool(np, "little-endian"); + if (soc.little_endian) + svr = ioread32(&soc.dcfg_ccsr->svr); else - svr = ioread32be(®s->svr); - iounmap(regs); + svr = ioread32be(&soc.dcfg_ccsr->svr); of_node_put(np); /* Register soc device */ soc_dev_attr = kzalloc_obj(*soc_dev_attr); - if (!soc_dev_attr) - return -ENOMEM; + if (!soc_dev_attr) { + ret = -ENOMEM; + goto err_unmap_dcfg_ccsr; + } ret = soc_attr_read_machine(soc_dev_attr); if (ret) @@ -276,6 +280,9 @@ static int __init fsl_guts_init(void) kfree(soc_dev_attr->family); err_free_soc_dev_attr: kfree(soc_dev_attr); +err_unmap_dcfg_ccsr: + iounmap(soc.dcfg_ccsr); + soc.dcfg_ccsr = NULL; return ret; }