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
29
30#include <common.h>
31#include <pci.h>
32#include "isa.h"
33
34#ifdef CONFIG_405GP
35#ifdef CONFIG_PCI
36
37DECLARE_GLOBAL_DATA_PTR;
38
39#include "piix4_pci.h"
40#include "pci_parts.h"
41
42void pci_pip405_write_regs(struct pci_controller *hose, pci_dev_t dev,
43 struct pci_config_table *entry)
44{
45 struct pci_pip405_config_entry *table;
46 int i;
47
48 table = (struct pci_pip405_config_entry*) entry->priv[0];
49
50 for (i=0; table[i].width; i++)
51 {
52#ifdef DEBUG
53 printf("Reg 0x%02X Value 0x%08lX Width %02d written\n",
54 table[i].index, table[i].val, table[i].width);
55#endif
56
57 switch(table[i].width)
58 {
59 case 1: pci_hose_write_config_byte(hose, dev, table[i].index, table[i].val); break;
60 case 2: pci_hose_write_config_word(hose, dev, table[i].index, table[i].val); break;
61 case 4: pci_hose_write_config_dword(hose, dev, table[i].index, table[i].val); break;
62 }
63 }
64}
65
66
67static void pci_pip405_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
68{
69 unsigned char int_line = 0xff;
70 unsigned char pin;
71
72
73
74 if(PCI_DEV(dev)==0)
75 return;
76 pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_PIN, &pin);
77 if ((pin == 0) || (pin > 4))
78 return;
79
80 int_line = ((PCI_DEV(dev) + (pin-1) + 10) % 4) + 28;
81 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
82#ifdef DEBUG
83 printf("Fixup IRQ: dev %d (%x) int line %d 0x%x\n",
84 PCI_DEV(dev),dev,int_line,int_line);
85#endif
86}
87
88extern void pci_405gp_init(struct pci_controller *hose);
89
90
91static struct pci_controller hose = {
92 config_table: pci_pip405_config_table,
93 fixup_irq: pci_pip405_fixup_irq,
94};
95
96
97void pci_init_board(void)
98{
99
100 hose.fixup_irq = pci_pip405_fixup_irq;
101 hose.config_table = pci_pip405_config_table;
102#ifdef DEBUG
103 printf("Init PCI: fixup_irq=%p config_table=%p hose=%p\n",pci_pip405_fixup_irq,pci_pip405_config_table,hose);
104#endif
105 pci_405gp_init(&hose);
106}
107
108#endif
109#endif
110