coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
nc_fpga_early.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/mmio.h>
4 #include <device/pci.h>
5 #include <device/pci_def.h>
6 #include <device/pci_ids.h>
7 #include <device/pci_ops.h>
8 #include <types.h>
9 
10 #include "nc_fpga.h"
11 
12 static DEVTREE_CONST uint32_t fpga_bar = CONFIG_EARLY_PCI_MMIO_BASE;
13 static bool nc_fpga_present = false;
14 
15 int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base)
16 {
17  pci_devfn_t pci_dev = PCI_DEV(bus, dev, 0);
19 
20  if (id != (0x4091 << 16 | PCI_VID_SIEMENS))
21  return -1;
22 
23  /* Setup base address for BAR0. */
25  /* Enable memory access for pci_dev. */
27  reg16 |= PCI_COMMAND_MEMORY;
29  nc_fpga_present = true;
30 
31  return 0;
32 }
33 
34 void nc_fpga_remap(uint32_t new_mmio)
35 {
36 #if ENV_RAMSTAGE
37  fpga_bar = new_mmio;
38 #endif
39 }
40 
42 {
43  /* The function pci_earyl_device_probe is called in bootblock and romstage. Make sure
44  that in these stages the initialization code was successful before the POST code
45  value is written to the register. */
46  if ((ENV_BOOTBLOCK || ENV_ROMSTAGE) && nc_fpga_present == false)
47  return;
49 }
pte_t value
Definition: mmu.c:91
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
#define pci_dev
#define NC_FPGA_POST_OFFSET
Definition: nc_fpga.h:20
void nc_fpga_remap(uint32_t new_mmio)
Definition: nc_fpga_early.c:34
static DEVTREE_CONST uint32_t fpga_bar
Definition: nc_fpga_early.c:12
int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base)
Definition: nc_fpga_early.c:15
void nc_fpga_post(uint8_t value)
Definition: nc_fpga_early.c:41
static bool nc_fpga_present
Definition: nc_fpga_early.c:13
#define PCI_COMMAND_MEMORY
Definition: pci_def.h:12
#define PCI_BASE_ADDRESS_0
Definition: pci_def.h:63
#define PCI_COMMAND
Definition: pci_def.h:10
#define PCI_VENDOR_ID
Definition: pci_def.h:8
#define PCI_VID_SIEMENS
Definition: pci_ids.h:1491
static __always_inline uint32_t pci_s_read_config32(pci_devfn_t dev, uint16_t reg)
Definition: pci_io_cfg.h:92
static __always_inline uint16_t pci_s_read_config16(pci_devfn_t dev, uint16_t reg)
Definition: pci_io_cfg.h:86
static __always_inline void pci_s_write_config16(pci_devfn_t dev, uint16_t reg, uint16_t value)
Definition: pci_io_cfg.h:104
static __always_inline void pci_s_write_config32(pci_devfn_t dev, uint16_t reg, uint32_t value)
Definition: pci_io_cfg.h:110
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
#define ENV_BOOTBLOCK
Definition: rules.h:148
#define ENV_ROMSTAGE
Definition: rules.h:149
#define DEVTREE_CONST
Definition: stddef.h:30
unsigned int uint32_t
Definition: stdint.h:14
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8
Definition: device.h:76