2009-04-28 22:21:52 +07:00
|
|
|
/*
|
|
|
|
* Secondary CPU startup routine source file.
|
|
|
|
*
|
2014-04-23 02:40:39 +07:00
|
|
|
* Copyright (C) 2009-2014 Texas Instruments, Inc.
|
2009-04-28 22:21:52 +07:00
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Santosh Shilimkar <santosh.shilimkar@ti.com>
|
|
|
|
*
|
|
|
|
* Interface functions needed for the SMP. This file is based on arm
|
|
|
|
* realview smp platform.
|
|
|
|
* Copyright (c) 2003 ARM Limited.
|
|
|
|
*
|
|
|
|
* This program is free software,you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
ARM: OMAP4460: Workaround for ROM bug because of CA9 r2pX GIC control register change.
On OMAP4+ devices, GIC register context is lost when MPUSS hits
the OSWR(Open Switch Retention). On the CPU wakeup path, ROM code
gets executed and one of the steps in it is to restore the
saved context of the GIC. The ROM Code GIC distributor restoration
is split in two parts: CPU specific register done by each CPU and
common register done by only one CPU.
Below is the abstract flow.
...............................................................
- MPUSS in OSWR state.
- CPU0 wakes up on the event(interrupt) and start executing ROM code.
[..]
- CPU0 executes "GIC Restoration:"
[...]
- CPU0 swicthes to non-secure mode and jumps to OS resume code.
[...]
- CPU0 is online in OS
- CPU0 enables the GIC distributor. GICD.Enable Non-secure = 1
- CPU0 wakes up CPU1 with clock-domain force wakeup method.
- CPU0 continues it's execution.
[..]
- CPU1 wakes up and start executing ROM code.
[..]
- CPU1 executes "GIC Restoration:"
[..]
- CPU1 swicthes to non-secure mode and jumps to OS resume code.
[...]
- CPU1 is online in OS and start executing.
[...] -
GIC Restoration: /* Common routine for HS and GP devices */
{
if (GICD != 1) { /* This will be true in OSWR state */
if (GIC_SAR_BACKUP_STATE == SAVED)
- CPU restores GIC distributor
else
- reconfigure GIC distributor to boot values.
GICD.Enable secure = 1
}
if (GIC_SAR_BACKUP_STATE == SAVED)
- CPU restore its GIC CPU interface registers if saved.
else
- reconfigure its GIC CPU interface registers to boot
values.
}
...............................................................
So as mentioned in the flow, GICD != 1 condition decides how
the GIC registers are handled in ROM code wakeup path from
OSWR. As evident from the flow, ROM code relies on the entire
GICD register value and not specific register bits.
The assumption was valid till CortexA9 r1pX version since there
was only one banked bit to control secure and non-secure GICD.
Secure view which ROM code sees:
bit 0 == Enable Non-secure
Non-secure view which HLOS sees:
bit 0 == Enable secure
But GICD register has changed between CortexA9 r1pX and r2pX.
On r2pX GICD register is composed of 2 bits.
Secure view which ROM code sees:
bit 1 == Enable Non-secure
bit 0 == Enable secure
Non-secure view which HLOS sees:
bit 0 == Enable Non-secure
Hence on OMAP4460(r2pX) devices, if you go through the
above flow again during CPU1 wakeup, GICD == 3 and hence
ROM code fails to understand the real wakeup power state
and reconfigures GIC distributor to boot values. This is
nasty since you loose the entire interrupt controller
context in a live system.
The ROM code fix done on next OMAP4 device (OMAP4470 - r2px) is to
check "GICD.Enable secure != 1" for GIC restoration in OSWR wakeup path.
Since ROM code can't be fixed on OMAP4460 devices, a work around
needs to be implemented. As evident from the flow, as long as
CPU1 sees GICD == 1 in it's wakeup path from OSWR, the issue
won't happen. Below is the flow with the work-around.
...............................................................
- MPUSS in OSWR state.
- CPU0 wakes up on the event(interrupt) and start executing ROM code.
[..]
- CPU0 executes "GIC Restoration:"
[..]
- CPU0 swicthes to non-secure mode and jumps to OS resume code.
[..]
- CPU0 is online in OS.
- CPU0 does GICD.Enable Non-secure = 0
- CPU0 wakes up CPU1 with clock domain force wakeup method.
- CPU0 waits for GICD.Enable Non-secure = 1
- CPU0 coninues it's execution.
[..]
- CPU1 wakes up and start executing ROM code.
[..]
- CPU1 executes "GIC Restoration:"
[..]
- CPU1 swicthes to non-secure mode and jumps to OS resume code.
[..]
- CPU1 is online in OS
- CPU1 does GICD.Enable Non-secure = 1
- CPU1 start executing
[...]
...............................................................
With this procedure, the GIC configuration done between the
CPU0 wakeup and CPU1 wakeup will not be lost but during this
short windows, the CPU0 will not receive interrupts.
The BUG is applicable to only OMAP4460(r2pX) devices.
OMAP4470 (also r2pX) is not affected by this bug because
ROM code has been fixed.
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
2012-10-18 16:20:05 +07:00
|
|
|
#include "omap44xx.h"
|
|
|
|
|
2012-03-19 20:59:41 +07:00
|
|
|
/* Physical address needed since MMU not enabled yet on secondary core */
|
|
|
|
#define AUX_CORE_BOOT0_PA 0x48281800
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OMAP5 specific entry point for secondary CPU to jump from ROM
|
|
|
|
* code. This routine also provides a holding flag into which
|
|
|
|
* secondary core is held until we're ready for it to initialise.
|
|
|
|
* The primary core will update this flag using a hardware
|
2014-04-23 02:40:39 +07:00
|
|
|
* register AuxCoreBoot0.
|
2012-03-19 20:59:41 +07:00
|
|
|
*/
|
|
|
|
ENTRY(omap5_secondary_startup)
|
|
|
|
wait: ldr r2, =AUX_CORE_BOOT0_PA @ read from AuxCoreBoot0
|
|
|
|
ldr r0, [r2]
|
|
|
|
mov r0, r0, lsr #5
|
|
|
|
mrc p15, 0, r4, c0, c0, 5
|
|
|
|
and r4, r4, #0x0f
|
|
|
|
cmp r0, r4
|
|
|
|
bne wait
|
|
|
|
b secondary_startup
|
2014-04-30 09:53:47 +07:00
|
|
|
ENDPROC(omap5_secondary_startup)
|
2009-04-28 22:21:52 +07:00
|
|
|
/*
|
|
|
|
* OMAP4 specific entry point for secondary CPU to jump from ROM
|
|
|
|
* code. This routine also provides a holding flag into which
|
|
|
|
* secondary core is held until we're ready for it to initialise.
|
2009-12-12 07:16:35 +07:00
|
|
|
* The primary core will update this flag using a hardware
|
|
|
|
* register AuxCoreBoot0.
|
2009-04-28 22:21:52 +07:00
|
|
|
*/
|
2013-04-05 19:59:02 +07:00
|
|
|
ENTRY(omap4_secondary_startup)
|
2009-12-12 07:16:35 +07:00
|
|
|
hold: ldr r12,=0x103
|
|
|
|
dsb
|
2010-04-07 14:47:21 +07:00
|
|
|
smc #0 @ read from AuxCoreBoot0
|
2009-12-12 07:16:35 +07:00
|
|
|
mov r0, r0, lsr #9
|
|
|
|
mrc p15, 0, r4, c0, c0, 5
|
|
|
|
and r4, r4, #0x0f
|
|
|
|
cmp r0, r4
|
2009-04-28 22:21:52 +07:00
|
|
|
bne hold
|
|
|
|
|
|
|
|
/*
|
2009-12-12 07:16:35 +07:00
|
|
|
* we've been released from the wait loop,secondary_stack
|
2009-04-28 22:21:52 +07:00
|
|
|
* should now contain the SVC stack for this core
|
|
|
|
*/
|
|
|
|
b secondary_startup
|
2013-04-05 19:59:02 +07:00
|
|
|
ENDPROC(omap4_secondary_startup)
|
2009-04-28 22:21:52 +07:00
|
|
|
|
2013-04-05 19:59:02 +07:00
|
|
|
ENTRY(omap4460_secondary_startup)
|
ARM: OMAP4460: Workaround for ROM bug because of CA9 r2pX GIC control register change.
On OMAP4+ devices, GIC register context is lost when MPUSS hits
the OSWR(Open Switch Retention). On the CPU wakeup path, ROM code
gets executed and one of the steps in it is to restore the
saved context of the GIC. The ROM Code GIC distributor restoration
is split in two parts: CPU specific register done by each CPU and
common register done by only one CPU.
Below is the abstract flow.
...............................................................
- MPUSS in OSWR state.
- CPU0 wakes up on the event(interrupt) and start executing ROM code.
[..]
- CPU0 executes "GIC Restoration:"
[...]
- CPU0 swicthes to non-secure mode and jumps to OS resume code.
[...]
- CPU0 is online in OS
- CPU0 enables the GIC distributor. GICD.Enable Non-secure = 1
- CPU0 wakes up CPU1 with clock-domain force wakeup method.
- CPU0 continues it's execution.
[..]
- CPU1 wakes up and start executing ROM code.
[..]
- CPU1 executes "GIC Restoration:"
[..]
- CPU1 swicthes to non-secure mode and jumps to OS resume code.
[...]
- CPU1 is online in OS and start executing.
[...] -
GIC Restoration: /* Common routine for HS and GP devices */
{
if (GICD != 1) { /* This will be true in OSWR state */
if (GIC_SAR_BACKUP_STATE == SAVED)
- CPU restores GIC distributor
else
- reconfigure GIC distributor to boot values.
GICD.Enable secure = 1
}
if (GIC_SAR_BACKUP_STATE == SAVED)
- CPU restore its GIC CPU interface registers if saved.
else
- reconfigure its GIC CPU interface registers to boot
values.
}
...............................................................
So as mentioned in the flow, GICD != 1 condition decides how
the GIC registers are handled in ROM code wakeup path from
OSWR. As evident from the flow, ROM code relies on the entire
GICD register value and not specific register bits.
The assumption was valid till CortexA9 r1pX version since there
was only one banked bit to control secure and non-secure GICD.
Secure view which ROM code sees:
bit 0 == Enable Non-secure
Non-secure view which HLOS sees:
bit 0 == Enable secure
But GICD register has changed between CortexA9 r1pX and r2pX.
On r2pX GICD register is composed of 2 bits.
Secure view which ROM code sees:
bit 1 == Enable Non-secure
bit 0 == Enable secure
Non-secure view which HLOS sees:
bit 0 == Enable Non-secure
Hence on OMAP4460(r2pX) devices, if you go through the
above flow again during CPU1 wakeup, GICD == 3 and hence
ROM code fails to understand the real wakeup power state
and reconfigures GIC distributor to boot values. This is
nasty since you loose the entire interrupt controller
context in a live system.
The ROM code fix done on next OMAP4 device (OMAP4470 - r2px) is to
check "GICD.Enable secure != 1" for GIC restoration in OSWR wakeup path.
Since ROM code can't be fixed on OMAP4460 devices, a work around
needs to be implemented. As evident from the flow, as long as
CPU1 sees GICD == 1 in it's wakeup path from OSWR, the issue
won't happen. Below is the flow with the work-around.
...............................................................
- MPUSS in OSWR state.
- CPU0 wakes up on the event(interrupt) and start executing ROM code.
[..]
- CPU0 executes "GIC Restoration:"
[..]
- CPU0 swicthes to non-secure mode and jumps to OS resume code.
[..]
- CPU0 is online in OS.
- CPU0 does GICD.Enable Non-secure = 0
- CPU0 wakes up CPU1 with clock domain force wakeup method.
- CPU0 waits for GICD.Enable Non-secure = 1
- CPU0 coninues it's execution.
[..]
- CPU1 wakes up and start executing ROM code.
[..]
- CPU1 executes "GIC Restoration:"
[..]
- CPU1 swicthes to non-secure mode and jumps to OS resume code.
[..]
- CPU1 is online in OS
- CPU1 does GICD.Enable Non-secure = 1
- CPU1 start executing
[...]
...............................................................
With this procedure, the GIC configuration done between the
CPU0 wakeup and CPU1 wakeup will not be lost but during this
short windows, the CPU0 will not receive interrupts.
The BUG is applicable to only OMAP4460(r2pX) devices.
OMAP4470 (also r2pX) is not affected by this bug because
ROM code has been fixed.
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
2012-10-18 16:20:05 +07:00
|
|
|
hold_2: ldr r12,=0x103
|
|
|
|
dsb
|
|
|
|
smc #0 @ read from AuxCoreBoot0
|
|
|
|
mov r0, r0, lsr #9
|
|
|
|
mrc p15, 0, r4, c0, c0, 5
|
|
|
|
and r4, r4, #0x0f
|
|
|
|
cmp r0, r4
|
|
|
|
bne hold_2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GIC distributor control register has changed between
|
|
|
|
* CortexA9 r1pX and r2pX. The Control Register secure
|
|
|
|
* banked version is now composed of 2 bits:
|
|
|
|
* bit 0 == Secure Enable
|
|
|
|
* bit 1 == Non-Secure Enable
|
|
|
|
* The Non-Secure banked register has not changed
|
|
|
|
* Because the ROM Code is based on the r1pX GIC, the CPU1
|
|
|
|
* GIC restoration will cause a problem to CPU0 Non-Secure SW.
|
|
|
|
* The workaround must be:
|
|
|
|
* 1) Before doing the CPU1 wakeup, CPU0 must disable
|
|
|
|
* the GIC distributor
|
|
|
|
* 2) CPU1 must re-enable the GIC distributor on
|
|
|
|
* it's wakeup path.
|
|
|
|
*/
|
|
|
|
ldr r1, =OMAP44XX_GIC_DIST_BASE
|
|
|
|
ldr r0, [r1]
|
|
|
|
orr r0, #1
|
|
|
|
str r0, [r1]
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we've been released from the wait loop,secondary_stack
|
|
|
|
* should now contain the SVC stack for this core
|
|
|
|
*/
|
|
|
|
b secondary_startup
|
2013-04-05 19:59:02 +07:00
|
|
|
ENDPROC(omap4460_secondary_startup)
|