Use SCP core init code, which resets the SCP core, as a SCP core stop. Once stop is invoked, the SCP core is reset and ready to be loaded with new software, which is practical for SCP firwmare development.
Signed-off-by: Marek Vasut <[email protected]> --- Cc: Nobuhiro Iwamatsu <[email protected]> Cc: Tom Rini <[email protected]> Cc: [email protected] --- drivers/remoteproc/renesas_rsip.c | 79 +++++++++++++++---------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/drivers/remoteproc/renesas_rsip.c b/drivers/remoteproc/renesas_rsip.c index cbf999e88f2..96f3bf77eb8 100644 --- a/drivers/remoteproc/renesas_rsip.c +++ b/drivers/remoteproc/renesas_rsip.c @@ -169,6 +169,42 @@ static int renesas_rsip_rproc_load(struct udevice *dev, ulong addr, ulong size) return 0; } +/** + * renesas_rsip_rproc_init() - Initialize the remote processor + * @dev: corresponding remote processor device + * + * Return: 0 if all went ok, else corresponding -ve error + */ +static int renesas_rsip_rproc_init(struct udevice *dev) +{ + struct renesas_rsip_rproc_privdata *priv = dev_get_priv(dev); + struct reset_ctl *rst = dev_get_priv(dev->parent); + u32 addr; + + if (priv->core_id != 0) /* No init for non-SCP cores */ + return 0; + + /* + * Put SCP into reset, configure SCP entry point address and systick + * timer, release SCP from reset, and zero out SCP STCM regions. + */ + reset_assert(rst); + + writel(SCP_STCM, SCP_CFGVECTABLE); + writel(SCP_CFGNSSTCALIB_13_3MHZ, SCP_CFGNSSTCALIB); + setbits_le32(SCP_CPUWAIT, SCP_CPUWAIT_WAIT); + + reset_deassert(rst); + + /* Fill zero to SCP STCM regions 0 ... 27 */ + for (addr = SCP_STCM; addr < 0xc1061b00; addr += 8) + writeq(0, addr); + + asm volatile("dsb sy"); + + return 0; +} + /** * renesas_rsip_rproc_start() - Start the remote processor * @dev: corresponding remote processor device @@ -211,9 +247,9 @@ static int renesas_rsip_rproc_stop(struct udevice *dev) { struct renesas_rsip_rproc_privdata *priv = dev_get_priv(dev); - if (priv->core_id == 0) { /* SCP */ - setbits_le32(SCP_CPUWAIT, SCP_CPUWAIT_WAIT); - return 0; + if (priv->core_id == 0) { + /* SCP */ + return renesas_rsip_rproc_init(dev); } return 0; @@ -244,43 +280,6 @@ static int renesas_rsip_rproc_is_running(struct udevice *dev) return 1; } -/** - * renesas_rsip_rproc_init() - Initialize the remote processor - * @dev: corresponding remote processor device - * - * Return: 0 if all went ok, else corresponding -ve error - */ -static int renesas_rsip_rproc_init(struct udevice *dev) -{ - struct renesas_rsip_rproc_privdata *priv = dev_get_priv(dev); - struct reset_ctl *rst = dev_get_priv(dev->parent); - u32 addr; - - if (priv->core_id != 0) /* No init for non-SCP cores */ - return 0; - - /* - * Put SCP into reset, configure SCP entry point address and systick - * timer, release SCP from reset, and zero out SCP STCM regions. - */ - - reset_assert(rst); - - writel(SCP_STCM, SCP_CFGVECTABLE); - writel(SCP_CFGNSSTCALIB_13_3MHZ, SCP_CFGNSSTCALIB); - setbits_le32(SCP_CPUWAIT, SCP_CPUWAIT_WAIT); - - reset_deassert(rst); - - /* Fill zero to SCP STCM regions 0 ... 27 */ - for (addr = SCP_STCM; addr < 0xc1061b00; addr += 8) - writeq(0, addr); - - asm volatile("dsb sy"); - - return 0; -} - /** * renesas_rsip_rproc_device_to_virt() - Convert device address to virtual address * @dev: corresponding remote processor device -- 2.53.0
