blob: 22b6dfe497255c130f87971f1f6029ba9a1e6f4e [file] [log] [blame]
Patrick Georgi40a3e322015-06-22 19:41:29 +02001/*
2 * This file is part of the coreboot project.
3 *
Patrick Georgi40a3e322015-06-22 19:41:29 +02004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Patrick Georgi40a3e322015-06-22 19:41:29 +020013 */
14
Ting Shendff29e02019-01-28 18:15:00 +080015#include <bootmem.h>
Aaron Durbinbc98cc62015-09-02 09:21:36 -050016#include <bootmode.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020017#include <bootstate.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020018#include <console/console.h>
19#include <device/device.h>
20#include <soc/nvidia/tegra/dc.h>
21#include <soc/addressmap.h>
22#include <soc/clock.h>
23#include <soc/cpu.h>
24#include <soc/mc.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020025#include <soc/nvidia/tegra/apbmisc.h>
Yen Linae3d71a2015-06-01 15:32:09 -070026#include <soc/sdram.h>
27#include <soc/sdram_configs.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020028
29#include "chip.h"
30
Ting Shendff29e02019-01-28 18:15:00 +080031void bootmem_platform_add_ranges(void)
32{
33 uintptr_t begin;
34 size_t size;
35 carveout_range(CARVEOUT_TZ, &begin, &size);
36 if (size == 0)
37 return;
38 bootmem_add_range(begin * MiB, size * MiB, BM_MEM_BL31);
39}
40
Elyes HAOUAS3fcb2182018-05-25 10:03:57 +020041static void soc_read_resources(struct device *dev)
Patrick Georgi40a3e322015-06-22 19:41:29 +020042{
43 unsigned long index = 0;
44 int i; uintptr_t begin, end;
45 size_t size;
46
Ting Shendff29e02019-01-28 18:15:00 +080047 for (i = CARVEOUT_TZ + 1; i < CARVEOUT_NUM; i++) {
Patrick Georgi40a3e322015-06-22 19:41:29 +020048 carveout_range(i, &begin, &size);
49 if (size == 0)
50 continue;
51 reserved_ram_resource(dev, index++, begin * KiB, size * KiB);
52 }
53
54 memory_in_range_below_4gb(&begin, &end);
55 size = end - begin;
56 ram_resource(dev, index++, begin * KiB, size * KiB);
57
58 memory_in_range_above_4gb(&begin, &end);
59 size = end - begin;
60 ram_resource(dev, index++, begin * KiB, size * KiB);
61}
62
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070063static struct device_operations soc_ops = {
64 .read_resources = soc_read_resources,
65 .set_resources = DEVICE_NOOP,
66 .enable_resources = DEVICE_NOOP,
67 .init = DEVICE_NOOP,
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070068};
Patrick Georgi40a3e322015-06-22 19:41:29 +020069
Elyes HAOUAS3fcb2182018-05-25 10:03:57 +020070static void enable_tegra210_dev(struct device *dev)
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070071{
72 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
73 dev->ops = &soc_ops;
Patrick Georgi40a3e322015-06-22 19:41:29 +020074
Julius Wernercd49cce2019-03-05 16:53:33 -080075 if (!CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT))
Aaron Durbinbc98cc62015-09-02 09:21:36 -050076 return;
77
78 if (display_init_required())
Patrick Georgi40a3e322015-06-22 19:41:29 +020079 display_startup(dev);
Aaron Durbinbc98cc62015-09-02 09:21:36 -050080 else
81 printk(BIOS_INFO, "Skipping display init.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020082}
83
Patrick Georgi40a3e322015-06-22 19:41:29 +020084static void tegra210_init(void *chip_info)
85{
86 struct tegra_revision rev;
87
88 tegra_revision_info(&rev);
89
90 printk(BIOS_INFO, "chip %x rev %02x.%x\n",
91 rev.chip_id, rev.major, rev.minor);
Yen Linae3d71a2015-06-01 15:32:09 -070092
93 /* Save sdram parameters to scratch regs to be used in LP0 resume */
94 sdram_lp0_save_params(get_sdram_config());
95 printk(BIOS_INFO, "sdram params saved.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020096}
97
98struct chip_operations soc_nvidia_tegra210_ops = {
99 CHIP_NAME("SOC Nvidia Tegra210")
100 .init = tegra210_init,
101 .enable_dev = enable_tegra210_dev,
102};
103
Patrick Georgi40a3e322015-06-22 19:41:29 +0200104static void enable_plld(void *unused)
105{
106 /*
107 * Configure a conservative 300MHz clock for PLLD. The kernel cannot
108 * handle PLLD not being configured so enable PLLD unconditionally
109 * with a default clock rate.
110 */
111 clock_configure_plld(300 * MHz);
112}
113
114/*
115 * The PLLD being enabled is done at BS_DEV_INIT time because mainboard_init()
116 * is the first thing called. This ensures PLLD is up and functional before
117 * anything that mainboard can do that implicitly relies on PLLD.
118 */
119BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL);