blob: cd969cb5182d4e3bb6a9b4dcaf739f2495f18ae0 [file] [log] [blame]
Wolfgang Denk52744b42013-07-28 22:12:45 +02001/*
Wolfgang Denk815c9672013-09-17 11:24:06 +02002 * SPDX-License-Identifier: GPL-2.0 IBM-pibs
Wolfgang Denk52744b42013-07-28 22:12:45 +02003 */
wdenkc6097192002-11-03 00:24:07 +00004/*
5 * Adapted for PIP405 03.07.01
6 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
7 *
8 * TODO: Clean-up
9 */
10
11#include <common.h>
12#include <pci.h>
13#include "isa.h"
14
15#ifdef CONFIG_405GP
16#ifdef CONFIG_PCI
17
Wolfgang Denk6405a152006-03-31 18:32:53 +020018DECLARE_GLOBAL_DATA_PTR;
wdenkc6097192002-11-03 00:24:07 +000019
20#include "piix4_pci.h"
21#include "pci_parts.h"
22
23void pci_pip405_write_regs(struct pci_controller *hose, pci_dev_t dev,
24 struct pci_config_table *entry)
25{
26 struct pci_pip405_config_entry *table;
27 int i;
28
29 table = (struct pci_pip405_config_entry*) entry->priv[0];
30
31 for (i=0; table[i].width; i++)
32 {
33#ifdef DEBUG
34 printf("Reg 0x%02X Value 0x%08lX Width %02d written\n",
35 table[i].index, table[i].val, table[i].width);
36#endif
37
38 switch(table[i].width)
39 {
40 case 1: pci_hose_write_config_byte(hose, dev, table[i].index, table[i].val); break;
41 case 2: pci_hose_write_config_word(hose, dev, table[i].index, table[i].val); break;
42 case 4: pci_hose_write_config_dword(hose, dev, table[i].index, table[i].val); break;
43 }
44 }
45}
46
47
48static void pci_pip405_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
49{
50 unsigned char int_line = 0xff;
wdenkb02744a2003-04-05 00:53:31 +000051 unsigned char pin;
wdenkc6097192002-11-03 00:24:07 +000052 /*
53 * Write pci interrupt line register
54 */
55 if(PCI_DEV(dev)==0) /* Device0 = PPC405 -> skip */
56 return;
wdenkb02744a2003-04-05 00:53:31 +000057 pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_PIN, &pin);
58 if ((pin == 0) || (pin > 4))
59 return;
60
61 int_line = ((PCI_DEV(dev) + (pin-1) + 10) % 4) + 28;
62 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
wdenkc6097192002-11-03 00:24:07 +000063#ifdef DEBUG
wdenkb02744a2003-04-05 00:53:31 +000064 printf("Fixup IRQ: dev %d (%x) int line %d 0x%x\n",
65 PCI_DEV(dev),dev,int_line,int_line);
wdenkc6097192002-11-03 00:24:07 +000066#endif
wdenkc6097192002-11-03 00:24:07 +000067}
68
69extern void pci_405gp_init(struct pci_controller *hose);
70
71
72static struct pci_controller hose = {
73 config_table: pci_pip405_config_table,
74 fixup_irq: pci_pip405_fixup_irq,
75};
76
wdenkb02744a2003-04-05 00:53:31 +000077
stroesef5dd4102003-02-14 11:21:23 +000078void pci_init_board(void)
wdenkc6097192002-11-03 00:24:07 +000079{
80 /*we want the ptrs to RAM not flash (ie don't use init list)*/
81 hose.fixup_irq = pci_pip405_fixup_irq;
82 hose.config_table = pci_pip405_config_table;
wdenkb02744a2003-04-05 00:53:31 +000083#ifdef DEBUG
84 printf("Init PCI: fixup_irq=%p config_table=%p hose=%p\n",pci_pip405_fixup_irq,pci_pip405_config_table,hose);
85#endif
wdenkc6097192002-11-03 00:24:07 +000086 pci_405gp_init(&hose);
87}
88
89#endif /* CONFIG_PCI */
90#endif /* CONFIG_405GP */