Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2019 Google LLC |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 10 | #include <asm/arch/iomap.h> |
Bernhard Messerklinger | d9461aa | 2020-05-18 12:33:34 +0200 | [diff] [blame^] | 11 | #include <asm/arch/fsp_bindings.h> |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 12 | #include <asm/fsp2/fsp_internal.h> |
| 13 | #include <dm/uclass-internal.h> |
| 14 | |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 15 | int fspm_update_config(struct udevice *dev, struct fspm_upd *upd) |
| 16 | { |
| 17 | struct fsp_m_config *cfg = &upd->config; |
| 18 | struct fspm_arch_upd *arch = &upd->arch; |
Bernhard Messerklinger | d9461aa | 2020-05-18 12:33:34 +0200 | [diff] [blame^] | 19 | ofnode node; |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 20 | |
| 21 | arch->nvs_buffer_ptr = NULL; |
| 22 | prepare_mrc_cache(upd); |
| 23 | arch->stack_base = (void *)0xfef96000; |
| 24 | arch->boot_loader_tolum_size = 0; |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 25 | arch->boot_mode = FSP_BOOT_WITH_FULL_CONFIGURATION; |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 26 | |
Bernhard Messerklinger | d9461aa | 2020-05-18 12:33:34 +0200 | [diff] [blame^] | 27 | node = dev_ofnode(dev); |
| 28 | if (!ofnode_valid(node)) |
| 29 | return log_msg_ret("fsp-m settings", -ENOENT); |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 30 | |
Bernhard Messerklinger | d9461aa | 2020-05-18 12:33:34 +0200 | [diff] [blame^] | 31 | return fsp_m_update_config_from_dtb(node, cfg); |
Simon Glass | 42bf7db | 2019-12-08 17:40:19 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | /* |
| 35 | * The FSP-M binary appears to break the SPI controller. It can be fixed by |
| 36 | * writing the BAR again, so do that here |
| 37 | */ |
| 38 | int fspm_done(struct udevice *dev) |
| 39 | { |
| 40 | struct udevice *spi; |
| 41 | int ret; |
| 42 | |
| 43 | /* Don't probe the device, since that reads the BAR */ |
| 44 | ret = uclass_find_first_device(UCLASS_SPI, &spi); |
| 45 | if (ret) |
| 46 | return log_msg_ret("SPI", ret); |
| 47 | if (!spi) |
| 48 | return log_msg_ret("no SPI", -ENODEV); |
| 49 | |
| 50 | dm_pci_write_config32(spi, PCI_BASE_ADDRESS_0, |
| 51 | IOMAP_SPI_BASE | PCI_BASE_ADDRESS_SPACE_MEMORY); |
| 52 | |
| 53 | return 0; |
| 54 | } |