From: Ioana Ciornei <[email protected]>

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 struture.

Signed-off-by: Ioana Ciornei <[email protected]>
Signed-off-by: Vladimir Oltean <[email protected]>
---
v1->v2: none
---
 drivers/soc/fsl/guts.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
index f87ee47c1503..a0a52a5603a5 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,18 +202,17 @@ 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(&regs->svr);
+       soc.little_endian = of_property_read_bool(np, "little-endian");
+       if (soc.little_endian)
+               svr = ioread32(&soc.dcfg_ccsr->svr);
        else
-               svr = ioread32be(&regs->svr);
-       iounmap(regs);
+               svr = ioread32be(&soc.dcfg_ccsr->svr);
        of_node_put(np);
 
        /* Register soc device */
@@ -263,6 +265,8 @@ static int __init fsl_guts_init(void)
 
 err_nomem:
        ret = -ENOMEM;
+
+       iounmap(soc.dcfg_ccsr);
 err:
        kfree(soc_dev_attr->family);
        kfree(soc_dev_attr->soc_id);
-- 
2.34.1


Reply via email to