Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 4 | * |
| 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 Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
Ting Shen | dff29e0 | 2019-01-28 18:15:00 +0800 | [diff] [blame] | 15 | #include <bootmem.h> |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 16 | #include <bootmode.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 17 | #include <bootstate.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 18 | #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 Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 25 | #include <soc/nvidia/tegra/apbmisc.h> |
Yen Lin | ae3d71a | 2015-06-01 15:32:09 -0700 | [diff] [blame] | 26 | #include <soc/sdram.h> |
| 27 | #include <soc/sdram_configs.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 28 | |
| 29 | #include "chip.h" |
| 30 | |
Ting Shen | dff29e0 | 2019-01-28 18:15:00 +0800 | [diff] [blame] | 31 | void 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 HAOUAS | 3fcb218 | 2018-05-25 10:03:57 +0200 | [diff] [blame] | 41 | static void soc_read_resources(struct device *dev) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 42 | { |
| 43 | unsigned long index = 0; |
| 44 | int i; uintptr_t begin, end; |
| 45 | size_t size; |
| 46 | |
Ting Shen | dff29e0 | 2019-01-28 18:15:00 +0800 | [diff] [blame] | 47 | for (i = CARVEOUT_TZ + 1; i < CARVEOUT_NUM; i++) { |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 48 | 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 Shaikh | fdb3a8d | 2015-10-15 15:50:30 -0700 | [diff] [blame] | 63 | static 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 Shaikh | fdb3a8d | 2015-10-15 15:50:30 -0700 | [diff] [blame] | 68 | }; |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 69 | |
Elyes HAOUAS | 3fcb218 | 2018-05-25 10:03:57 +0200 | [diff] [blame] | 70 | static void enable_tegra210_dev(struct device *dev) |
Furquan Shaikh | fdb3a8d | 2015-10-15 15:50:30 -0700 | [diff] [blame] | 71 | { |
| 72 | if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 73 | dev->ops = &soc_ops; |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 74 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 75 | if (!CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT)) |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 76 | return; |
| 77 | |
| 78 | if (display_init_required()) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 79 | display_startup(dev); |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 80 | else |
| 81 | printk(BIOS_INFO, "Skipping display init.\n"); |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 82 | } |
| 83 | |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 84 | static 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 Lin | ae3d71a | 2015-06-01 15:32:09 -0700 | [diff] [blame] | 92 | |
| 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 Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | struct 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 Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 104 | static 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 | */ |
| 119 | BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL); |