Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 AMD |
| 5 | * Written by Yinghai Lu <yinghailu@amd.com> for AMD. |
| 6 | * Copyright (C) 2007 Silicon Integrated Systems Corp. (SiS) |
| 7 | * Written by Morgan Tsai <my_tsai@sis.com> for SiS. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 20 | #include <console/console.h> |
| 21 | #include <device/pci.h> |
| 22 | #include <string.h> |
| 23 | #include <stdint.h> |
| 24 | #include <arch/pirq_routing.h> |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 25 | #include <device/pci_ids.h> |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 26 | #include <cpu/amd/amdk8_sysconf.h> |
| 27 | |
| 28 | static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, uint8_t devfn, uint8_t link0, uint16_t bitmap0, |
| 29 | uint8_t link1, uint16_t bitmap1, uint8_t link2, uint16_t bitmap2,uint8_t link3, uint16_t bitmap3, |
| 30 | uint8_t slot, uint8_t rfu) |
| 31 | { |
| 32 | pirq_info->bus = bus; |
| 33 | pirq_info->devfn = devfn; |
| 34 | pirq_info->irq[0].link = link0; |
| 35 | pirq_info->irq[0].bitmap = bitmap0; |
| 36 | pirq_info->irq[1].link = link1; |
| 37 | pirq_info->irq[1].bitmap = bitmap1; |
| 38 | pirq_info->irq[2].link = link2; |
| 39 | pirq_info->irq[2].bitmap = bitmap2; |
| 40 | pirq_info->irq[3].link = link3; |
| 41 | pirq_info->irq[3].bitmap = bitmap3; |
| 42 | pirq_info->slot = slot; |
| 43 | pirq_info->rfu = rfu; |
| 44 | } |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 45 | extern unsigned char bus_sis966[8]; //1 |
| 46 | |
| 47 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 48 | { |
| 49 | |
| 50 | struct irq_routing_table *pirq; |
| 51 | struct irq_info *pirq_info; |
| 52 | unsigned slot_num; |
| 53 | uint8_t *v; |
| 54 | unsigned sbdn; |
| 55 | |
| 56 | uint8_t sum=0; |
| 57 | int i; |
| 58 | |
| 59 | get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c |
| 60 | sbdn = sysconf.sbdn; |
| 61 | |
| 62 | /* Align the table to be 16 byte aligned. */ |
| 63 | addr += 15; |
| 64 | addr &= ~15; |
| 65 | |
Kyösti Mälkki | 9533d83 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 66 | /* This table must be between 0xf0000 & 0x100000 */ |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 67 | printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 68 | |
| 69 | pirq = (void *)(addr); |
| 70 | v = (uint8_t *)(addr); |
| 71 | |
| 72 | pirq->signature = PIRQ_SIGNATURE; |
| 73 | pirq->version = PIRQ_VERSION; |
| 74 | |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 75 | pirq->rtr_bus = 0; |
| 76 | pirq->rtr_devfn = PCI_DEVFN(2, 0); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 77 | |
| 78 | pirq->exclusive_irqs = 0; |
| 79 | |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 80 | pirq->rtr_vendor = PCI_VENDOR_ID_SIS; |
Morgan Tsai | 31e805d | 2007-11-14 01:34:02 +0000 | [diff] [blame] | 81 | pirq->rtr_device = PCI_DEVICE_ID_SIS_SIS966_LPC; |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 82 | |
| 83 | pirq->miniport_data = 0; |
| 84 | |
| 85 | memset(pirq->rfu, 0, sizeof(pirq->rfu)); |
| 86 | |
| 87 | pirq_info = (void *) ( &pirq->checksum + 1); |
| 88 | slot_num = 0; |
| 89 | |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 90 | write_pirq_info(pirq_info, 0, PCI_DEVFN(2, 0), 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 91 | pirq_info++; slot_num++; |
| 92 | |
| 93 | pirq->size = 32 + 16 * slot_num; |
| 94 | |
| 95 | for (i = 0; i < pirq->size; i++) |
| 96 | sum += v[i]; |
| 97 | |
| 98 | sum = pirq->checksum - sum; |
| 99 | |
| 100 | if (sum != pirq->checksum) { |
| 101 | pirq->checksum = sum; |
| 102 | } |
| 103 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 104 | printk(BIOS_INFO, "done.\n"); |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 105 | |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 106 | { |
| 107 | device_t dev; |
| 108 | dev = dev_find_slot(0, PCI_DEVFN(2,0)); |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 109 | if (dev) { |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 110 | /* initialize PCI interupts - these assignments depend |
| 111 | on the PCB routing of PINTA-D |
| 112 | |
| 113 | PINTA = IRQ10 |
| 114 | PINTB = IRQ11 |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 115 | PINTC = NA |
| 116 | PINTD = IRQ10 |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 117 | PINTE = IRQ11 |
| 118 | PINTF = IRQ5 |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 119 | PINTG = NA |
| 120 | PINTH = IRQ7 |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 121 | |
| 122 | */ |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 123 | uint8_t reg[8]={0x41,0x42,0x43,0x44,0x60,0x61,0x62,0x63}; |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 124 | uint8_t irq[8]={0x0A,0X0B,0X0,0X0a,0X0B,0X05,0X0,0X07}; |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 125 | |
| 126 | for(i=0;i<8;i++) |
| 127 | pci_write_config8(dev, reg[i], irq[i]); |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 128 | } // endif |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 129 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 130 | printk(BIOS_DEBUG, "Setting Onboard SiS Southbridge\n"); |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 131 | |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 132 | dev = dev_find_slot(0, PCI_DEVFN(2,5)); // 5513 (IDE) |
| 133 | pci_write_config8(dev, 0x3C, 0x0A); |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 134 | dev = dev_find_slot(0, PCI_DEVFN(3,0)); // USB 1.1 |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 135 | pci_write_config8(dev, 0x3C, 0x0B); |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 136 | dev = dev_find_slot(0, PCI_DEVFN(3,1)); // USB 1.1 |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 137 | pci_write_config8(dev, 0x3C, 0x05); |
| 138 | dev = dev_find_slot(0, PCI_DEVFN(3,3)); // USB 2.0 |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 139 | pci_write_config8(dev, 0x3C, 0x07); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 140 | dev = dev_find_slot(0, PCI_DEVFN(4,0)); // 191 (LAN) |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 141 | pci_write_config8(dev, 0x3C, 0x0A); |
Morgan Tsai | 31e805d | 2007-11-14 01:34:02 +0000 | [diff] [blame] | 142 | dev = dev_find_slot(0, PCI_DEVFN(5,0)); // 1183 (SATA) |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 143 | pci_write_config8(dev, 0x3C, 0x0B); |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 144 | dev = dev_find_slot(0, PCI_DEVFN(6,0)); // PCI-E |
| 145 | pci_write_config8(dev, 0x3C, 0x0A); |
| 146 | dev = dev_find_slot(0, PCI_DEVFN(7,0)); // PCI-E |
| 147 | pci_write_config8(dev, 0x3C, 0x0A); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 148 | dev = dev_find_slot(0, PCI_DEVFN(15,0)); // Azalia |
| 149 | pci_write_config8(dev, 0x3C, 0x05); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 152 | printk(BIOS_DEBUG, "pirq routing table, size=%d\n", pirq->size); |
Morgan Tsai | c8cf4ad | 2007-11-20 14:11:24 +0000 | [diff] [blame] | 153 | for (i = 0; i < pirq->size; i+=4) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 154 | printk(BIOS_DEBUG, "%.2x%.2x%.2x%.2x\n", v[i+3],v[i+2],v[i+1],v[i]); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 155 | |
| 156 | return (unsigned long) pirq_info; |
| 157 | |
| 158 | } |