coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
soc.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <bootmem.h>
4 #include <bootmode.h>
5 #include <bootstate.h>
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <soc/nvidia/tegra/dc.h>
9 #include <soc/addressmap.h>
10 #include <soc/clock.h>
11 #include <soc/cpu.h>
12 #include <soc/mc.h>
14 #include <soc/sdram.h>
15 #include <soc/sdram_configs.h>
16 
17 #include "chip.h"
18 
20 {
21  uintptr_t begin;
22  size_t size;
23  carveout_range(CARVEOUT_TZ, &begin, &size);
24  if (size == 0)
25  return;
26  bootmem_add_range(begin * MiB, size * MiB, BM_MEM_BL31);
27 }
28 
29 static void soc_read_resources(struct device *dev)
30 {
31  unsigned long index = 0;
32  int i; uintptr_t begin, end;
33  size_t size;
34 
35  for (i = CARVEOUT_TZ + 1; i < CARVEOUT_NUM; i++) {
36  carveout_range(i, &begin, &size);
37  if (size == 0)
38  continue;
39  reserved_ram_resource(dev, index++, begin * KiB, size * KiB);
40  }
41 
42  memory_in_range_below_4gb(&begin, &end);
43  size = end - begin;
44  ram_resource(dev, index++, begin * KiB, size * KiB);
45 
46  memory_in_range_above_4gb(&begin, &end);
47  size = end - begin;
48  ram_resource(dev, index++, begin * KiB, size * KiB);
49 }
50 
51 static struct device_operations soc_ops = {
53  .set_resources = noop_set_resources,
54 };
55 
56 static void enable_tegra210_dev(struct device *dev)
57 {
58  if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
59  dev->ops = &soc_ops;
60 
61  if (!CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT))
62  return;
63 
65  display_startup(dev);
66  else
67  printk(BIOS_INFO, "Skipping display init.\n");
68 }
69 
70 static void tegra210_init(void *chip_info)
71 {
72  struct tegra_revision rev;
73 
74  tegra_revision_info(&rev);
75 
76  printk(BIOS_INFO, "chip %x rev %02x.%x\n",
77  rev.chip_id, rev.major, rev.minor);
78 
79  /* Save sdram parameters to scratch regs to be used in LP0 resume */
81  printk(BIOS_INFO, "sdram params saved.\n");
82 }
83 
85  CHIP_NAME("SOC Nvidia Tegra210")
86  .init = tegra210_init,
87  .enable_dev = enable_tegra210_dev,
88 };
89 
90 static void enable_plld(void *unused)
91 {
92  /*
93  * Configure a conservative 300MHz clock for PLLD. The kernel cannot
94  * handle PLLD not being configured so enable PLLD unconditionally
95  * with a default clock rate.
96  */
98 }
99 
100 /*
101  * The PLLD being enabled is done at BS_DEV_INIT time because mainboard_init()
102  * is the first thing called. This ensures PLLD is up and functional before
103  * anything that mainboard can do that implicitly relies on PLLD.
104  */
void memory_in_range_above_4gb(uintptr_t *base_mib, uintptr_t *end_mib)
Definition: addressmap.c:226
void carveout_range(int id, uintptr_t *base_mib, size_t *size_mib)
Definition: addressmap.c:53
void memory_in_range_below_4gb(uintptr_t *base_mib, uintptr_t *end_mib)
Definition: addressmap.c:219
void tegra_revision_info(struct tegra_revision *id)
Definition: apbmisc.c:20
const struct sdram_info * get_sdram_config(void)
Definition: sdram_configs.c:85
@ BM_MEM_BL31
Definition: bootmem.h:30
void bootmem_add_range(uint64_t start, uint64_t size, const enum bootmem_type tag)
Definition: bootmem.c:88
int display_init_required(void)
Definition: bootmode.c:22
@ BS_DEV_INIT
Definition: bootstate.h:83
@ BS_ON_ENTRY
Definition: bootstate.h:95
#define MiB
Definition: helpers.h:76
#define MHz
Definition: helpers.h:80
#define KiB
Definition: helpers.h:75
void bootmem_platform_add_ranges(void)
Definition: soc.c:312
#define printk(level,...)
Definition: stdlib.h:16
@ CONFIG
Definition: dsi_common.h:201
static void display_startup(void)
Definition: mainboard.c:207
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_set_resources(struct device *dev)
Definition: device.h:74
#define ram_resource(dev, idx, basek, sizek)
Definition: device.h:321
#define reserved_ram_resource(dev, idx, basek, sizek)
Definition: device.h:324
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
void sdram_lp0_save_params(const struct sdram_params *sdram)
Definition: sdram_lp0.c:24
static void enable_plld(void *unused)
Definition: soc.c:90
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, enable_plld, NULL)
static void soc_read_resources(struct device *dev)
Definition: soc.c:29
static void tegra210_init(void *chip_info)
Definition: soc.c:70
static struct device_operations soc_ops
Definition: soc.c:51
static void enable_tegra210_dev(struct device *dev)
Definition: soc.c:56
struct chip_operations soc_nvidia_tegra210_ops
Definition: soc.c:84
@ DEVICE_PATH_CPU_CLUSTER
Definition: path.h:14
u32 clock_configure_plld(u32 frequency)
Definition: clock.c:385
@ CARVEOUT_TZ
Definition: addressmap.h:102
@ CARVEOUT_NUM
Definition: addressmap.h:109
#define NULL
Definition: stddef.h:19
unsigned long uintptr_t
Definition: stdint.h:21
void(* read_resources)(struct device *dev)
Definition: device.h:39
enum device_path_type type
Definition: path.h:114
Definition: device.h:107
struct device_path path
Definition: device.h:115
struct device_operations * ops
Definition: device.h:143