blob: f5eb44f4f3313a20d97ada7f54315dc0e4809464 [file] [log] [blame]
Angel Ponsa2ee7612020-04-04 18:51:15 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Patrick Georgi40a3e322015-06-22 19:41:29 +02003
Ting Shendff29e02019-01-28 18:15:00 +08004#include <bootmem.h>
Aaron Durbinbc98cc62015-09-02 09:21:36 -05005#include <bootmode.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02006#include <bootstate.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02007#include <console/console.h>
8#include <device/device.h>
9#include <soc/nvidia/tegra/dc.h>
10#include <soc/addressmap.h>
11#include <soc/clock.h>
12#include <soc/cpu.h>
13#include <soc/mc.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020014#include <soc/nvidia/tegra/apbmisc.h>
Yen Linae3d71a2015-06-01 15:32:09 -070015#include <soc/sdram.h>
16#include <soc/sdram_configs.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020017
18#include "chip.h"
19
Ting Shendff29e02019-01-28 18:15:00 +080020void bootmem_platform_add_ranges(void)
21{
22 uintptr_t begin;
23 size_t size;
24 carveout_range(CARVEOUT_TZ, &begin, &size);
25 if (size == 0)
26 return;
27 bootmem_add_range(begin * MiB, size * MiB, BM_MEM_BL31);
28}
29
Elyes HAOUAS3fcb2182018-05-25 10:03:57 +020030static void soc_read_resources(struct device *dev)
Patrick Georgi40a3e322015-06-22 19:41:29 +020031{
32 unsigned long index = 0;
33 int i; uintptr_t begin, end;
34 size_t size;
35
Ting Shendff29e02019-01-28 18:15:00 +080036 for (i = CARVEOUT_TZ + 1; i < CARVEOUT_NUM; i++) {
Patrick Georgi40a3e322015-06-22 19:41:29 +020037 carveout_range(i, &begin, &size);
38 if (size == 0)
39 continue;
40 reserved_ram_resource(dev, index++, begin * KiB, size * KiB);
41 }
42
43 memory_in_range_below_4gb(&begin, &end);
44 size = end - begin;
45 ram_resource(dev, index++, begin * KiB, size * KiB);
46
47 memory_in_range_above_4gb(&begin, &end);
48 size = end - begin;
49 ram_resource(dev, index++, begin * KiB, size * KiB);
50}
51
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070052static struct device_operations soc_ops = {
53 .read_resources = soc_read_resources,
Nico Huber2f8ba692020-04-05 14:05:24 +020054 .set_resources = noop_set_resources,
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070055};
Patrick Georgi40a3e322015-06-22 19:41:29 +020056
Elyes HAOUAS3fcb2182018-05-25 10:03:57 +020057static void enable_tegra210_dev(struct device *dev)
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070058{
59 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
60 dev->ops = &soc_ops;
Patrick Georgi40a3e322015-06-22 19:41:29 +020061
Julius Wernercd49cce2019-03-05 16:53:33 -080062 if (!CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT))
Aaron Durbinbc98cc62015-09-02 09:21:36 -050063 return;
64
65 if (display_init_required())
Patrick Georgi40a3e322015-06-22 19:41:29 +020066 display_startup(dev);
Aaron Durbinbc98cc62015-09-02 09:21:36 -050067 else
68 printk(BIOS_INFO, "Skipping display init.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020069}
70
Patrick Georgi40a3e322015-06-22 19:41:29 +020071static void tegra210_init(void *chip_info)
72{
73 struct tegra_revision rev;
74
75 tegra_revision_info(&rev);
76
77 printk(BIOS_INFO, "chip %x rev %02x.%x\n",
78 rev.chip_id, rev.major, rev.minor);
Yen Linae3d71a2015-06-01 15:32:09 -070079
80 /* Save sdram parameters to scratch regs to be used in LP0 resume */
81 sdram_lp0_save_params(get_sdram_config());
82 printk(BIOS_INFO, "sdram params saved.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020083}
84
85struct chip_operations soc_nvidia_tegra210_ops = {
86 CHIP_NAME("SOC Nvidia Tegra210")
87 .init = tegra210_init,
88 .enable_dev = enable_tegra210_dev,
89};
90
Patrick Georgi40a3e322015-06-22 19:41:29 +020091static void enable_plld(void *unused)
92{
93 /*
94 * Configure a conservative 300MHz clock for PLLD. The kernel cannot
95 * handle PLLD not being configured so enable PLLD unconditionally
96 * with a default clock rate.
97 */
98 clock_configure_plld(300 * MHz);
99}
100
101/*
102 * The PLLD being enabled is done at BS_DEV_INIT time because mainboard_init()
103 * is the first thing called. This ensures PLLD is up and functional before
104 * anything that mainboard can do that implicitly relies on PLLD.
105 */
106BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL);