2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 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>
21 #include <southbridge/amd/cimx_wrapper/sb800/lpc.h>
23 void lpc_read_resources(device_t dev)
27 /* Get the normal pci resources of this device */
28 pci_dev_read_resources(dev); /* We got one for APIC, or one more for TRAP */
30 pci_get_resource(dev, SPIROM_BASE_ADDRESS); /* SPI ROM base address */
32 /* Add an extra subtractive resource for both memory and I/O. */
33 res = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0));
36 res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE |
37 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
39 res = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0));
40 res->base = 0xff800000;
41 res->size = 0x00800000; /* 8 MB for flash */
42 res->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE |
43 IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
45 res = new_resource(dev, 3); /* IOAPIC */
46 res->base = 0xfec00000;
47 res->size = 0x00001000;
48 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
50 compact_resources(dev);
53 void lpc_set_resources(struct device *dev)
57 pci_dev_set_resources(dev);
59 /* Specical case. SPI Base Address. The SpiRomEnable should be set. */
60 res = find_resource(dev, SPIROM_BASE_ADDRESS);
61 pci_write_config32(dev, SPIROM_BASE_ADDRESS, res->base | 1 << 1);
65 * @brief Enable resources for children devices
67 * @param dev the device whos children's resources are to be enabled
70 void lpc_enable_childrens_resources(device_t dev)
77 reg = pci_read_config32(dev, 0x44);
78 reg_x = pci_read_config32(dev, 0x48);
80 for (link = dev->link_list; link; link = link->next) {
82 for (child = link->children; child;
83 child = child->sibling) {
85 && (child->path.type == DEVICE_PATH_PNP)) {
87 for (res = child->resource_list; res; res = res->next) {
88 u32 base, end; /* don't need long long */
89 if (!(res->flags & IORESOURCE_IO))
92 end = resource_end(res);
94 printk(BIOS_DEBUG, "sb800 lpc decode:%s, base=0x%08x, end=0x%08x\n",
95 dev_path(child), base, end);
102 case 0x3f8: /* COM1 */
105 case 0x2f8: /* COM2 */
108 case 0x378: /* Parallal 1 */
111 case 0x3f0: /* FD0 */
114 case 0x220: /* Aduio 0 */
117 case 0x300: /* Midi 0 */
140 continue; /* only 3 var ; compact them ? */
159 pci_write_config32(dev, 0x44, reg);
160 pci_write_config32(dev, 0x48, reg_x);
161 /* Set WideIO for as many IOs found (fall through is on purpose) */
164 pci_write_config16(dev, 0x90, reg_var[2]);
166 pci_write_config16(dev, 0x66, reg_var[1]);
168 //pci_write_config16(dev, 0x64, reg_var[0]); //cause filo can not find sata