aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/bus/ti-sysc.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 80d60f43db56..b31bf03ea497 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -490,32 +490,29 @@ static int sysc_check_registers(struct sysc *ddata)
490 490
491/** 491/**
492 * syc_ioremap - ioremap register space for the interconnect target module 492 * syc_ioremap - ioremap register space for the interconnect target module
493 * @ddata: deviec driver data 493 * @ddata: device driver data
494 * 494 *
495 * Note that the interconnect target module registers can be anywhere 495 * Note that the interconnect target module registers can be anywhere
496 * within the first child device address space. For example, SGX has 496 * within the interconnect target module range. For example, SGX has
497 * them at offset 0x1fc00 in the 32MB module address space. We just 497 * them at offset 0x1fc00 in the 32MB module address space. And cpsw
498 * what we need around the interconnect target module registers. 498 * has them at offset 0x1200 in the CPSW_WR child. Usually the
499 * the interconnect target module registers are at the beginning of
500 * the module range though.
499 */ 501 */
500static int sysc_ioremap(struct sysc *ddata) 502static int sysc_ioremap(struct sysc *ddata)
501{ 503{
502 u32 size = 0; 504 int size;
503
504 if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
505 size = ddata->offsets[SYSC_SYSSTATUS];
506 else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
507 size = ddata->offsets[SYSC_SYSCONFIG];
508 else if (ddata->offsets[SYSC_REVISION] >= 0)
509 size = ddata->offsets[SYSC_REVISION];
510 else
511 return -EINVAL;
512 505
513 size &= 0xfff00; 506 size = max3(ddata->offsets[SYSC_REVISION],
514 size += SZ_256; 507 ddata->offsets[SYSC_SYSCONFIG],
508 ddata->offsets[SYSC_SYSSTATUS]);
509
510 if (size < 0 || (size + sizeof(u32)) > ddata->module_size)
511 return -EINVAL;
515 512
516 ddata->module_va = devm_ioremap(ddata->dev, 513 ddata->module_va = devm_ioremap(ddata->dev,
517 ddata->module_pa, 514 ddata->module_pa,
518 size); 515 size + sizeof(u32));
519 if (!ddata->module_va) 516 if (!ddata->module_va)
520 return -EIO; 517 return -EIO;
521 518