2009-04-28 15:21:52 +00:00
|
|
|
/*
|
|
|
|
* OMAP4 SMP source file. It contains platform specific fucntions
|
|
|
|
* needed for the linux smp kernel.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Texas Instruments, Inc.
|
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Santosh Shilimkar <santosh.shilimkar@ti.com>
|
|
|
|
*
|
|
|
|
* Platform file needed for the OMAP4 SMP. This file is based on arm
|
|
|
|
* realview smp platform.
|
|
|
|
* * Copyright (c) 2002 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/init.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/io.h>
|
2012-12-27 19:10:24 +00:00
|
|
|
#include <linux/irqchip/arm-gic.h>
|
2009-04-28 15:21:52 +00:00
|
|
|
|
|
|
|
#include <asm/smp_scu.h>
|
2012-02-24 18:34:35 +00:00
|
|
|
|
2012-09-20 18:41:14 +00:00
|
|
|
#include "omap-secure.h"
|
2012-09-20 18:41:16 +00:00
|
|
|
#include "omap-wakeupgen.h"
|
2012-05-09 15:08:35 +00:00
|
|
|
#include <asm/cputype.h>
|
2011-11-10 21:45:17 +00:00
|
|
|
|
2012-08-31 17:59:07 +00:00
|
|
|
#include "soc.h"
|
2012-02-24 18:34:35 +00:00
|
|
|
#include "iomap.h"
|
2011-11-10 21:45:17 +00:00
|
|
|
#include "common.h"
|
2010-06-16 16:49:49 +00:00
|
|
|
#include "clockdomain.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 09:20:05 +00:00
|
|
|
#include "pm.h"
|
2010-06-16 16:49:49 +00:00
|
|
|
|
2012-03-19 13:59:41 +00:00
|
|
|
#define CPU_MASK 0xff0ffff0
|
|
|
|
#define CPU_CORTEX_A9 0x410FC090
|
|
|
|
#define CPU_CORTEX_A15 0x410FC0F0
|
|
|
|
|
|
|
|
#define OMAP5_CORE_COUNT 0x2
|
|
|
|
|
2012-11-15 00:54:27 +00:00
|
|
|
u16 pm44xx_errata;
|
|
|
|
|
2009-04-28 15:21:52 +00:00
|
|
|
/* SCU base address */
|
2009-10-19 22:25:26 +00:00
|
|
|
static void __iomem *scu_base;
|
2009-04-28 15:21:52 +00:00
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(boot_lock);
|
|
|
|
|
2011-03-03 12:33:25 +00:00
|
|
|
void __iomem *omap4_get_scu_base(void)
|
|
|
|
{
|
|
|
|
return scu_base;
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:43:14 +00:00
|
|
|
static void omap4_secondary_init(unsigned int cpu)
|
2009-04-28 15:21:52 +00:00
|
|
|
{
|
2010-06-16 16:49:48 +00:00
|
|
|
/*
|
|
|
|
* Configure ACTRL and enable NS SMP bit access on CPU1 on HS device.
|
|
|
|
* OMAP44XX EMU/HS devices - CPU0 SMP bit access is enabled in PPA
|
|
|
|
* init and for CPU1, a secure PPA API provided. CPU0 must be ON
|
|
|
|
* while executing NS_SMP API on CPU1 and PPA version must be 1.4.0+.
|
|
|
|
* OMAP443X GP devices- SMP bit isn't accessible.
|
|
|
|
* OMAP446X GP devices - SMP bit access is enabled on both CPUs.
|
|
|
|
*/
|
|
|
|
if (cpu_is_omap443x() && (omap_type() != OMAP2_DEVICE_TYPE_GP))
|
|
|
|
omap_secure_dispatcher(OMAP4_PPA_CPU_ACTRL_SMP_INDEX,
|
|
|
|
4, 0, 0, 0, 0, 0);
|
|
|
|
|
2009-04-28 15:21:52 +00:00
|
|
|
/*
|
|
|
|
* Synchronise with the boot thread.
|
|
|
|
*/
|
|
|
|
spin_lock(&boot_lock);
|
|
|
|
spin_unlock(&boot_lock);
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:43:14 +00:00
|
|
|
static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)
|
2009-04-28 15:21:52 +00:00
|
|
|
{
|
2010-06-16 16:49:49 +00:00
|
|
|
static struct clockdomain *cpu1_clkdm;
|
|
|
|
static bool booted;
|
2013-02-08 17:20:58 +00:00
|
|
|
static struct powerdomain *cpu1_pwrdm;
|
2012-05-09 15:08:35 +00:00
|
|
|
void __iomem *base = omap_get_wakeupgen_base();
|
|
|
|
|
2009-04-28 15:21:52 +00:00
|
|
|
/*
|
|
|
|
* Set synchronisation state between this boot processor
|
|
|
|
* and the secondary one
|
|
|
|
*/
|
|
|
|
spin_lock(&boot_lock);
|
|
|
|
|
|
|
|
/*
|
2009-12-12 00:16:35 +00:00
|
|
|
* Update the AuxCoreBoot0 with boot state for secondary core.
|
2013-04-05 12:59:02 +00:00
|
|
|
* omap4_secondary_startup() routine will hold the secondary core till
|
2009-04-28 15:21:52 +00:00
|
|
|
* the AuxCoreBoot1 register is updated with cpu state
|
|
|
|
* A barrier is added to ensure that write buffer is drained
|
|
|
|
*/
|
2012-05-09 15:08:35 +00:00
|
|
|
if (omap_secure_apis_support())
|
|
|
|
omap_modify_auxcoreboot0(0x200, 0xfffffdff);
|
|
|
|
else
|
|
|
|
__raw_writel(0x20, base + OMAP_AUX_CORE_BOOT_0);
|
|
|
|
|
2013-02-08 17:20:58 +00:00
|
|
|
if (!cpu1_clkdm && !cpu1_pwrdm) {
|
2010-06-16 16:49:49 +00:00
|
|
|
cpu1_clkdm = clkdm_lookup("mpu1_clkdm");
|
2013-02-08 17:20:58 +00:00
|
|
|
cpu1_pwrdm = pwrdm_lookup("cpu1_pwrdm");
|
|
|
|
}
|
2010-06-16 16:49:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The SGI(Software Generated Interrupts) are not wakeup capable
|
|
|
|
* from low power states. This is known limitation on OMAP4 and
|
|
|
|
* needs to be worked around by using software forced clockdomain
|
|
|
|
* wake-up. To wakeup CPU1, CPU0 forces the CPU1 clockdomain to
|
|
|
|
* software force wakeup. The clockdomain is then put back to
|
|
|
|
* hardware supervised mode.
|
|
|
|
* More details can be found in OMAP4430 TRM - Version J
|
|
|
|
* Section :
|
|
|
|
* 4.3.4.2 Power States of CPU0 and CPU1
|
|
|
|
*/
|
2013-02-08 17:20:58 +00:00
|
|
|
if (booted && cpu1_pwrdm && cpu1_clkdm) {
|
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 09:20:05 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-10-18 09:20:08 +00:00
|
|
|
if (IS_PM44XX_ERRATUM(PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD)) {
|
|
|
|
local_irq_disable();
|
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 09:20:05 +00:00
|
|
|
gic_dist_disable();
|
2012-10-18 09:20:08 +00:00
|
|
|
}
|
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 09:20:05 +00:00
|
|
|
|
2013-02-08 17:20:58 +00:00
|
|
|
/*
|
|
|
|
* Ensure that CPU power state is set to ON to avoid CPU
|
|
|
|
* powerdomain transition on wfi
|
|
|
|
*/
|
2010-06-16 16:49:49 +00:00
|
|
|
clkdm_wakeup(cpu1_clkdm);
|
2013-02-08 17:20:58 +00:00
|
|
|
omap_set_pwrdm_state(cpu1_pwrdm, PWRDM_POWER_ON);
|
2010-06-16 16:49:49 +00:00
|
|
|
clkdm_allow_idle(cpu1_clkdm);
|
2012-10-18 09:20:08 +00:00
|
|
|
|
|
|
|
if (IS_PM44XX_ERRATUM(PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD)) {
|
|
|
|
while (gic_dist_disabled()) {
|
|
|
|
udelay(1);
|
|
|
|
cpu_relax();
|
|
|
|
}
|
|
|
|
gic_timer_retrigger();
|
|
|
|
local_irq_enable();
|
|
|
|
}
|
2010-06-16 16:49:49 +00:00
|
|
|
} else {
|
|
|
|
dsb_sev();
|
|
|
|
booted = true;
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:05:48 +00:00
|
|
|
arch_send_wakeup_ipi_mask(cpumask_of(cpu));
|
2009-04-28 15:21:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now the secondary core is starting up let it run its
|
|
|
|
* calibrations, then wait for it to finish
|
|
|
|
*/
|
|
|
|
spin_unlock(&boot_lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise the CPU possible map early - this describes the CPUs
|
|
|
|
* which may be present or become present in the system.
|
|
|
|
*/
|
2011-09-08 12:15:22 +00:00
|
|
|
static void __init omap4_smp_init_cpus(void)
|
2009-04-28 15:21:52 +00:00
|
|
|
{
|
2012-03-19 13:59:41 +00:00
|
|
|
unsigned int i = 0, ncores = 1, cpu_id;
|
|
|
|
|
|
|
|
/* Use ARM cpuid check here, as SoC detection will not work so early */
|
2013-01-30 16:38:21 +00:00
|
|
|
cpu_id = read_cpuid_id() & CPU_MASK;
|
2012-03-19 13:59:41 +00:00
|
|
|
if (cpu_id == CPU_CORTEX_A9) {
|
|
|
|
/*
|
|
|
|
* Currently we can't call ioremap here because
|
|
|
|
* SoC detection won't work until after init_early.
|
|
|
|
*/
|
2013-01-23 08:26:19 +00:00
|
|
|
scu_base = OMAP2_L4_IO_ADDRESS(scu_a9_get_base());
|
2012-03-19 13:59:41 +00:00
|
|
|
BUG_ON(!scu_base);
|
|
|
|
ncores = scu_get_core_count(scu_base);
|
|
|
|
} else if (cpu_id == CPU_CORTEX_A15) {
|
|
|
|
ncores = OMAP5_CORE_COUNT;
|
|
|
|
}
|
2009-04-28 15:21:52 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
2011-10-20 21:04:18 +00:00
|
|
|
if (ncores > nr_cpu_ids) {
|
|
|
|
pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
|
|
|
|
ncores, nr_cpu_ids);
|
|
|
|
ncores = nr_cpu_ids;
|
2009-04-28 15:21:52 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 10:42:58 +00:00
|
|
|
for (i = 0; i < ncores; i++)
|
|
|
|
set_cpu_possible(i, true);
|
|
|
|
}
|
|
|
|
|
2011-09-08 12:15:22 +00:00
|
|
|
static void __init omap4_smp_prepare_cpus(unsigned int max_cpus)
|
2010-12-03 10:42:58 +00:00
|
|
|
{
|
2013-04-05 12:59:02 +00:00
|
|
|
void *startup_addr = omap4_secondary_startup;
|
2013-02-10 08:24:00 +00:00
|
|
|
void __iomem *base = omap_get_wakeupgen_base();
|
2009-04-28 15:21:52 +00:00
|
|
|
|
2010-12-03 11:09:48 +00:00
|
|
|
/*
|
|
|
|
* Initialise the SCU and wake up the secondary core using
|
|
|
|
* wakeup_secondary().
|
|
|
|
*/
|
2012-03-19 13:59:41 +00:00
|
|
|
if (scu_base)
|
|
|
|
scu_enable(scu_base);
|
2013-02-10 08:24:00 +00:00
|
|
|
|
|
|
|
if (cpu_is_omap446x()) {
|
2013-04-05 12:59:02 +00:00
|
|
|
startup_addr = omap4460_secondary_startup;
|
2013-02-10 08:24:00 +00:00
|
|
|
pm44xx_errata |= PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write the address of secondary startup routine into the
|
|
|
|
* AuxCoreBoot1 where ROM code will jump and start executing
|
|
|
|
* on secondary core once out of WFE
|
|
|
|
* A barrier is added to ensure that write buffer is drained
|
|
|
|
*/
|
|
|
|
if (omap_secure_apis_support())
|
|
|
|
omap_auxcoreboot_addr(virt_to_phys(startup_addr));
|
|
|
|
else
|
|
|
|
__raw_writel(virt_to_phys(omap5_secondary_startup),
|
|
|
|
base + OMAP_AUX_CORE_BOOT_1);
|
|
|
|
|
2009-04-28 15:21:52 +00:00
|
|
|
}
|
2011-09-08 12:15:22 +00:00
|
|
|
|
|
|
|
struct smp_operations omap4_smp_ops __initdata = {
|
|
|
|
.smp_init_cpus = omap4_smp_init_cpus,
|
|
|
|
.smp_prepare_cpus = omap4_smp_prepare_cpus,
|
|
|
|
.smp_secondary_init = omap4_secondary_init,
|
|
|
|
.smp_boot_secondary = omap4_boot_secondary,
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
.cpu_die = omap4_cpu_die,
|
|
|
|
#endif
|
|
|
|
};
|