[U-Boot] [PATCH 23/39] x86: Refactor PCI to permit alternate init
Simon Glass
sjg at chromium.org
Thu Nov 6 21:20:15 CET 2014
We want access PCI earlier in the init sequence, so refactor the code so
that it does not require use of a BSS variable to work. This will allow us
to use early malloc() to store information about a PCI hose.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/x86/cpu/pci.c | 26 +++++++++++++++++++++++---
arch/x86/include/asm/u-boot-x86.h | 3 +++
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/arch/x86/cpu/pci.c b/arch/x86/cpu/pci.c
index f35c8b3..a72175d 100644
--- a/arch/x86/cpu/pci.c
+++ b/arch/x86/cpu/pci.c
@@ -10,6 +10,8 @@
*/
#include <common.h>
+#include <errno.h>
+#include <malloc.h>
#include <pci.h>
#include <asm/pci.h>
@@ -31,10 +33,8 @@ static struct pci_config_table pci_x86_config_table[] = {
{}
};
-void pci_init_board(void)
+static void pci_setup_hose(struct pci_controller *hose)
{
- struct pci_controller *hose = &x86_hose;
-
hose->config_table = pci_x86_config_table;
hose->first_busno = 0;
hose->last_busno = 0;
@@ -44,7 +44,27 @@ void pci_init_board(void)
hose->region_count = 1;
pci_setup_type1(hose);
+}
+
+int pci_early_init_hose(struct pci_controller **hosep)
+{
+ struct pci_controller *hose;
+
+ hose = calloc(1, sizeof(struct pci_controller));
+ if (!hose)
+ return -ENOMEM;
+
+ pci_setup_hose(hose);
+ *hosep = hose;
+
+ return 0;
+}
+
+void pci_init_board(void)
+{
+ struct pci_controller *hose = &x86_hose;
+ pci_setup_hose(hose);
pci_register_hose(hose);
pci_hose_scan(hose);
diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h
index 8d5b438..6404cd3 100644
--- a/arch/x86/include/asm/u-boot-x86.h
+++ b/arch/x86/include/asm/u-boot-x86.h
@@ -37,6 +37,9 @@ int cpu_init_interrupts(void);
/* board/.../... */
int dram_init(void);
+struct pci_controller;
+int pci_early_init_hose(struct pci_controller **hosep);
+
int cleanup_before_linux(void);
int x86_cleanup_before_linux(void);
void x86_enable_caches(void);
--
2.1.0.rc2.206.gedb03e5
More information about the U-Boot
mailing list