Wolfgang Denk | 52744b4 | 2013-07-28 22:12:45 +0200 | [diff] [blame] | 1 | /* |
Wolfgang Denk | 815c967 | 2013-09-17 11:24:06 +0200 | [diff] [blame] | 2 | * SPDX-License-Identifier: GPL-2.0 IBM-pibs |
Wolfgang Denk | 52744b4 | 2013-07-28 22:12:45 +0200 | [diff] [blame] | 3 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4 | /* |
| 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 Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 19 | |
| 20 | #include "piix4_pci.h" |
| 21 | #include "pci_parts.h" |
| 22 | |
| 23 | void 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 | |
| 48 | static void pci_pip405_fixup_irq(struct pci_controller *hose, pci_dev_t dev) |
| 49 | { |
| 50 | unsigned char int_line = 0xff; |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 51 | unsigned char pin; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 52 | /* |
| 53 | * Write pci interrupt line register |
| 54 | */ |
| 55 | if(PCI_DEV(dev)==0) /* Device0 = PPC405 -> skip */ |
| 56 | return; |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 57 | 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); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 63 | #ifdef DEBUG |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 64 | printf("Fixup IRQ: dev %d (%x) int line %d 0x%x\n", |
| 65 | PCI_DEV(dev),dev,int_line,int_line); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 66 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | extern void pci_405gp_init(struct pci_controller *hose); |
| 70 | |
| 71 | |
| 72 | static struct pci_controller hose = { |
| 73 | config_table: pci_pip405_config_table, |
| 74 | fixup_irq: pci_pip405_fixup_irq, |
| 75 | }; |
| 76 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 77 | |
stroese | f5dd410 | 2003-02-14 11:21:23 +0000 | [diff] [blame] | 78 | void pci_init_board(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 79 | { |
| 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; |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 83 | #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 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 86 | pci_405gp_init(&hose); |
| 87 | } |
| 88 | |
| 89 | #endif /* CONFIG_PCI */ |
| 90 | #endif /* CONFIG_405GP */ |