mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
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 <ioana.ciornei@nxp.com> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> 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) <chleroy@kernel.org>
This commit is contained in:
parent
450e2f6a53
commit
c559ba052a
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user