blob: b4f51e8587a6f353410f0845f4f3ed1d2107e740 [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,
54 .set_resources = DEVICE_NOOP,
55 .enable_resources = DEVICE_NOOP,
56 .init = DEVICE_NOOP,
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070057};
Patrick Georgi40a3e322015-06-22 19:41:29 +020058
Elyes HAOUAS3fcb2182018-05-25 10:03:57 +020059static void enable_tegra210_dev(struct device *dev)
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070060{
61 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
62 dev->ops = &soc_ops;
Patrick Georgi40a3e322015-06-22 19:41:29 +020063
Julius Wernercd49cce2019-03-05 16:53:33 -080064 if (!CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT))
Aaron Durbinbc98cc62015-09-02 09:21:36 -050065 return;
66
67 if (display_init_required())
Patrick Georgi40a3e322015-06-22 19:41:29 +020068 display_startup(dev);
Aaron Durbinbc98cc62015-09-02 09:21:36 -050069 else
70 printk(BIOS_INFO, "Skipping display init.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020071}
72
Patrick Georgi40a3e322015-06-22 19:41:29 +020073static void tegra210_init(void *chip_info)
74{
75 struct tegra_revision rev;
76
77 tegra_revision_info(&rev);
78
79 printk(BIOS_INFO, "chip %x rev %02x.%x\n",
80 rev.chip_id, rev.major, rev.minor);
Yen Linae3d71a2015-06-01 15:32:09 -070081
82 /* Save sdram parameters to scratch regs to be used in LP0 resume */
83 sdram_lp0_save_params(get_sdram_config());
84 printk(BIOS_INFO, "sdram params saved.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020085}
86
87struct chip_operations soc_nvidia_tegra210_ops = {
88 CHIP_NAME("SOC Nvidia Tegra210")
89 .init = tegra210_init,
90 .enable_dev = enable_tegra210_dev,
91};
92
Patrick Georgi40a3e322015-06-22 19:41:29 +020093static void enable_plld(void *unused)
94{
95 /*
96 * Configure a conservative 300MHz clock for PLLD. The kernel cannot
97 * handle PLLD not being configured so enable PLLD unconditionally
98 * with a default clock rate.
99 */
100 clock_configure_plld(300 * MHz);
101}
102
103/*
104 * The PLLD being enabled is done at BS_DEV_INIT time because mainboard_init()
105 * is the first thing called. This ensures PLLD is up and functional before
106 * anything that mainboard can do that implicitly relies on PLLD.
107 */
108BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL);