Skip to content

Commit 5a04f32

Browse files
Roger Quadrosgregkh
authored andcommitted
ARM: OMAP2+: hwmod: Fix SOFTRESET logic
commit 313a76e upstream. In _ocp_softreset(), after _set_softreset() + write_sysconfig(), the hwmod's sysc_cache will always contain SOFTRESET bit set so all further writes to sysconfig using this cache will initiate a repeated SOFTRESET e.g. enable_sysc(). This is true for OMAP3 like platforms that have RESET_DONE status in the SYSSTATUS register and so the the SOFTRESET bit in SYSCONFIG is not automatically cleared. It is not a problem for OMAP4 like platforms that indicate RESET completion by clearing the SOFTRESET bit in the SYSCONFIG register. This repeated SOFTRESET is undesired and was the root cause of USB host issues on OMAP3 platforms when hwmod was allowed to do the SOFTRESET for the USB Host module. To fix this we clear the SOFTRESET bit and update the sysconfig register + sysc_cache using write_sysconfig(). Signed-off-by: Roger Quadros <rogerq@ti.com> Tested-by: Tomi Valkeinen <tomi.valkeinen@ti.com> # Panda, BeagleXM [paul@pwsan.com: renamed _clr_softreset() to _clear_softreset()] Signed-off-by: Paul Walmsley <paul@pwsan.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f5749e3 commit 5a04f32

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

‎arch/arm/mach-omap2/omap_hwmod.c‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
399399
}
400400

401401
/**
402-
* _set_softreset: set OCP_SYSCONFIG.CLOCKACTIVITY bits in @v
402+
* _set_softreset: set OCP_SYSCONFIG.SOFTRESET bit in @v
403403
* @oh: struct omap_hwmod *
404404
* @v: pointer to register contents to modify
405405
*
@@ -426,6 +426,36 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
426426
return 0;
427427
}
428428

429+
/**
430+
* _clear_softreset: clear OCP_SYSCONFIG.SOFTRESET bit in @v
431+
* @oh: struct omap_hwmod *
432+
* @v: pointer to register contents to modify
433+
*
434+
* Clear the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
435+
* error or 0 upon success.
436+
*/
437+
static int _clear_softreset(struct omap_hwmod *oh, u32 *v)
438+
{
439+
u32 softrst_mask;
440+
441+
if (!oh->class->sysc ||
442+
!(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))
443+
return -EINVAL;
444+
445+
if (!oh->class->sysc->sysc_fields) {
446+
WARN(1,
447+
"omap_hwmod: %s: sysc_fields absent for sysconfig class\n",
448+
oh->name);
449+
return -EINVAL;
450+
}
451+
452+
softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
453+
454+
*v &= ~softrst_mask;
455+
456+
return 0;
457+
}
458+
429459
/**
430460
* _wait_softreset_complete - wait for an OCP softreset to complete
431461
* @oh: struct omap_hwmod * to wait on
@@ -1909,6 +1939,12 @@ static int _ocp_softreset(struct omap_hwmod *oh)
19091939
ret = _set_softreset(oh, &v);
19101940
if (ret)
19111941
goto dis_opt_clks;
1942+
1943+
_write_sysconfig(v, oh);
1944+
ret = _clear_softreset(oh, &v);
1945+
if (ret)
1946+
goto dis_opt_clks;
1947+
19121948
_write_sysconfig(v, oh);
19131949

19141950
if (oh->class->sysc->srst_udelay)
@@ -3148,6 +3184,11 @@ int omap_hwmod_softreset(struct omap_hwmod *oh)
31483184
goto error;
31493185
_write_sysconfig(v, oh);
31503186

3187+
ret = _clear_softreset(oh, &v);
3188+
if (ret)
3189+
goto error;
3190+
_write_sysconfig(v, oh);
3191+
31513192
error:
31523193
return ret;
31533194
}

0 commit comments

Comments
 (0)