blob: 1071d68b60d73dea5502506c6103a372e919da18 [file] [log] [blame]
Patrick Georgi40a3e322015-06-22 19:41:29 +02001/*
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.
Patrick Georgi40a3e322015-06-22 19:41:29 +020015 */
16
17#include <arch/io.h>
18#include <arch/cache.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020019#include <cpu/cpu.h>
Aaron Durbinbc98cc62015-09-02 09:21:36 -050020#include <bootmode.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020021#include <bootstate.h>
22#include <cbmem.h>
23#include <console/console.h>
24#include <device/device.h>
25#include <soc/nvidia/tegra/dc.h>
26#include <soc/addressmap.h>
27#include <soc/clock.h>
28#include <soc/cpu.h>
29#include <soc/mc.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020030#include <soc/nvidia/tegra/apbmisc.h>
31#include <string.h>
32#include <timer.h>
Yen Linae3d71a2015-06-01 15:32:09 -070033#include <soc/sdram.h>
34#include <soc/sdram_configs.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020035
36#include "chip.h"
37
38static void soc_read_resources(device_t dev)
39{
40 unsigned long index = 0;
41 int i; uintptr_t begin, end;
42 size_t size;
43
44 for (i = 0; i < CARVEOUT_NUM; i++) {
45 carveout_range(i, &begin, &size);
46 if (size == 0)
47 continue;
48 reserved_ram_resource(dev, index++, begin * KiB, size * KiB);
49 }
50
51 memory_in_range_below_4gb(&begin, &end);
52 size = end - begin;
53 ram_resource(dev, index++, begin * KiB, size * KiB);
54
55 memory_in_range_above_4gb(&begin, &end);
56 size = end - begin;
57 ram_resource(dev, index++, begin * KiB, size * KiB);
58}
59
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070060static struct device_operations soc_ops = {
61 .read_resources = soc_read_resources,
62 .set_resources = DEVICE_NOOP,
63 .enable_resources = DEVICE_NOOP,
64 .init = DEVICE_NOOP,
65 .scan_bus = NULL,
66};
Patrick Georgi40a3e322015-06-22 19:41:29 +020067
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070068static void enable_tegra210_dev(device_t dev)
69{
70 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
71 dev->ops = &soc_ops;
Patrick Georgi40a3e322015-06-22 19:41:29 +020072
Aaron Durbinbc98cc62015-09-02 09:21:36 -050073 if (!IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT))
74 return;
75
76 if (display_init_required())
Patrick Georgi40a3e322015-06-22 19:41:29 +020077 display_startup(dev);
Aaron Durbinbc98cc62015-09-02 09:21:36 -050078 else
79 printk(BIOS_INFO, "Skipping display init.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020080}
81
Patrick Georgi40a3e322015-06-22 19:41:29 +020082static void tegra210_init(void *chip_info)
83{
84 struct tegra_revision rev;
85
86 tegra_revision_info(&rev);
87
88 printk(BIOS_INFO, "chip %x rev %02x.%x\n",
89 rev.chip_id, rev.major, rev.minor);
Yen Linae3d71a2015-06-01 15:32:09 -070090
91 /* Save sdram parameters to scratch regs to be used in LP0 resume */
92 sdram_lp0_save_params(get_sdram_config());
93 printk(BIOS_INFO, "sdram params saved.\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020094}
95
96struct chip_operations soc_nvidia_tegra210_ops = {
97 CHIP_NAME("SOC Nvidia Tegra210")
98 .init = tegra210_init,
99 .enable_dev = enable_tegra210_dev,
100};
101
Patrick Georgi40a3e322015-06-22 19:41:29 +0200102static void enable_plld(void *unused)
103{
104 /*
105 * Configure a conservative 300MHz clock for PLLD. The kernel cannot
106 * handle PLLD not being configured so enable PLLD unconditionally
107 * with a default clock rate.
108 */
109 clock_configure_plld(300 * MHz);
110}
111
112/*
113 * The PLLD being enabled is done at BS_DEV_INIT time because mainboard_init()
114 * is the first thing called. This ensures PLLD is up and functional before
115 * anything that mainboard can do that implicitly relies on PLLD.
116 */
117BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL);