x86: Support use of PCI before relocation
[oweals/u-boot.git] / arch / x86 / cpu / pci.c
1 /*
2  * Copyright (c) 2011 The Chromium OS Authors.
3  * (C) Copyright 2008,2009
4  * Graeme Russ, <graeme.russ@gmail.com>
5  *
6  * (C) Copyright 2002
7  * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
8  *
9  * SPDX-License-Identifier:     GPL-2.0+
10  */
11
12 #include <common.h>
13 #include <errno.h>
14 #include <malloc.h>
15 #include <pci.h>
16 #include <asm/pci.h>
17
18 static struct pci_controller x86_hose;
19
20 int pci_early_init_hose(struct pci_controller **hosep)
21 {
22         struct pci_controller *hose;
23
24         hose = calloc(1, sizeof(struct pci_controller));
25         if (!hose)
26                 return -ENOMEM;
27
28         board_pci_setup_hose(hose);
29         pci_setup_type1(hose);
30         gd->arch.hose = hose;
31         *hosep = hose;
32
33         return 0;
34 }
35
36 void pci_init_board(void)
37 {
38         struct pci_controller *hose = &x86_hose;
39
40         /* Stop using the early hose */
41         gd->arch.hose = NULL;
42
43         board_pci_setup_hose(hose);
44         pci_setup_type1(hose);
45         pci_register_hose(hose);
46
47         hose->last_busno = pci_hose_scan(hose);
48 }