1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <bootmode.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <soc/nvidia/tegra/dc.h>
7 #include <soc/display.h>
8 #include <soc/sdram.h>
9 #include <symbols.h>
10
11 #include "chip.h"
12
13 /* this sucks, but for now, fb size/location are hardcoded.
14 * Will break if we get 2. Sigh.
15 * We assume it's all multiples of MiB for MMUs sake.
16 */
soc_read_resources(struct device * dev)17 static void soc_read_resources(struct device *dev)
18 {
19 uint64_t lcdbase = fb_base_mb();
20 uint64_t fb_size = FB_SIZE_MB;
21
22 ram_from_to(dev, 0, (uintptr_t)_dram, (sdram_max_addressable_mb() - fb_size) * MiB);
23 mmio_range(dev, 1, lcdbase * MiB, fb_size * MiB);
24
25 ram_from_to(dev, 2, sdram_max_addressable_mb() * (uint64_t)MiB,
26 (uintptr_t)_dram + sdram_size_mb() * (uint64_t)MiB);
27 }
28
soc_init(struct device * dev)29 static void soc_init(struct device *dev)
30 {
31 if (display_init_required())
32 display_startup(dev);
33 else
34 printk(BIOS_INFO, "Skipping display init.\n");
35 printk(BIOS_INFO, "CPU: Tegra124\n");
36 }
37
38 static struct device_operations soc_ops = {
39 .read_resources = soc_read_resources,
40 .set_resources = noop_set_resources,
41 .init = soc_init,
42 };
43
enable_tegra124_dev(struct device * dev)44 static void enable_tegra124_dev(struct device *dev)
45 {
46 dev->ops = &soc_ops;
47 }
48
49 struct chip_operations soc_nvidia_tegra124_ops = {
50 .name = "SOC Nvidia Tegra124",
51 .enable_dev = enable_tegra124_dev,
52 };
53