/ {
compatible = "rockchip,rk3188";
interrupt-parent = <&gic>;
+ rockchip,sram = <&sram>;
aliases {
serial0 = &uart0;
reg = <0x10080000 0x20>; /* 32 bytes */
};
- sram@10080020 {
+ sram: sram@10080020 {
compatible = "mmio-sram";
reg = <0x10080020 (0x8000 - 0x20)>; /* 32k - 32 */
map-exec;
CONFIG_CMA=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_UID_STAT=y
+CONFIG_SRAM=y
CONFIG_SCSI=y
CONFIG_SCSI_TGT=y
CONFIG_BLK_DEV_SD=y
*/
#include <linux/clk-provider.h>
+#include <linux/genalloc.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/of_platform.h>
#include <asm/hardware/cache-l2x0.h>
#include "cpu_axi.h"
+#include "sram.h"
static int __init rockchip_cpu_axi_init(void)
{
return 0;
}
early_initcall(rockchip_pl330_l2_cache_init);
+
+struct gen_pool *rockchip_sram_pool = NULL;
+struct pie_chunk *rockchip_pie_chunk = NULL;
+void *rockchip_sram_virt = NULL;
+size_t rockchip_sram_size = 0;
+char *rockchip_sram_stack = NULL;
+
+int __init rockchip_pie_init(void)
+{
+ struct device_node *np;
+
+ np = of_find_node_by_path("/");
+ if (!np)
+ return -ENODEV;
+
+ rockchip_sram_pool = of_get_named_gen_pool(np, "rockchip,sram", 0);
+ if (!rockchip_sram_pool) {
+ pr_err("%s: failed to get sram pool\n", __func__);
+ return -ENODEV;
+ }
+ rockchip_sram_size = gen_pool_size(rockchip_sram_pool);
+
+ return 0;
+}
#include "cpu_axi.h"
#include "grf.h"
#include "iomap.h"
+#include "sram.h"
#define RK3188_DEVICE(name) \
{ \
.init_time = rk3188_dt_init_timer,
.dt_compat = rk3188_dt_compat,
MACHINE_END
+
+#define CPU 3188
+char PIE_DATA(sram_stack)[1024];
+EXPORT_PIE_SYMBOL(DATA(sram_stack));
+
+static int __init rk3188_pie_init(void)
+{
+ int err;
+
+ if (!cpu_is_rk3188())
+ return 0;
+
+ err = rockchip_pie_init();
+ if (err)
+ return err;
+
+ rockchip_pie_chunk = pie_load_sections(rockchip_sram_pool, rk3188);
+ if (IS_ERR(rockchip_pie_chunk)) {
+ err = PTR_ERR(rockchip_pie_chunk);
+ pr_err("%s: failed to load section %d\n", __func__, err);
+ rockchip_pie_chunk = NULL;
+ return err;
+ }
+
+ rockchip_sram_virt = kern_to_pie(rockchip_pie_chunk, &__pie_common_start[0]);
+ rockchip_sram_stack = kern_to_pie(rockchip_pie_chunk, (char *) DATA(sram_stack) + sizeof(DATA(sram_stack)));
+
+ return 0;
+}
+arch_initcall(rk3188_pie_init);
--- /dev/null
+#ifndef __MACH_ROCKCHIP_SRAM_H
+#define __MACH_ROCKCHIP_SRAM_H
+
+#include <linux/pie.h>
+#include <asm/pie.h>
+
+extern char __pie_common_start[];
+extern char __pie_common_end[];
+extern char __pie_overlay_start[];
+
+extern struct gen_pool *rockchip_sram_pool;
+extern struct pie_chunk *rockchip_pie_chunk;
+extern void *rockchip_sram_virt;
+extern size_t rockchip_sram_size;
+extern char *rockchip_sram_stack;
+extern char __pie_data(rk3188) __pie_rk3188_sram_stack[1024];
+
+#define RK_PIE_DATA3(x) __pie_data(rk##x)
+#define RK_PIE_DATA2(x) RK_PIE_DATA3(x)
+#define RK_PIE_DATA RK_PIE_DATA2(CPU)
+
+#define DATA3(x, y) __pie_rk##y##_##x
+#define DATA2(x, y) DATA3(x, y)
+#define DATA(x) DATA2(x, CPU)
+
+#define RK_PIE3(x) __pie(rk##x)
+#define RK_PIE2(x) RK_PIE3(x)
+#define RK_PIE RK_PIE2(CPU)
+
+#define FUNC3(x, y) __pie_rk##y##_##x
+#define FUNC2(x, y) FUNC3(x, y)
+#define FUNC(x) FUNC2(x, CPU)
+
+#define PIE_FUNC(x) RK_PIE FUNC(x)
+#define PIE_DATA(x) RK_PIE_DATA DATA(x)
+
+#define DEFINE_PIE_DATA(x) PIE_DATA(x); EXPORT_PIE_SYMBOL(DATA(x));
+
+/* Tag variables with this */
+#define __sramdata RK_PIE_DATA
+/* Tag functions inside SRAM called from outside SRAM with this */
+#define __sramfunc RK_PIE noinline
+/* Tag function inside SRAM called from inside SRAM with this */
+#define __sramlocalfunc RK_PIE
+
+extern void call_with_stack(void (*fn)(void *), void *arg, void *sp);
+extern int __init rockchip_pie_init(void);
+
+#endif