blob: 30f51d0ef54eb89c675a6f339b779c1847c4f680 [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
Shunqian Zhengd1cec752016-05-04 16:21:36 +080016#include <bootmode.h>
huang linc14b54d2016-03-02 18:38:40 +080017#include <console/console.h>
Lin Huang19eb7502016-03-26 11:50:05 +080018#include <cpu/cpu.h>
huang linc14b54d2016-03-02 18:38:40 +080019#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>
huang linc14b54d2016-03-02 18:38:40 +080024#include <stddef.h>
Lin Huang19eb7502016-03-26 11:50:05 +080025#include <stdlib.h>
huang linc14b54d2016-03-02 18:38:40 +080026#include <string.h>
27#include <symbols.h>
Xing Zheng53d6d842016-12-06 17:12:21 +080028#include <arm-trusted-firmware/plat/rockchip/rk3399/include/shared/bl31_param.h>
huang linc14b54d2016-03-02 18:38:40 +080029
Elyes HAOUASf3ca88b2018-05-25 09:52:45 +020030static void soc_read_resources(struct device *dev)
huang linc14b54d2016-03-02 18:38:40 +080031{
Lin Huangf00af582016-11-15 11:40:58 +080032 ram_resource(dev, 0, (uintptr_t)_dram / KiB, sdram_size_mb() * KiB);
huang linc14b54d2016-03-02 18:38:40 +080033}
34
Elyes HAOUASf3ca88b2018-05-25 09:52:45 +020035static void soc_init(struct device *dev)
huang linc14b54d2016-03-02 18:38:40 +080036{
Xing Zheng53d6d842016-12-06 17:12:21 +080037 /*
38 * Reserve the whole TZRAM area because it will be marked as secure-only
39 * by BL31 and can not be accessed by the non-secure kernel.
huang linc14b54d2016-03-02 18:38:40 +080040 */
Xing Zheng53d6d842016-12-06 17:12:21 +080041 mmio_resource(dev, 1, (TZRAM_BASE / KiB), (TZRAM_SIZE / KiB));
Shunqian Zhengd1cec752016-05-04 16:21:36 +080042
43 if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT) && display_init_required())
Lin Huang152e6752016-10-20 14:22:11 -070044 rk_display_init(dev);
Shunqian Zhengd1cec752016-05-04 16:21:36 +080045 else
46 printk(BIOS_INFO, "Display initialization disabled.\n");
Julius Werner7f965892016-08-29 15:07:58 -070047
48 /* We don't need big CPUs, but bring them up as a courtesy to Linux. */
49 rkclk_configure_cpu(APLL_600_MHZ, CPU_CLUSTER_BIG);
huang linc14b54d2016-03-02 18:38:40 +080050}
51
52static struct device_operations soc_ops = {
53 .read_resources = soc_read_resources,
54 .init = soc_init,
55};
56
Elyes HAOUASf3ca88b2018-05-25 09:52:45 +020057static void enable_soc_dev(struct device *dev)
huang linc14b54d2016-03-02 18:38:40 +080058{
59 dev->ops = &soc_ops;
60}
61
62struct chip_operations soc_rockchip_rk3399_ops = {
Paul Menzel37277762016-07-03 09:45:26 +020063 CHIP_NAME("SOC Rockchip RK3399")
huang linc14b54d2016-03-02 18:38:40 +080064 .enable_dev = enable_soc_dev,
65};