Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. |
| 6 | * Copyright 2013 Google Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
Julius Werner | f0d21ff3 | 2014-10-20 13:24:14 -0700 | [diff] [blame] | 18 | #include <arch/io.h> |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 19 | #include <bootmode.h> |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 20 | #include <console/console.h> |
| 21 | #include <device/device.h> |
| 22 | #include <soc/nvidia/tegra/dc.h> |
Tom Warren | 64982c50 | 2014-01-23 13:37:50 -0700 | [diff] [blame] | 23 | #include <soc/display.h> |
Julius Werner | f0d21ff3 | 2014-10-20 13:24:14 -0700 | [diff] [blame] | 24 | #include <soc/sdram.h> |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 25 | #include <symbols.h> |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 26 | |
Julius Werner | f0d21ff3 | 2014-10-20 13:24:14 -0700 | [diff] [blame] | 27 | #include "chip.h" |
| 28 | |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 29 | /* this sucks, but for now, fb size/location are hardcoded. |
| 30 | * Will break if we get 2. Sigh. |
| 31 | * We assume it's all multiples of MiB for MMUs sake. |
| 32 | */ |
| 33 | static void soc_enable(device_t dev) |
| 34 | { |
Tom Warren | 64982c50 | 2014-01-23 13:37:50 -0700 | [diff] [blame] | 35 | u32 lcdbase = fb_base_mb(); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 36 | unsigned long fb_size = FB_SIZE_MB; |
Tom Warren | 64982c50 | 2014-01-23 13:37:50 -0700 | [diff] [blame] | 37 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 38 | ram_resource(dev, 0, (uintptr_t)_dram/KiB, |
Gabe Black | 5cbbc70 | 2014-02-08 05:17:38 -0800 | [diff] [blame] | 39 | (sdram_max_addressable_mb() - fb_size)*KiB - |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 40 | (uintptr_t)_dram/KiB); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 41 | mmio_resource(dev, 1, lcdbase*KiB, fb_size*KiB); |
Gabe Black | 5cbbc70 | 2014-02-08 05:17:38 -0800 | [diff] [blame] | 42 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 43 | u32 sdram_end_mb = sdram_size_mb() + (uintptr_t)_dram/MiB; |
Gabe Black | 5cbbc70 | 2014-02-08 05:17:38 -0800 | [diff] [blame] | 44 | |
| 45 | if (sdram_end_mb > sdram_max_addressable_mb()) |
| 46 | ram_resource(dev, 2, sdram_max_addressable_mb()*KiB, |
| 47 | (sdram_end_mb - sdram_max_addressable_mb())*KiB); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static void soc_init(device_t dev) |
| 51 | { |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 52 | if (display_init_required()) |
Gabe Black | 042f849 | 2014-03-31 21:01:14 -0700 | [diff] [blame] | 53 | display_startup(dev); |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 54 | else |
| 55 | printk(BIOS_INFO, "Skipping display init.\n"); |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 56 | printk(BIOS_INFO, "CPU: Tegra124\n"); |
| 57 | } |
| 58 | |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 59 | static struct device_operations soc_ops = { |
Edward O'Callaghan | 0625a8b | 2014-10-31 08:03:16 +1100 | [diff] [blame] | 60 | .read_resources = DEVICE_NOOP, |
| 61 | .set_resources = DEVICE_NOOP, |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 62 | .enable_resources = soc_enable, |
| 63 | .init = soc_init, |
| 64 | .scan_bus = 0, |
| 65 | }; |
| 66 | |
| 67 | static void enable_tegra124_dev(device_t dev) |
| 68 | { |
| 69 | dev->ops = &soc_ops; |
| 70 | } |
| 71 | |
| 72 | struct chip_operations soc_nvidia_tegra124_ops = { |
| 73 | CHIP_NAME("SOC Nvidia Tegra124") |
| 74 | .enable_dev = enable_tegra124_dev, |
| 75 | }; |