blob: a9d6835b3a7141df18fb81f135a40f4f51b97233 [file] [log] [blame]
Patrick Georgi40a3e322015-06-22 19:41:29 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
5 * Copyright 2014 Google Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Patrick Georgi40a3e322015-06-22 19:41:29 +020015 */
16
Patrick Georgi40a3e322015-06-22 19:41:29 +020017#include <arch/cache.h>
Ting Shendff29e02019-01-28 18:15:00 +080018#include <bootmem.h>
Aaron Durbinbc98cc62015-09-02 09:21:36 -050019#include <bootmode.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020020#include <bootstate.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020021#include <console/console.h>
22#include <device/device.h>
23#include <soc/nvidia/tegra/dc.h>
24#include <soc/addressmap.h>
25#include <soc/clock.h>
26#include <soc/cpu.h>
27#include <soc/mc.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020028#include <soc/nvidia/tegra/apbmisc.h>
29#include <string.h>
30#include <timer.h>
Yen Linae3d71a2015-06-01 15:32:09 -070031#include <soc/sdram.h>
32#include <soc/sdram_configs.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020033
34#include "chip.h"
35
Ting Shendff29e02019-01-28 18:15:00 +080036void bootmem_platform_add_ranges(void)
37{
38 uintptr_t begin;
39 size_t size;
40 carveout_range(CARVEOUT_TZ, &begin, &size);
41 if (size == 0)
42 return;
43 bootmem_add_range(begin * MiB, size * MiB, BM_MEM_BL31);
44}
45
Elyes HAOUAS3fcb2182018-05-25 10:03:57 +020046static void soc_read_resources(struct device *dev)
Patrick Georgi40a3e322015-06-22 19:41:29 +020047{
48 unsigned long index = 0;
49 int i; uintptr_t begin, end;
50 size_t size;
51
Ting Shendff29e02019-01-28 18:15:00 +080052 for (i = CARVEOUT_TZ + 1; i < CARVEOUT_NUM; i++) {
Patrick Georgi40a3e322015-06-22 19:41:29 +020053 carveout_range(i, &begin, &size);
54 if (size == 0)
55 continue;
56 reserved_ram_resource(dev, index++, begin * KiB, size * KiB);
57 }
58
59 memory_in_range_below_4gb(&begin, &end);
60 size = end - begin;
61 ram_resource(dev, index++, begin * KiB, size * KiB);
62
63 memory_in_range_above_4gb(&begin, &end);
64 size = end - begin;
65 ram_resource(dev, index++, begin * KiB, size * KiB);
66}
67
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070068static struct device_operations soc_ops = {
69 .read_resources = soc_read_resources,
70 .set_resources = DEVICE_NOOP,
71 .enable_resources = DEVICE_NOOP,
72 .init = DEVICE_NOOP,
73 .scan_bus = NULL,
74};
Patrick Georgi40a3e322015-06-22 19:41:29 +020075
Elyes HAOUAS3fcb2182018-05-25 10:03:57 +020076static void enable_tegra210_dev(struct device *dev)
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070077{
78 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
79 dev->ops = &soc_ops;
Patrick Georgi40a3e322015-06-22 19:41:29 +020080
Julius Wernercd49cce2019-03-05 16:53:33 -080081 if (!CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT))
Aaron Durbinbc98cc62015-09-02 09:21:36 -050082 return;
83
84 if (display_init_required())
Patrick Georgi40a3e322015-06-22 19:41:29 +020085 display_startup(dev);
Aaron Durbinbc98cc62015-09-02 09:21:36 -050086 else
87 printk(BIOS_INFO, "Skipping display init.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020088}
89
Patrick Georgi40a3e322015-06-22 19:41:29 +020090static void tegra210_init(void *chip_info)
91{
92 struct tegra_revision rev;
93
94 tegra_revision_info(&rev);
95
96 printk(BIOS_INFO, "chip %x rev %02x.%x\n",
97 rev.chip_id, rev.major, rev.minor);
Yen Linae3d71a2015-06-01 15:32:09 -070098
99 /* Save sdram parameters to scratch regs to be used in LP0 resume */
100 sdram_lp0_save_params(get_sdram_config());
101 printk(BIOS_INFO, "sdram params saved.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +0200102}
103
104struct chip_operations soc_nvidia_tegra210_ops = {
105 CHIP_NAME("SOC Nvidia Tegra210")
106 .init = tegra210_init,
107 .enable_dev = enable_tegra210_dev,
108};
109
Patrick Georgi40a3e322015-06-22 19:41:29 +0200110static void enable_plld(void *unused)
111{
112 /*
113 * Configure a conservative 300MHz clock for PLLD. The kernel cannot
114 * handle PLLD not being configured so enable PLLD unconditionally
115 * with a default clock rate.
116 */
117 clock_configure_plld(300 * MHz);
118}
119
120/*
121 * The PLLD being enabled is done at BS_DEV_INIT time because mainboard_init()
122 * is the first thing called. This ensures PLLD is up and functional before
123 * anything that mainboard can do that implicitly relies on PLLD.
124 */
125BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL);