mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 09:13:38 +00:00
ARM: omap: un-merge plat/sram.c
The sram initialization code is the only shared omap1/2 code that is not a standalone driver, but it is very short. Having two copies of this code means some duplication of the sources, but actually saves object code size as it can be inlined better. Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
parent
04e8d9d139
commit
11237651e2
@ -356,7 +356,7 @@ static int __init omap1_init_devices(void)
|
||||
if (!cpu_class_is_omap1())
|
||||
return -ENODEV;
|
||||
|
||||
omap_sram_init();
|
||||
omap1_sram_init();
|
||||
omap1_clk_late_init();
|
||||
|
||||
/* please keep these calls, and their implementations above,
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <asm/fncpy.h>
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/set_memory.h>
|
||||
|
||||
#include <asm/mach/map.h>
|
||||
|
||||
@ -22,18 +23,77 @@
|
||||
|
||||
#define OMAP1_SRAM_PA 0x20000000
|
||||
#define SRAM_BOOTLOADER_SZ 0x80
|
||||
#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
|
||||
|
||||
static void __iomem *omap_sram_base;
|
||||
static unsigned long omap_sram_start;
|
||||
static unsigned long omap_sram_skip;
|
||||
static unsigned long omap_sram_size;
|
||||
static void __iomem *omap_sram_ceil;
|
||||
|
||||
/*
|
||||
* Memory allocator for SRAM: calculates the new ceiling address
|
||||
* for pushing a function using the fncpy API.
|
||||
*
|
||||
* Note that fncpy requires the returned address to be aligned
|
||||
* to an 8-byte boundary.
|
||||
*/
|
||||
static void *omap_sram_push_address(unsigned long size)
|
||||
{
|
||||
unsigned long available, new_ceil = (unsigned long)omap_sram_ceil;
|
||||
|
||||
available = omap_sram_ceil - (omap_sram_base + omap_sram_skip);
|
||||
|
||||
if (size > available) {
|
||||
pr_err("Not enough space in SRAM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_ceil -= size;
|
||||
new_ceil = ROUND_DOWN(new_ceil, FNCPY_ALIGN);
|
||||
omap_sram_ceil = IOMEM(new_ceil);
|
||||
|
||||
return (void *)omap_sram_ceil;
|
||||
}
|
||||
|
||||
void *omap_sram_push(void *funcp, unsigned long size)
|
||||
{
|
||||
void *sram;
|
||||
unsigned long base;
|
||||
int pages;
|
||||
void *dst = NULL;
|
||||
|
||||
sram = omap_sram_push_address(size);
|
||||
if (!sram)
|
||||
return NULL;
|
||||
|
||||
base = (unsigned long)sram & PAGE_MASK;
|
||||
pages = PAGE_ALIGN(size) / PAGE_SIZE;
|
||||
|
||||
set_memory_rw(base, pages);
|
||||
|
||||
dst = fncpy(sram, funcp, size);
|
||||
|
||||
set_memory_ro(base, pages);
|
||||
set_memory_x(base, pages);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/*
|
||||
* The amount of SRAM depends on the core type.
|
||||
* Note that we cannot try to test for SRAM here because writes
|
||||
* to secure SRAM will hang the system. Also the SRAM is not
|
||||
* yet mapped at this point.
|
||||
* Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.
|
||||
*/
|
||||
static void __init omap_detect_and_map_sram(void)
|
||||
{
|
||||
unsigned long omap_sram_skip = SRAM_BOOTLOADER_SZ;
|
||||
unsigned long omap_sram_start = OMAP1_SRAM_PA;
|
||||
unsigned long omap_sram_size;
|
||||
unsigned long base;
|
||||
int pages;
|
||||
|
||||
omap_sram_skip = SRAM_BOOTLOADER_SZ;
|
||||
omap_sram_start = OMAP1_SRAM_PA;
|
||||
|
||||
if (cpu_is_omap7xx())
|
||||
omap_sram_size = 0x32000; /* 200K */
|
||||
@ -47,8 +107,27 @@ static void __init omap_detect_and_map_sram(void)
|
||||
omap_sram_size = 0x4000;
|
||||
}
|
||||
|
||||
omap_map_sram(omap_sram_start, omap_sram_size,
|
||||
omap_sram_skip, 1);
|
||||
omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE);
|
||||
omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size, 1);
|
||||
if (!omap_sram_base) {
|
||||
pr_err("SRAM: Could not map\n");
|
||||
return;
|
||||
}
|
||||
|
||||
omap_sram_ceil = omap_sram_base + omap_sram_size;
|
||||
|
||||
/*
|
||||
* Looks like we need to preserve some bootloader code at the
|
||||
* beginning of SRAM for jumping to flash for reboot to work...
|
||||
*/
|
||||
memset_io(omap_sram_base + omap_sram_skip, 0,
|
||||
omap_sram_size - omap_sram_skip);
|
||||
|
||||
base = (unsigned long)omap_sram_base;
|
||||
pages = PAGE_ALIGN(omap_sram_size) / PAGE_SIZE;
|
||||
|
||||
set_memory_ro(base, pages);
|
||||
set_memory_x(base, pages);
|
||||
}
|
||||
|
||||
static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);
|
||||
@ -62,7 +141,7 @@ void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)
|
||||
_omap_sram_reprogram_clock(dpllctl, ckctl);
|
||||
}
|
||||
|
||||
int __init omap_sram_init(void)
|
||||
int __init omap1_sram_init(void)
|
||||
{
|
||||
omap_detect_and_map_sram();
|
||||
_omap_sram_reprogram_clock =
|
||||
|
@ -1,8 +1,10 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <plat/sram.h>
|
||||
|
||||
extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl);
|
||||
|
||||
int omap1_sram_init(void);
|
||||
void *omap_sram_push(void *funcp, unsigned long size);
|
||||
|
||||
/* Do not use these */
|
||||
extern void omap1_sram_reprogram_clock(u32 ckctl, u32 dpllctl);
|
||||
extern unsigned long omap1_sram_reprogram_clock_sz;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <asm/fncpy.h>
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/set_memory.h>
|
||||
|
||||
#include <asm/mach/map.h>
|
||||
|
||||
@ -47,8 +48,68 @@
|
||||
#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
|
||||
|
||||
static unsigned long omap_sram_start;
|
||||
static unsigned long omap_sram_skip;
|
||||
static unsigned long omap_sram_size;
|
||||
static void __iomem *omap_sram_base;
|
||||
static unsigned long omap_sram_skip;
|
||||
static void __iomem *omap_sram_ceil;
|
||||
|
||||
/*
|
||||
* Memory allocator for SRAM: calculates the new ceiling address
|
||||
* for pushing a function using the fncpy API.
|
||||
*
|
||||
* Note that fncpy requires the returned address to be aligned
|
||||
* to an 8-byte boundary.
|
||||
*/
|
||||
static void *omap_sram_push_address(unsigned long size)
|
||||
{
|
||||
unsigned long available, new_ceil = (unsigned long)omap_sram_ceil;
|
||||
|
||||
available = omap_sram_ceil - (omap_sram_base + omap_sram_skip);
|
||||
|
||||
if (size > available) {
|
||||
pr_err("Not enough space in SRAM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_ceil -= size;
|
||||
new_ceil = ROUND_DOWN(new_ceil, FNCPY_ALIGN);
|
||||
omap_sram_ceil = IOMEM(new_ceil);
|
||||
|
||||
return (void *)omap_sram_ceil;
|
||||
}
|
||||
|
||||
void *omap_sram_push(void *funcp, unsigned long size)
|
||||
{
|
||||
void *sram;
|
||||
unsigned long base;
|
||||
int pages;
|
||||
void *dst = NULL;
|
||||
|
||||
sram = omap_sram_push_address(size);
|
||||
if (!sram)
|
||||
return NULL;
|
||||
|
||||
base = (unsigned long)sram & PAGE_MASK;
|
||||
pages = PAGE_ALIGN(size) / PAGE_SIZE;
|
||||
|
||||
set_memory_rw(base, pages);
|
||||
|
||||
dst = fncpy(sram, funcp, size);
|
||||
|
||||
set_memory_ro(base, pages);
|
||||
set_memory_x(base, pages);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/*
|
||||
* The SRAM context is lost during off-idle and stack
|
||||
* needs to be reset.
|
||||
*/
|
||||
static void omap_sram_reset(void)
|
||||
{
|
||||
omap_sram_ceil = omap_sram_base + omap_sram_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Depending on the target RAMFS firewall setup, the public usable amount of
|
||||
@ -119,6 +180,8 @@ static void __init omap_detect_sram(void)
|
||||
*/
|
||||
static void __init omap2_map_sram(void)
|
||||
{
|
||||
unsigned long base;
|
||||
int pages;
|
||||
int cached = 1;
|
||||
|
||||
if (cpu_is_omap34xx()) {
|
||||
@ -132,8 +195,30 @@ static void __init omap2_map_sram(void)
|
||||
cached = 0;
|
||||
}
|
||||
|
||||
omap_map_sram(omap_sram_start, omap_sram_size,
|
||||
omap_sram_skip, cached);
|
||||
if (omap_sram_size == 0)
|
||||
return;
|
||||
|
||||
omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE);
|
||||
omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size, cached);
|
||||
if (!omap_sram_base) {
|
||||
pr_err("SRAM: Could not map\n");
|
||||
return;
|
||||
}
|
||||
|
||||
omap_sram_reset();
|
||||
|
||||
/*
|
||||
* Looks like we need to preserve some bootloader code at the
|
||||
* beginning of SRAM for jumping to flash for reboot to work...
|
||||
*/
|
||||
memset_io(omap_sram_base + omap_sram_skip, 0,
|
||||
omap_sram_size - omap_sram_skip);
|
||||
|
||||
base = (unsigned long)omap_sram_base;
|
||||
pages = PAGE_ALIGN(omap_sram_size) / PAGE_SIZE;
|
||||
|
||||
set_memory_ro(base, pages);
|
||||
set_memory_x(base, pages);
|
||||
}
|
||||
|
||||
static void (*_omap2_sram_ddr_init)(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#include <plat/sram.h>
|
||||
|
||||
extern void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,
|
||||
u32 base_cs, u32 force_unlock);
|
||||
@ -14,6 +13,10 @@ extern u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass);
|
||||
|
||||
extern void omap3_sram_restore_context(void);
|
||||
|
||||
extern int __init omap_sram_init(void);
|
||||
|
||||
extern void *omap_sram_push(void *funcp, unsigned long size);
|
||||
|
||||
/* Do not use these */
|
||||
extern void omap24xx_sram_reprogram_clock(u32 ckctl, u32 dpllctl);
|
||||
extern unsigned long omap24xx_sram_reprogram_clock_sz;
|
||||
|
@ -6,4 +6,4 @@
|
||||
ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/arch/arm/plat-omap/include
|
||||
|
||||
# Common support
|
||||
obj-y := sram.o
|
||||
obj-y :=
|
||||
|
@ -1,8 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
int omap_sram_init(void);
|
||||
|
||||
void omap_map_sram(unsigned long start, unsigned long size,
|
||||
unsigned long skip, int cached);
|
||||
void omap_sram_reset(void);
|
||||
|
||||
extern void *omap_sram_push(void *funcp, unsigned long size);
|
@ -1,129 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* linux/arch/arm/plat-omap/sram.c
|
||||
*
|
||||
* OMAP SRAM detection and management
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation
|
||||
* Written by Tony Lindgren <tony@atomide.com>
|
||||
*
|
||||
* Copyright (C) 2009-2012 Texas Instruments
|
||||
* Added OMAP4/5 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
|
||||
*/
|
||||
#undef DEBUG
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
#include <asm/fncpy.h>
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/set_memory.h>
|
||||
|
||||
#include <asm/mach/map.h>
|
||||
|
||||
#include <plat/sram.h>
|
||||
|
||||
#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
|
||||
|
||||
static void __iomem *omap_sram_base;
|
||||
static unsigned long omap_sram_skip;
|
||||
static unsigned long omap_sram_size;
|
||||
static void __iomem *omap_sram_ceil;
|
||||
|
||||
/*
|
||||
* Memory allocator for SRAM: calculates the new ceiling address
|
||||
* for pushing a function using the fncpy API.
|
||||
*
|
||||
* Note that fncpy requires the returned address to be aligned
|
||||
* to an 8-byte boundary.
|
||||
*/
|
||||
static void *omap_sram_push_address(unsigned long size)
|
||||
{
|
||||
unsigned long available, new_ceil = (unsigned long)omap_sram_ceil;
|
||||
|
||||
available = omap_sram_ceil - (omap_sram_base + omap_sram_skip);
|
||||
|
||||
if (size > available) {
|
||||
pr_err("Not enough space in SRAM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_ceil -= size;
|
||||
new_ceil = ROUND_DOWN(new_ceil, FNCPY_ALIGN);
|
||||
omap_sram_ceil = IOMEM(new_ceil);
|
||||
|
||||
return (void *)omap_sram_ceil;
|
||||
}
|
||||
|
||||
void *omap_sram_push(void *funcp, unsigned long size)
|
||||
{
|
||||
void *sram;
|
||||
unsigned long base;
|
||||
int pages;
|
||||
void *dst = NULL;
|
||||
|
||||
sram = omap_sram_push_address(size);
|
||||
if (!sram)
|
||||
return NULL;
|
||||
|
||||
base = (unsigned long)sram & PAGE_MASK;
|
||||
pages = PAGE_ALIGN(size) / PAGE_SIZE;
|
||||
|
||||
set_memory_rw(base, pages);
|
||||
|
||||
dst = fncpy(sram, funcp, size);
|
||||
|
||||
set_memory_ro(base, pages);
|
||||
set_memory_x(base, pages);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/*
|
||||
* The SRAM context is lost during off-idle and stack
|
||||
* needs to be reset.
|
||||
*/
|
||||
void omap_sram_reset(void)
|
||||
{
|
||||
omap_sram_ceil = omap_sram_base + omap_sram_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.
|
||||
*/
|
||||
void __init omap_map_sram(unsigned long start, unsigned long size,
|
||||
unsigned long skip, int cached)
|
||||
{
|
||||
unsigned long base;
|
||||
int pages;
|
||||
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
start = ROUND_DOWN(start, PAGE_SIZE);
|
||||
omap_sram_size = size;
|
||||
omap_sram_skip = skip;
|
||||
omap_sram_base = __arm_ioremap_exec(start, size, cached);
|
||||
if (!omap_sram_base) {
|
||||
pr_err("SRAM: Could not map\n");
|
||||
return;
|
||||
}
|
||||
|
||||
omap_sram_reset();
|
||||
|
||||
/*
|
||||
* Looks like we need to preserve some bootloader code at the
|
||||
* beginning of SRAM for jumping to flash for reboot to work...
|
||||
*/
|
||||
memset_io(omap_sram_base + omap_sram_skip, 0,
|
||||
omap_sram_size - omap_sram_skip);
|
||||
|
||||
base = (unsigned long)omap_sram_base;
|
||||
pages = PAGE_ALIGN(omap_sram_size) / PAGE_SIZE;
|
||||
|
||||
set_memory_ro(base, pages);
|
||||
set_memory_x(base, pages);
|
||||
}
|
Loading…
Reference in New Issue
Block a user