first round name simplification. drop the <component>_ prefix.
[coreboot.git] / src / southbridge / amd / rs690 / ht.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 Advanced Micro Devices, Inc.
5  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <console/console.h>
21 #include <device/device.h>
22 #include <device/pci.h>
23 #include <device/pci_ids.h>
24 #include <device/pci_ops.h>
25 #include "rs690.h"
26
27 /* for UMA internal graphics */
28 void avoid_lpc_dma_deadlock(device_t nb_dev, device_t sb_dev)
29 {
30         device_t k8_f0;
31         u8 reg;
32
33         k8_f0 = dev_find_slot(0, PCI_DEVFN(0x18, 0));
34         set_nbcfg_enable_bits(k8_f0, 0x68, 3 << 21, 1 << 21);
35
36         reg = nbpcie_p_read_index(sb_dev, 0x10);
37         reg |= 0x100;           /* bit9=1 */
38         nbpcie_p_write_index(sb_dev, 0x10, reg);
39
40         reg = nbpcie_p_read_index(nb_dev, 0x10);
41         reg |= 0x100;           /* bit9=1 */
42         nbpcie_p_write_index(nb_dev, 0x10, reg);
43
44         /* Enable NP protocol over PCIE for memory-mapped writes targeting LPC
45          * Set this bit to avoid a deadlock condition. */
46         reg = htiu_read_index(nb_dev, 0x6);
47         reg |= 0x1000000;       /* bit26 */
48         htiu_write_index(nb_dev, 0x6, reg);
49 }
50
51 static void pcie_init(struct device *dev)
52 {
53         /* Enable pci error detecting */
54         u32 dword;
55
56         printk(BIOS_INFO, "pcie_init in rs690_ht.c\n");
57
58         /* System error enable */
59         dword = pci_read_config32(dev, 0x04);
60         dword |= (1 << 8);      /* System error enable */
61         dword |= (1 << 30);     /* Clear possible errors */
62         pci_write_config32(dev, 0x04, dword);
63
64         /*
65          * 1 is APIC enable
66          * 18 is enable nb to accept A4 interrupt request from SB.
67          */
68         dword = pci_read_config32(dev, 0x4C);
69         dword |= 1 << 1 | 1 << 18;      /* Clear possible errors */
70         pci_write_config32(dev, 0x4C, dword);
71 }
72
73 static struct pci_operations lops_pci = {
74         .set_subsystem = pci_dev_set_subsystem,
75 };
76
77 static struct device_operations ht_ops = {
78         .read_resources = pci_dev_read_resources,
79         .set_resources = pci_dev_set_resources,
80         .enable_resources = pci_dev_enable_resources,
81         .init = pcie_init,
82         .scan_bus = 0,
83         .ops_pci = &lops_pci,
84 };
85
86 static const struct pci_driver ht_driver __pci_driver = {
87         .ops = &ht_ops,
88         .vendor = PCI_VENDOR_ID_ATI,
89         .device = PCI_DEVICE_ID_ATI_RS690_HT,
90 };