Commit 1bc28b34 authored by Tero Kristo's avatar Tero Kristo Committed by Tony Lindgren

ARM: OMAP2+: PRM: add generic API for checking hardreset status

PRM driver now has a generic API for checking hardreset status. SoC
specific support functions are registered through the prm_ll_data.
Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
Acked-by: default avatarPaul Walmsley <paul@pwsan.com>
Tested-by: default avatarNishanth Menon <nm@ti.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 37fb59d7
...@@ -2951,8 +2951,8 @@ static int _omap2_deassert_hardreset(struct omap_hwmod *oh, ...@@ -2951,8 +2951,8 @@ static int _omap2_deassert_hardreset(struct omap_hwmod *oh,
static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh, static int _omap2_is_hardreset_asserted(struct omap_hwmod *oh,
struct omap_hwmod_rst_info *ohri) struct omap_hwmod_rst_info *ohri)
{ {
return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs, return omap_prm_is_hardreset_asserted(ohri->st_shift, 0,
ohri->st_shift); oh->prcm.omap2.module_offs, 0);
} }
/** /**
...@@ -3024,10 +3024,11 @@ static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh, ...@@ -3024,10 +3024,11 @@ static int _omap4_is_hardreset_asserted(struct omap_hwmod *oh,
if (!oh->clkdm) if (!oh->clkdm)
return -EINVAL; return -EINVAL;
return omap4_prminst_is_hardreset_asserted(ohri->rst_shift, return omap_prm_is_hardreset_asserted(ohri->rst_shift,
oh->clkdm->pwrdm.ptr->prcm_partition, oh->clkdm->pwrdm.ptr->
oh->clkdm->pwrdm.ptr->prcm_offs, prcm_partition,
oh->prcm.omap4.rstctrl_offs); oh->clkdm->pwrdm.ptr->prcm_offs,
oh->prcm.omap4.rstctrl_offs);
} }
/** /**
...@@ -3087,9 +3088,9 @@ static int _am33xx_deassert_hardreset(struct omap_hwmod *oh, ...@@ -3087,9 +3088,9 @@ static int _am33xx_deassert_hardreset(struct omap_hwmod *oh,
static int _am33xx_is_hardreset_asserted(struct omap_hwmod *oh, static int _am33xx_is_hardreset_asserted(struct omap_hwmod *oh,
struct omap_hwmod_rst_info *ohri) struct omap_hwmod_rst_info *ohri)
{ {
return am33xx_prm_is_hardreset_asserted(ohri->rst_shift, return omap_prm_is_hardreset_asserted(ohri->rst_shift, 0,
oh->clkdm->pwrdm.ptr->prcm_offs, oh->clkdm->pwrdm.ptr->prcm_offs,
oh->prcm.omap4.rstctrl_offs); oh->prcm.omap4.rstctrl_offs);
} }
/* Public functions */ /* Public functions */
......
...@@ -152,6 +152,7 @@ extern int prm_unregister(struct prm_ll_data *pld); ...@@ -152,6 +152,7 @@ extern int prm_unregister(struct prm_ll_data *pld);
int omap_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, u16 offset); int omap_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, u16 offset);
int omap_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 prm_mod, int omap_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 prm_mod,
u16 offset, u16 st_offset); u16 offset, u16 st_offset);
int omap_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset);
extern u32 prm_read_reset_sources(void); extern u32 prm_read_reset_sources(void);
extern bool prm_was_any_context_lost_old(u8 part, s16 inst, u16 idx); extern bool prm_was_any_context_lost_old(u8 part, s16 inst, u16 idx);
extern void prm_clear_context_loss_flags_old(u8 part, s16 inst, u16 idx); extern void prm_clear_context_loss_flags_old(u8 part, s16 inst, u16 idx);
......
...@@ -214,6 +214,7 @@ static struct prm_ll_data omap2xxx_prm_ll_data = { ...@@ -214,6 +214,7 @@ static struct prm_ll_data omap2xxx_prm_ll_data = {
.read_reset_sources = &omap2xxx_prm_read_reset_sources, .read_reset_sources = &omap2xxx_prm_read_reset_sources,
.assert_hardreset = &omap2_prm_assert_hardreset, .assert_hardreset = &omap2_prm_assert_hardreset,
.deassert_hardreset = &omap2_prm_deassert_hardreset, .deassert_hardreset = &omap2_prm_deassert_hardreset,
.is_hardreset_asserted = &omap2_prm_is_hardreset_asserted,
}; };
int __init omap2xxx_prm_init(void) int __init omap2xxx_prm_init(void)
......
...@@ -24,14 +24,16 @@ ...@@ -24,14 +24,16 @@
/** /**
* omap2_prm_is_hardreset_asserted - read the HW reset line state of * omap2_prm_is_hardreset_asserted - read the HW reset line state of
* submodules contained in the hwmod module * submodules contained in the hwmod module
* @prm_mod: PRM submodule base (e.g. CORE_MOD)
* @shift: register bit shift corresponding to the reset line to check * @shift: register bit shift corresponding to the reset line to check
* @part: PRM partition, ignored for OMAP2
* @prm_mod: PRM submodule base (e.g. CORE_MOD)
* @offset: register offset, ignored for OMAP2
* *
* Returns 1 if the (sub)module hardreset line is currently asserted, * Returns 1 if the (sub)module hardreset line is currently asserted,
* 0 if the (sub)module hardreset line is not currently asserted, or * 0 if the (sub)module hardreset line is not currently asserted, or
* -EINVAL if called while running on a non-OMAP2/3 chip. * -EINVAL if called while running on a non-OMAP2/3 chip.
*/ */
int omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift) int omap2_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset)
{ {
return omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL, return omap2_prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL,
(1 << shift)); (1 << shift));
......
...@@ -100,7 +100,7 @@ static inline u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx) ...@@ -100,7 +100,7 @@ static inline u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
} }
/* These omap2_ PRM functions apply to both OMAP2 and 3 */ /* These omap2_ PRM functions apply to both OMAP2 and 3 */
extern int omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift); int omap2_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset);
int omap2_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, int omap2_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod,
u16 offset); u16 offset);
int omap2_prm_deassert_hardreset(u8 rst_shift, u8 st_shift, u8 part, int omap2_prm_deassert_hardreset(u8 rst_shift, u8 st_shift, u8 part,
......
...@@ -52,6 +52,7 @@ u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx) ...@@ -52,6 +52,7 @@ u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx)
* am33xx_prm_is_hardreset_asserted - read the HW reset line state of * am33xx_prm_is_hardreset_asserted - read the HW reset line state of
* submodules contained in the hwmod module * submodules contained in the hwmod module
* @shift: register bit shift corresponding to the reset line to check * @shift: register bit shift corresponding to the reset line to check
* @part: PRM partition, ignored for AM33xx
* @inst: CM instance register offset (*_INST macro) * @inst: CM instance register offset (*_INST macro)
* @rstctrl_offs: RM_RSTCTRL register address offset for this module * @rstctrl_offs: RM_RSTCTRL register address offset for this module
* *
...@@ -59,7 +60,8 @@ u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx) ...@@ -59,7 +60,8 @@ u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx)
* 0 if the (sub)module hardreset line is not currently asserted, or * 0 if the (sub)module hardreset line is not currently asserted, or
* -EINVAL upon parameter error. * -EINVAL upon parameter error.
*/ */
int am33xx_prm_is_hardreset_asserted(u8 shift, s16 inst, u16 rstctrl_offs) static int am33xx_prm_is_hardreset_asserted(u8 shift, u8 part, s16 inst,
u16 rstctrl_offs)
{ {
u32 v; u32 v;
...@@ -121,7 +123,7 @@ static int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part, ...@@ -121,7 +123,7 @@ static int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part,
u32 mask = 1 << st_shift; u32 mask = 1 << st_shift;
/* Check the current status to avoid de-asserting the line twice */ /* Check the current status to avoid de-asserting the line twice */
if (am33xx_prm_is_hardreset_asserted(shift, inst, rstctrl_offs) == 0) if (am33xx_prm_is_hardreset_asserted(shift, 0, inst, rstctrl_offs) == 0)
return -EEXIST; return -EEXIST;
/* Clear the reset status by writing 1 to the status bit */ /* Clear the reset status by writing 1 to the status bit */
...@@ -133,7 +135,7 @@ static int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part, ...@@ -133,7 +135,7 @@ static int am33xx_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part,
am33xx_prm_rmw_reg_bits(mask, 0, inst, rstctrl_offs); am33xx_prm_rmw_reg_bits(mask, 0, inst, rstctrl_offs);
/* wait the status to be set */ /* wait the status to be set */
omap_test_timeout(am33xx_prm_is_hardreset_asserted(st_shift, inst, omap_test_timeout(am33xx_prm_is_hardreset_asserted(st_shift, 0, inst,
rstst_offs), rstst_offs),
MAX_MODULE_HARDRESET_WAIT, c); MAX_MODULE_HARDRESET_WAIT, c);
...@@ -351,6 +353,7 @@ struct pwrdm_ops am33xx_pwrdm_operations = { ...@@ -351,6 +353,7 @@ struct pwrdm_ops am33xx_pwrdm_operations = {
static struct prm_ll_data am33xx_prm_ll_data = { static struct prm_ll_data am33xx_prm_ll_data = {
.assert_hardreset = am33xx_prm_assert_hardreset, .assert_hardreset = am33xx_prm_assert_hardreset,
.deassert_hardreset = am33xx_prm_deassert_hardreset, .deassert_hardreset = am33xx_prm_deassert_hardreset,
.is_hardreset_asserted = am33xx_prm_is_hardreset_asserted,
}; };
int __init am33xx_prm_init(void) int __init am33xx_prm_init(void)
......
...@@ -122,8 +122,6 @@ extern u32 am33xx_prm_read_reg(s16 inst, u16 idx); ...@@ -122,8 +122,6 @@ extern u32 am33xx_prm_read_reg(s16 inst, u16 idx);
extern void am33xx_prm_write_reg(u32 val, s16 inst, u16 idx); extern void am33xx_prm_write_reg(u32 val, s16 inst, u16 idx);
extern u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx); extern u32 am33xx_prm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx);
extern void am33xx_prm_global_warm_sw_reset(void); extern void am33xx_prm_global_warm_sw_reset(void);
extern int am33xx_prm_is_hardreset_asserted(u8 shift, s16 inst,
u16 rstctrl_offs);
int am33xx_prm_init(void); int am33xx_prm_init(void);
#endif /* ASSEMBLER */ #endif /* ASSEMBLER */
......
...@@ -666,6 +666,7 @@ static struct prm_ll_data omap3xxx_prm_ll_data = { ...@@ -666,6 +666,7 @@ static struct prm_ll_data omap3xxx_prm_ll_data = {
.late_init = &omap3xxx_prm_late_init, .late_init = &omap3xxx_prm_late_init,
.assert_hardreset = &omap2_prm_assert_hardreset, .assert_hardreset = &omap2_prm_assert_hardreset,
.deassert_hardreset = &omap2_prm_deassert_hardreset, .deassert_hardreset = &omap2_prm_deassert_hardreset,
.is_hardreset_asserted = &omap2_prm_is_hardreset_asserted,
}; };
int __init omap3xxx_prm_init(void) int __init omap3xxx_prm_init(void)
......
...@@ -690,6 +690,7 @@ static struct prm_ll_data omap44xx_prm_ll_data = { ...@@ -690,6 +690,7 @@ static struct prm_ll_data omap44xx_prm_ll_data = {
.late_init = &omap44xx_prm_late_init, .late_init = &omap44xx_prm_late_init,
.assert_hardreset = omap4_prminst_assert_hardreset, .assert_hardreset = omap4_prminst_assert_hardreset,
.deassert_hardreset = omap4_prminst_deassert_hardreset, .deassert_hardreset = omap4_prminst_deassert_hardreset,
.is_hardreset_asserted = omap4_prminst_is_hardreset_asserted,
}; };
int __init omap44xx_prm_init(void) int __init omap44xx_prm_init(void)
......
...@@ -466,6 +466,26 @@ int omap_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 prm_mod, ...@@ -466,6 +466,26 @@ int omap_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 prm_mod,
offset, st_offset); offset, st_offset);
} }
/**
* omap_prm_is_hardreset_asserted - check the hardreset status for an IP block
* @shift: register bit shift corresponding to the reset line
* @part: PRM partition
* @prm_mod: PRM submodule base or instance offset
* @offset: register offset
*
* Checks if a hardware reset line for an IP block is enabled or not.
*/
int omap_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset)
{
if (!prm_ll_data->is_hardreset_asserted) {
WARN_ONCE(1, "prm: %s: no mapping function defined\n",
__func__);
return -EINVAL;
}
return prm_ll_data->is_hardreset_asserted(shift, part, prm_mod, offset);
}
/** /**
* prm_register - register per-SoC low-level data with the PRM * prm_register - register per-SoC low-level data with the PRM
* @pld: low-level per-SoC OMAP PRM data & function pointers to register * @pld: low-level per-SoC OMAP PRM data & function pointers to register
......
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