Commit 0ef8e3bb authored by Tony Lindgren's avatar Tony Lindgren

bus: ti-sysc: Fix module register ioremap for larger offsets

We can have the interconnect target module control registers pretty
much anywhere within the module range. The current code attempts an
incomplete optimization of the ioremap size but does it wrong and
it only works for registers at the beginning of the module.

Let's just use the largest control register to calculate the ioremap
size. The ioremapped range is for most part cached anyways so there
is no need for size optimization. Let's also update the comments
accordingly.

Fixes: 0eecc636 ("bus: ti-sysc: Add minimal TI sysc interconnect
target driver")
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 1dbcb97c
...@@ -490,32 +490,29 @@ static int sysc_check_registers(struct sysc *ddata) ...@@ -490,32 +490,29 @@ static int sysc_check_registers(struct sysc *ddata)
/** /**
* syc_ioremap - ioremap register space for the interconnect target module * syc_ioremap - ioremap register space for the interconnect target module
* @ddata: deviec driver data * @ddata: device driver data
* *
* Note that the interconnect target module registers can be anywhere * Note that the interconnect target module registers can be anywhere
* within the first child device address space. For example, SGX has * within the interconnect target module range. For example, SGX has
* them at offset 0x1fc00 in the 32MB module address space. We just * them at offset 0x1fc00 in the 32MB module address space. And cpsw
* what we need around the interconnect target module registers. * has them at offset 0x1200 in the CPSW_WR child. Usually the
* the interconnect target module registers are at the beginning of
* the module range though.
*/ */
static int sysc_ioremap(struct sysc *ddata) static int sysc_ioremap(struct sysc *ddata)
{ {
u32 size = 0; int size;
if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
size = ddata->offsets[SYSC_SYSSTATUS];
else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
size = ddata->offsets[SYSC_SYSCONFIG];
else if (ddata->offsets[SYSC_REVISION] >= 0)
size = ddata->offsets[SYSC_REVISION];
else
return -EINVAL;
size &= 0xfff00; size = max3(ddata->offsets[SYSC_REVISION],
size += SZ_256; ddata->offsets[SYSC_SYSCONFIG],
ddata->offsets[SYSC_SYSSTATUS]);
if (size < 0 || (size + sizeof(u32)) > ddata->module_size)
return -EINVAL;
ddata->module_va = devm_ioremap(ddata->dev, ddata->module_va = devm_ioremap(ddata->dev,
ddata->module_pa, ddata->module_pa,
size); size + sizeof(u32));
if (!ddata->module_va) if (!ddata->module_va)
return -EIO; return -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment