blob: 5e540a676519b560680361e9624fea5e20932c3d [file] [log] [blame]
David Hendricks8cbd5692017-12-01 20:49:48 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2018 Facebook, Inc.
5 * Copyright 2003-2017 Cavium Inc. <support@cavium.com>
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 * Derived from Cavium's BSD-3 Clause OCTEONTX-SDK-6.2.0.
17 */
18
19#include <bootmode.h>
20#include <console/console.h>
21#include <cpu/cpu.h>
22#include <device/device.h>
23#include <soc/addressmap.h>
24#include <soc/clock.h>
25#include <soc/sdram.h>
26#include <soc/timer.h>
27#include <stddef.h>
28#include <stdlib.h>
29#include <string.h>
30#include <symbols.h>
31#include <libbdk-boot/bdk-boot.h>
Patrick Rudolphd0c67972018-04-17 13:47:55 +020032#include <soc/ecam0.h>
David Hendricks8cbd5692017-12-01 20:49:48 -080033
34static void soc_read_resources(device_t dev)
35{
36 ram_resource(dev, 0, (uintptr_t)_dram / KiB, sdram_size_mb() * KiB);
37}
38
39static void soc_init(device_t dev)
40{
41 /* Init ECAM, MDIO, PEM, PHY, QLM ... */
42 bdk_boot();
43
44 /* TODO: additional trustzone init */
45}
46
47static void soc_final(device_t dev)
48{
49 watchdog_disable(0);
50}
51
52static struct device_operations soc_ops = {
Patrick Rudolph88f81af2018-04-11 11:40:55 +020053 .read_resources = soc_read_resources,
54 .set_resources = DEVICE_NOOP,
55 .enable_resources = DEVICE_NOOP,
56 .init = soc_init,
57 .final = soc_final,
58 .scan_bus = NULL,
David Hendricks8cbd5692017-12-01 20:49:48 -080059};
60
61static void enable_soc_dev(device_t dev)
62{
Patrick Rudolphd0c67972018-04-17 13:47:55 +020063 if (dev->path.type == DEVICE_PATH_DOMAIN &&
64 dev->path.domain.domain == 0) {
65 dev->ops = &pci_domain_ops_ecam0;
66 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
67 dev->ops = &soc_ops;
68 }
David Hendricks8cbd5692017-12-01 20:49:48 -080069}
70
71struct chip_operations soc_cavium_cn81xx_ops = {
72 CHIP_NAME("SOC Cavium CN81XX")
73 .enable_dev = enable_soc_dev,
74};