David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 1 | /* |
| 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 Rudolph | d0c6797 | 2018-04-17 13:47:55 +0200 | [diff] [blame^] | 32 | #include <soc/ecam0.h> |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 33 | |
| 34 | static void soc_read_resources(device_t dev) |
| 35 | { |
| 36 | ram_resource(dev, 0, (uintptr_t)_dram / KiB, sdram_size_mb() * KiB); |
| 37 | } |
| 38 | |
| 39 | static 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 | |
| 47 | static void soc_final(device_t dev) |
| 48 | { |
| 49 | watchdog_disable(0); |
| 50 | } |
| 51 | |
| 52 | static struct device_operations soc_ops = { |
Patrick Rudolph | 88f81af | 2018-04-11 11:40:55 +0200 | [diff] [blame] | 53 | .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 Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static void enable_soc_dev(device_t dev) |
| 62 | { |
Patrick Rudolph | d0c6797 | 2018-04-17 13:47:55 +0200 | [diff] [blame^] | 63 | 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 Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | struct chip_operations soc_cavium_cn81xx_ops = { |
| 72 | CHIP_NAME("SOC Cavium CN81XX") |
| 73 | .enable_dev = enable_soc_dev, |
| 74 | }; |