adb047e3fe6ce43f58c21d92bf5160e43eb6b3e8
[coreboot.git] / src / arch / ppc / lib / pci_dev.c
1 #include <arch/io.h>
2 #include <arch/pciconf.h>
3
4 /*
5  * Direct access to PCI hardware...
6  */
7
8 uint8_t pci_ppc_read_config8(unsigned char bus, int devfn, int where)
9 {
10         uint8_t res;
11
12         out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where));
13         res = in_8((unsigned char *)PCIC0_CFGDATA + (where & 3));
14         return res;
15 }
16
17 uint16_t pci_ppc_read_config16(unsigned char bus, int devfn, int where)
18 {
19         uint16_t res;
20
21         out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where));
22         res = in_le16((unsigned short *)PCIC0_CFGDATA + (where & 2));
23         return res;
24 }
25
26 uint32_t pci_ppc_read_config32(unsigned char bus, int devfn, int where)
27 {
28         uint32_t res;
29
30         out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where));
31         res = in_le32((unsigned *)PCIC0_CFGDATA);
32         return res;
33 }
34
35 int pci_ppc_write_config8(unsigned char bus, int devfn, int where, uint8_t data)
36 {
37         out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where));
38         out_8((unsigned char *)PCIC0_CFGDATA + (where & 3), data);
39         return 0;
40 }
41
42 int pci_ppc_write_config16(unsigned char bus, int devfn, int where, uint16_t data)
43 {
44         out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where));
45         out_le16((unsigned short *)PCIC0_CFGDATA + (where & 2), data);
46         return 0;
47 }
48
49 int pci_ppc_write_config32(unsigned char bus, int devfn, int where, uint32_t data)
50 {
51         out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where));
52         out_le32((unsigned *)PCIC0_CFGDATA, data);
53         return 0;
54 }