1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include <common.h>
29#include <asm/io.h>
30#include <pci.h>
31
32#define cfg_read(val, addr, op) (*val = op((int)(addr)))
33#define cfg_write(val, addr, op) op((val), (int)(addr))
34
35#define TYPE1_PCI_OP(rw, size, type, op, mask) \
36static int \
37type1_##rw##_config_##size(struct pci_controller *hose, \
38 pci_dev_t dev, int offset, type val) \
39{ \
40 outl(dev | (offset & 0xfc) | 0x80000000, (int)hose->cfg_addr); \
41 cfg_##rw(val, hose->cfg_data + (offset & mask), op); \
42 return 0; \
43}
44
45TYPE1_PCI_OP(read, byte, u8 *, inb, 3)
46TYPE1_PCI_OP(read, word, u16 *, inw, 2)
47TYPE1_PCI_OP(read, dword, u32 *, inl, 0)
48
49TYPE1_PCI_OP(write, byte, u8, outb, 3)
50TYPE1_PCI_OP(write, word, u16, outw, 2)
51TYPE1_PCI_OP(write, dword, u32, outl, 0)
52
53
54#define PCI_REG_ADDR 0x00000cf8
55#define PCI_REG_DATA 0x00000cfc
56
57void pci_setup_type1(struct pci_controller *hose)
58{
59 pci_set_ops(hose,
60 type1_read_config_byte,
61 type1_read_config_word,
62 type1_read_config_dword,
63 type1_write_config_byte,
64 type1_write_config_word,
65 type1_write_config_dword);
66
67 hose->cfg_addr = (unsigned int *)PCI_REG_ADDR;
68 hose->cfg_data = (unsigned char *)PCI_REG_DATA;
69}
70