2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2009-2010 iWave Systems
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <device/pci_ids.h>
32 #define SCH_ACPI_CTL 0x58
33 #define SCH_SIRQ_CTL 0x68
34 #define PIRQA_ROUT 0x60
35 #define PIRQB_ROUT 0x61
36 #define PIRQC_ROUT 0x62
37 #define PIRQD_ROUT 0x63
38 #define PIRQE_ROUT 0x64
39 #define PIRQF_ROUT 0x65
40 #define PIRQG_ROUT 0x66
41 #define PIRQH_ROUT 0x67
43 typedef struct southbridge_intel_sch_config config_t;
45 /* PIRQ[n]_ROUT[3:0] - PIRQ Routing Control
46 * 0x00 - 0000 = Reserved
47 * 0x01 - 0001 = Reserved
48 * 0x02 - 0010 = Reserved
54 * 0x08 - 1000 = Reserved
59 * 0x0D - 1101 = Reserved
62 * PIRQ[n]_ROUT[7] - PIRQ Routing Control
63 * 0x80 - The PIRQ is not routed.
74 static void sch_pirq_init(device_t dev)
77 /* Get the chip configuration */
78 config_t *config = dev->chip_info;
80 pci_write_config8(dev, PIRQA_ROUT, config->pirqa_routing);
81 pci_write_config8(dev, PIRQB_ROUT, config->pirqb_routing);
82 pci_write_config8(dev, PIRQC_ROUT, config->pirqc_routing);
83 pci_write_config8(dev, PIRQD_ROUT, config->pirqd_routing);
85 pci_write_config8(dev, PIRQE_ROUT, config->pirqe_routing);
86 pci_write_config8(dev, PIRQF_ROUT, config->pirqf_routing);
87 pci_write_config8(dev, PIRQG_ROUT, config->pirqg_routing);
88 pci_write_config8(dev, PIRQH_ROUT, config->pirqh_routing);
90 /* Eric Biederman once said we should let the OS do this.
91 * I am not so sure anymore he was right.
94 for(irq_dev = all_devices; irq_dev; irq_dev = irq_dev->next)
96 u8 int_pin=0, int_line=0;
98 if (!irq_dev->enabled || irq_dev->path.type != DEVICE_PATH_PCI)
101 int_pin = pci_read_config8(irq_dev, PCI_INTERRUPT_PIN);
105 case 1: /* INTA# */ int_line = config->pirqa_routing; break;
106 case 2: /* INTB# */ int_line = config->pirqb_routing; break;
107 case 3: /* INTC# */ int_line = config->pirqc_routing; break;
108 case 4: /* INTD# */ int_line = config->pirqd_routing; break;
114 pci_write_config8(irq_dev, PCI_INTERRUPT_LINE, int_line);
117 static void sch_fixups(struct device *dev)
120 /* This needs to happen after PCI enumeration
121 RCBA32(0x1d40) |= 1;*/
122 rcba_base = pci_read_config32(dev, 0xF0);
123 /*Remove the enable bit*/
124 rcba_base = rcba_base >> 1;
125 rcba_base = rcba_base << 1;
126 *((volatile u32 *)(rcba_base +0x104)) &= 0xFF00FFFF;
129 static void lpc_init(struct device *dev)
131 printk(BIOS_DEBUG, "SCH: lpc_init\n");
133 /* Setup the PIRQ. */
135 pci_write_config8(dev, SCH_SIRQ_CTL,0x80);
139 static void sch_lpc_read_resources(device_t dev)
141 struct resource *res;
143 /* Get the normal PCI resources of this device. */
144 pci_dev_read_resources(dev);
146 /* Add an extra subtractive resource for both memory and I/O. */
147 res = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0));
150 res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE |
151 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
153 res = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0));
154 res->base = 0xff800000;
155 res->size = 0x00800000; /* 8 MB for flash */
156 res->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE |
157 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
159 res = new_resource(dev, 3); /* IOAPIC */
160 res->base = 0xfec00000;
161 res->size = 0x00001000;
162 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
165 static void set_subsystem(device_t dev, unsigned vendor, unsigned device)
167 if (!vendor || !device) {
168 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
169 pci_read_config32(dev, PCI_VENDOR_ID));
171 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
172 ((device & 0xffff) << 16) | (vendor & 0xffff));
176 static struct pci_operations pci_ops = {
177 .set_subsystem = set_subsystem,
180 static struct device_operations device_ops = {
181 .read_resources = sch_lpc_read_resources,
182 .set_resources = pci_dev_set_resources,
183 .enable_resources = pci_dev_enable_resources,
185 .scan_bus = scan_static_bus,
189 /* SCH LPC Interface */
190 static const struct pci_driver sch_lpc __pci_driver = {
192 .vendor = PCI_VENDOR_ID_INTEL,