Angel Pons | a2ee761 | 2020-04-04 18:51:15 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 3 | |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 4 | #include <bootmode.h> |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <soc/nvidia/tegra/dc.h> |
Tom Warren | 64982c50 | 2014-01-23 13:37:50 -0700 | [diff] [blame] | 8 | #include <soc/display.h> |
Julius Werner | f0d21ff3 | 2014-10-20 13:24:14 -0700 | [diff] [blame] | 9 | #include <soc/sdram.h> |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 10 | #include <symbols.h> |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 11 | |
Julius Werner | f0d21ff3 | 2014-10-20 13:24:14 -0700 | [diff] [blame] | 12 | #include "chip.h" |
| 13 | |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 14 | /* this sucks, but for now, fb size/location are hardcoded. |
| 15 | * Will break if we get 2. Sigh. |
| 16 | * We assume it's all multiples of MiB for MMUs sake. |
| 17 | */ |
Elyes HAOUAS | 3fcb218 | 2018-05-25 10:03:57 +0200 | [diff] [blame] | 18 | static void soc_enable(struct device *dev) |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 19 | { |
Tom Warren | 64982c50 | 2014-01-23 13:37:50 -0700 | [diff] [blame] | 20 | u32 lcdbase = fb_base_mb(); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 21 | unsigned long fb_size = FB_SIZE_MB; |
Tom Warren | 64982c50 | 2014-01-23 13:37:50 -0700 | [diff] [blame] | 22 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 23 | ram_resource(dev, 0, (uintptr_t)_dram/KiB, |
Gabe Black | 5cbbc70 | 2014-02-08 05:17:38 -0800 | [diff] [blame] | 24 | (sdram_max_addressable_mb() - fb_size)*KiB - |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 25 | (uintptr_t)_dram/KiB); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 26 | mmio_resource(dev, 1, lcdbase*KiB, fb_size*KiB); |
Gabe Black | 5cbbc70 | 2014-02-08 05:17:38 -0800 | [diff] [blame] | 27 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 28 | u32 sdram_end_mb = sdram_size_mb() + (uintptr_t)_dram/MiB; |
Gabe Black | 5cbbc70 | 2014-02-08 05:17:38 -0800 | [diff] [blame] | 29 | |
| 30 | if (sdram_end_mb > sdram_max_addressable_mb()) |
| 31 | ram_resource(dev, 2, sdram_max_addressable_mb()*KiB, |
| 32 | (sdram_end_mb - sdram_max_addressable_mb())*KiB); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Elyes HAOUAS | 3fcb218 | 2018-05-25 10:03:57 +0200 | [diff] [blame] | 35 | static void soc_init(struct device *dev) |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 36 | { |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 37 | if (display_init_required()) |
Gabe Black | 042f849 | 2014-03-31 21:01:14 -0700 | [diff] [blame] | 38 | display_startup(dev); |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 39 | else |
| 40 | printk(BIOS_INFO, "Skipping display init.\n"); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 41 | printk(BIOS_INFO, "CPU: Tegra124\n"); |
| 42 | } |
| 43 | |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 44 | static struct device_operations soc_ops = { |
Edward O'Callaghan | 0625a8b | 2014-10-31 08:03:16 +1100 | [diff] [blame] | 45 | .read_resources = DEVICE_NOOP, |
| 46 | .set_resources = DEVICE_NOOP, |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 47 | .enable_resources = soc_enable, |
| 48 | .init = soc_init, |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Elyes HAOUAS | 3fcb218 | 2018-05-25 10:03:57 +0200 | [diff] [blame] | 51 | static void enable_tegra124_dev(struct device *dev) |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 52 | { |
| 53 | dev->ops = &soc_ops; |
| 54 | } |
| 55 | |
| 56 | struct chip_operations soc_nvidia_tegra124_ops = { |
| 57 | CHIP_NAME("SOC Nvidia Tegra124") |
| 58 | .enable_dev = enable_tegra124_dev, |
| 59 | }; |