blob: 483dfcd690650c54674584169b99ef00967964d0 [file] [log] [blame]
Tomasz Figabca28f82012-12-11 13:58:43 +09001/*
2 * Copyright (C) 2012 Samsung Electronics.
3 * Kyungmin Park <kyungmin.park@samsung.com>
4 * Tomasz Figa <t.figa@samsung.com>
5 *
6 * This program is free software,you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/io.h>
13#include <linux/init.h>
14#include <linux/of.h>
15#include <linux/of_address.h>
16
17#include <asm/firmware.h>
18
19#include <mach/map.h>
20
Sachin Kamatb3205de2014-05-13 07:13:44 +090021#include "common.h"
Tomasz Figabca28f82012-12-11 13:58:43 +090022#include "smc.h"
23
24static int exynos_do_idle(void)
25{
26 exynos_smc(SMC_CMD_SLEEP, 0, 0, 0);
27 return 0;
28}
29
30static int exynos_cpu_boot(int cpu)
31{
32 exynos_smc(SMC_CMD_CPU1BOOT, cpu, 0, 0);
33 return 0;
34}
35
36static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
37{
Sachin Kamatb3205de2014-05-13 07:13:44 +090038 void __iomem *boot_reg;
39
40 if (!sysram_ns_base_addr)
41 return -ENODEV;
42
43 boot_reg = sysram_ns_base_addr + 0x1c + 4*cpu;
Tomasz Figabca28f82012-12-11 13:58:43 +090044
45 __raw_writel(boot_addr, boot_reg);
46 return 0;
47}
48
49static const struct firmware_ops exynos_firmware_ops = {
50 .do_idle = exynos_do_idle,
51 .set_cpu_boot_addr = exynos_set_cpu_boot_addr,
52 .cpu_boot = exynos_cpu_boot,
53};
54
55void __init exynos_firmware_init(void)
56{
Tomasz Figa4ee1cc72013-06-15 09:13:25 +090057 struct device_node *nd;
58 const __be32 *addr;
Tomasz Figabca28f82012-12-11 13:58:43 +090059
Tomasz Figa4ee1cc72013-06-15 09:13:25 +090060 nd = of_find_compatible_node(NULL, NULL,
61 "samsung,secure-firmware");
62 if (!nd)
63 return;
Tomasz Figabca28f82012-12-11 13:58:43 +090064
Tomasz Figa4ee1cc72013-06-15 09:13:25 +090065 addr = of_get_address(nd, 0, NULL, NULL);
66 if (!addr) {
67 pr_err("%s: No address specified.\n", __func__);
68 return;
Tomasz Figabca28f82012-12-11 13:58:43 +090069 }
70
71 pr_info("Running under secure firmware.\n");
72
73 register_firmware_ops(&exynos_firmware_ops);
74}