2 * This file is part of the coreboot project.
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <device/pci.h>
22 #include <console/console.h> /* printk */
25 void lpc_read_resources(device_t dev)
29 printk(BIOS_DEBUG, "SB900 - Lpc.c - lpc_read_resources - Start.\n");
30 /* Get the normal pci resources of this device */
31 pci_dev_read_resources(dev); /* We got one for APIC, or one more for TRAP */
33 pci_get_resource(dev, SPIROM_BASE_ADDRESS); /* SPI ROM base address */
35 /* Add an extra subtractive resource for both memory and I/O. */
36 res = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0));
39 res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE |
40 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
42 res = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0));
43 res->base = 0xff800000;
44 res->size = 0x00800000; /* 8 MB for flash */
45 res->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE |
46 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
48 res = new_resource(dev, 3); /* IOAPIC */
49 res->base = 0xfec00000;
50 res->size = 0x00001000;
51 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
53 compact_resources(dev);
54 printk(BIOS_DEBUG, "SB900 - Lpc.c - lpc_read_resources - End.\n");
57 void lpc_set_resources(struct device *dev)
61 printk(BIOS_DEBUG, "SB900 - Lpc.c - lpc_set_resources - Start.\n");
62 pci_dev_set_resources(dev);
64 /* Specical case. SPI Base Address. The SpiRomEnable should be set. */
65 res = find_resource(dev, SPIROM_BASE_ADDRESS);
66 pci_write_config32(dev, SPIROM_BASE_ADDRESS, res->base | 1 << 1);
67 printk(BIOS_DEBUG, "SB900 - Lpc.c - lpc_set_resources - End.\n");
71 * @brief Enable resources for children devices
73 * @param dev the device whos children's resources are to be enabled
76 void lpc_enable_childrens_resources(device_t dev)
83 printk(BIOS_DEBUG, "SB900 - Lpc.c - lpc_enable_childrens_resources - Start.\n");
84 reg = pci_read_config32(dev, 0x44);
85 reg_x = pci_read_config32(dev, 0x48);
87 for (link = dev->link_list; link; link = link->next) {
89 for (child = link->children; child;
90 child = child->sibling) {
92 && (child->path.type == DEVICE_PATH_PNP)) {
94 for (res = child->resource_list; res; res = res->next) {
95 u32 base, end; /* don't need long long */
96 if (!(res->flags & IORESOURCE_IO))
99 end = resource_end(res);
101 printk(BIOS_DEBUG, "sb900 lpc decode:%s, base=0x%08x, end=0x%08x\n",
102 dev_path(child), base, end);
109 case 0x3f8: /* COM1 */
112 case 0x2f8: /* COM2 */
115 case 0x378: /* Parallal 1 */
118 case 0x3f0: /* FD0 */
121 case 0x220: /* Aduio 0 */
124 case 0x300: /* Midi 0 */
147 continue; /* only 3 var ; compact them ? */
166 pci_write_config32(dev, 0x44, reg);
167 pci_write_config32(dev, 0x48, reg_x);
168 /* Set WideIO for as many IOs found (fall through is on purpose) */
171 pci_write_config16(dev, 0x90, reg_var[2]);
173 pci_write_config16(dev, 0x66, reg_var[1]);
175 //pci_write_config16(dev, 0x64, reg_var[0]); //cause filo can not find sata
178 printk(BIOS_DEBUG, "SB900 - Lpc.c - lpc_enable_childrens_resources - End.\n");