2010-05-15 02:05:26 +07:00
|
|
|
/*
|
|
|
|
* OMAP4 specific common source file.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Texas Instruments, Inc.
|
|
|
|
* Author:
|
|
|
|
* Santosh Shilimkar <santosh.shilimkar@ti.com>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/io.h>
|
2012-10-18 16:20:08 +07:00
|
|
|
#include <linux/irq.h>
|
2012-11-06 05:18:28 +07:00
|
|
|
#include <linux/irqchip.h>
|
2010-05-15 02:05:26 +07:00
|
|
|
#include <linux/platform_device.h>
|
2011-06-26 08:04:31 +07:00
|
|
|
#include <linux/memblock.h>
|
2012-08-28 07:43:01 +07:00
|
|
|
#include <linux/of_irq.h>
|
|
|
|
#include <linux/of_platform.h>
|
|
|
|
#include <linux/export.h>
|
2012-12-28 02:10:24 +07:00
|
|
|
#include <linux/irqchip/arm-gic.h>
|
2013-02-25 15:42:58 +07:00
|
|
|
#include <linux/of_address.h>
|
2013-07-09 06:01:40 +07:00
|
|
|
#include <linux/reboot.h>
|
2014-09-10 23:04:04 +07:00
|
|
|
#include <linux/genalloc.h>
|
2010-05-15 02:05:26 +07:00
|
|
|
|
|
|
|
#include <asm/hardware/cache-l2x0.h>
|
2011-06-26 08:04:31 +07:00
|
|
|
#include <asm/mach/map.h>
|
2012-01-13 22:00:51 +07:00
|
|
|
#include <asm/memblock.h>
|
2012-10-18 16:20:08 +07:00
|
|
|
#include <asm/smp_twd.h>
|
2010-05-15 02:05:26 +07:00
|
|
|
|
2012-09-21 01:41:16 +07:00
|
|
|
#include "omap-wakeupgen.h"
|
2012-09-01 00:59:07 +07:00
|
|
|
#include "soc.h"
|
2012-10-30 09:50:21 +07:00
|
|
|
#include "iomap.h"
|
2011-11-11 04:45:17 +07:00
|
|
|
#include "common.h"
|
2012-10-30 09:56:07 +07:00
|
|
|
#include "prminst44xx.h"
|
2012-10-30 09:57:39 +07:00
|
|
|
#include "prcm_mpu44xx.h"
|
2011-01-01 21:26:04 +07:00
|
|
|
#include "omap4-sar-layout.h"
|
2012-10-02 01:47:06 +07:00
|
|
|
#include "omap-secure.h"
|
2012-10-29 23:35:35 +07:00
|
|
|
#include "sram.h"
|
2010-05-15 02:05:26 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_CACHE_L2X0
|
2011-03-03 19:33:25 +07:00
|
|
|
static void __iomem *l2cache_base;
|
2010-05-15 02:05:26 +07:00
|
|
|
#endif
|
|
|
|
|
2011-01-01 21:26:04 +07:00
|
|
|
static void __iomem *sar_ram_base;
|
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
|
|
|
static void __iomem *gic_dist_base_addr;
|
2012-10-18 16:20:08 +07:00
|
|
|
static void __iomem *twd_base;
|
|
|
|
|
|
|
|
#define IRQ_LOCALTIMER 29
|
2011-01-01 21:26:04 +07:00
|
|
|
|
2015-06-06 06:38:08 +07:00
|
|
|
#ifdef CONFIG_OMAP_INTERCONNECT_BARRIER
|
|
|
|
|
2015-06-06 06:13:40 +07:00
|
|
|
/* Used to implement memory barrier on DRAM path */
|
|
|
|
#define OMAP4_DRAM_BARRIER_VA 0xfe600000
|
|
|
|
|
2015-06-06 06:38:08 +07:00
|
|
|
static void __iomem *dram_sync, *sram_sync;
|
|
|
|
static phys_addr_t dram_sync_paddr;
|
|
|
|
static u32 dram_sync_size;
|
|
|
|
|
|
|
|
/*
|
2016-05-21 18:50:19 +07:00
|
|
|
* The OMAP4 bus structure contains asynchronous bridges which can buffer
|
2015-06-06 06:38:08 +07:00
|
|
|
* data writes from the MPU. These asynchronous bridges can be found on
|
|
|
|
* paths between the MPU to EMIF, and the MPU to L3 interconnects.
|
|
|
|
*
|
|
|
|
* We need to be careful about re-ordering which can happen as a result
|
|
|
|
* of different accesses being performed via different paths, and
|
|
|
|
* therefore different asynchronous bridges.
|
|
|
|
*/
|
2015-06-06 06:13:40 +07:00
|
|
|
|
2015-06-06 06:38:08 +07:00
|
|
|
/*
|
|
|
|
* OMAP4 interconnect barrier which is called for each mb() and wmb().
|
|
|
|
* This is to ensure that normal paths to DRAM (normal memory, cacheable
|
|
|
|
* accesses) are properly synchronised with writes to DMA coherent memory
|
|
|
|
* (normal memory, uncacheable) and device writes.
|
|
|
|
*
|
|
|
|
* The mb() and wmb() barriers only operate only on the MPU->MA->EMIF
|
|
|
|
* path, as we need to ensure that data is visible to other system
|
|
|
|
* masters prior to writes to those system masters being seen.
|
|
|
|
*
|
|
|
|
* Note: the SRAM path is not synchronised via mb() and wmb().
|
|
|
|
*/
|
|
|
|
static void omap4_mb(void)
|
|
|
|
{
|
|
|
|
if (dram_sync)
|
|
|
|
writel_relaxed(0, dram_sync);
|
|
|
|
}
|
2015-06-06 06:13:40 +07:00
|
|
|
|
2015-06-06 06:38:08 +07:00
|
|
|
/*
|
|
|
|
* OMAP4 Errata i688 - asynchronous bridge corruption when entering WFI.
|
|
|
|
*
|
|
|
|
* If a data is stalled inside asynchronous bridge because of back
|
|
|
|
* pressure, it may be accepted multiple times, creating pointer
|
|
|
|
* misalignment that will corrupt next transfers on that data path until
|
|
|
|
* next reset of the system. No recovery procedure once the issue is hit,
|
|
|
|
* the path remains consistently broken.
|
|
|
|
*
|
|
|
|
* Async bridges can be found on paths between MPU to EMIF and MPU to L3
|
|
|
|
* interconnects.
|
|
|
|
*
|
|
|
|
* This situation can happen only when the idle is initiated by a Master
|
|
|
|
* Request Disconnection (which is trigged by software when executing WFI
|
|
|
|
* on the CPU).
|
|
|
|
*
|
|
|
|
* The work-around for this errata needs all the initiators connected
|
|
|
|
* through an async bridge to ensure that data path is properly drained
|
|
|
|
* before issuing WFI. This condition will be met if one Strongly ordered
|
|
|
|
* access is performed to the target right before executing the WFI.
|
|
|
|
*
|
|
|
|
* In MPU case, L3 T2ASYNC FIFO and DDR T2ASYNC FIFO needs to be drained.
|
|
|
|
* IO barrier ensure that there is no synchronisation loss on initiators
|
|
|
|
* operating on both interconnect port simultaneously.
|
|
|
|
*
|
|
|
|
* This is a stronger version of the OMAP4 memory barrier below, and
|
|
|
|
* operates on both the MPU->MA->EMIF path but also the MPU->OCP path
|
|
|
|
* as well, and is necessary prior to executing a WFI.
|
|
|
|
*/
|
|
|
|
void omap_interconnect_sync(void)
|
2015-06-06 06:13:40 +07:00
|
|
|
{
|
|
|
|
if (dram_sync && sram_sync) {
|
|
|
|
writel_relaxed(readl_relaxed(dram_sync), dram_sync);
|
|
|
|
writel_relaxed(readl_relaxed(sram_sync), sram_sync);
|
|
|
|
isb();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init omap4_sram_init(void)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
|
|
|
struct gen_pool *sram_pool;
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "ti,omap4-mpu");
|
|
|
|
if (!np)
|
|
|
|
pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
|
|
|
|
__func__);
|
2015-06-06 06:38:08 +07:00
|
|
|
sram_pool = of_gen_pool_get(np, "sram", 0);
|
2015-06-06 06:13:40 +07:00
|
|
|
if (!sram_pool)
|
|
|
|
pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
|
|
|
|
__func__);
|
|
|
|
else
|
|
|
|
sram_sync = (void *)gen_pool_alloc(sram_pool, PAGE_SIZE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
omap_arch_initcall(omap4_sram_init);
|
|
|
|
|
|
|
|
/* Steal one page physical memory for barrier implementation */
|
2015-06-06 06:38:08 +07:00
|
|
|
void __init omap_barrier_reserve_memblock(void)
|
2015-06-06 06:13:40 +07:00
|
|
|
{
|
2015-06-06 06:38:08 +07:00
|
|
|
dram_sync_size = ALIGN(PAGE_SIZE, SZ_1M);
|
|
|
|
dram_sync_paddr = arm_memblock_steal(dram_sync_size, SZ_1M);
|
2015-06-06 06:13:40 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void __init omap_barriers_init(void)
|
|
|
|
{
|
|
|
|
struct map_desc dram_io_desc[1];
|
|
|
|
|
|
|
|
dram_io_desc[0].virtual = OMAP4_DRAM_BARRIER_VA;
|
2015-06-06 06:38:08 +07:00
|
|
|
dram_io_desc[0].pfn = __phys_to_pfn(dram_sync_paddr);
|
|
|
|
dram_io_desc[0].length = dram_sync_size;
|
2015-06-06 06:13:40 +07:00
|
|
|
dram_io_desc[0].type = MT_MEMORY_RW_SO;
|
|
|
|
iotable_init(dram_io_desc, ARRAY_SIZE(dram_io_desc));
|
|
|
|
dram_sync = (void __iomem *) dram_io_desc[0].virtual;
|
|
|
|
|
2015-06-06 06:38:08 +07:00
|
|
|
pr_info("OMAP4: Map %pa to %p for dram barrier\n",
|
|
|
|
&dram_sync_paddr, dram_sync);
|
2015-06-06 06:13:40 +07:00
|
|
|
|
2015-06-06 06:38:08 +07:00
|
|
|
soc_mb = omap4_mb;
|
2015-06-06 06:13:40 +07:00
|
|
|
}
|
2015-06-06 06:38:08 +07:00
|
|
|
|
2015-06-06 06:13:40 +07:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
void gic_dist_disable(void)
|
|
|
|
{
|
|
|
|
if (gic_dist_base_addr)
|
2014-04-16 00:37:46 +07:00
|
|
|
writel_relaxed(0x0, gic_dist_base_addr + GIC_DIST_CTRL);
|
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
|
|
|
}
|
|
|
|
|
2013-10-23 02:07:15 +07:00
|
|
|
void gic_dist_enable(void)
|
|
|
|
{
|
|
|
|
if (gic_dist_base_addr)
|
2014-04-16 00:37:46 +07:00
|
|
|
writel_relaxed(0x1, gic_dist_base_addr + GIC_DIST_CTRL);
|
2013-10-23 02:07:15 +07:00
|
|
|
}
|
|
|
|
|
2012-10-18 16:20:08 +07:00
|
|
|
bool gic_dist_disabled(void)
|
|
|
|
{
|
2014-04-16 00:37:46 +07:00
|
|
|
return !(readl_relaxed(gic_dist_base_addr + GIC_DIST_CTRL) & 0x1);
|
2012-10-18 16:20:08 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void gic_timer_retrigger(void)
|
|
|
|
{
|
2014-04-16 00:37:46 +07:00
|
|
|
u32 twd_int = readl_relaxed(twd_base + TWD_TIMER_INTSTAT);
|
|
|
|
u32 gic_int = readl_relaxed(gic_dist_base_addr + GIC_DIST_PENDING_SET);
|
|
|
|
u32 twd_ctrl = readl_relaxed(twd_base + TWD_TIMER_CONTROL);
|
2012-10-18 16:20:08 +07:00
|
|
|
|
|
|
|
if (twd_int && !(gic_int & BIT(IRQ_LOCALTIMER))) {
|
|
|
|
/*
|
|
|
|
* The local timer interrupt got lost while the distributor was
|
|
|
|
* disabled. Ack the pending interrupt, and retrigger it.
|
|
|
|
*/
|
|
|
|
pr_warn("%s: lost localtimer interrupt\n", __func__);
|
2014-04-16 00:37:46 +07:00
|
|
|
writel_relaxed(1, twd_base + TWD_TIMER_INTSTAT);
|
2012-10-18 16:20:08 +07:00
|
|
|
if (!(twd_ctrl & TWD_TIMER_CONTROL_PERIODIC)) {
|
2014-04-16 00:37:46 +07:00
|
|
|
writel_relaxed(1, twd_base + TWD_TIMER_COUNTER);
|
2012-10-18 16:20:08 +07:00
|
|
|
twd_ctrl |= TWD_TIMER_CONTROL_ENABLE;
|
2014-04-16 00:37:46 +07:00
|
|
|
writel_relaxed(twd_ctrl, twd_base + TWD_TIMER_CONTROL);
|
2012-10-18 16:20:08 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-15 02:05:26 +07:00
|
|
|
#ifdef CONFIG_CACHE_L2X0
|
2010-07-31 23:10:10 +07:00
|
|
|
|
2011-03-03 19:33:25 +07:00
|
|
|
void __iomem *omap4_get_l2cache_base(void)
|
|
|
|
{
|
|
|
|
return l2cache_base;
|
|
|
|
}
|
|
|
|
|
2015-01-08 13:48:58 +07:00
|
|
|
void omap4_l2c310_write_sec(unsigned long val, unsigned reg)
|
2010-07-31 23:10:10 +07:00
|
|
|
{
|
2014-03-17 00:45:56 +07:00
|
|
|
unsigned smc_op;
|
2010-07-31 23:10:10 +07:00
|
|
|
|
2014-03-17 00:45:56 +07:00
|
|
|
switch (reg) {
|
|
|
|
case L2X0_CTRL:
|
|
|
|
smc_op = OMAP4_MON_L2X0_CTRL_INDEX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case L2X0_AUX_CTRL:
|
|
|
|
smc_op = OMAP4_MON_L2X0_AUXCTRL_INDEX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case L2X0_DEBUG_CTRL:
|
|
|
|
smc_op = OMAP4_MON_L2X0_DBG_CTRL_INDEX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case L310_PREFETCH_CTRL:
|
|
|
|
smc_op = OMAP4_MON_L2X0_PREFETCH_INDEX;
|
|
|
|
break;
|
|
|
|
|
2014-07-14 20:13:46 +07:00
|
|
|
case L310_POWER_CTRL:
|
|
|
|
pr_info_once("OMAP L2C310: ROM does not support power control setting\n");
|
|
|
|
return;
|
|
|
|
|
2014-03-17 00:45:56 +07:00
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "OMAP L2C310: ignoring write to reg 0x%x\n", reg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
omap_smc1(smc_op, val);
|
2011-02-22 16:00:44 +07:00
|
|
|
}
|
|
|
|
|
2014-04-22 15:28:01 +07:00
|
|
|
int __init omap_l2_cache_init(void)
|
2010-05-15 02:05:26 +07:00
|
|
|
{
|
|
|
|
/* Static mapping, never released */
|
|
|
|
l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
|
2011-03-03 19:06:52 +07:00
|
|
|
if (WARN_ON(!l2cache_base))
|
|
|
|
return -ENOMEM;
|
2010-05-15 02:05:26 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2011-01-01 21:26:04 +07:00
|
|
|
|
|
|
|
void __iomem *omap4_get_sar_ram_base(void)
|
|
|
|
{
|
|
|
|
return sar_ram_base;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-06-22 15:59:39 +07:00
|
|
|
* SAR RAM used to save and restore the HW context in low power modes.
|
|
|
|
* Note that we need to initialize this very early for kexec. See
|
|
|
|
* omap4_mpuss_early_init().
|
2011-01-01 21:26:04 +07:00
|
|
|
*/
|
2016-06-22 15:59:39 +07:00
|
|
|
void __init omap4_sar_ram_init(void)
|
2011-01-01 21:26:04 +07:00
|
|
|
{
|
2013-02-06 19:24:39 +07:00
|
|
|
unsigned long sar_base;
|
|
|
|
|
2011-01-01 21:26:04 +07:00
|
|
|
/*
|
|
|
|
* To avoid code running on other OMAPs in
|
|
|
|
* multi-omap builds
|
|
|
|
*/
|
2013-02-06 19:24:39 +07:00
|
|
|
if (cpu_is_omap44xx())
|
|
|
|
sar_base = OMAP44XX_SAR_RAM_BASE;
|
|
|
|
else if (soc_is_omap54xx())
|
|
|
|
sar_base = OMAP54XX_SAR_RAM_BASE;
|
|
|
|
else
|
2016-06-22 15:59:39 +07:00
|
|
|
return;
|
2011-01-01 21:26:04 +07:00
|
|
|
|
|
|
|
/* Static mapping, never released */
|
2013-02-06 19:24:39 +07:00
|
|
|
sar_ram_base = ioremap(sar_base, SZ_16K);
|
2011-01-01 21:26:04 +07:00
|
|
|
if (WARN_ON(!sar_ram_base))
|
2016-06-22 15:59:39 +07:00
|
|
|
return;
|
2011-01-01 21:26:04 +07:00
|
|
|
}
|
2012-04-25 18:57:46 +07:00
|
|
|
|
2015-03-11 22:43:49 +07:00
|
|
|
static const struct of_device_id intc_match[] = {
|
|
|
|
{ .compatible = "ti,omap4-wugen-mpu", },
|
|
|
|
{ .compatible = "ti,omap5-wugen-mpu", },
|
2015-01-17 17:21:08 +07:00
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
2015-03-11 22:43:49 +07:00
|
|
|
static struct device_node *intc_node;
|
2015-01-17 17:21:08 +07:00
|
|
|
|
2012-06-05 18:01:06 +07:00
|
|
|
void __init omap_gic_of_init(void)
|
|
|
|
{
|
2013-02-25 15:42:58 +07:00
|
|
|
struct device_node *np;
|
|
|
|
|
2015-03-11 22:43:49 +07:00
|
|
|
intc_node = of_find_matching_node(NULL, intc_match);
|
|
|
|
if (WARN_ON(!intc_node)) {
|
|
|
|
pr_err("No WUGEN found in DT, system will misbehave.\n");
|
|
|
|
pr_err("UPDATE YOUR DEVICE TREE!\n");
|
|
|
|
}
|
|
|
|
|
2013-02-25 15:42:58 +07:00
|
|
|
/* Extract GIC distributor and TWD bases for OMAP4460 ROM Errata WA */
|
|
|
|
if (!cpu_is_omap446x())
|
|
|
|
goto skip_errata_init;
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-gic");
|
|
|
|
gic_dist_base_addr = of_iomap(np, 0);
|
|
|
|
WARN_ON(!gic_dist_base_addr);
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-twd-timer");
|
|
|
|
twd_base = of_iomap(np, 0);
|
|
|
|
WARN_ON(!twd_base);
|
|
|
|
|
|
|
|
skip_errata_init:
|
2012-11-06 05:18:28 +07:00
|
|
|
irqchip_init();
|
2012-06-05 18:01:06 +07:00
|
|
|
}
|