blob: aa01c4222b40334db58a603cbcbee82f5f671d6b [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
Kyungmin Park989ff3f2014-05-09 06:19:18 +090021#include <plat/cpu.h>
22
Tomasz Figabca28f82012-12-11 13:58:43 +090023#include "smc.h"
24
25static int exynos_do_idle(void)
26{
27 exynos_smc(SMC_CMD_SLEEP, 0, 0, 0);
28 return 0;
29}
30
31static int exynos_cpu_boot(int cpu)
32{
Kyungmin Park989ff3f2014-05-09 06:19:18 +090033 /*
34 * The second parameter of SMC_CMD_CPU1BOOT command means CPU id.
35 * But, Exynos4212 has only one secondary CPU so second parameter
36 * isn't used for informing secure firmware about CPU id.
37 */
38 if (soc_is_exynos4212())
39 cpu = 0;
40
Tomasz Figabca28f82012-12-11 13:58:43 +090041 exynos_smc(SMC_CMD_CPU1BOOT, cpu, 0, 0);
42 return 0;
43}
44
45static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
46{
Kyungmin Park989ff3f2014-05-09 06:19:18 +090047 void __iomem *boot_reg = S5P_VA_SYSRAM_NS + 0x1c;
48
49 if (!soc_is_exynos4212())
50 boot_reg += 4*cpu;
Tomasz Figabca28f82012-12-11 13:58:43 +090051
52 __raw_writel(boot_addr, boot_reg);
53 return 0;
54}
55
56static const struct firmware_ops exynos_firmware_ops = {
57 .do_idle = exynos_do_idle,
58 .set_cpu_boot_addr = exynos_set_cpu_boot_addr,
59 .cpu_boot = exynos_cpu_boot,
60};
61
62void __init exynos_firmware_init(void)
63{
Tomasz Figa4ee1cc72013-06-15 09:13:25 +090064 struct device_node *nd;
65 const __be32 *addr;
Tomasz Figabca28f82012-12-11 13:58:43 +090066
Tomasz Figa4ee1cc72013-06-15 09:13:25 +090067 nd = of_find_compatible_node(NULL, NULL,
68 "samsung,secure-firmware");
69 if (!nd)
70 return;
Tomasz Figabca28f82012-12-11 13:58:43 +090071
Tomasz Figa4ee1cc72013-06-15 09:13:25 +090072 addr = of_get_address(nd, 0, NULL, NULL);
73 if (!addr) {
74 pr_err("%s: No address specified.\n", __func__);
75 return;
Tomasz Figabca28f82012-12-11 13:58:43 +090076 }
77
78 pr_info("Running under secure firmware.\n");
79
80 register_firmware_ops(&exynos_firmware_ops);
81}