blob: 40889a7e05faccee4bc78625820ed6919090f6e3 [file] [log] [blame]
Tom Warren25258852014-07-15 10:34:19 -07001/*
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.
Tom Warren25258852014-07-15 10:34:19 -070015 */
16
Tom Warren25258852014-07-15 10:34:19 -070017#include <arch/io.h>
Aaron Durbin127f0512014-08-28 09:46:10 -050018#include <arch/cache.h>
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050019#include <cpu/cpu.h>
Aaron Durbinbc98cc62015-09-02 09:21:36 -050020#include <bootmode.h>
Aaron Durbin2962d1e2014-11-19 12:01:39 -060021#include <bootstate.h>
Aaron Durbin127f0512014-08-28 09:46:10 -050022#include <cbmem.h>
Julius Werner96195ee2014-10-20 13:25:21 -070023#include <console/console.h>
24#include <device/device.h>
Jimmy Zhang1f4db4042014-11-03 11:41:02 -080025#include <soc/nvidia/tegra/dc.h>
Tom Warren25258852014-07-15 10:34:19 -070026#include <soc/addressmap.h>
Furquan Shaikheb5e5882014-08-15 15:26:01 -070027#include <soc/clock.h>
Aaron Durbin79eb2b32014-08-27 17:51:19 -050028#include <soc/cpu.h>
Aaron Durbinbf534182014-08-04 11:40:45 -050029#include <soc/nvidia/tegra/apbmisc.h>
Julius Werner96195ee2014-10-20 13:25:21 -070030#include <string.h>
31#include <timer.h>
Julius Werner96195ee2014-10-20 13:25:21 -070032
Aaron Durbin79eb2b32014-08-27 17:51:19 -050033#include "chip.h"
Tom Warren25258852014-07-15 10:34:19 -070034
35static void soc_read_resources(device_t dev)
36{
37 unsigned long index = 0;
38 int i; uintptr_t begin, end;
39 size_t size;
40
Tom Warren25258852014-07-15 10:34:19 -070041 for (i = 0; i < CARVEOUT_NUM; i++) {
42 carveout_range(i, &begin, &size);
43 if (size == 0)
44 continue;
45 reserved_ram_resource(dev, index++, begin * KiB, size * KiB);
46 }
47
Tom Warren25258852014-07-15 10:34:19 -070048 memory_in_range_below_4gb(&begin, &end);
49 size = end - begin;
50 ram_resource(dev, index++, begin * KiB, size * KiB);
51
52 memory_in_range_above_4gb(&begin, &end);
53 size = end - begin;
54 ram_resource(dev, index++, begin * KiB, size * KiB);
55}
56
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070057static struct device_operations soc_ops = {
58 .read_resources = soc_read_resources,
59 .set_resources = DEVICE_NOOP,
60 .enable_resources = DEVICE_NOOP,
61 .init = DEVICE_NOOP,
62 .scan_bus = NULL,
63};
64
65static void enable_tegra132_dev(device_t dev)
Aaron Durbin47f18d42015-01-23 14:13:23 -060066{
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070067 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
68 dev->ops = &soc_ops;
Aaron Durbin47f18d42015-01-23 14:13:23 -060069
Aaron Durbinbc98cc62015-09-02 09:21:36 -050070 if (!IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT))
71 return;
72
73 if (display_init_required())
Jimmy Zhang1f4db4042014-11-03 11:41:02 -080074 display_startup(dev);
Aaron Durbinbc98cc62015-09-02 09:21:36 -050075 else
76 printk(BIOS_INFO, "Skipping display init.\n");
Tom Warren25258852014-07-15 10:34:19 -070077}
78
Aaron Durbinbf534182014-08-04 11:40:45 -050079static void tegra132_init(void *chip_info)
80{
81 struct tegra_revision rev;
82
83 tegra_revision_info(&rev);
84
85 printk(BIOS_INFO, "chip %x rev %02x.%x\n",
86 rev.chip_id, rev.major, rev.minor);
87
Aaron Durbin159aa122014-09-09 11:58:18 -050088 printk(BIOS_INFO, "MTS build %u\n", raw_read_aidr_el1());
Aaron Durbinbf534182014-08-04 11:40:45 -050089}
90
Tom Warren25258852014-07-15 10:34:19 -070091struct chip_operations soc_nvidia_tegra132_ops = {
92 CHIP_NAME("SOC Nvidia Tegra132")
Aaron Durbinbf534182014-08-04 11:40:45 -050093 .init = tegra132_init,
Tom Warren25258852014-07-15 10:34:19 -070094 .enable_dev = enable_tegra132_dev,
95};
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050096
Aaron Durbin2962d1e2014-11-19 12:01:39 -060097static void enable_plld(void *unused)
98{
99 /*
100 * Configure a conservative 300MHz clock for PLLD. The kernel cannot
101 * handle PLLD not being configured so enable PLLD unconditionally
102 * with a default clock rate.
103 */
104 clock_configure_plld(300 * MHz);
105}
106
107/*
108 * The PLLD being enabled is done at BS_DEV_INIT time because mainboard_init()
109 * is the first thing called. This ensures PLLD is up and functional before
110 * anything that mainboard can do that implicitly relies on PLLD.
111 */
112BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL);