]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/x86/cpu/pci.c
x86: Add a x86_ prefix to the x86-specific PCI functions
[people/ms/u-boot.git] / arch / x86 / cpu / pci.c
CommitLineData
d188b18f
SG
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>
7430f108
SG
13#include <errno.h>
14#include <malloc.h>
d188b18f
SG
15#include <pci.h>
16#include <asm/pci.h>
17
4722c035
BM
18DECLARE_GLOBAL_DATA_PTR;
19
d188b18f
SG
20static struct pci_controller x86_hose;
21
7430f108
SG
22int pci_early_init_hose(struct pci_controller **hosep)
23{
24 struct pci_controller *hose;
25
26 hose = calloc(1, sizeof(struct pci_controller));
27 if (!hose)
28 return -ENOMEM;
29
30 board_pci_setup_hose(hose);
31 pci_setup_type1(hose);
fa5530b8 32 hose->last_busno = pci_hose_scan(hose);
8f9052fd 33 gd->hose = hose;
7430f108
SG
34 *hosep = hose;
35
36 return 0;
37}
38
e94ea6f6
SG
39__weak int board_pci_pre_scan(struct pci_controller *hose)
40{
41 return 0;
42}
43
44__weak int board_pci_post_scan(struct pci_controller *hose)
45{
46 return 0;
47}
48
d188b18f
SG
49void pci_init_board(void)
50{
51 struct pci_controller *hose = &x86_hose;
52
7430f108 53 /* Stop using the early hose */
8f9052fd 54 gd->hose = NULL;
7430f108 55
d188b18f
SG
56 board_pci_setup_hose(hose);
57 pci_setup_type1(hose);
58 pci_register_hose(hose);
59
e94ea6f6 60 board_pci_pre_scan(hose);
d188b18f 61 hose->last_busno = pci_hose_scan(hose);
e94ea6f6 62 board_pci_post_scan(hose);
d188b18f 63}
6fb3b72e
SG
64
65static struct pci_controller *get_hose(void)
66{
8f9052fd
BM
67 if (gd->hose)
68 return gd->hose;
6fb3b72e
SG
69
70 return pci_bus_to_hose(0);
71}
72
31f57c28 73unsigned int x86_pci_read_config8(pci_dev_t dev, unsigned where)
6fb3b72e
SG
74{
75 uint8_t value;
76
77 pci_hose_read_config_byte(get_hose(), dev, where, &value);
78
79 return value;
80}
81
31f57c28 82unsigned int x86_pci_read_config16(pci_dev_t dev, unsigned where)
6fb3b72e
SG
83{
84 uint16_t value;
85
86 pci_hose_read_config_word(get_hose(), dev, where, &value);
87
88 return value;
89}
90
31f57c28 91unsigned int x86_pci_read_config32(pci_dev_t dev, unsigned where)
6fb3b72e
SG
92{
93 uint32_t value;
94
95 pci_hose_read_config_dword(get_hose(), dev, where, &value);
96
97 return value;
98}
99
31f57c28 100void x86_pci_write_config8(pci_dev_t dev, unsigned where, unsigned value)
6fb3b72e
SG
101{
102 pci_hose_write_config_byte(get_hose(), dev, where, value);
103}
104
31f57c28 105void x86_pci_write_config16(pci_dev_t dev, unsigned where, unsigned value)
6fb3b72e
SG
106{
107 pci_hose_write_config_word(get_hose(), dev, where, value);
108}
109
31f57c28 110void x86_pci_write_config32(pci_dev_t dev, unsigned where, unsigned value)
6fb3b72e
SG
111{
112 pci_hose_write_config_dword(get_hose(), dev, where, value);
113}