blob: 65b791d5a3c048ae3808c77570ae6b1cde19f687 [file] [log] [blame]
huang linc14b54d2016-03-02 18:38:40 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2015 MediaTek Inc.
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 as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
Julius Werner314b5c32019-02-20 17:50:42 -080016#include <bootmem.h>
Shunqian Zhengd1cec752016-05-04 16:21:36 +080017#include <bootmode.h>
huang linc14b54d2016-03-02 18:38:40 +080018#include <console/console.h>
19#include <device/device.h>
Lin Huang19eb7502016-03-26 11:50:05 +080020#include <soc/addressmap.h>
Julius Werner7f965892016-08-29 15:07:58 -070021#include <soc/clock.h>
Shunqian Zhengd1cec752016-05-04 16:21:36 +080022#include <soc/display.h>
Lin Huangf00af582016-11-15 11:40:58 +080023#include <soc/sdram.h>
Julius Werner314b5c32019-02-20 17:50:42 -080024#include <soc/symbols.h>
huang linc14b54d2016-03-02 18:38:40 +080025#include <stddef.h>
Lin Huang19eb7502016-03-26 11:50:05 +080026#include <stdlib.h>
huang linc14b54d2016-03-02 18:38:40 +080027#include <string.h>
28#include <symbols.h>
Xing Zheng53d6d842016-12-06 17:12:21 +080029#include <arm-trusted-firmware/plat/rockchip/rk3399/include/shared/bl31_param.h>
huang linc14b54d2016-03-02 18:38:40 +080030
Julius Werner314b5c32019-02-20 17:50:42 -080031void bootmem_platform_add_ranges(void)
32{
Julius Werner7e0dea62019-02-20 18:39:22 -080033 bootmem_add_range((uintptr_t)_pmu_sram, REGION_SIZE(pmu_sram),
34 BM_MEM_BL31);
35 bootmem_add_range((uintptr_t)_bl31_sram, REGION_SIZE(bl31_sram),
36 BM_MEM_BL31);
Julius Werner314b5c32019-02-20 17:50:42 -080037}
38
Elyes HAOUASf3ca88b2018-05-25 09:52:45 +020039static void soc_read_resources(struct device *dev)
huang linc14b54d2016-03-02 18:38:40 +080040{
Lin Huangf00af582016-11-15 11:40:58 +080041 ram_resource(dev, 0, (uintptr_t)_dram / KiB, sdram_size_mb() * KiB);
huang linc14b54d2016-03-02 18:38:40 +080042}
43
Elyes HAOUASf3ca88b2018-05-25 09:52:45 +020044static void soc_init(struct device *dev)
huang linc14b54d2016-03-02 18:38:40 +080045{
Xing Zheng53d6d842016-12-06 17:12:21 +080046 /*
47 * Reserve the whole TZRAM area because it will be marked as secure-only
48 * by BL31 and can not be accessed by the non-secure kernel.
huang linc14b54d2016-03-02 18:38:40 +080049 */
Xing Zheng53d6d842016-12-06 17:12:21 +080050 mmio_resource(dev, 1, (TZRAM_BASE / KiB), (TZRAM_SIZE / KiB));
Shunqian Zhengd1cec752016-05-04 16:21:36 +080051
Julius Wernercd49cce2019-03-05 16:53:33 -080052 if (CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT) && display_init_required())
Lin Huang152e6752016-10-20 14:22:11 -070053 rk_display_init(dev);
Shunqian Zhengd1cec752016-05-04 16:21:36 +080054 else
55 printk(BIOS_INFO, "Display initialization disabled.\n");
Julius Werner7f965892016-08-29 15:07:58 -070056
57 /* We don't need big CPUs, but bring them up as a courtesy to Linux. */
58 rkclk_configure_cpu(APLL_600_MHZ, CPU_CLUSTER_BIG);
huang linc14b54d2016-03-02 18:38:40 +080059}
60
61static struct device_operations soc_ops = {
62 .read_resources = soc_read_resources,
63 .init = soc_init,
64};
65
Elyes HAOUASf3ca88b2018-05-25 09:52:45 +020066static void enable_soc_dev(struct device *dev)
huang linc14b54d2016-03-02 18:38:40 +080067{
68 dev->ops = &soc_ops;
69}
70
71struct chip_operations soc_rockchip_rk3399_ops = {
Paul Menzel37277762016-07-03 09:45:26 +020072 CHIP_NAME("SOC Rockchip RK3399")
huang linc14b54d2016-03-02 18:38:40 +080073 .enable_dev = enable_soc_dev,
74};