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> |
| 32 | |
| 33 | static void soc_read_resources(device_t dev) |
| 34 | { |
| 35 | ram_resource(dev, 0, (uintptr_t)_dram / KiB, sdram_size_mb() * KiB); |
| 36 | } |
| 37 | |
| 38 | static void soc_init(device_t dev) |
| 39 | { |
| 40 | /* Init ECAM, MDIO, PEM, PHY, QLM ... */ |
| 41 | bdk_boot(); |
| 42 | |
| 43 | /* TODO: additional trustzone init */ |
| 44 | } |
| 45 | |
| 46 | static void soc_final(device_t dev) |
| 47 | { |
| 48 | watchdog_disable(0); |
| 49 | } |
| 50 | |
| 51 | static struct device_operations soc_ops = { |
Patrick Rudolph | 88f81af | 2018-04-11 11:40:55 +0200 | [diff] [blame] | 52 | .read_resources = soc_read_resources, |
| 53 | .set_resources = DEVICE_NOOP, |
| 54 | .enable_resources = DEVICE_NOOP, |
| 55 | .init = soc_init, |
| 56 | .final = soc_final, |
| 57 | .scan_bus = NULL, |
David Hendricks | 8cbd569 | 2017-12-01 20:49:48 -0800 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static void enable_soc_dev(device_t dev) |
| 61 | { |
| 62 | dev->ops = &soc_ops; |
| 63 | } |
| 64 | |
| 65 | struct chip_operations soc_cavium_cn81xx_ops = { |
| 66 | CHIP_NAME("SOC Cavium CN81XX") |
| 67 | .enable_dev = enable_soc_dev, |
| 68 | }; |