blob: 107246781860c177ba8a1086a37a1974c8405711 [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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
Tom Warren25258852014-07-15 10:34:19 -070021#include <arch/io.h>
Aaron Durbin127f0512014-08-28 09:46:10 -050022#include <arch/cache.h>
Aaron Durbindec44e92014-09-17 11:47:35 -050023#include <arch/spintable.h>
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050024#include <cpu/cpu.h>
Aaron Durbin127f0512014-08-28 09:46:10 -050025#include <cbmem.h>
Julius Werner96195ee2014-10-20 13:25:21 -070026#include <console/console.h>
27#include <device/device.h>
Tom Warren25258852014-07-15 10:34:19 -070028#include <soc/addressmap.h>
Furquan Shaikheb5e5882014-08-15 15:26:01 -070029#include <soc/clock.h>
Aaron Durbin79eb2b32014-08-27 17:51:19 -050030#include <soc/cpu.h>
Aaron Durbinbf534182014-08-04 11:40:45 -050031#include <soc/nvidia/tegra/apbmisc.h>
Julius Werner96195ee2014-10-20 13:25:21 -070032#include <string.h>
33#include <timer.h>
34#include <vendorcode/google/chromeos/chromeos.h>
35
Aaron Durbin79eb2b32014-08-27 17:51:19 -050036#include "chip.h"
Tom Warren25258852014-07-15 10:34:19 -070037
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
Tom Warren25258852014-07-15 10:34:19 -070044 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
Tom Warren25258852014-07-15 10:34:19 -070051 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
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050060static size_t cntrl_total_cpus(void)
Aaron Durbin79eb2b32014-08-27 17:51:19 -050061{
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050062 return CONFIG_MAX_CPUS;
Aaron Durbin79eb2b32014-08-27 17:51:19 -050063}
64
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050065static int cntrl_start_cpu(unsigned int id, void (*entry)(void))
Aaron Durbin79eb2b32014-08-27 17:51:19 -050066{
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050067 if (id != 1)
68 return -1;
69 start_cpu(1, entry);
70 return 0;
Aaron Durbin79eb2b32014-08-27 17:51:19 -050071}
72
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050073static struct cpu_control_ops cntrl_ops = {
74 .total_cpus = cntrl_total_cpus,
75 .start_cpu = cntrl_start_cpu,
76};
77
Tom Warren25258852014-07-15 10:34:19 -070078static void soc_init(device_t dev)
79{
Aaron Durbindec44e92014-09-17 11:47:35 -050080 struct soc_nvidia_tegra132_config *cfg;
Aaron Durbin79eb2b32014-08-27 17:51:19 -050081
Furquan Shaikheb5e5882014-08-15 15:26:01 -070082 clock_init_arm_generic_timer();
Aaron Durbin79eb2b32014-08-27 17:51:19 -050083
Aaron Durbindec44e92014-09-17 11:47:35 -050084 cfg = dev->chip_info;
85 spintable_init((void *)cfg->spintable_addr);
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050086 arch_initialize_cpus(dev, &cntrl_ops);
Tom Warren25258852014-07-15 10:34:19 -070087}
88
Tom Warren25258852014-07-15 10:34:19 -070089static struct device_operations soc_ops = {
90 .read_resources = soc_read_resources,
Edward O'Callaghanc1a9dfe2015-03-26 20:10:09 +110091 .set_resources = DEVICE_NOOP,
92 .enable_resources = DEVICE_NOOP,
Tom Warren25258852014-07-15 10:34:19 -070093 .init = soc_init,
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050094 .scan_bus = NULL,
Tom Warren25258852014-07-15 10:34:19 -070095};
96
97static void enable_tegra132_dev(device_t dev)
98{
Aaron Durbinb6a81fa2014-09-06 02:36:40 -050099 if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
100 dev->ops = &soc_ops;
Tom Warren25258852014-07-15 10:34:19 -0700101}
102
Aaron Durbinbf534182014-08-04 11:40:45 -0500103static void tegra132_init(void *chip_info)
104{
105 struct tegra_revision rev;
106
107 tegra_revision_info(&rev);
108
109 printk(BIOS_INFO, "chip %x rev %02x.%x\n",
110 rev.chip_id, rev.major, rev.minor);
111
Aaron Durbin159aa122014-09-09 11:58:18 -0500112 printk(BIOS_INFO, "MTS build %u\n", raw_read_aidr_el1());
Aaron Durbinbf534182014-08-04 11:40:45 -0500113}
114
Tom Warren25258852014-07-15 10:34:19 -0700115struct chip_operations soc_nvidia_tegra132_ops = {
116 CHIP_NAME("SOC Nvidia Tegra132")
Aaron Durbinbf534182014-08-04 11:40:45 -0500117 .init = tegra132_init,
Tom Warren25258852014-07-15 10:34:19 -0700118 .enable_dev = enable_tegra132_dev,
119};
Aaron Durbinb6a81fa2014-09-06 02:36:40 -0500120
121static void tegra132_cpu_init(device_t cpu)
122{
Aaron Durbinb6a81fa2014-09-06 02:36:40 -0500123}
124
125static const struct cpu_device_id ids[] = {
126 { 0x4e0f0000 },
127 { CPU_ID_END },
128};
129
130static struct device_operations cpu_dev_ops = {
131 .init = tegra132_cpu_init,
132};
133
134static const struct cpu_driver driver __cpu_driver = {
135 .ops = &cpu_dev_ops,
136 .id_table = ids,
137};